|
|
@@ -86,54 +86,83 @@ $.BootstrapTable = class extends $.BootstrapTable {
|
|
|
|
|
|
let $menu = $(this.constants.html.toolbarDropdown.join(''))
|
|
|
|
|
|
- this.$export = $(`
|
|
|
- <div class="export ${this.constants.classes.buttonsDropdown}">
|
|
|
- <button class="${this.constants.buttonsClass} dropdown-toggle"
|
|
|
+ let exportTypes = o.exportTypes
|
|
|
+
|
|
|
+ if (typeof exportTypes === 'string') {
|
|
|
+ const types = exportTypes.slice(1, -1).replace(/ /g, '').split(',')
|
|
|
+ exportTypes = types.map(t => t.slice(1, -1))
|
|
|
+ }
|
|
|
+
|
|
|
+ if (exportTypes.length === 1) {
|
|
|
+ this.$export = $(`
|
|
|
+ <div class="export">
|
|
|
+ <button class="${this.constants.buttonsClass}"
|
|
|
aria-label="Export"
|
|
|
- data-toggle="dropdown"
|
|
|
type="button"
|
|
|
title="${o.formatExport()}">
|
|
|
${o.showButtonIcons ? Utils.sprintf(this.constants.html.icon, o.iconsPrefix, o.icons.export) : ''}
|
|
|
${o.showButtonText ? o.formatExport() : ''}
|
|
|
- ${this.constants.html.dropdownCaret}
|
|
|
</button>
|
|
|
</div>
|
|
|
`).appendTo($btnGroup)
|
|
|
- this.$export.append($menu)
|
|
|
|
|
|
- this.updateExportButton()
|
|
|
+ this.updateExportButton()
|
|
|
|
|
|
- let exportTypes = o.exportTypes
|
|
|
+ $btnGroup.click(e => {
|
|
|
+ e.preventDefault()
|
|
|
|
|
|
- if (typeof exportTypes === 'string') {
|
|
|
- const types = exportTypes.slice(1, -1).replace(/ /g, '').split(',')
|
|
|
- exportTypes = types.map(t => t.slice(1, -1))
|
|
|
- }
|
|
|
+ const type = exportTypes[0]
|
|
|
+ const exportOptions = {
|
|
|
+ type,
|
|
|
+ escape: false
|
|
|
+ }
|
|
|
|
|
|
- // themes support
|
|
|
- if ($menu.children().length) {
|
|
|
- $menu = $menu.children().eq(0)
|
|
|
- }
|
|
|
- for (const type of exportTypes) {
|
|
|
- if (TYPE_NAME.hasOwnProperty(type)) {
|
|
|
- const $item = $(Utils.sprintf(this.constants.html.pageDropdownItem,
|
|
|
- '', TYPE_NAME[type]))
|
|
|
- $item.attr('data-type', type)
|
|
|
- $menu.append($item)
|
|
|
- }
|
|
|
+ this.exportTable(exportOptions)
|
|
|
+ })
|
|
|
}
|
|
|
+ else {
|
|
|
+ this.$export = $(`
|
|
|
+ <div class="export ${this.constants.classes.buttonsDropdown}">
|
|
|
+ <button class="${this.constants.buttonsClass} dropdown-toggle"
|
|
|
+ aria-label="Export"
|
|
|
+ data-toggle="dropdown"
|
|
|
+ type="button"
|
|
|
+ title="${o.formatExport()}">
|
|
|
+ ${o.showButtonIcons ? Utils.sprintf(this.constants.html.icon, o.iconsPrefix, o.icons.export) : ''}
|
|
|
+ ${o.showButtonText ? o.formatExport() : ''}
|
|
|
+ ${this.constants.html.dropdownCaret}
|
|
|
+ </button>
|
|
|
+ </div>
|
|
|
+ `).appendTo($btnGroup)
|
|
|
+ this.$export.append($menu)
|
|
|
|
|
|
- $menu.children().click(e => {
|
|
|
- e.preventDefault()
|
|
|
+ this.updateExportButton()
|
|
|
|
|
|
- const type = $(e.currentTarget).data('type')
|
|
|
- const exportOptions = {
|
|
|
- type,
|
|
|
- escape: false
|
|
|
+ // themes support
|
|
|
+ if ($menu.children().length) {
|
|
|
+ $menu = $menu.children().eq(0)
|
|
|
}
|
|
|
+ for (const type of exportTypes) {
|
|
|
+ if (TYPE_NAME.hasOwnProperty(type)) {
|
|
|
+ const $item = $(Utils.sprintf(this.constants.html.pageDropdownItem,
|
|
|
+ '', TYPE_NAME[type]))
|
|
|
+ $item.attr('data-type', type)
|
|
|
+ $menu.append($item)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $menu.children().click(e => {
|
|
|
+ e.preventDefault()
|
|
|
+
|
|
|
+ const type = $(e.currentTarget).data('type')
|
|
|
+ const exportOptions = {
|
|
|
+ type,
|
|
|
+ escape: false
|
|
|
+ }
|
|
|
|
|
|
- this.exportTable(exportOptions)
|
|
|
- })
|
|
|
+ this.exportTable(exportOptions)
|
|
|
+ })
|
|
|
+ }
|
|
|
this.handleToolbar()
|
|
|
}
|
|
|
|