瀏覽代碼

Update to v1.8 and add function for Text Label

Update to v1.8 and add function for Text Label
Stein, Peter 11 年之前
父節點
當前提交
8ffc607fb3
共有 1 個文件被更改,包括 10 次插入2 次删除
  1. 10 2
      static/js/bootstrap-switch.js

+ 10 - 2
static/js/bootstrap-switch.js

@@ -1,5 +1,5 @@
 /*! ============================================================
- * bootstrapSwitch v1.7 by Larentis Mattia @SpiritualGuru
+ * bootstrapSwitch v1.8 by Larentis Mattia @SpiritualGuru
  * http://www.larentis.eu/
  * 
  * Enhanced for radiobuttons by Stein, Peter @BdMdesigN
@@ -32,7 +32,8 @@
               , moving
               , onLabel = "ON"
               , offLabel = "OFF"
-              , icon = false;
+              , icon = false
+              , textLabel = false;
 
             $.each(['switch-mini', 'switch-small', 'switch-large'], function (i, el) {
               if (classes.indexOf(el) >= 0)
@@ -53,6 +54,9 @@
             if ($element.data('label-icon') !== undefined)
               icon = $element.data('label-icon');
 
+            if ($element.data('text-label') !== undefined)
+              textLabel = $element.data('text-label');
+
             $switchLeft = $('<span>')
               .addClass("switch-left")
               .addClass(myClasses)
@@ -77,6 +81,10 @@
             if (icon) {
               $label.html('<i class="icon ' + icon + '"></i>');
             }
+            
+            if (textLabel) {
+              $label.html('<div class="text-label">' + textLabel + '</div>');
+            }
 
             $div = $element.find(inputSelector).wrap($('<div>')).parent().data('animated', false);