bootstrap-table-rails 1.8.2 → 1.8.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +68 -29
- data/bootstrap-table-rails-1.8.2.gem +0 -0
- data/lib/bootstrap-table-rails/version.rb +1 -1
- data/vendor/assets/javascripts/bootstrap-table-all.js +5177 -9
- data/vendor/assets/javascripts/bootstrap-table-locale-all.js +1500 -6
- data/vendor/assets/javascripts/bootstrap-table.js +2506 -8
- data/vendor/assets/javascripts/extensions/bootstrap-table-angular.js +105 -7
- data/vendor/assets/javascripts/extensions/bootstrap-table-cookie.js +318 -7
- data/vendor/assets/javascripts/extensions/bootstrap-table-editable.js +107 -7
- data/vendor/assets/javascripts/extensions/bootstrap-table-export.js +103 -7
- data/vendor/assets/javascripts/extensions/bootstrap-table-filter-control.js +458 -7
- data/vendor/assets/javascripts/extensions/bootstrap-table-filter.js +67 -7
- data/vendor/assets/javascripts/extensions/bootstrap-table-flat-json.js +62 -7
- data/vendor/assets/javascripts/extensions/bootstrap-table-group-by.js +228 -0
- data/vendor/assets/javascripts/extensions/bootstrap-table-key-events.js +80 -7
- data/vendor/assets/javascripts/extensions/bootstrap-table-mobile.js +142 -7
- data/vendor/assets/javascripts/extensions/bootstrap-table-multiple-sort.js +378 -7
- data/vendor/assets/javascripts/extensions/bootstrap-table-natural-sorting.js +47 -7
- data/vendor/assets/javascripts/extensions/bootstrap-table-reorder-columns.js +130 -7
- data/vendor/assets/javascripts/extensions/bootstrap-table-reorder-rows.js +115 -7
- data/vendor/assets/javascripts/extensions/bootstrap-table-resizable.js +74 -7
- data/vendor/assets/javascripts/extensions/bootstrap-table-toolbar.js +245 -7
- data/vendor/assets/javascripts/locale/bootstrap-table-ar-SA.js +40 -0
- data/vendor/assets/javascripts/locale/bootstrap-table-ca-ES.js +43 -0
- data/vendor/assets/javascripts/locale/bootstrap-table-cs-CZ.js +44 -0
- data/vendor/assets/javascripts/locale/bootstrap-table-da-DK.js +37 -0
- data/vendor/assets/javascripts/locale/bootstrap-table-de-DE.js +37 -0
- data/vendor/assets/javascripts/locale/bootstrap-table-el-GR.js +28 -0
- data/vendor/assets/javascripts/locale/bootstrap-table-en-US.js +43 -0
- data/vendor/assets/javascripts/locale/bootstrap-table-es-AR.js +31 -0
- data/vendor/assets/javascripts/locale/bootstrap-table-es-CR.js +40 -0
- data/vendor/assets/javascripts/locale/bootstrap-table-es-ES.js +43 -0
- data/vendor/assets/javascripts/locale/bootstrap-table-es-MX.js +32 -0
- data/vendor/assets/javascripts/locale/bootstrap-table-es-NI.js +40 -0
- data/vendor/assets/javascripts/locale/bootstrap-table-es-SP.js +40 -0
- data/vendor/assets/javascripts/locale/bootstrap-table-fa-IR.js +43 -0
- data/vendor/assets/javascripts/locale/bootstrap-table-fr-BE.js +28 -0
- data/vendor/assets/javascripts/locale/bootstrap-table-fr-FR.js +41 -0
- data/vendor/assets/javascripts/locale/bootstrap-table-hr-HR.js +44 -0
- data/vendor/assets/javascripts/locale/bootstrap-table-hu-HU.js +43 -0
- data/vendor/assets/javascripts/locale/bootstrap-table-it-IT.js +37 -0
- data/vendor/assets/javascripts/locale/bootstrap-table-ja-JP.js +40 -0
- data/vendor/assets/javascripts/locale/bootstrap-table-ka-GE.js +40 -0
- data/vendor/assets/javascripts/locale/bootstrap-table-ko-KR.js +37 -0
- data/vendor/assets/javascripts/locale/bootstrap-table-ms-MY.js +40 -0
- data/vendor/assets/javascripts/locale/bootstrap-table-nb-NO.js +37 -0
- data/vendor/assets/javascripts/locale/bootstrap-table-nl-NL.js +28 -0
- data/vendor/assets/javascripts/locale/bootstrap-table-pl-PL.js +37 -0
- data/vendor/assets/javascripts/locale/bootstrap-table-pt-BR.js +41 -0
- data/vendor/assets/javascripts/locale/bootstrap-table-pt-PT.js +28 -0
- data/vendor/assets/javascripts/locale/bootstrap-table-ro-RO.js +43 -0
- data/vendor/assets/javascripts/locale/bootstrap-table-ru-RU.js +36 -0
- data/vendor/assets/javascripts/locale/bootstrap-table-sk-SK.js +37 -0
- data/vendor/assets/javascripts/locale/bootstrap-table-sv-SE.js +37 -0
- data/vendor/assets/javascripts/locale/bootstrap-table-th-TH.js +37 -0
- data/vendor/assets/javascripts/locale/bootstrap-table-tr-TR.js +41 -0
- data/vendor/assets/javascripts/locale/bootstrap-table-uk-UA.js +37 -0
- data/vendor/assets/javascripts/locale/bootstrap-table-ur-PK.js +37 -0
- data/vendor/assets/javascripts/locale/bootstrap-table-vi-VN.js +28 -0
- data/vendor/assets/javascripts/locale/bootstrap-table-zh-CN.js +40 -0
- data/vendor/assets/javascripts/locale/bootstrap-table-zh-TW.js +40 -0
- data/vendor/assets/stylesheets/bootstrap-table.css +297 -1
- data/vendor/assets/stylesheets/extensions/bootstrap-table-group-by.css +53 -0
- metadata +44 -2
@@ -1,7 +1,47 @@
|
|
1
|
-
|
2
|
-
*
|
3
|
-
*
|
4
|
-
*
|
5
|
-
*
|
6
|
-
|
7
|
-
|
1
|
+
/**
|
2
|
+
* @author: Brian Huisman
|
3
|
+
* @webSite: http://www.greywyvern.com
|
4
|
+
* @version: v1.0.0
|
5
|
+
* JS function to allow natural sorting on bootstrap-table columns
|
6
|
+
* just add data-sorter="alphanum" to any th
|
7
|
+
*
|
8
|
+
* @update Dennis Hernández <http://djhvscf.github.io/Blog>
|
9
|
+
*/
|
10
|
+
|
11
|
+
function alphanum(a, b) {
|
12
|
+
function chunkify(t) {
|
13
|
+
var tz = [],
|
14
|
+
x = 0,
|
15
|
+
y = -1,
|
16
|
+
n = 0,
|
17
|
+
i,
|
18
|
+
j;
|
19
|
+
|
20
|
+
while (i = (j = t.charAt(x++)).charCodeAt(0)) {
|
21
|
+
var m = (i === 46 || (i >= 48 && i <= 57));
|
22
|
+
if (m !== n) {
|
23
|
+
tz[++y] = "";
|
24
|
+
n = m;
|
25
|
+
}
|
26
|
+
tz[y] += j;
|
27
|
+
}
|
28
|
+
return tz;
|
29
|
+
}
|
30
|
+
|
31
|
+
var aa = chunkify(a);
|
32
|
+
var bb = chunkify(b);
|
33
|
+
|
34
|
+
for (x = 0; aa[x] && bb[x]; x++) {
|
35
|
+
if (aa[x] !== bb[x]) {
|
36
|
+
var c = Number(aa[x]),
|
37
|
+
d = Number(bb[x]);
|
38
|
+
|
39
|
+
if (c == aa[x] && d == bb[x]) {
|
40
|
+
return c - d;
|
41
|
+
} else {
|
42
|
+
return (aa[x] > bb[x]) ? 1 : -1;
|
43
|
+
}
|
44
|
+
}
|
45
|
+
}
|
46
|
+
return aa.length - bb.length;
|
47
|
+
}
|
@@ -1,7 +1,130 @@
|
|
1
|
-
|
2
|
-
*
|
3
|
-
*
|
4
|
-
*
|
5
|
-
|
6
|
-
|
7
|
-
!function
|
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
|
+
var getFieldIndex = function (columns, field) {
|
12
|
+
var index = -1;
|
13
|
+
|
14
|
+
$.each(columns, function (i, column) {
|
15
|
+
if (column.field === field) {
|
16
|
+
index = i;
|
17
|
+
return false;
|
18
|
+
}
|
19
|
+
return true;
|
20
|
+
});
|
21
|
+
return index;
|
22
|
+
};
|
23
|
+
|
24
|
+
$.extend($.fn.bootstrapTable.defaults, {
|
25
|
+
reorderableColumns: false,
|
26
|
+
maxMovingRows: 10,
|
27
|
+
onReorderColumn: function (headerFields) {
|
28
|
+
return false;
|
29
|
+
},
|
30
|
+
dragaccept: null
|
31
|
+
});
|
32
|
+
|
33
|
+
$.extend($.fn.bootstrapTable.Constructor.EVENTS, {
|
34
|
+
'reorder-column.bs.table': 'onReorderColumn'
|
35
|
+
});
|
36
|
+
|
37
|
+
var BootstrapTable = $.fn.bootstrapTable.Constructor,
|
38
|
+
_initHeader = BootstrapTable.prototype.initHeader,
|
39
|
+
_toggleColumn = BootstrapTable.prototype.toggleColumn,
|
40
|
+
_toggleView = BootstrapTable.prototype.toggleView,
|
41
|
+
_resetView = BootstrapTable.prototype.resetView;
|
42
|
+
|
43
|
+
BootstrapTable.prototype.initHeader = function () {
|
44
|
+
_initHeader.apply(this, Array.prototype.slice.apply(arguments));
|
45
|
+
|
46
|
+
if (!this.options.reorderableColumns) {
|
47
|
+
return;
|
48
|
+
}
|
49
|
+
|
50
|
+
this.makeRowsReorderable();
|
51
|
+
};
|
52
|
+
|
53
|
+
BootstrapTable.prototype.toggleColumn = function () {
|
54
|
+
_toggleColumn.apply(this, Array.prototype.slice.apply(arguments));
|
55
|
+
|
56
|
+
if (!this.options.reorderableColumns) {
|
57
|
+
return;
|
58
|
+
}
|
59
|
+
|
60
|
+
this.makeRowsReorderable();
|
61
|
+
};
|
62
|
+
|
63
|
+
BootstrapTable.prototype.toggleView = function () {
|
64
|
+
_toggleView.apply(this, Array.prototype.slice.apply(arguments));
|
65
|
+
|
66
|
+
if (!this.options.reorderableColumns) {
|
67
|
+
return;
|
68
|
+
}
|
69
|
+
|
70
|
+
if (this.options.cardView) {
|
71
|
+
return;
|
72
|
+
}
|
73
|
+
|
74
|
+
this.makeRowsReorderable();
|
75
|
+
};
|
76
|
+
|
77
|
+
BootstrapTable.prototype.resetView = function () {
|
78
|
+
_resetView.apply(this, Array.prototype.slice.apply(arguments));
|
79
|
+
|
80
|
+
if (!this.options.reorderableColumns) {
|
81
|
+
return;
|
82
|
+
}
|
83
|
+
|
84
|
+
this.makeRowsReorderable();
|
85
|
+
};
|
86
|
+
|
87
|
+
BootstrapTable.prototype.makeRowsReorderable = function () {
|
88
|
+
var that = this;
|
89
|
+
try {
|
90
|
+
$(this.$el).dragtable('destroy');
|
91
|
+
} catch (e) {}
|
92
|
+
$(this.$el).dragtable({
|
93
|
+
maxMovingRows: that.options.maxMovingRows,
|
94
|
+
dragaccept: that.options.dragaccept,
|
95
|
+
clickDelay:200,
|
96
|
+
beforeStop: function() {
|
97
|
+
var ths = [],
|
98
|
+
columns = [],
|
99
|
+
columnsHidden = [],
|
100
|
+
columnIndex = -1;
|
101
|
+
that.$header.find('th').each(function (i) {
|
102
|
+
ths.push($(this).data('field'));
|
103
|
+
});
|
104
|
+
|
105
|
+
//Exist columns not shown
|
106
|
+
if (ths.length < that.columns.length) {
|
107
|
+
columnsHidden = $.grep(that.columns, function (column) {
|
108
|
+
return !column.visible;
|
109
|
+
});
|
110
|
+
for (var i = 0; i < columnsHidden.length; i++) {
|
111
|
+
ths.push(columnsHidden[i].field);
|
112
|
+
}
|
113
|
+
}
|
114
|
+
|
115
|
+
for (var i = 0; i < ths.length; i++ ) {
|
116
|
+
columnIndex = getFieldIndex(that.columns, ths[i]);
|
117
|
+
if (columnIndex !== -1) {
|
118
|
+
columns.push(that.columns[columnIndex]);
|
119
|
+
that.columns.splice(columnIndex, 1);
|
120
|
+
}
|
121
|
+
}
|
122
|
+
|
123
|
+
that.columns = that.columns.concat(columns);
|
124
|
+
that.header.fields = ths;
|
125
|
+
that.resetView();
|
126
|
+
that.trigger('reorder-column', ths);
|
127
|
+
}
|
128
|
+
});
|
129
|
+
};
|
130
|
+
}(jQuery);
|
@@ -1,7 +1,115 @@
|
|
1
|
-
|
2
|
-
*
|
3
|
-
*
|
4
|
-
*
|
5
|
-
|
6
|
-
|
7
|
-
!function
|
1
|
+
/**
|
2
|
+
* @author: Dennis Hernández
|
3
|
+
* @webSite: http://djhvscf.github.io/Blog
|
4
|
+
* @version: v1.0.0
|
5
|
+
*/
|
6
|
+
|
7
|
+
!function ($) {
|
8
|
+
|
9
|
+
'use strict';
|
10
|
+
|
11
|
+
var isSearch = false;
|
12
|
+
|
13
|
+
var rowAttr = function (row, index) {
|
14
|
+
return {
|
15
|
+
id: 'customId_' + index
|
16
|
+
};
|
17
|
+
};
|
18
|
+
|
19
|
+
$.extend($.fn.bootstrapTable.defaults, {
|
20
|
+
reorderableRows: false,
|
21
|
+
onDragStyle: null,
|
22
|
+
onDropStyle: null,
|
23
|
+
onDragClass: "reorder_rows_onDragClass",
|
24
|
+
dragHandle: null,
|
25
|
+
useRowAttrFunc: false,
|
26
|
+
onReorderRowsDrag: function (table, row) {
|
27
|
+
return false;
|
28
|
+
},
|
29
|
+
onReorderRowsDrop: function (table, row) {
|
30
|
+
return false;
|
31
|
+
},
|
32
|
+
onReorderRow: function (newData) {
|
33
|
+
return false;
|
34
|
+
}
|
35
|
+
});
|
36
|
+
|
37
|
+
$.extend($.fn.bootstrapTable.Constructor.EVENTS, {
|
38
|
+
'reorder-row.bs.table': 'onReorderRow'
|
39
|
+
});
|
40
|
+
|
41
|
+
var BootstrapTable = $.fn.bootstrapTable.Constructor,
|
42
|
+
_init = BootstrapTable.prototype.init,
|
43
|
+
_initSearch = BootstrapTable.prototype.initSearch;
|
44
|
+
|
45
|
+
BootstrapTable.prototype.init = function () {
|
46
|
+
|
47
|
+
if (!this.options.reorderableRows) {
|
48
|
+
return;
|
49
|
+
}
|
50
|
+
|
51
|
+
var that = this;
|
52
|
+
if (this.options.useRowAttrFunc) {
|
53
|
+
this.options.rowAttributes = rowAttr;
|
54
|
+
}
|
55
|
+
|
56
|
+
var onPostBody = this.options.onPostBody;
|
57
|
+
this.options.onPostBody = function () {
|
58
|
+
setTimeout(function () {
|
59
|
+
that.makeRowsReorderable();
|
60
|
+
onPostBody.apply();
|
61
|
+
}, 1);
|
62
|
+
};
|
63
|
+
|
64
|
+
_init.apply(this, Array.prototype.slice.apply(arguments));
|
65
|
+
};
|
66
|
+
|
67
|
+
BootstrapTable.prototype.initSearch = function () {
|
68
|
+
_initSearch.apply(this, Array.prototype.slice.apply(arguments));
|
69
|
+
|
70
|
+
if (!this.options.reorderableRows) {
|
71
|
+
return;
|
72
|
+
}
|
73
|
+
|
74
|
+
//Known issue after search if you reorder the rows the data is not display properly
|
75
|
+
//isSearch = true;
|
76
|
+
};
|
77
|
+
|
78
|
+
BootstrapTable.prototype.makeRowsReorderable = function () {
|
79
|
+
if (this.options.cardView) {
|
80
|
+
return;
|
81
|
+
}
|
82
|
+
|
83
|
+
var that = this;
|
84
|
+
this.$el.tableDnD({
|
85
|
+
onDragStyle: that.options.onDragStyle,
|
86
|
+
onDropStyle: that.options.onDropStyle,
|
87
|
+
onDragClass: that.options.onDragClass,
|
88
|
+
onDrop: that.onDrop,
|
89
|
+
onDragStart: that.options.onReorderRowsDrag,
|
90
|
+
dragHandle: that.options.dragHandle
|
91
|
+
});
|
92
|
+
};
|
93
|
+
|
94
|
+
BootstrapTable.prototype.onDrop = function (table, droppedRow) {
|
95
|
+
var tableBs = $(table),
|
96
|
+
tableBsData = tableBs.data('bootstrap.table'),
|
97
|
+
tableBsOptions = tableBs.data('bootstrap.table').options,
|
98
|
+
row = null,
|
99
|
+
newData = [];
|
100
|
+
|
101
|
+
for (var i = 0; i < table.tBodies[0].rows.length; i++) {
|
102
|
+
row = $(table.tBodies[0].rows[i]);
|
103
|
+
newData.push(tableBsOptions.data[row.data('index')]);
|
104
|
+
row.data('index', i).attr('data-index', i);
|
105
|
+
}
|
106
|
+
|
107
|
+
tableBsOptions.data = newData;
|
108
|
+
|
109
|
+
//Call the user defined function
|
110
|
+
tableBsOptions.onReorderRowsDrop.apply(table, [table, droppedRow]);
|
111
|
+
|
112
|
+
//Call the event reorder-row
|
113
|
+
tableBsData.trigger('reorder-row', newData);
|
114
|
+
};
|
115
|
+
}(jQuery);
|
@@ -1,7 +1,74 @@
|
|
1
|
-
|
2
|
-
*
|
3
|
-
*
|
4
|
-
*
|
5
|
-
|
6
|
-
|
7
|
-
|
1
|
+
/**
|
2
|
+
* @author: Dennis Hernández
|
3
|
+
* @webSite: http://djhvscf.github.io/Blog
|
4
|
+
* @version: v1.0.0
|
5
|
+
*/
|
6
|
+
|
7
|
+
(function ($) {
|
8
|
+
'use strict';
|
9
|
+
|
10
|
+
var initResizable = function (that) {
|
11
|
+
//Deletes the plugin to re-create it
|
12
|
+
that.$el.colResizable({disable: true});
|
13
|
+
|
14
|
+
//Creates the plugin
|
15
|
+
that.$el.colResizable({
|
16
|
+
liveDrag: that.options.liveDrag,
|
17
|
+
fixed: that.options.fixed,
|
18
|
+
headerOnly: that.options.headerOnly,
|
19
|
+
minWidth: that.options.minWidth,
|
20
|
+
hoverCursor: that.options.hoverCursor,
|
21
|
+
dragCursor: that.options.dragCursor,
|
22
|
+
onResize: that.onResize,
|
23
|
+
onDrag: that.options.onResizableDrag
|
24
|
+
});
|
25
|
+
};
|
26
|
+
|
27
|
+
$.extend($.fn.bootstrapTable.defaults, {
|
28
|
+
resizable: false,
|
29
|
+
liveDrag: false,
|
30
|
+
fixed: true,
|
31
|
+
headerOnly: false,
|
32
|
+
minWidth: 15,
|
33
|
+
hoverCursor: 'e-resize',
|
34
|
+
dragCursor: 'e-resize',
|
35
|
+
onResizableResize: function (e) {
|
36
|
+
return false;
|
37
|
+
},
|
38
|
+
onResizableDrag: function (e) {
|
39
|
+
return false;
|
40
|
+
}
|
41
|
+
});
|
42
|
+
|
43
|
+
var BootstrapTable = $.fn.bootstrapTable.Constructor,
|
44
|
+
_toggleView = BootstrapTable.prototype.toggleView,
|
45
|
+
_resetView = BootstrapTable.prototype.resetView;
|
46
|
+
|
47
|
+
BootstrapTable.prototype.toggleView = function () {
|
48
|
+
_toggleView.apply(this, Array.prototype.slice.apply(arguments));
|
49
|
+
|
50
|
+
if (this.options.resizable && this.options.cardView) {
|
51
|
+
//Deletes the plugin
|
52
|
+
$(this.$el).colResizable({disable: true});
|
53
|
+
}
|
54
|
+
};
|
55
|
+
|
56
|
+
BootstrapTable.prototype.resetView = function () {
|
57
|
+
var that = this;
|
58
|
+
|
59
|
+
_resetView.apply(this, Array.prototype.slice.apply(arguments));
|
60
|
+
|
61
|
+
if (this.options.resizable) {
|
62
|
+
// because in fitHeader function, we use setTimeout(func, 100);
|
63
|
+
setTimeout(function () {
|
64
|
+
initResizable(that);
|
65
|
+
}, 100);
|
66
|
+
}
|
67
|
+
};
|
68
|
+
|
69
|
+
BootstrapTable.prototype.onResize = function (e) {
|
70
|
+
var that = $(e.currentTarget);
|
71
|
+
that.bootstrapTable('resetView');
|
72
|
+
that.data('bootstrap.table').options.onResizableResize.apply(e);
|
73
|
+
}
|
74
|
+
})(jQuery);
|
@@ -1,7 +1,245 @@
|
|
1
|
-
|
2
|
-
*
|
3
|
-
*
|
4
|
-
*
|
5
|
-
*
|
6
|
-
*/
|
7
|
-
|
1
|
+
/**
|
2
|
+
* @author: aperez <aperez@datadec.es>
|
3
|
+
* @version: v2.0.0
|
4
|
+
*
|
5
|
+
* @update Dennis Hernández <http://djhvscf.github.io/Blog>
|
6
|
+
*/
|
7
|
+
|
8
|
+
!function($) {
|
9
|
+
'use strict';
|
10
|
+
|
11
|
+
var firstLoad = false;
|
12
|
+
|
13
|
+
var sprintf = function(str) {
|
14
|
+
var args = arguments,
|
15
|
+
flag = true,
|
16
|
+
i = 1;
|
17
|
+
|
18
|
+
str = str.replace(/%s/g, function() {
|
19
|
+
var arg = args[i++];
|
20
|
+
|
21
|
+
if (typeof arg === 'undefined') {
|
22
|
+
flag = false;
|
23
|
+
return '';
|
24
|
+
}
|
25
|
+
return arg;
|
26
|
+
});
|
27
|
+
return flag ? str : '';
|
28
|
+
};
|
29
|
+
|
30
|
+
var calculateObjectValue = function (self, name, args, defaultValue) {
|
31
|
+
if (typeof name === 'string') {
|
32
|
+
// support obj.func1.func2
|
33
|
+
var names = name.split('.');
|
34
|
+
|
35
|
+
if (names.length > 1) {
|
36
|
+
name = window;
|
37
|
+
$.each(names, function (i, f) {
|
38
|
+
name = name[f];
|
39
|
+
});
|
40
|
+
} else {
|
41
|
+
name = window[name];
|
42
|
+
}
|
43
|
+
}
|
44
|
+
if (typeof name === 'object') {
|
45
|
+
return name;
|
46
|
+
}
|
47
|
+
if (typeof name === 'function') {
|
48
|
+
return name.apply(self, args);
|
49
|
+
}
|
50
|
+
return defaultValue;
|
51
|
+
};
|
52
|
+
|
53
|
+
var showAvdSearch = function(pColumns, searchTitle, searchText, that) {
|
54
|
+
if (!$("#avdSearchModal").hasClass("modal")) {
|
55
|
+
var vModal = "<div id=\"avdSearchModal\" class=\"modal fade\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"mySmallModalLabel\" aria-hidden=\"true\">";
|
56
|
+
vModal += "<div class=\"modal-dialog modal-xs\">";
|
57
|
+
vModal += " <div class=\"modal-content\">";
|
58
|
+
vModal += " <div class=\"modal-header\">";
|
59
|
+
vModal += " <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-hidden=\"true\" >×</button>";
|
60
|
+
vModal += sprintf(" <h4 class=\"modal-title\">%s</h4>", searchTitle);
|
61
|
+
vModal += " </div>";
|
62
|
+
vModal += " <div class=\"modal-body modal-body-custom\">";
|
63
|
+
vModal += " <div class=\"container-fluid\" id=\"avdSearchModalContent\" style=\"padding-right: 0px;padding-left: 0px;\" >";
|
64
|
+
vModal += " </div>";
|
65
|
+
vModal += " </div>";
|
66
|
+
vModal += " </div>";
|
67
|
+
vModal += " </div>";
|
68
|
+
vModal += "</div>";
|
69
|
+
|
70
|
+
$("body").append($(vModal));
|
71
|
+
|
72
|
+
var vFormAvd = createFormAvd(pColumns, searchText, that),
|
73
|
+
timeoutId = 0;;
|
74
|
+
|
75
|
+
$('#avdSearchModalContent').append(vFormAvd.join(''));
|
76
|
+
|
77
|
+
$('#' + that.options.idForm).off('keyup blur', 'input').on('keyup blur', 'input', function (event) {
|
78
|
+
clearTimeout(timeoutId);
|
79
|
+
timeoutId = setTimeout(function () {
|
80
|
+
that.onColumnAdvancedSearch(event);
|
81
|
+
}, that.options.searchTimeOut);
|
82
|
+
});
|
83
|
+
|
84
|
+
$("#btnCloseAvd").click(function() {
|
85
|
+
$("#avdSearchModal").modal('hide');
|
86
|
+
});
|
87
|
+
|
88
|
+
$("#avdSearchModal").modal();
|
89
|
+
} else {
|
90
|
+
$("#avdSearchModal").modal();
|
91
|
+
}
|
92
|
+
};
|
93
|
+
|
94
|
+
var createFormAvd = function(pColumns, searchText, that) {
|
95
|
+
var htmlForm = [];
|
96
|
+
htmlForm.push(sprintf('<form class="form-horizontal" id="%s" action="%s" >', that.options.idForm, that.options.actionForm));
|
97
|
+
for (var i in pColumns) {
|
98
|
+
var vObjCol = pColumns[i];
|
99
|
+
if (!vObjCol.checkbox && vObjCol.visible && vObjCol.searchable) {
|
100
|
+
htmlForm.push('<div class="form-group">');
|
101
|
+
htmlForm.push(sprintf('<label class="col-sm-4 control-label">%s</label>', vObjCol.title));
|
102
|
+
htmlForm.push('<div class="col-sm-6">');
|
103
|
+
htmlForm.push(sprintf('<input type="text" class="form-control input-md" name="%s" placeholder="%s" id="%s">', vObjCol.field, vObjCol.title, vObjCol.field));
|
104
|
+
htmlForm.push('</div>');
|
105
|
+
htmlForm.push('</div>');
|
106
|
+
}
|
107
|
+
}
|
108
|
+
|
109
|
+
htmlForm.push('<div class="form-group">');
|
110
|
+
htmlForm.push('<div class="col-sm-offset-9 col-sm-3">');
|
111
|
+
htmlForm.push(sprintf('<button type="button" id="btnCloseAvd" class="btn btn-default" >%s</button>', searchText));
|
112
|
+
htmlForm.push('</div>');
|
113
|
+
htmlForm.push('</div>');
|
114
|
+
htmlForm.push('</form>');
|
115
|
+
|
116
|
+
return htmlForm;
|
117
|
+
};
|
118
|
+
|
119
|
+
$.extend($.fn.bootstrapTable.defaults, {
|
120
|
+
advancedSearch: false,
|
121
|
+
idForm: 'advancedSearch',
|
122
|
+
actionForm: '',
|
123
|
+
idTable: undefined,
|
124
|
+
onColumnAdvancedSearch: function (field, text) {
|
125
|
+
return false;
|
126
|
+
}
|
127
|
+
});
|
128
|
+
|
129
|
+
$.extend($.fn.bootstrapTable.defaults.icons, {
|
130
|
+
advancedSearchIcon: 'glyphicon-chevron-down'
|
131
|
+
});
|
132
|
+
|
133
|
+
$.extend($.fn.bootstrapTable.Constructor.EVENTS, {
|
134
|
+
'column-advanced-search.bs.table': 'onColumnAdvancedSearch'
|
135
|
+
});
|
136
|
+
|
137
|
+
$.extend($.fn.bootstrapTable.locales, {
|
138
|
+
formatAdvancedSearch: function() {
|
139
|
+
return 'Advanced search';
|
140
|
+
},
|
141
|
+
formatAdvancedCloseButton: function() {
|
142
|
+
return "Close";
|
143
|
+
}
|
144
|
+
});
|
145
|
+
|
146
|
+
$.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales);
|
147
|
+
|
148
|
+
var BootstrapTable = $.fn.bootstrapTable.Constructor,
|
149
|
+
_initToolbar = BootstrapTable.prototype.initToolbar,
|
150
|
+
_load = BootstrapTable.prototype.load,
|
151
|
+
_initSearch = BootstrapTable.prototype.initSearch;
|
152
|
+
|
153
|
+
BootstrapTable.prototype.initToolbar = function() {
|
154
|
+
_initToolbar.apply(this, Array.prototype.slice.apply(arguments));
|
155
|
+
|
156
|
+
if (!this.options.search) {
|
157
|
+
return;
|
158
|
+
}
|
159
|
+
|
160
|
+
if (!this.options.advancedSearch) {
|
161
|
+
return;
|
162
|
+
}
|
163
|
+
|
164
|
+
var that = this,
|
165
|
+
html = [];
|
166
|
+
|
167
|
+
html.push(sprintf('<div class="columns columns-%s btn-group pull-%s" role="group">', this.options.buttonsAlign, this.options.buttonsAlign));
|
168
|
+
html.push(sprintf('<button class="btn btn-default%s' + '" type="button" name="advancedSearch" title="%s">', that.options.iconSize === undefined ? '' : ' btn-' + that.options.iconSize, that.options.formatAdvancedSearch()));
|
169
|
+
html.push(sprintf('<i class="%s %s"></i>', that.options.iconsPrefix, that.options.icons.advancedSearchIcon))
|
170
|
+
html.push('</button></div>');
|
171
|
+
|
172
|
+
that.$toolbar.prepend(html.join(''));
|
173
|
+
|
174
|
+
that.$toolbar.find('button[name="advancedSearch"]')
|
175
|
+
.off('click').on('click', function() {
|
176
|
+
showAvdSearch(that.columns, that.options.formatAdvancedSearch(), that.options.formatAdvancedCloseButton(), that);
|
177
|
+
});
|
178
|
+
};
|
179
|
+
|
180
|
+
BootstrapTable.prototype.load = function(data) {
|
181
|
+
_load.apply(this, Array.prototype.slice.apply(arguments));
|
182
|
+
|
183
|
+
if (!this.options.advancedSearch) {
|
184
|
+
return;
|
185
|
+
}
|
186
|
+
|
187
|
+
if (typeof this.options.idTable === 'undefined') {
|
188
|
+
return;
|
189
|
+
} else {
|
190
|
+
if (!firstLoad) {
|
191
|
+
var height = parseInt($(".bootstrap-table").height());
|
192
|
+
height += 10;
|
193
|
+
$("#" + this.options.idTable).bootstrapTable("resetView", {height: height});
|
194
|
+
firstLoad = true;
|
195
|
+
}
|
196
|
+
}
|
197
|
+
};
|
198
|
+
|
199
|
+
BootstrapTable.prototype.initSearch = function () {
|
200
|
+
_initSearch.apply(this, Array.prototype.slice.apply(arguments));
|
201
|
+
|
202
|
+
if (!this.options.advancedSearch) {
|
203
|
+
return;
|
204
|
+
}
|
205
|
+
|
206
|
+
var that = this;
|
207
|
+
var fp = $.isEmptyObject(this.filterColumnsPartial) ? null : this.filterColumnsPartial;
|
208
|
+
|
209
|
+
this.data = fp ? $.grep(this.data, function (item, i) {
|
210
|
+
for (var key in fp) {
|
211
|
+
var fval = fp[key].toLowerCase();
|
212
|
+
var value = item[key];
|
213
|
+
value = calculateObjectValue(that.header,
|
214
|
+
that.header.formatters[$.inArray(key, that.header.fields)],
|
215
|
+
[value, item, i], value);
|
216
|
+
|
217
|
+
if (!($.inArray(key, that.header.fields) !== -1 &&
|
218
|
+
(typeof value === 'string' || typeof value === 'number') &&
|
219
|
+
(value + '').toLowerCase().indexOf(fval) !== -1)) {
|
220
|
+
return false;
|
221
|
+
}
|
222
|
+
}
|
223
|
+
return true;
|
224
|
+
}) : this.data;
|
225
|
+
};
|
226
|
+
|
227
|
+
BootstrapTable.prototype.onColumnAdvancedSearch = function (event) {
|
228
|
+
var text = $.trim($(event.currentTarget).val());
|
229
|
+
var $field = $(event.currentTarget)[0].id;
|
230
|
+
|
231
|
+
if ($.isEmptyObject(this.filterColumnsPartial)) {
|
232
|
+
this.filterColumnsPartial = {};
|
233
|
+
}
|
234
|
+
if (text) {
|
235
|
+
this.filterColumnsPartial[$field] = text;
|
236
|
+
} else {
|
237
|
+
delete this.filterColumnsPartial[$field];
|
238
|
+
}
|
239
|
+
|
240
|
+
this.options.pageNumber = 1;
|
241
|
+
this.onSearch(event);
|
242
|
+
this.updatePagination();
|
243
|
+
this.trigger('column-advanced-search', $field, text);
|
244
|
+
};
|
245
|
+
}(jQuery);
|