ソースを参照

Improved copy-rows to support all themes

zhixin 6 年 前
コミット
0bd4253b8f
1 ファイル変更8 行追加14 行削除
  1. 8 14
      src/extensions/copy-rows/bootstrap-table-copy-rows.js

+ 8 - 14
src/extensions/copy-rows/bootstrap-table-copy-rows.js

@@ -5,18 +5,12 @@
 
 const Utils = $.fn.bootstrapTable.utils
 
-const constants = {
-  3: {
-    icons: {
-      copy: 'glyphicon-copy icon-pencil'
-    }
-  },
-  4: {
-    icons: {
-      copy: 'fa-copy'
-    }
-  }
-}[Utils.bootstrapVersion]
+$.extend($.fn.bootstrapTable.defaults.icons, {
+  copy: {
+    bootstrap3: 'glyphicon-copy icon-pencil',
+    materialize: 'content_copy'
+  }[$.fn.bootstrapTable.theme] || 'fa-copy'
+})
 
 const copyText = text => {
   const textField = document.createElement('textarea')
@@ -49,12 +43,12 @@ $.BootstrapTable = class extends $.BootstrapTable {
   initToolbar (...args) {
     super.initToolbar(...args)
 
-    const $btnGroup = this.$toolbar.find('>.btn-group')
+    const $btnGroup = this.$toolbar.find('>.columns')
 
     if (this.options.showCopyRows && this.header.stateField) {
       this.$copyButton = $(`
         <button class="${this.constants.buttonsClass}">
-        <i class="${this.options.iconsPrefix} ${constants.icons.copy}"></i>
+        ${Utils.sprintf(this.constants.html.icon, this.options.iconsPrefix, this.options.icons.copy)}
         </button>
       `)
       $btnGroup.append(this.$copyButton)