Browse Source

Adding possibility to use FontAwesome icons set. Fixes #337

SMGladkovskiy 11 years ago
parent
commit
716768c557
2 changed files with 27 additions and 3 deletions
  1. 18 0
      docs/_includes/documentation/table-options.md
  2. 9 3
      src/bootstrap-table.js

+ 18 - 0
docs/_includes/documentation/table-options.md

@@ -69,6 +69,24 @@ The table options is defined in `jQuery.fn.bootstrapTable.defaults`.
         <td>Defines the column sort order, can only be 'asc' or 'desc'.</td>
     </tr>
     <tr>
+        <td>iconsPrefix</td>
+        <td>data-icons-prefix</td>
+        <td>String</td>
+        <td>'glyphicon'</td>
+        <td>Defines icon set name ('glyphicon' or 'fa' for FontAwesome). By default 'glyphicon' is used. </td>
+    </tr>
+    <tr>
+        <td>icons</td>
+        <td>-</td>
+        <td>Object</td>
+        <td>{<br/>
+        &nbsp;&nbsp;refresh: 'glyphicon-refresh icon-refresh',<br/>
+        &nbsp;&nbsp;toggle: 'glyphicon-list-alt icon-list-alt',<br/>
+        &nbsp;&nbsp;columns: 'glyphicon-th icon-th'<br/>
+        }</td>
+        <td>Defines icons that used for refresh, toggle and columns buttons</td>
+    </tr>
+    <tr>
         <td>columns</td>
         <td>-</td>
         <td>Array</td>

+ 9 - 3
src/bootstrap-table.js

@@ -166,6 +166,12 @@
         sortable: true,
         maintainSelected: false,
         searchTimeOut: 500,
+        iconsPrefix: 'glyphicon', // glyphicon of fa (font awesome)
+        icons: {
+            refresh: 'glyphicon-refresh icon-refresh',
+            toggle: 'glyphicon-list-alt icon-list-alt',
+            columns: 'glyphicon-th icon-th'
+        },
 
         rowStyle: function (row, index) {return {};},
 
@@ -557,14 +563,14 @@
         if (this.options.showRefresh) {
             html.push(sprintf('<button class="btn btn-default" type="button" name="refresh" title="%s">',
                 this.options.formatRefresh()),
-                '<i class="glyphicon glyphicon-refresh icon-refresh"></i>',
+                '<i class="'+this.options.iconsPrefix+' '+this.options.icons.refresh+'"></i>',
                 '</button>');
         }
 
         if (this.options.showToggle) {
             html.push(sprintf('<button class="btn btn-default" type="button" name="toggle" title="%s">',
                 this.options.formatToggle()),
-                '<i class="glyphicon glyphicon glyphicon-list-alt icon-list-alt"></i>',
+                '<i class="'+this.options.iconsPrefix+' '+this.options.icons.toggle+'"></i>',
                 '</button>');
         }
 
@@ -572,7 +578,7 @@
             html.push(sprintf('<div class="keep-open btn-group" title="%s">',
                 this.options.formatColumns()),
                 '<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">',
-                '<i class="glyphicon glyphicon-th icon-th"></i>',
+                '<i class="'+this.options.iconsPrefix+' '+this.options.icons.columns+'"></i>',
                 ' <span class="caret"></span>',
                 '</button>',
                 '<ul class="dropdown-menu" role="menu">');