소스 검색

updated version to 3.0.0

Emanuele Marchi 11 년 전
부모
커밋
a1702d1767

+ 1 - 1
bower.json

@@ -1,7 +1,7 @@
 {
   "name": "bootstrap-switch",
   "description": "Turn checkboxes and radio buttons in toggle switches.",
-  "version": "2.0.1",
+  "version": "3.0.0",
   "main": [
     "build/js/bootstrap-switch.js",
     "build/css/bootstrap3/bootstrap-switch.css"

+ 1 - 1
build/css/bootstrap2/bootstrap-switch.css

@@ -1,5 +1,5 @@
 /* ========================================================================
- * bootstrap-switch - v2.0.1
+ * bootstrap-switch - v3.0.0
  * http://www.bootstrap-switch.org
  * ========================================================================
  * Copyright 2012-2013 Mattia Larentis

+ 1 - 1
build/css/bootstrap2/bootstrap-switch.min.css

@@ -1,5 +1,5 @@
 /* ========================================================================
- * bootstrap-switch - v2.0.1
+ * bootstrap-switch - v3.0.0
  * http://www.bootstrap-switch.org
  * ========================================================================
  * Copyright 2012-2013 Mattia Larentis

+ 1 - 1
build/css/bootstrap3/bootstrap-switch.css

@@ -1,5 +1,5 @@
 /* ========================================================================
- * bootstrap-switch - v2.0.1
+ * bootstrap-switch - v3.0.0
  * http://www.bootstrap-switch.org
  * ========================================================================
  * Copyright 2012-2013 Mattia Larentis

+ 1 - 1
build/css/bootstrap3/bootstrap-switch.min.css

@@ -1,5 +1,5 @@
 /* ========================================================================
- * bootstrap-switch - v2.0.1
+ * bootstrap-switch - v3.0.0
  * http://www.bootstrap-switch.org
  * ========================================================================
  * Copyright 2012-2013 Mattia Larentis

+ 23 - 5
build/js/bootstrap-switch.js

@@ -1,5 +1,5 @@
 /* ========================================================================
- * bootstrap-switch - v2.0.1
+ * bootstrap-switch - v3.0.0
  * http://www.bootstrap-switch.org
  * ========================================================================
  * Copyright 2012-2013 Mattia Larentis
@@ -98,7 +98,7 @@
         this._elementHandlers();
         this._handleHandlers();
         this._labelHandlers();
-        this._form();
+        this._formHandler();
       }
 
       BootstrapSwitch.prototype._constructor = BootstrapSwitch;
@@ -110,7 +110,8 @@
         if (this.options.disabled || this.options.readonly) {
           return this.$element;
         }
-        this.$element.prop("checked", !!value).trigger("change", skip);
+        value = !!value;
+        this.$element.prop("checked", value).trigger("change", skip);
         return this.$element;
       };
 
@@ -262,7 +263,7 @@
         var _this = this;
         return this.$element.on({
           "change.bootstrapSwitch": function(e, skip) {
-            var checked;
+            var $radios, checked;
             e.preventDefault();
             e.stopPropagation();
             e.stopImmediatePropagation();
@@ -272,6 +273,11 @@
             }
             _this.options.state = checked;
             _this.$wrapper.removeClass(checked ? "switch-off" : "switch-on").addClass(checked ? "switch-on" : "switch-off");
+            $radios = _this._radioSiblings();
+            console.log($radios);
+            if ($radios) {
+              $radios.prop("checked", !value).trigger("change", skip);
+            }
             if (!skip) {
               return _this.$element.trigger("switchChange", {
                 el: _this.$element,
@@ -377,7 +383,7 @@
         });
       };
 
-      BootstrapSwitch.prototype._form = function() {
+      BootstrapSwitch.prototype._formHandler = function() {
         var $form;
         $form = this.$element.closest("form");
         if ($form.data("bootstrap-switch")) {
@@ -394,6 +400,18 @@
         }).data("bootstrap-switch", true);
       };
 
+      BootstrapSwitch.prototype._radioSiblings = function() {
+        var $elements;
+        if (!this.$element.is(":radio")) {
+          return false;
+        }
+        $elements = $("[name='" + (this.$element.attr('name')) + "']").not(this.$element);
+        if (!$elements.length) {
+          return false;
+        }
+        return $elements;
+      };
+
       return BootstrapSwitch;
 
     })();

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 1 - 1
build/js/bootstrap-switch.min.js


+ 1 - 1
composer.json

@@ -1,7 +1,7 @@
 {
   "name": "nostalgiaz/bootstrap-switch",
   "description": "Turn checkboxes and radio buttons in toggle switches.",
-  "version": "2.0.1",
+  "version": "3.0.0",
   "type": "component",
   "keywords": [
     "bootstrap",

+ 1 - 1
index.html

@@ -32,7 +32,7 @@
     </a>
     <header class="header">
       <div class="container">
-        <h1>Bootstrap Switch <span class="small">2.0.1</span></h1>
+        <h1>Bootstrap Switch <span class="small">3.0.0</span></h1>
         <h2>Turn checkboxes and radio buttons in toggle switches.</h2>
         <br>
         <iframe src="http://ghbtns.com/github-btn.html?user=nostalgiaz&amp;repo=bootstrap-switch&amp;type=watch&amp;count=true" allowtransparency="true" frameborder="0" scrolling="0" width="120" height="30"></iframe>

+ 1 - 1
package.json

@@ -1,7 +1,7 @@
 {
   "name": "bootstrap-switch",
   "description": "Turn checkboxes and radio buttons in toggle switches.",
-  "version": "2.0.1",
+  "version": "3.0.0",
   "keywords": [
     "bootstrap",
     "switch",

+ 18 - 4
src/coffee/bootstrap-switch.coffee

@@ -56,10 +56,9 @@
       @$element.before(@$on).before(@$label).before @$off
 
       @_elementHandlers()
-      # @_wrapperHandlers()
       @_handleHandlers()
       @_labelHandlers()
-      @_form()
+      @_formHandler()
 
       # TODO: @$label.hasClass "label-change-switch" in toggleState
 
@@ -69,7 +68,9 @@
       return @options.state if typeof value is "undefined"
       return @$element if @options.disabled or @options.readonly
 
-      @$element.prop("checked", not not value).trigger "change", skip
+      value = not not value
+
+      @$element.prop("checked", value).trigger "change", skip
       @$element
 
     toggleState: (skip) ->
@@ -77,6 +78,7 @@
 
       @$element.prop("checked", not @options.state).trigger "change", skip
 
+
     ###
     TODO: refactor
     toggleRadioState: (uncheck, skip) ->
@@ -203,6 +205,10 @@
           .removeClass(if checked then "switch-off" else "switch-on")
           .addClass if checked then "switch-on" else "switch-off"
 
+          $radios = @_radioSiblings()
+          console.log $radios
+          $radios.prop("checked", not value).trigger "change", skip if $radios
+
           @$element.trigger "switchChange", el: @$element, value: checked if not skip
         "focus.bootstrapSwitch": (e) =>
           e.preventDefault()
@@ -283,7 +289,7 @@
           @toggleState()
           @$element.trigger "focus"
 
-    _form: ->
+    _formHandler: ->
       $form = @$element.closest "form"
 
       return if $form.data "bootstrap-switch"
@@ -298,6 +304,14 @@
         , 1
       .data "bootstrap-switch", true
 
+    _radioSiblings: ->
+      return false unless @$element.is ":radio"
+
+      $elements = $("[name='#{@$element.attr('name')}']").not @$element
+
+      return false unless $elements.length
+      $elements
+
   $.fn.extend bootstrapSwitch: (option, args...) ->
     ret = @
     @each ->

이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.