Skip to content

Commit 977fe11

Browse files
committed
Fix wenzhixin#3709, wenzhixin#3671: toolbar extension supports bootstrap 4
1 parent 075823c commit 977fe11

File tree

1 file changed

+43
-14
lines changed

1 file changed

+43
-14
lines changed

src/extensions/toolbar/bootstrap-table-toolbar.js

Lines changed: 43 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,39 @@
99
($ => {
1010
const Utils = $.fn.bootstrapTable.utils
1111

12+
const bootstrap = {
13+
3: {
14+
icons: {
15+
advancedSearchIcon: 'glyphicon-chevron-down'
16+
},
17+
html: {
18+
modalHeader: `
19+
<div class="modal-header">
20+
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
21+
<span aria-hidden="true">&times;</span>
22+
</button>
23+
<h4 class="modal-title">%s</h4>
24+
</div>
25+
`
26+
}
27+
},
28+
4: {
29+
icons: {
30+
advancedSearchIcon: 'fa-chevron-down'
31+
},
32+
html: {
33+
modalHeader: `
34+
<div class="modal-header">
35+
<h4 class="modal-title">%s</h4>
36+
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
37+
<span aria-hidden="true">&times;</span>
38+
</button>
39+
</div>
40+
`
41+
}
42+
}
43+
}[Utils.bootstrapVersion]
44+
1245
$.extend($.fn.bootstrapTable.defaults, {
1346
advancedSearch: false,
1447
idForm: 'advancedSearch',
@@ -20,7 +53,7 @@
2053
})
2154

2255
$.extend($.fn.bootstrapTable.defaults.icons, {
23-
advancedSearchIcon: 'glyphicon-chevron-down'
56+
advancedSearchIcon: bootstrap.icons.advancedSearchIcon
2457
})
2558

2659
$.extend($.fn.bootstrapTable.Constructor.EVENTS, {
@@ -69,14 +102,17 @@
69102
<div id="avdSearchModal_${o.idTable}" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
70103
<div class="modal-dialog modal-xs">
71104
<div class="modal-content">
72-
<div class="modal-header">
73-
<button type="button" class="close" data-dismiss="modal" aria-hidden="true" >&times;</button>
74-
<h4 class="modal-title">${o.formatAdvancedSearch()}</h4>
75-
</div>
105+
${Utils.sprintf(bootstrap.html.modalHeader, o.formatAdvancedSearch())}
76106
<div class="modal-body modal-body-custom">
77-
<div class="container-fluid" id="avdSearchModalContent_${o.idTable}" style="padding-right: 0px; padding-left: 0px;" >
107+
<div class="container-fluid" id="avdSearchModalContent_${o.idTable}"
108+
style="padding-right: 0px; padding-left: 0px;" >
78109
</div>
79110
</div>
111+
<div class="modal-footer">
112+
<button type="button" id="btnCloseAvd_${o.idTable}" class="btn btn-${o.buttonsClass}">
113+
${o.formatAdvancedCloseButton()}
114+
</button>
115+
</div>
80116
</div>
81117
</div>
82118
</div>
@@ -110,7 +146,7 @@
110146
for (let column of this.columns) {
111147
if (!column.checkbox && column.visible && column.searchable) {
112148
html.push(`
113-
<div class="form-group">
149+
<div class="form-group row">
114150
<label class="col-sm-4 control-label">${column.title}</label>
115151
<div class="col-sm-6">
116152
<input type="text" class="form-control input-md" name="${column.field}" placeholder="${column.title}" id="${column.field}">
@@ -120,13 +156,6 @@
120156
}
121157
}
122158

123-
html.push(`
124-
<div class="form-group">
125-
<div class="col-sm-offset-9 col-sm-3">
126-
<button type="button" id="btnCloseAvd_${o.idTable}" class="btn btn-default">${o.formatAdvancedCloseButton()}</button>
127-
</div>
128-
</div>
129-
`)
130159
html.push('</form>')
131160

132161
return html

0 commit comments

Comments
 (0)