table.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. (function (global, factory) {
  2. if (typeof define === "function" && define.amd) {
  3. define("/Plugin/table", ["exports", "jquery", "Plugin"], factory);
  4. } else if (typeof exports !== "undefined") {
  5. factory(exports, require("jquery"), require("Plugin"));
  6. } else {
  7. var mod = {
  8. exports: {}
  9. };
  10. factory(mod.exports, global.jQuery, global.Plugin);
  11. global.PluginTable = mod.exports;
  12. }
  13. })(this, function (_exports, _jquery, _Plugin2) {
  14. "use strict";
  15. Object.defineProperty(_exports, "__esModule", {
  16. value: true
  17. });
  18. _exports.default = void 0;
  19. _jquery = babelHelpers.interopRequireDefault(_jquery);
  20. _Plugin2 = babelHelpers.interopRequireDefault(_Plugin2);
  21. var NAME = 'tableSection';
  22. var TableSection =
  23. /*#__PURE__*/
  24. function (_Plugin) {
  25. babelHelpers.inherits(TableSection, _Plugin);
  26. function TableSection() {
  27. babelHelpers.classCallCheck(this, TableSection);
  28. return babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(TableSection).apply(this, arguments));
  29. }
  30. babelHelpers.createClass(TableSection, [{
  31. key: "getName",
  32. value: function getName() {
  33. return NAME;
  34. }
  35. }, {
  36. key: "render",
  37. value: function render() {
  38. this.$el.data('tableApi', this);
  39. }
  40. }, {
  41. key: "toggle",
  42. value: function toggle(e) {
  43. var $el = this.$el;
  44. if (e.target.type !== 'checkbox' && e.target.type !== 'button' && e.target.tagName.toLowerCase() !== 'a' && !(0, _jquery.default)(e.target).parent('div.checkbox-custom').length) {
  45. if ($el.hasClass('active')) {
  46. $el.removeClass('active');
  47. } else {
  48. $el.siblings('.table-section').removeClass('active');
  49. $el.addClass('active');
  50. }
  51. }
  52. }
  53. }], [{
  54. key: "api",
  55. value: function api() {
  56. var api = 'click|toggle';
  57. var touch = typeof document.ontouchstart !== 'undefined';
  58. if (touch) {
  59. api = 'touchstart|toggle';
  60. }
  61. return api;
  62. }
  63. }]);
  64. return TableSection;
  65. }(_Plugin2.default);
  66. _Plugin2.default.register(NAME, TableSection);
  67. var _default = TableSection;
  68. _exports.default = _default;
  69. });