瀏覽代碼

update documentation

Mattia Larentis 11 年之前
父節點
當前提交
e6da5c15cd
共有 1 個文件被更改,包括 8 次插入9 次删除
  1. 8 9
      static/js/bootstrap-switch.js

+ 8 - 9
static/js/bootstrap-switch.js

@@ -1,7 +1,7 @@
 /*! ============================================================
  * bootstrapSwitch v1.8 by Larentis Mattia @SpiritualGuru
  * http://www.larentis.eu/
- * 
+ *
  * Enhanced for radiobuttons by Stein, Peter @BdMdesigN
  * http://www.bdmdesign.org/
  *
@@ -186,8 +186,7 @@
 
                 $this.on('click touchend', function (e) {
                   var $this = $(this)
-                    , $target = $(e.target)
-                    , $myRadioCheckBox = $target.siblings('input');
+                    , $myInputBox = $this.siblings('input');
 
                   e.stopImmediatePropagation();
                   e.preventDefault();
@@ -195,12 +194,12 @@
                   $this.unbind('mouseleave');
 
                   if (moving)
-                    $myRadioCheckBox.prop('checked', !(parseInt($this.parent().css('left')) < -25));
+                    $myInputBox.prop('checked', !(parseInt($this.parent().css('left')) < -25));
                   else
-                    $myRadioCheckBox.prop("checked", !$myRadioCheckBox.is(":checked"));
+                    $myInputBox.prop("checked", !$myInputBox.is(":checked"));
 
                   moving = false;
-                  $myRadioCheckBox.trigger('change');
+                  $myInputBox.trigger('change');
                 });
 
                 $this.on('mouseleave', function (e) {
@@ -210,7 +209,7 @@
                   e.preventDefault();
                   e.stopImmediatePropagation();
 
-                  $this.unbind('mouseleave');
+                  $this.unbind('mouseleave mousemove');
                   $this.trigger('mouseup');
 
                   $myInputBox.prop('checked', !(parseInt($this.parent().css('left')) < -25)).trigger('change');
@@ -220,7 +219,7 @@
                   e.stopImmediatePropagation();
                   e.preventDefault();
 
-                  $(this).unbind('mousemove');
+                  $(this).trigger('mouseleave');
                 });
               }
             });
@@ -332,7 +331,7 @@
         var $label = $element.find("label");
         $.each(['switch-mini', 'switch-small', 'switch-large'], function (i, el) {
           if (el !== value) {
-            $switchLeft.removeClass(el)
+            $switchLeft.removeClass(el);
             $switchRight.removeClass(el);
             $label.removeClass(el);
           } else {