Browse Source

Update bootstrap-table-auto-refresh.js

Icon broken in font-awesome v5.
Greg 6 years ago
parent
commit
ba0aac3ac8
1 changed files with 24 additions and 3 deletions
  1. 24 3
      src/extensions/auto-refresh/bootstrap-table-auto-refresh.js

+ 24 - 3
src/extensions/auto-refresh/bootstrap-table-auto-refresh.js

@@ -15,10 +15,31 @@
         autoRefreshStatus: true,
         autoRefreshFunction: null
     });
+    
+    var bootstrapVersion = 3;
+    try {
+      var rawVersion = $.fn.dropdown.Constructor.VERSION;
 
-    $.extend($.fn.bootstrapTable.defaults.icons, {
-        autoRefresh: 'glyphicon-time icon-time'
-    });
+      // Only try to parse VERSION if is is defined.
+      // It is undefined in older versions of Bootstrap (tested with 3.1.1).
+      if (rawVersion !== undefined) {
+        bootstrapVersion = parseInt(rawVersion, 10);
+      }
+    } catch (e) {
+      // ignore
+    }
+    
+    switch(bootstrapVersion){
+        case 4:
+            $.extend($.fn.bootstrapTable.defaults.icons, {
+                autoRefresh: 'fa-clock'
+            });
+            break;
+        default:
+            $.extend($.fn.bootstrapTable.defaults.icons, {
+                autoRefresh: 'glyphicon-time icon-time'
+            });
+    }
 
     $.extend($.fn.bootstrapTable.locales, {
         formatAutoRefresh: function() {