Bläddra i källkod

Update to v1.8 and add function for Text Label

Update to v1.8 and add function for Text Label
Stein, Peter 11 år sedan
förälder
incheckning
8ffc607fb3
1 ändrade filer med 10 tillägg och 2 borttagningar
  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/
  * http://www.larentis.eu/
  * 
  * 
  * Enhanced for radiobuttons by Stein, Peter @BdMdesigN
  * Enhanced for radiobuttons by Stein, Peter @BdMdesigN
@@ -32,7 +32,8 @@
               , moving
               , moving
               , onLabel = "ON"
               , onLabel = "ON"
               , offLabel = "OFF"
               , offLabel = "OFF"
-              , icon = false;
+              , icon = false
+              , textLabel = false;
 
 
             $.each(['switch-mini', 'switch-small', 'switch-large'], function (i, el) {
             $.each(['switch-mini', 'switch-small', 'switch-large'], function (i, el) {
               if (classes.indexOf(el) >= 0)
               if (classes.indexOf(el) >= 0)
@@ -53,6 +54,9 @@
             if ($element.data('label-icon') !== undefined)
             if ($element.data('label-icon') !== undefined)
               icon = $element.data('label-icon');
               icon = $element.data('label-icon');
 
 
+            if ($element.data('text-label') !== undefined)
+              textLabel = $element.data('text-label');
+
             $switchLeft = $('<span>')
             $switchLeft = $('<span>')
               .addClass("switch-left")
               .addClass("switch-left")
               .addClass(myClasses)
               .addClass(myClasses)
@@ -77,6 +81,10 @@
             if (icon) {
             if (icon) {
               $label.html('<i class="icon ' + icon + '"></i>');
               $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);
             $div = $element.find(inputSelector).wrap($('<div>')).parent().data('animated', false);