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.bootstrapTableAutoRefresh = mod.exports;
|
12 | }
|
13 | })(this, function () {
|
14 | 'use strict';
|
15 |
|
16 | function _classCallCheck(instance, Constructor) {
|
17 | if (!(instance instanceof Constructor)) {
|
18 | throw new TypeError("Cannot call a class as a function");
|
19 | }
|
20 | }
|
21 |
|
22 | var _createClass = function () {
|
23 | function defineProperties(target, props) {
|
24 | for (var i = 0; i < props.length; i++) {
|
25 | var descriptor = props[i];
|
26 | descriptor.enumerable = descriptor.enumerable || false;
|
27 | descriptor.configurable = true;
|
28 | if ("value" in descriptor) descriptor.writable = true;
|
29 | Object.defineProperty(target, descriptor.key, descriptor);
|
30 | }
|
31 | }
|
32 |
|
33 | return function (Constructor, protoProps, staticProps) {
|
34 | if (protoProps) defineProperties(Constructor.prototype, protoProps);
|
35 | if (staticProps) defineProperties(Constructor, staticProps);
|
36 | return Constructor;
|
37 | };
|
38 | }();
|
39 |
|
40 | function _possibleConstructorReturn(self, call) {
|
41 | if (!self) {
|
42 | throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
43 | }
|
44 |
|
45 | return call && (typeof call === "object" || typeof call === "function") ? call : self;
|
46 | }
|
47 |
|
48 | var _get = function get(object, property, receiver) {
|
49 | if (object === null) object = Function.prototype;
|
50 | var desc = Object.getOwnPropertyDescriptor(object, property);
|
51 |
|
52 | if (desc === undefined) {
|
53 | var parent = Object.getPrototypeOf(object);
|
54 |
|
55 | if (parent === null) {
|
56 | return undefined;
|
57 | } else {
|
58 | return get(parent, property, receiver);
|
59 | }
|
60 | } else if ("value" in desc) {
|
61 | return desc.value;
|
62 | } else {
|
63 | var getter = desc.get;
|
64 |
|
65 | if (getter === undefined) {
|
66 | return undefined;
|
67 | }
|
68 |
|
69 | return getter.call(receiver);
|
70 | }
|
71 | };
|
72 |
|
73 | function _inherits(subClass, superClass) {
|
74 | if (typeof superClass !== "function" && superClass !== null) {
|
75 | throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
|
76 | }
|
77 |
|
78 | subClass.prototype = Object.create(superClass && superClass.prototype, {
|
79 | constructor: {
|
80 | value: subClass,
|
81 | enumerable: false,
|
82 | writable: true,
|
83 | configurable: true
|
84 | }
|
85 | });
|
86 | if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
|
87 | }
|
88 |
|
89 | |
90 |
|
91 |
|
92 |
|
93 |
|
94 |
|
95 | (function ($) {
|
96 | var Utils = $.fn.bootstrapTable.utils;
|
97 |
|
98 | $.extend($.fn.bootstrapTable.defaults, {
|
99 | autoRefresh: false,
|
100 | autoRefreshInterval: 60,
|
101 | autoRefreshSilent: true,
|
102 | autoRefreshStatus: true,
|
103 | autoRefreshFunction: null
|
104 | });
|
105 |
|
106 | $.extend($.fn.bootstrapTable.defaults.icons, {
|
107 | autoRefresh: Utils.bootstrapVersion === 4 ? 'fa-clock' : 'glyphicon-time icon-time'
|
108 | });
|
109 |
|
110 | $.extend($.fn.bootstrapTable.locales, {
|
111 | formatAutoRefresh: function formatAutoRefresh() {
|
112 | return 'Auto Refresh';
|
113 | }
|
114 | });
|
115 |
|
116 | $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales);
|
117 |
|
118 | $.BootstrapTable = function (_$$BootstrapTable) {
|
119 | _inherits(_class, _$$BootstrapTable);
|
120 |
|
121 | function _class() {
|
122 | _classCallCheck(this, _class);
|
123 |
|
124 | return _possibleConstructorReturn(this, (_class.__proto__ || Object.getPrototypeOf(_class)).apply(this, arguments));
|
125 | }
|
126 |
|
127 | _createClass(_class, [{
|
128 | key: 'init',
|
129 | value: function init() {
|
130 | var _get2,
|
131 | _this2 = this;
|
132 |
|
133 | for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
134 | args[_key] = arguments[_key];
|
135 | }
|
136 |
|
137 | (_get2 = _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), 'init', this)).call.apply(_get2, [this].concat(args));
|
138 |
|
139 | if (this.options.autoRefresh && this.options.autoRefreshStatus) {
|
140 | this.options.autoRefreshFunction = setInterval(function () {
|
141 | _this2.refresh({ silent: _this2.options.autoRefreshSilent });
|
142 | }, this.options.autoRefreshInterval * 1000);
|
143 | }
|
144 | }
|
145 | }, {
|
146 | key: 'initToolbar',
|
147 | value: function initToolbar() {
|
148 | var _get3;
|
149 |
|
150 | for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
151 | args[_key2] = arguments[_key2];
|
152 | }
|
153 |
|
154 | (_get3 = _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), 'initToolbar', this)).call.apply(_get3, [this].concat(args));
|
155 |
|
156 | if (this.options.autoRefresh) {
|
157 | var $btnGroup = this.$toolbar.find('>.btn-group');
|
158 | var $btnAutoRefresh = $btnGroup.find('.auto-refresh');
|
159 |
|
160 | if (!$btnAutoRefresh.length) {
|
161 | $btnAutoRefresh = $('\n <button class="auto-refresh btn' + Utils.sprintf(' btn-%s', this.options.buttonsClass) + '\n ' + Utils.sprintf(' btn-%s', this.options.iconSize) + '\n ' + (this.options.autoRefreshStatus ? 'active' : '') + '"\n type="button" title="' + this.options.formatAutoRefresh() + '">\n <i class="' + this.options.iconsPrefix + ' ' + this.options.icons.autoRefresh + '"></i>\n </button>\n ').appendTo($btnGroup);
|
162 |
|
163 | $btnAutoRefresh.on('click', $.proxy(this.toggleAutoRefresh, this));
|
164 | }
|
165 | }
|
166 | }
|
167 | }, {
|
168 | key: 'toggleAutoRefresh',
|
169 | value: function toggleAutoRefresh() {
|
170 | var _this3 = this;
|
171 |
|
172 | if (this.options.autoRefresh) {
|
173 | if (this.options.autoRefreshStatus) {
|
174 | clearInterval(this.options.autoRefreshFunction);
|
175 | this.$toolbar.find('>.btn-group').find('.auto-refresh').removeClass('active');
|
176 | } else {
|
177 | this.options.autoRefreshFunction = setInterval(function () {
|
178 | _this3.refresh({ silent: _this3.options.autoRefreshSilent });
|
179 | }, this.options.autoRefreshInterval * 1000);
|
180 | this.$toolbar.find('>.btn-group').find('.auto-refresh').addClass('active');
|
181 | }
|
182 | this.options.autoRefreshStatus = !this.options.autoRefreshStatus;
|
183 | }
|
184 | }
|
185 | }]);
|
186 |
|
187 | return _class;
|
188 | }($.BootstrapTable);
|
189 | })(jQuery);
|
190 | }); |
\ | No newline at end of file |