bootstrap-table-page-jump-to.js 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. (function (global, factory) {
  2. typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('core-js/modules/es.array.concat.js'), require('core-js/modules/es.array.find.js'), require('core-js/modules/es.object.assign.js'), require('core-js/modules/es.object.to-string.js'), require('jquery')) :
  3. typeof define === 'function' && define.amd ? define(['core-js/modules/es.array.concat.js', 'core-js/modules/es.array.find.js', 'core-js/modules/es.object.assign.js', 'core-js/modules/es.object.to-string.js', 'jquery'], factory) :
  4. (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(null, null, null, null, global.jQuery));
  5. })(this, (function (es_array_concat_js, es_array_find_js, es_object_assign_js, es_object_toString_js, $) { 'use strict';
  6. function _arrayLikeToArray(r, a) {
  7. (null == a || a > r.length) && (a = r.length);
  8. for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
  9. return n;
  10. }
  11. function _assertThisInitialized(e) {
  12. if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  13. return e;
  14. }
  15. function _callSuper(t, o, e) {
  16. return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e));
  17. }
  18. function _classCallCheck(a, n) {
  19. if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
  20. }
  21. function _defineProperties(e, r) {
  22. for (var t = 0; t < r.length; t++) {
  23. var o = r[t];
  24. o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o);
  25. }
  26. }
  27. function _createClass(e, r, t) {
  28. return r && _defineProperties(e.prototype, r), Object.defineProperty(e, "prototype", {
  29. writable: !1
  30. }), e;
  31. }
  32. function _createForOfIteratorHelper(r, e) {
  33. var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
  34. if (!t) {
  35. if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e ) {
  36. t && (r = t);
  37. var n = 0,
  38. F = function () {};
  39. return {
  40. s: F,
  41. n: function () {
  42. return n >= r.length ? {
  43. done: !0
  44. } : {
  45. done: !1,
  46. value: r[n++]
  47. };
  48. },
  49. e: function (r) {
  50. throw r;
  51. },
  52. f: F
  53. };
  54. }
  55. throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  56. }
  57. var o,
  58. a = !0,
  59. u = !1;
  60. return {
  61. s: function () {
  62. t = t.call(r);
  63. },
  64. n: function () {
  65. var r = t.next();
  66. return a = r.done, r;
  67. },
  68. e: function (r) {
  69. u = !0, o = r;
  70. },
  71. f: function () {
  72. try {
  73. a || null == t.return || t.return();
  74. } finally {
  75. if (u) throw o;
  76. }
  77. }
  78. };
  79. }
  80. function _get() {
  81. return _get = "undefined" != typeof Reflect && Reflect.get ? Reflect.get.bind() : function (e, t, r) {
  82. var p = _superPropBase(e, t);
  83. if (p) {
  84. var n = Object.getOwnPropertyDescriptor(p, t);
  85. return n.get ? n.get.call(arguments.length < 3 ? e : r) : n.value;
  86. }
  87. }, _get.apply(null, arguments);
  88. }
  89. function _getPrototypeOf(t) {
  90. return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {
  91. return t.__proto__ || Object.getPrototypeOf(t);
  92. }, _getPrototypeOf(t);
  93. }
  94. function _inherits(t, e) {
  95. if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function");
  96. t.prototype = Object.create(e && e.prototype, {
  97. constructor: {
  98. value: t,
  99. writable: !0,
  100. configurable: !0
  101. }
  102. }), Object.defineProperty(t, "prototype", {
  103. writable: !1
  104. }), e && _setPrototypeOf(t, e);
  105. }
  106. function _isNativeReflectConstruct() {
  107. try {
  108. var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
  109. } catch (t) {}
  110. return (_isNativeReflectConstruct = function () {
  111. return !!t;
  112. })();
  113. }
  114. function _possibleConstructorReturn(t, e) {
  115. if (e && ("object" == typeof e || "function" == typeof e)) return e;
  116. if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined");
  117. return _assertThisInitialized(t);
  118. }
  119. function _setPrototypeOf(t, e) {
  120. return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
  121. return t.__proto__ = e, t;
  122. }, _setPrototypeOf(t, e);
  123. }
  124. function _superPropBase(t, o) {
  125. for (; !{}.hasOwnProperty.call(t, o) && null !== (t = _getPrototypeOf(t)););
  126. return t;
  127. }
  128. function _toPrimitive(t, r) {
  129. if ("object" != typeof t || !t) return t;
  130. var e = t[Symbol.toPrimitive];
  131. if (void 0 !== e) {
  132. var i = e.call(t, r );
  133. if ("object" != typeof i) return i;
  134. throw new TypeError("@@toPrimitive must return a primitive value.");
  135. }
  136. return (String )(t);
  137. }
  138. function _toPropertyKey(t) {
  139. var i = _toPrimitive(t, "string");
  140. return "symbol" == typeof i ? i : i + "";
  141. }
  142. function _unsupportedIterableToArray(r, a) {
  143. if (r) {
  144. if ("string" == typeof r) return _arrayLikeToArray(r, a);
  145. var t = {}.toString.call(r).slice(8, -1);
  146. return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
  147. }
  148. }
  149. /**
  150. * @author Jay <jwang@dizsoft.com>
  151. * @update zhixin wen <wenzhixin2010@gmail.com>
  152. */
  153. var Utils = $.fn.bootstrapTable.utils;
  154. Object.assign($.fn.bootstrapTable.defaults, {
  155. showJumpTo: false,
  156. showJumpToByPages: 0
  157. });
  158. Object.assign($.fn.bootstrapTable.locales, {
  159. formatJumpTo: function formatJumpTo() {
  160. return 'GO';
  161. }
  162. });
  163. Object.assign($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales);
  164. $.BootstrapTable = /*#__PURE__*/function (_$$BootstrapTable) {
  165. function _class() {
  166. _classCallCheck(this, _class);
  167. return _callSuper(this, _class, arguments);
  168. }
  169. _inherits(_class, _$$BootstrapTable);
  170. return _createClass(_class, [{
  171. key: "initPagination",
  172. value: function initPagination() {
  173. var _get2,
  174. _this = this;
  175. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  176. args[_key] = arguments[_key];
  177. }
  178. (_get2 = _get(_getPrototypeOf(_class.prototype), "initPagination", this)).call.apply(_get2, [this].concat(args));
  179. if (this.options.showJumpTo && this.totalPages >= this.options.showJumpToByPages) {
  180. var $pageGroup = this.$pagination.find('> .pagination');
  181. var $jumpTo = $pageGroup.find('.page-jump-to');
  182. if (!$jumpTo.length) {
  183. $jumpTo = $(Utils.sprintf(this.constants.html.inputGroup, "<input type=\"number\"\n class=\"".concat(this.constants.classes.input).concat(Utils.sprintf(' %s%s', this.constants.classes.inputPrefix, this.options.iconSize), "\"\n value=\"").concat(this.options.pageNumber, "\"\n min=\"1\"\n max=\"").concat(this.totalPages, "\">"), "<button class=\"".concat(this.constants.buttonsClass, "\" type=\"button\">\n ").concat(this.options.formatJumpTo(), "\n </button>"))).addClass('page-jump-to').appendTo($pageGroup);
  184. var _iterator = _createForOfIteratorHelper($jumpTo),
  185. _step;
  186. try {
  187. var _loop = function _loop() {
  188. var el = _step.value;
  189. var $input = $(el).find('input');
  190. $(el).find('button').click(function () {
  191. _this.selectPage(+$input.val());
  192. });
  193. $input.keyup(function (e) {
  194. if ($input.val() === '') {
  195. return;
  196. }
  197. if (e.keyCode === 13) {
  198. _this.selectPage(+$input.val());
  199. return;
  200. }
  201. if (+$input.val() < +$input.attr('min')) {
  202. $input.val($input.attr('min'));
  203. } else if (+$input.val() > +$input.attr('max')) {
  204. $input.val($input.attr('max'));
  205. }
  206. });
  207. $input.blur(function () {
  208. if ($input.val() === '') {
  209. $input.val(_this.options.pageNumber);
  210. }
  211. });
  212. };
  213. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  214. _loop();
  215. }
  216. } catch (err) {
  217. _iterator.e(err);
  218. } finally {
  219. _iterator.f();
  220. }
  221. }
  222. }
  223. }
  224. }]);
  225. }($.BootstrapTable);
  226. }));