corrade-nucleus-nucleons – Blame information for rev 24
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
20 | office | 1 | /** |
2 | * @author: Alec Fenichel |
||
3 | * @webSite: https://fenichelar.com |
||
4 | * @version: v1.0.0 |
||
5 | */ |
||
6 | |||
7 | (function ($) { |
||
8 | |||
9 | 'use strict'; |
||
10 | |||
11 | $.extend($.fn.bootstrapTable.defaults, { |
||
12 | autoRefresh: false, |
||
13 | autoRefreshInterval: 60, |
||
14 | autoRefreshSilent: true, |
||
15 | autoRefreshStatus: true, |
||
16 | autoRefreshFunction: null |
||
17 | }); |
||
18 | |||
19 | $.extend($.fn.bootstrapTable.defaults.icons, { |
||
20 | autoRefresh: 'glyphicon-time icon-time' |
||
21 | }); |
||
22 | |||
23 | $.extend($.fn.bootstrapTable.locales, { |
||
24 | formatAutoRefresh: function() { |
||
25 | return 'Auto Refresh'; |
||
26 | } |
||
27 | }); |
||
28 | |||
29 | $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales); |
||
30 | |||
31 | var BootstrapTable = $.fn.bootstrapTable.Constructor; |
||
32 | var _init = BootstrapTable.prototype.init; |
||
33 | var _initToolbar = BootstrapTable.prototype.initToolbar; |
||
34 | var sprintf = $.fn.bootstrapTable.utils.sprintf; |
||
35 | |||
36 | BootstrapTable.prototype.init = function () { |
||
37 | _init.apply(this, Array.prototype.slice.apply(arguments)); |
||
38 | |||
39 | if (this.options.autoRefresh && this.options.autoRefreshStatus) { |
||
40 | var that = this; |
||
41 | this.options.autoRefreshFunction = setInterval(function () { |
||
42 | that.refresh({silent: that.options.autoRefreshSilent}); |
||
43 | }, this.options.autoRefreshInterval*1000); |
||
44 | } |
||
45 | }; |
||
46 | |||
47 | BootstrapTable.prototype.initToolbar = function() { |
||
48 | _initToolbar.apply(this, Array.prototype.slice.apply(arguments)); |
||
49 | |||
50 | if (this.options.autoRefresh) { |
||
51 | var $btnGroup = this.$toolbar.find('>.btn-group'); |
||
52 | var $btnAutoRefresh = $btnGroup.find('.auto-refresh'); |
||
53 | |||
54 | if (!$btnAutoRefresh.length) { |
||
55 | $btnAutoRefresh = $([ |
||
56 | sprintf('<button class="btn btn-default auto-refresh %s" ', this.options.autoRefreshStatus ? 'enabled' : ''), |
||
57 | 'type="button" ', |
||
58 | sprintf('title="%s">', this.options.formatAutoRefresh()), |
||
59 | sprintf('<i class="%s %s"></i>', this.options.iconsPrefix, this.options.icons.autoRefresh), |
||
60 | '</button>' |
||
61 | ].join('')).appendTo($btnGroup); |
||
62 | |||
63 | $btnAutoRefresh.on('click', $.proxy(this.toggleAutoRefresh, this)); |
||
64 | } |
||
65 | } |
||
66 | }; |
||
67 | |||
68 | BootstrapTable.prototype.toggleAutoRefresh = function() { |
||
69 | if (this.options.autoRefresh) { |
||
70 | if (this.options.autoRefreshStatus) { |
||
71 | clearInterval(this.options.autoRefreshFunction); |
||
72 | this.$toolbar.find('>.btn-group').find('.auto-refresh').removeClass('enabled'); |
||
73 | } else { |
||
74 | var that = this; |
||
75 | this.options.autoRefreshFunction = setInterval(function () { |
||
76 | that.refresh({silent: that.options.autoRefreshSilent}); |
||
77 | }, this.options.autoRefreshInterval*1000); |
||
78 | this.$toolbar.find('>.btn-group').find('.auto-refresh').addClass('enabled'); |
||
79 | } |
||
80 | this.options.autoRefreshStatus = !this.options.autoRefreshStatus; |
||
81 | } |
||
82 | }; |
||
83 | |||
84 | })(jQuery); |