bootstrap-table-materialize.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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.bootstrapTableMaterialize = mod.exports;
  12. }
  13. })(this, function () {
  14. 'use strict';
  15. function _classCallCheck(instance, Constructor) {
  16. if (!(instance instanceof Constructor)) {
  17. throw new TypeError("Cannot call a class as a function");
  18. }
  19. }
  20. var _createClass = function () {
  21. function defineProperties(target, props) {
  22. for (var i = 0; i < props.length; i++) {
  23. var descriptor = props[i];
  24. descriptor.enumerable = descriptor.enumerable || false;
  25. descriptor.configurable = true;
  26. if ("value" in descriptor) descriptor.writable = true;
  27. Object.defineProperty(target, descriptor.key, descriptor);
  28. }
  29. }
  30. return function (Constructor, protoProps, staticProps) {
  31. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  32. if (staticProps) defineProperties(Constructor, staticProps);
  33. return Constructor;
  34. };
  35. }();
  36. function _possibleConstructorReturn(self, call) {
  37. if (!self) {
  38. throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  39. }
  40. return call && (typeof call === "object" || typeof call === "function") ? call : self;
  41. }
  42. var _get = function get(object, property, receiver) {
  43. if (object === null) object = Function.prototype;
  44. var desc = Object.getOwnPropertyDescriptor(object, property);
  45. if (desc === undefined) {
  46. var parent = Object.getPrototypeOf(object);
  47. if (parent === null) {
  48. return undefined;
  49. } else {
  50. return get(parent, property, receiver);
  51. }
  52. } else if ("value" in desc) {
  53. return desc.value;
  54. } else {
  55. var getter = desc.get;
  56. if (getter === undefined) {
  57. return undefined;
  58. }
  59. return getter.call(receiver);
  60. }
  61. };
  62. function _inherits(subClass, superClass) {
  63. if (typeof superClass !== "function" && superClass !== null) {
  64. throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
  65. }
  66. subClass.prototype = Object.create(superClass && superClass.prototype, {
  67. constructor: {
  68. value: subClass,
  69. enumerable: false,
  70. writable: true,
  71. configurable: true
  72. }
  73. });
  74. if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
  75. }
  76. /**
  77. * @author zhixin wen <wenzhixin2010@gmail.com>
  78. * https://github.com/wenzhixin/bootstrap-table/
  79. * theme: https://github.com/jgthms/bulma/
  80. */
  81. (function ($) {
  82. $.extend($.fn.bootstrapTable.defaults, {
  83. classes: 'table highlight',
  84. buttonsPrefix: '',
  85. buttonsClass: 'waves-effect waves-light btn',
  86. iconsPrefix: 'material-icons',
  87. icons: {
  88. paginationSwitchDown: 'grid_on',
  89. paginationSwitchUp: 'grid_off',
  90. refresh: 'refresh',
  91. toggleOff: 'tablet',
  92. toggleOn: 'tablet_android',
  93. columns: 'view_list',
  94. detailOpen: 'add',
  95. detailClose: 'remove',
  96. fullscreen: 'fullscreen'
  97. }
  98. });
  99. $.BootstrapTable = function (_$$BootstrapTable) {
  100. _inherits(_class, _$$BootstrapTable);
  101. function _class() {
  102. _classCallCheck(this, _class);
  103. return _possibleConstructorReturn(this, (_class.__proto__ || Object.getPrototypeOf(_class)).apply(this, arguments));
  104. }
  105. _createClass(_class, [{
  106. key: 'initConstants',
  107. value: function initConstants() {
  108. _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), 'initConstants', this).call(this);
  109. this.constants.theme = 'materialize';
  110. this.constants.classes.buttonsGroup = '';
  111. this.constants.classes.buttonsDropdown = '';
  112. this.constants.classes.input = 'input-field';
  113. this.constants.classes.input = '';
  114. this.constants.classes.paginationDropdown = '';
  115. this.constants.html.toobarDropdow = ['<ul id="toolbar-dropdown" class="dropdown-content">', '</ul>'];
  116. this.constants.html.toobarDropdowItem = '<li><label>%s</label></li>';
  117. this.constants.html.pageDropdown = ['<ul id="page-list-dropdown" class="dropdown-content">', '</ul>'];
  118. this.constants.html.pageDropdownItem = '<li><a class="%s" href="#">%s</a></li>';
  119. this.constants.html.dropdownCaret = '<i class="material-icons">arrow_drop_down</i>';
  120. this.constants.html.pagination = ['<ul class="pagination%s">', '</ul>'], this.constants.html.paginationItem = '<li class="waves-effect page-item%s"><a href="#">%s</a></li>';
  121. this.constants.html.icon = '<i class="%s">%s</i>';
  122. }
  123. }, {
  124. key: 'initToolbar',
  125. value: function initToolbar() {
  126. _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), 'initToolbar', this).call(this);
  127. if (this.options.showColumns) {
  128. this.$toolbar.find('.dropdown-toggle').attr('data-target', 'toolbar-dropdown').dropdown({
  129. alignment: 'right',
  130. constrainWidth: false,
  131. closeOnClick: false
  132. });
  133. }
  134. }
  135. }, {
  136. key: 'initPagination',
  137. value: function initPagination() {
  138. _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), 'initPagination', this).call(this);
  139. if (this.pagination && !this.options.onlyInfoPagination) {
  140. this.$pagination.find('.dropdown-toggle').attr('data-target', 'page-list-dropdown').dropdown();
  141. }
  142. }
  143. }]);
  144. return _class;
  145. }($.BootstrapTable);
  146. })(jQuery);
  147. });