Browse Source

Merge pull request #4 from t3chn0r/master

jQuery 1.9.0 compatibility and pixel perfect calculations
Mattia Larentis 12 years ago
parent
commit
235a325f28
2 changed files with 12 additions and 12 deletions
  1. 5 5
      static/js/jquery.switch.js
  2. 7 7
      static/sass/bootstrap-switch.scss

+ 5 - 5
static/js/jquery.switch.js

@@ -128,8 +128,8 @@
                   $this.unbind('mouseleave');
 
                   if (moving)
-                    $myCheckBox.attr('checked', !(parseInt($this.parent().css('left')) < -25));
-                  else $myCheckBox.attr("checked", !$myCheckBox.is(":checked"));
+                    $myCheckBox.prop('checked', !(parseInt($this.parent().css('left')) < -25));
+                  else $myCheckBox.prop("checked", !$myCheckBox.is(":checked"));
 
                   moving = false;
                   $myCheckBox.trigger('change');
@@ -145,7 +145,7 @@
                   $this.unbind('mouseleave');
                   $this.trigger('mouseup');
 
-                  $myCheckBox.attr('checked', !(parseInt($this.parent().css('left')) < -25)).trigger('change');
+                  $myCheckBox.prop('checked', !(parseInt($this.parent().css('left')) < -25)).trigger('change');
                 });
 
                 $this.on('mouseup', function (e) {
@@ -164,10 +164,10 @@
       },
       toggleState:function (skipOnChange) {
         var $input = $(this).find('input:checkbox');
-        $input.attr('checked', !$input.is(':checked')).trigger('change', skipOnChange);
+        $input.prop('checked', !$input.is(':checked')).trigger('change', skipOnChange);
       },
       setState:function (value, skipOnChange) {
-        $(this).find('input:checkbox').attr('checked', value).trigger('change', skipOnChange);
+        $(this).find('input:checkbox').prop('checked', value).trigger('change', skipOnChange);
       },
       status:function () {
         return $(this).find('input:checkbox').is(':checked');

+ 7 - 7
static/sass/bootstrap-switch.scss

@@ -26,14 +26,14 @@ $border-radius: 4px;
   -ms-user-select: none;
   user-select: none;
 
-  min-width: 100px;
+  min-width: 102px;
 
   &.switch-mini {
-    min-width: 70px;
+    min-width: 72px;
   }
 
   &.switch-small {
-    min-width: 80px;
+    min-width: 81px;
   }
 
   &.switch-large {
@@ -57,7 +57,7 @@ $border-radius: 4px;
       @include transition(left 0.5s);
     }
     &.switch-off {
-      left: -49.5%;
+      left: -50%;
     }
     &.switch-on {
       left: 0%;
@@ -111,7 +111,7 @@ $border-radius: 4px;
     margin-top: -1px;
     margin-bottom: -1px;
     z-index: 100;
-    width: 34%;
+    width: 33.333333%;
     border-left: 1px solid $gray;
     border-right: 1px solid $gray;
 
@@ -122,7 +122,7 @@ $border-radius: 4px;
     color: $white;
     text-align: center;
     z-index: 1;
-    width: 33%;
+    width: 33.333333%;
 
     &.switch-left {
       @include border-top-left-radius($border-radius);
@@ -165,4 +165,4 @@ $border-radius: 4px;
       @include background-image(linear-gradient(bottom, $startColor, #BD362F));
     }
   }
-}
+}