corrade-nucleus-nucleons – Blame information for rev 24
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
20 | office | 1 | /** |
2 | * @author: Dennis Hernández |
||
3 | * @webSite: http://djhvscf.github.io/Blog |
||
4 | * @version: v1.1.0 |
||
5 | */ |
||
6 | |||
7 | !function ($) { |
||
8 | |||
9 | 'use strict'; |
||
10 | |||
11 | //From MDN site, https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter |
||
12 | var filterFn = function () { |
||
13 | if (!Array.prototype.filter) { |
||
14 | Array.prototype.filter = function(fun/*, thisArg*/) { |
||
15 | 'use strict'; |
||
16 | |||
17 | if (this === void 0 || this === null) { |
||
18 | throw new TypeError(); |
||
19 | } |
||
20 | |||
21 | var t = Object(this); |
||
22 | var len = t.length >>> 0; |
||
23 | if (typeof fun !== 'function') { |
||
24 | throw new TypeError(); |
||
25 | } |
||
26 | |||
27 | var res = []; |
||
28 | var thisArg = arguments.length >= 2 ? arguments[1] : void 0; |
||
29 | for (var i = 0; i < len; i++) { |
||
30 | if (i in t) { |
||
31 | var val = t[i]; |
||
32 | |||
33 | // NOTE: Technically this should Object.defineProperty at |
||
34 | // the next index, as push can be affected by |
||
35 | // properties on Object.prototype and Array.prototype. |
||
36 | // But that method's new, and collisions should be |
||
37 | // rare, so use the more-compatible alternative. |
||
38 | if (fun.call(thisArg, val, i, t)) { |
||
39 | res.push(val); |
||
40 | } |
||
41 | } |
||
42 | } |
||
43 | |||
44 | return res; |
||
45 | }; |
||
46 | } |
||
47 | }; |
||
48 | |||
49 | $.extend($.fn.bootstrapTable.defaults, { |
||
50 | reorderableColumns: false, |
||
51 | maxMovingRows: 10, |
||
52 | onReorderColumn: function (headerFields) { |
||
53 | return false; |
||
54 | }, |
||
55 | dragaccept: null |
||
56 | }); |
||
57 | |||
58 | $.extend($.fn.bootstrapTable.Constructor.EVENTS, { |
||
59 | 'reorder-column.bs.table': 'onReorderColumn' |
||
60 | }); |
||
61 | |||
62 | var BootstrapTable = $.fn.bootstrapTable.Constructor, |
||
63 | _initHeader = BootstrapTable.prototype.initHeader, |
||
64 | _toggleColumn = BootstrapTable.prototype.toggleColumn, |
||
65 | _toggleView = BootstrapTable.prototype.toggleView, |
||
66 | _resetView = BootstrapTable.prototype.resetView; |
||
67 | |||
68 | BootstrapTable.prototype.initHeader = function () { |
||
69 | _initHeader.apply(this, Array.prototype.slice.apply(arguments)); |
||
70 | |||
71 | if (!this.options.reorderableColumns) { |
||
72 | return; |
||
73 | } |
||
74 | |||
75 | this.makeRowsReorderable(); |
||
76 | }; |
||
77 | |||
78 | BootstrapTable.prototype.toggleColumn = function () { |
||
79 | _toggleColumn.apply(this, Array.prototype.slice.apply(arguments)); |
||
80 | |||
81 | if (!this.options.reorderableColumns) { |
||
82 | return; |
||
83 | } |
||
84 | |||
85 | this.makeRowsReorderable(); |
||
86 | }; |
||
87 | |||
88 | BootstrapTable.prototype.toggleView = function () { |
||
89 | _toggleView.apply(this, Array.prototype.slice.apply(arguments)); |
||
90 | |||
91 | if (!this.options.reorderableColumns) { |
||
92 | return; |
||
93 | } |
||
94 | |||
95 | if (this.options.cardView) { |
||
96 | return; |
||
97 | } |
||
98 | |||
99 | this.makeRowsReorderable(); |
||
100 | }; |
||
101 | |||
102 | BootstrapTable.prototype.resetView = function () { |
||
103 | _resetView.apply(this, Array.prototype.slice.apply(arguments)); |
||
104 | |||
105 | if (!this.options.reorderableColumns) { |
||
106 | return; |
||
107 | } |
||
108 | |||
109 | this.makeRowsReorderable(); |
||
110 | }; |
||
111 | |||
112 | BootstrapTable.prototype.makeRowsReorderable = function () { |
||
113 | var that = this; |
||
114 | try { |
||
115 | $(this.$el).dragtable('destroy'); |
||
116 | } catch (e) {} |
||
117 | $(this.$el).dragtable({ |
||
118 | maxMovingRows: that.options.maxMovingRows, |
||
119 | dragaccept: that.options.dragaccept, |
||
120 | clickDelay:200, |
||
121 | beforeStop: function() { |
||
122 | var ths = [], |
||
123 | formatters = [], |
||
124 | columns = [], |
||
125 | columnsHidden = [], |
||
126 | columnIndex = -1, |
||
127 | optionsColumns = []; |
||
128 | that.$header.find('th').each(function (i) { |
||
129 | ths.push($(this).data('field')); |
||
130 | formatters.push($(this).data('formatter')); |
||
131 | }); |
||
132 | |||
133 | //Exist columns not shown |
||
134 | if (ths.length < that.columns.length) { |
||
135 | columnsHidden = $.grep(that.columns, function (column) { |
||
136 | return !column.visible; |
||
137 | }); |
||
138 | for (var i = 0; i < columnsHidden.length; i++) { |
||
139 | ths.push(columnsHidden[i].field); |
||
140 | formatters.push(columnsHidden[i].formatter); |
||
141 | } |
||
142 | } |
||
143 | |||
144 | for (var i = 0; i < ths.length; i++ ) { |
||
145 | columnIndex = $.fn.bootstrapTable.utils.getFieldIndex(that.columns, ths[i]); |
||
146 | if (columnIndex !== -1) { |
||
147 | that.columns[columnIndex].fieldIndex = i; |
||
148 | columns.push(that.columns[columnIndex]); |
||
149 | that.columns.splice(columnIndex, 1); |
||
150 | } |
||
151 | } |
||
152 | |||
153 | that.columns = that.columns.concat(columns); |
||
154 | |||
155 | filterFn(); //Support <IE9 |
||
156 | $.each(that.columns, function(i, column) { |
||
157 | var found = false, |
||
158 | field = column.field; |
||
159 | that.options.columns[0].filter(function(item) { |
||
160 | if(!found && item["field"] == field) { |
||
161 | optionsColumns.push(item); |
||
162 | found = true; |
||
163 | return false; |
||
164 | } else |
||
165 | return true; |
||
166 | }) |
||
167 | }); |
||
168 | |||
169 | that.options.columns[0] = optionsColumns; |
||
170 | |||
171 | that.header.fields = ths; |
||
172 | that.header.formatters = formatters; |
||
173 | that.initHeader(); |
||
174 | that.initToolbar(); |
||
175 | that.initBody(); |
||
176 | that.resetView(); |
||
177 | that.trigger('reorder-column', ths); |
||
178 | } |
||
179 | }); |
||
180 | }; |
||
181 | }(jQuery); |