bootstrap-table-foundation.js 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. (function (global, factory) {
  2. typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('core-js/modules/es.array.find.js'), require('core-js/modules/es.array.includes.js'), require('core-js/modules/es.object.to-string.js'), require('core-js/modules/es.string.includes.js'), require('jquery')) :
  3. typeof define === 'function' && define.amd ? define(['core-js/modules/es.array.find.js', 'core-js/modules/es.array.includes.js', 'core-js/modules/es.object.to-string.js', 'core-js/modules/es.string.includes.js', 'jquery'], factory) :
  4. (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(null, null, null, null, global.jQuery));
  5. })(this, (function (es_array_find_js, es_array_includes_js, es_object_toString_js, es_string_includes_js, $) { 'use strict';
  6. function _assertThisInitialized(e) {
  7. if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  8. return e;
  9. }
  10. function _callSuper(t, o, e) {
  11. return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e));
  12. }
  13. function _classCallCheck(a, n) {
  14. if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
  15. }
  16. function _defineProperties(e, r) {
  17. for (var t = 0; t < r.length; t++) {
  18. var o = r[t];
  19. o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o);
  20. }
  21. }
  22. function _createClass(e, r, t) {
  23. return r && _defineProperties(e.prototype, r), Object.defineProperty(e, "prototype", {
  24. writable: !1
  25. }), e;
  26. }
  27. function _get() {
  28. return _get = "undefined" != typeof Reflect && Reflect.get ? Reflect.get.bind() : function (e, t, r) {
  29. var p = _superPropBase(e, t);
  30. if (p) {
  31. var n = Object.getOwnPropertyDescriptor(p, t);
  32. return n.get ? n.get.call(arguments.length < 3 ? e : r) : n.value;
  33. }
  34. }, _get.apply(null, arguments);
  35. }
  36. function _getPrototypeOf(t) {
  37. return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {
  38. return t.__proto__ || Object.getPrototypeOf(t);
  39. }, _getPrototypeOf(t);
  40. }
  41. function _inherits(t, e) {
  42. if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function");
  43. t.prototype = Object.create(e && e.prototype, {
  44. constructor: {
  45. value: t,
  46. writable: !0,
  47. configurable: !0
  48. }
  49. }), Object.defineProperty(t, "prototype", {
  50. writable: !1
  51. }), e && _setPrototypeOf(t, e);
  52. }
  53. function _isNativeReflectConstruct() {
  54. try {
  55. var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
  56. } catch (t) {}
  57. return (_isNativeReflectConstruct = function () {
  58. return !!t;
  59. })();
  60. }
  61. function _possibleConstructorReturn(t, e) {
  62. if (e && ("object" == typeof e || "function" == typeof e)) return e;
  63. if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined");
  64. return _assertThisInitialized(t);
  65. }
  66. function _setPrototypeOf(t, e) {
  67. return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
  68. return t.__proto__ = e, t;
  69. }, _setPrototypeOf(t, e);
  70. }
  71. function _superPropBase(t, o) {
  72. for (; !{}.hasOwnProperty.call(t, o) && null !== (t = _getPrototypeOf(t)););
  73. return t;
  74. }
  75. function _toPrimitive(t, r) {
  76. if ("object" != typeof t || !t) return t;
  77. var e = t[Symbol.toPrimitive];
  78. if (void 0 !== e) {
  79. var i = e.call(t, r );
  80. if ("object" != typeof i) return i;
  81. throw new TypeError("@@toPrimitive must return a primitive value.");
  82. }
  83. return (String )(t);
  84. }
  85. function _toPropertyKey(t) {
  86. var i = _toPrimitive(t, "string");
  87. return "symbol" == typeof i ? i : i + "";
  88. }
  89. /**
  90. * @author zhixin wen <wenzhixin2010@gmail.com>
  91. * https://github.com/wenzhixin/bootstrap-table/
  92. * theme: https://github.com/zurb/foundation-sites
  93. */
  94. var Utils = $.fn.bootstrapTable.utils;
  95. Utils.extend($.fn.bootstrapTable.defaults, {
  96. classes: 'table hover',
  97. buttonsPrefix: '',
  98. buttonsClass: 'button'
  99. });
  100. $.fn.bootstrapTable.theme = 'foundation';
  101. $.BootstrapTable = /*#__PURE__*/function (_$$BootstrapTable) {
  102. function _class() {
  103. _classCallCheck(this, _class);
  104. return _callSuper(this, _class, arguments);
  105. }
  106. _inherits(_class, _$$BootstrapTable);
  107. return _createClass(_class, [{
  108. key: "initConstants",
  109. value: function initConstants() {
  110. _get(_getPrototypeOf(_class.prototype), "initConstants", this).call(this);
  111. this.constants.classes.buttonsGroup = 'button-group';
  112. this.constants.classes.buttonsDropdown = 'dropdown-container';
  113. this.constants.classes.paginationDropdown = '';
  114. this.constants.classes.dropdownActive = 'is-active';
  115. this.constants.classes.paginationActive = 'current';
  116. this.constants.classes.buttonActive = 'success';
  117. this.constants.html.toolbarDropdown = ['<div class="dropdown-pane" data-dropdown><ul class="vertical menu">', '</ul></div>'];
  118. this.constants.html.toolbarDropdownItem = '<li class="dropdown-item-marker"><label class="dropdown-item">%s</label></li>';
  119. this.constants.html.toolbarDropdownSeparator = '<li><hr></li>';
  120. this.constants.html.pageDropdown = ['<div class="dropdown-pane" id="pagination-list-id" data-dropdown><ul class="vertical menu">', '</ul></div>'];
  121. this.constants.html.pageDropdownItem = '<li class="dropdown-item %s"><a href="#">%s</a></li>';
  122. this.constants.html.dropdownCaret = '<i class="fa fa-angle-down"></i>';
  123. this.constants.html.pagination = ['<ul class="pagination%s">', '</ul>'];
  124. this.constants.html.paginationItem = '<li><a class="page-item%s" aria-label="%s" href="#">%s</a></li>';
  125. this.constants.html.inputGroup = '<div class="input-group">%s <div class="input-group-button">%s</div></div>';
  126. this.constants.html.searchInput = '<input class="%s input-%s input-group-field" type="search" placeholder="%s">';
  127. }
  128. }, {
  129. key: "initToolbar",
  130. value: function initToolbar() {
  131. _get(_getPrototypeOf(_class.prototype), "initToolbar", this).call(this);
  132. this.handleToolbar();
  133. }
  134. }, {
  135. key: "handleToolbar",
  136. value: function handleToolbar() {
  137. if (this.$toolbar.find('.dropdown-toggle').length) {
  138. this.$toolbar.find('.dropdown-toggle').each(function (i, el) {
  139. if (!$(el).next().length) {
  140. return;
  141. }
  142. var id = "toolbar-columns-id".concat(i);
  143. $(el).next().attr('id', id);
  144. $(el).attr('data-toggle', id);
  145. var $pane = $(el).next().attr('data-position', 'bottom').attr('data-alignment', 'right');
  146. new window.Foundation.Dropdown($pane);
  147. });
  148. this._initDropdown();
  149. }
  150. }
  151. }, {
  152. key: "initPagination",
  153. value: function initPagination() {
  154. _get(_getPrototypeOf(_class.prototype), "initPagination", this).call(this);
  155. if (this.options.pagination && this.paginationParts.includes('pageSize')) {
  156. var $el = this.$pagination.find('.dropdown-toggle');
  157. $el.attr('data-toggle', $el.next().attr('id'));
  158. var $pane = this.$pagination.find('.dropdown-pane').attr('data-position', 'top').attr('data-alignment', 'left');
  159. new window.Foundation.Dropdown($pane);
  160. this._initDropdown();
  161. }
  162. }
  163. }, {
  164. key: "_initDropdown",
  165. value: function _initDropdown() {
  166. var $dropdowns = this.$container.find('.dropdown-toggle');
  167. $dropdowns.off('click').on('click', function (e) {
  168. var $this = $(e.currentTarget);
  169. e.stopPropagation();
  170. $this.next().foundation('toggle');
  171. if ($dropdowns.not($this).length) {
  172. $dropdowns.not($this).next().foundation('close');
  173. }
  174. });
  175. $(document).off('click.bs.dropdown.foundation').on('click.bs.dropdown.foundation', function () {
  176. $dropdowns.next().foundation('close');
  177. });
  178. }
  179. }]);
  180. }($.BootstrapTable);
  181. }));