UNPKG

2.01 kBJavaScriptView Raw
1(function (global, factory) {
2 if (typeof define === "function" && define.amd) {
3 define([], factory);
4 } else if (typeof exports !== "undefined") {
5 factory();
6 } else {
7 var mod = {
8 exports: {}
9 };
10 factory();
11 global.bootstrapTablePageJumpTo = mod.exports;
12 }
13})(this, function () {
14 'use strict';
15
16 /**
17 * @author Jay <jwang@dizsoft.com>
18 */
19
20 (function ($) {
21 'use strict';
22
23 var sprintf = $.fn.bootstrapTable.utils.sprintf;
24
25 $.extend($.fn.bootstrapTable.defaults, {
26 showJumpto: false,
27 exportOptions: {}
28 });
29
30 $.extend($.fn.bootstrapTable.locales, {
31 formatJumpto: function formatJumpto() {
32 return 'GO';
33 }
34 });
35 $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales);
36
37 var BootstrapTable = $.fn.bootstrapTable.Constructor,
38 _initPagination = BootstrapTable.prototype.initPagination;
39
40 BootstrapTable.prototype.initPagination = function () {
41 _initPagination.apply(this, Array.prototype.slice.apply(arguments));
42
43 if (this.options.showJumpto) {
44 var that = this,
45 $pageGroup = this.$pagination.find('ul.pagination'),
46 $jumpto = $pageGroup.find('li.jumpto');
47
48 if (!$jumpto.length) {
49 $jumpto = $(['<li class="jumpto">', '<input type="text" class="form-control">', '<button class="btn' + sprintf(' btn-%s', this.options.buttonsClass) + sprintf(' btn-%s', this.options.iconSize) + '" title="' + this.options.formatJumpto() + '" ' + ' type="button">' + this.options.formatJumpto(), '</button>', '</li>'].join('')).appendTo($pageGroup);
50
51 $jumpto.find('button').click(function () {
52 that.selectPage(parseInt($jumpto.find('input').val()));
53 });
54 }
55 }
56 };
57 })(jQuery);
58});
\No newline at end of file