فهرست منبع

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);