Browse Source

release candidate 2.0.0

Emanuele Marchi 11 years ago
parent
commit
7e528bf2fc

+ 4 - 2
.gitignore

@@ -1,2 +1,4 @@
-.idea
-.DS_Store
+.grunt
+node_modules
+components
+npm-debug.log

+ 92 - 0
Gruntfile.coffee

@@ -0,0 +1,92 @@
+"use strict"
+
+module.exports = (grunt) ->
+
+  # load all grunt tasks
+  require("matchdep").filterDev("grunt-*").forEach grunt.loadNpmTasks
+
+  grunt.initConfig
+
+    # load package json
+    pkg: grunt.file.readJSON "package.json"
+
+    coffeelint:
+      options:
+        arrow_spacing:
+          level: "error"
+        no_empty_param_list:
+          level: "error"
+        no_unnecessary_fat_arrows:
+          level: "error"
+        space_operators:
+          level: "error"
+        indentation:
+          value: 2
+          level: "error"
+        max_line_length:
+          level: "ignore"
+      build: ["Gruntfile.coffee", "src/coffee/**/*.coffee"]
+
+    coffee:
+      build:
+        expand: true
+        cwd: "src/coffee"
+        src: "**/*.coffee"
+        dest: "build/js"
+        ext: ".js"
+
+    uglify:
+      build:
+        preserveComments: "some"
+        expand: true
+        src: "build/js/bootstrap-switch.js"
+        ext: ".min.js"
+
+    less:
+      build:
+        files:
+          "build/css/bootstrap2/bootstrap-switch.css": "src/less/bootstrap2/bootstrap-switch.less"
+          "build/css/bootstrap3/bootstrap-switch.css": "src/less/bootstrap3/bootstrap-switch.less"
+
+    cssmin:
+      build:
+        expand: true
+        src: ["build/css/bootstrap2/bootstrap-switch.css", "build/css/bootstrap3/bootstrap-switch.css"]
+        ext: ".min.css"
+
+    usebanner:
+      build:
+        options:
+          banner: "/* ========================================================================\n" +
+          "* <%= pkg.name %> - v<%= pkg.version %>\n" +
+          "* <%= pkg.homepage %>\n" +
+          "* ========================================================================\n" +
+          "* Copyright 2012-2013 <%= pkg.author.name %>\n" +
+          "*\n" +
+          "* ========================================================================\n" +
+          "* Licensed under the Apache License, Version 2.0 (the \"License\");\n" +
+          "* you may not use this file except in compliance with the License.\n" +
+          "* You may obtain a copy of the License at\n" +
+          "*\n" +
+          "*     http://www.apache.org/licenses/LICENSE-2.0\n" +
+          "*\n" +
+          "* Unless required by applicable law or agreed to in writing, software\n" +
+          "* distributed under the License is distributed on an \"AS IS\" BASIS,\n" +
+          "* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n" +
+          "* See the License for the specific language governing permissions and\n" +
+          "* limitations under the License.\n" +
+          "* ========================================================================\n" +
+          "*/\n"
+        files:
+          src: ["build/**/*"]
+
+    jshint:
+      all: ["*.json", "build/js/*.js", "!**/*.min.js"]
+
+    bump:
+      options:
+        files: ["package.json", "bower.json"]
+        commitFiles: ["-a"]
+        push: false
+
+  grunt.registerTask "build", ["coffeelint", "coffee", "uglify", "less", "cssmin", "usebanner"]

+ 0 - 63
Gruntfile.js

@@ -1,63 +0,0 @@
-module.exports = function(grunt) {
-  // load all grunt tasks
-  require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
-
-  // Project configuration.
-  grunt.initConfig({
-    nodeunit: {
-      all: ['test/*_test.js']
-    },
-
-    less: {
-      build: {
-        files: {
-          "build/css/bootstrap2/bootstrap-switch.css": "src/less/bootstrap2/bootstrap-switch.less",
-          "build/css/bootstrap3/bootstrap-switch.css": "src/less/bootstrap3/bootstrap-switch.less",
-        }
-      }
-    },
-
-    coffee: {
-      build: {
-        expand: true,
-        cwd: 'src/coffee',
-        src: '**/*.coffee',
-        dest: 'build/js',
-        ext: '.js'
-      }
-    },
-
-    cssmin: {
-      build: {
-        expand: true,
-        src: ['build/css/bootstrap2/bootstrap-switch.css', 'build/css/bootstrap3/bootstrap-switch.css'],
-        ext: '.min.css'
-      }
-    },
-
-    uglify: {
-      build: {
-        preserveComments: 'some',
-        expand: true,
-        src: 'build/js/bootstrap-switch.js',
-        ext: '.min.js'
-      }
-    },
-
-    jshint: {
-      all: ['Gruntfile.js', '*.json', 'build/js/*.js', '!**/*.min.js']
-    },
-
-    bump: {
-      options: {
-        files: ['package.json', 'bower.json'],
-        commitFiles: ['-a'],
-        push: false
-      }
-    }
-
-  });
-
-  grunt.registerTask('build', ['less', 'coffee', 'cssmin', 'uglify']);
-
-};

+ 1 - 1
README.md

@@ -1,7 +1,7 @@
 Bootstrap Switch
 ================
 
-Turn radio and checkbox form input in switches. 
+Turn radio and checkbox form inputs in toggle switches.
 
 **Bootstrap 3 ready** thanks to [nabil1337](https://github.com/nabil1337)
 

+ 21 - 13
build/css/bootstrap2/bootstrap-switch.css

@@ -1,16 +1,24 @@
-/*! ===========================================================
- * bootstrap-switch v1.9.0 by Larentis Mattia @SpiritualGuru
- * http://www.larentis.eu/
- *
- * Enhanced for radiobuttons by Stein, Peter @BdMdesigN
- * http://www.bdmdesign.org/
- *
- * Project site:
- * http://www.bootstrap-switch.org
- * ============================================================
- * Licensed under the Apache License, Version 2.0
- * http://www.apache.org/licenses/LICENSE-2.0
- * ============================================================ */
+/* ========================================================================
+* bootstrap-switch - v2.0.0
+* http://www.bootstrap-switch.org
+* ========================================================================
+* Copyright 2012-2013 Mattia Larentis
+*
+* ========================================================================
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+* ========================================================================
+*/
+
 .clearfix {
   *zoom: 1;
 }

File diff suppressed because it is too large
+ 0 - 12
build/css/bootstrap2/bootstrap-switch.min.css


+ 22 - 14
build/css/bootstrap3/bootstrap-switch.css

@@ -1,16 +1,24 @@
-/*! ===========================================================
- * bootstrap-switch v1.9.0 by Larentis Mattia @SpiritualGuru
- * http://www.larentis.eu/
- *
- * Enhanced for radiobuttons by Stein, Peter @BdMdesigN
- * http://www.bdmdesign.org/
- *
- * Project site:
- * http://www.bootstrap-switch.org
- * ============================================================
- * Licensed under the Apache License, Version 2.0
- * http://www.apache.org/licenses/LICENSE-2.0
- * ============================================================ */
+/* ========================================================================
+* bootstrap-switch - v2.0.0
+* http://www.bootstrap-switch.org
+* ========================================================================
+* Copyright 2012-2013 Mattia Larentis
+*
+* ========================================================================
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+* ========================================================================
+*/
+
 .has-switch {
   display: inline-block;
   cursor: pointer;
@@ -83,7 +91,7 @@
   box-sizing: border-box;
   cursor: pointer;
   position: relative;
-  display: inline-block;
+  display: inline-block !important;
   height: 100%;
   padding-bottom: 4px;
   padding-top: 4px;

File diff suppressed because it is too large
+ 0 - 12
build/css/bootstrap3/bootstrap-switch.min.css


+ 29 - 24
build/js/bootstrap-switch.js

@@ -1,19 +1,24 @@
-/*! ============================================================
- * bootstrap-switch v1.9.0 by Larentis Mattia @SpiritualGuru
- * http://www.larentis.eu/
- *
- * Enhanced for radiobuttons by Stein, Peter @BdMdesigN
- * http://www.bdmdesign.org/
- *
- * Project site:
- * http://www.bootstrap-switch.org
- * ============================================================
- * Licensed under the Apache License, Version 2.0
- * http://www.apache.org/licenses/LICENSE-2.0
- * ============================================================
+/* ========================================================================
+* bootstrap-switch - v2.0.0
+* http://www.bootstrap-switch.org
+* ========================================================================
+* Copyright 2012-2013 Mattia Larentis
+*
+* ========================================================================
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+* ========================================================================
 */
 
-
 (function() {
   (function($) {
     $.fn.bootstrapSwitch = function(method) {
@@ -29,7 +34,7 @@
                 var html, label;
                 html = "ON";
                 label = $element.data("on-label");
-                if (typeof label !== "undefined") {
+                if (label != null) {
                   html = label;
                 }
                 return html;
@@ -41,7 +46,7 @@
                 var html, label;
                 html = "OFF";
                 label = $element.data("off-label");
-                if (typeof label !== "undefined") {
+                if (label != null) {
                   html = label;
                 }
                 return html;
@@ -54,10 +59,10 @@
                 html = "&nbsp;";
                 icon = $element.data("label-icon");
                 label = $element.data("text-label");
-                if (typeof icon !== "undefined") {
+                if (icon != null) {
                   html = "<i class=\"icon " + icon + "\"></i>";
                 }
-                if (typeof label !== "undefined") {
+                if (label != null) {
                   html = label;
                 }
                 return html;
@@ -83,10 +88,10 @@
                 }
               });
             }
-            if ($element.data("on") !== undefined) {
+            if ($element.data("on") != null) {
               $switchLeft.addClass("switch-" + $element.data("on"));
             }
-            if ($element.data("off") !== undefined) {
+            if ($element.data("off") != null) {
               $switchRight.addClass("switch-" + $element.data("off"));
             }
             $div.data("animated", false);
@@ -262,10 +267,10 @@
           $element = $(this);
           $switchLeft = $element.siblings(".switch-left");
           cls = $element.attr("data-on");
-          if (typeof value === "undefined") {
+          if (value == null) {
             return;
           }
-          if (typeof cls !== "undefined") {
+          if (cls != null) {
             $switchLeft.removeClass("switch-" + cls);
           }
           $switchLeft.addClass("switch-" + value);
@@ -276,10 +281,10 @@
           $element = $(this);
           $switchRight = $element.siblings(".switch-right");
           cls = $element.attr("data-off");
-          if (typeof value === "undefined") {
+          if (value == null) {
             return;
           }
-          if (typeof cls !== "undefined") {
+          if (cls != null) {
             $switchRight.removeClass("switch-" + cls);
           }
           $switchRight.addClass("switch-" + value);

File diff suppressed because it is too large
+ 0 - 0
build/js/bootstrap-switch.min.js


+ 54 - 71
docs/index.html

@@ -33,8 +33,8 @@
     <div class="row">
       <div class="col-sm-10 col-sm-offset-1">
         <header class="jumbotron">
-          <h1>Bootstrap switch</h1>
-          <h4>by <a href="http://larentis.eu" target="_blank">Mattia Larentis</a> (<a href="https://twitter.com/spiritualguru">@SpiritualGuru</a>), <a href="http://www.bdmdesign.org/" target="_blank">Peter Stein</a> and <a href="http://www.lostcrew.it" target="_blank">Emanuele Marchi</a></h4>
+          <h1>Bootstrap switch <span class="small">v.2.0.0</span></h1>
+          <h4><a href="http://larentis.eu" target="_blank">Mattia Larentis</a> (<a href="https://twitter.com/spiritualguru">@SpiritualGuru</a>) · <a href="http://www.bdmdesign.org/" target="_blank">Peter Stein</a> · <a href="http://www.lostcrew.it" target="_blank">Emanuele Marchi</a></h4>
           <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="170" height="30"></iframe>
           <iframe src="http://ghbtns.com/github-btn.html?user=nostalgiaz&amp;repo=bootstrap-switch&amp;type=fork&amp;count=true" allowtransparency="true" frameborder="0" scrolling="0" width="170" height="30"></iframe>
           <iframe src="http://ghbtns.com/github-btn.html?user=nostalgiaz&amp;type=follow&amp;count=true" allowtransparency="true" frameborder="0" scrolling="0" width="170" height="30"></iframe>
@@ -58,14 +58,12 @@
           <button id="btn-size-mini-switch" class="btn btn-default">Mini</button>
           <br>
         </div>
-        <pre class="language-markup">
-&lt;input type="checkbox" checked class="switch-large">
+        <pre class="language-markup"><code>&lt;input type="checkbox" checked class="switch-large">
 &lt;input type="checkbox" checked>
 &lt;input type="checkbox" checked class="switch-small">
 &lt;input type="checkbox" checked class="switch-mini">
-&lt;input type="checkbox" checked></pre>
-        <pre class="language-javascript">
-// Resets to the regular style
+&lt;input id="dimension-switch" type="checkbox" checked></code></pre>
+        <pre class="language-javascript"><code>// Resets to the regular style
 $('#dimension-switch').bootstrapSwitch('setSizeClass', '');
 
 // Sets a mini switch
@@ -75,7 +73,7 @@ $('#dimension-switch').bootstrapSwitch('setSizeClass', 'switch-mini');
 $('#dimension-switch').bootstrapSwitch('setSizeClass', 'switch-small');
 
 // Sets a large switch
-$('#dimension-switch').bootstrapSwitch('setSizeClass', 'switch-large');</pre>
+$('#dimension-switch').bootstrapSwitch('setSizeClass', 'switch-large');</code></pre>
         <h2><a name="colors" class="anchor" href="#colors">Colors</a></h2>
         <div class="bs-docs-example">
           <input type="checkbox" checked data-on="primary" data-off="info">
@@ -93,16 +91,15 @@ $('#dimension-switch').bootstrapSwitch('setSizeClass', 'switch-large');</pre>
           <button id="btn-color-on-switch" class="btn btn-success">Change ON color</button>
           <button id="btn-color-off-switch" class="btn btn-danger">Change OFF color</button>
         </div>
-        <pre class="language-markup">&lt;input type="checkbox" checked data-on="primary" data-off="info">
+        <pre class="language-markup"><code>&lt;input type="checkbox" checked data-on="primary" data-off="info">
 &lt;input type="checkbox" checked data-on="info" data-off="success">
 &lt;input type="checkbox" checked data-on="success" data-off="warning">
 &lt;input type="checkbox" checked data-on="warning" data-off="danger">
 &lt;input type="checkbox" checked data-on="danger" data-off="default">
 &lt;input type="checkbox" checked data-on="default" data-off="primary">
-&lt;input type="checkbox" id="change-color-switch" checked data-on="default" data-off="primary"></pre>
-        <pre class="language-javascript">
-$('#change-color-switch').bootstrapSwitch('setOnClass', 'success');
-$('#change-color-switch').bootstrapSwitch('setOffClass', 'danger');</pre>
+&lt;input type="checkbox" id="change-color-switch" checked data-on="default" data-off="primary"></code></pre>
+        <pre class="language-javascript"><code>$('#change-color-switch').bootstrapSwitch('setOnClass', 'success');
+$('#change-color-switch').bootstrapSwitch('setOffClass', 'danger');</code></pre>
           <h2><a name="animation" class="anchor" href="#animation">Animation <small>javascript</small></a></h2>
           <div class="bs-docs-example">
             <input type="checkbox" id="animated-switch" checked data-animated="false">
@@ -111,19 +108,17 @@ $('#change-color-switch').bootstrapSwitch('setOffClass', 'danger');</pre>
             <button id="btn-animate-switch" class="btn btn-default">Animate</button>
             <button id="btn-dont-animate-switch" class="btn btn-default">Don't animate</button>
           </div>
-          <pre class="language-markup">&lt;input type="checkbox" checked data-animated="false"></pre>
-          <pre class="language-javascript">
-// Enables animation for the selected item
+          <pre class="language-markup"><code>&lt;input type="checkbox" checked data-animated="false"></code></pre>
+         <pre class="language-javascript"><code>// Enables animation for the selected item
 $('#animated-switch').bootstrapSwitch('setAnimated', true);
 
 // Disables animation for the selected item
-$('#animated-switch').bootstrapSwitch('setAnimated', false);</pre>
+$('#animated-switch').bootstrapSwitch('setAnimated', false);</code></pre>
           <h2><a name="disabled" class="anchor" href="#disabled">Disabled</a></h2>
           <div class="bs-docs-example">
             <input type="checkbox" checked disabled>
           </div>
-          <pre class="language-markup">
-&lt;input type="checkbox" checked disabled></pre>
+          <pre class="language-markup"><code>&lt;input type="checkbox" checked disabled></code></pre>
           <h2><a name="text" class="anchor" href="#text">Text</a></h2>
           <div class="bs-docs-example">
             <input type="checkbox" id="label-switch" checked data-on-label="SI" data-off-label="NO">
@@ -131,20 +126,19 @@ $('#animated-switch').bootstrapSwitch('setAnimated', false);</pre>
             <button id="btn-label-on-switch" class="btn btn-default">Change "On" label</button>
             <button id="btn-label-off-switch" class="btn btn-default">Change "Off" label</button>
           </div>
-          <pre class="language-markup">&lt;input type="checkbox" checked data-on-label="SI" data-off-label="NO"></pre>
-          <pre class="language-javascript">
-$('#label-switch').bootstrapSwitch('setOnLabel', 'I');
-$('#label-switch').bootstrapSwitch('setOffLabel', 'O');</pre>
+          <pre class="language-markup"><code>&lt;input type="checkbox" checked data-on-label="SI" data-off-label="NO"></code></pre>
+         <pre class="language-javascript"><code>$('#label-switch').bootstrapSwitch('setOnLabel', 'I');
+$('#label-switch').bootstrapSwitch('setOffLabel', 'O');</code></pre>
           <h2><a name="label-text" class="anchor" href="#label-text">Label Text</a></h2>
           <div class="bs-docs-example">
             <input type="checkbox" checked data-text-label="TV">
           </div>
-          <pre class="language-markup">&lt;input type="checkbox" checked data-text-label="TV"></pre>
-          <h2><a name="html-text" class="anchor" href="#html-text">HTML text</a></h2>
+          <pre class="language-markup"><code>&lt;input type="checkbox" checked data-text-label="TV"></code></pre>
+         <h2><a name="html-text" class="anchor" href="#html-text">HTML text</a></h2>
           <div class="bs-docs-example">
             <input type="checkbox" checked data-on-label="<i class='icon-ok icon-white'></i>" data-off-label="<i class='icon-remove'></i>">
           </div>
-          <pre class="language-markup">&lt;input type="checkbox" checked data-on-label="&lt;i class='icon-ok icon-white'>&lt;/i>" data-off-label="&lt;i class='icon-remove'>&lt;/i>"></pre>
+          <pre class="language-markup"><code>&lt;input type="checkbox" checked data-on-label="&lt;i class='icon-ok icon-white'>&lt;/i>" data-offlabel="&lt;i class='icon-remove'>&lt;/i>"></code></pre>
           <h2><a name="html-text-label-icon" class="anchor" href="#html-text-label-icon">HTML text Label Icon</a></h2>
           <div class="bs-docs-example">
             <h5>Standard</h5>
@@ -154,20 +148,19 @@ $('#label-switch').bootstrapSwitch('setOffLabel', 'O');</pre>
             <h5>Flat UI</h5>
             <input type="checkbox" class="switch-large" checked data-label-icon="fui-video" data-on-label="<i class='fui-check icon-white'></i>" data-off-label="<i class='fui-cross'></i>">
           </div>
-          <pre class="language-markup">&lt;input type="checkbox" checked class="switch-large" data-label-icon="icon-fullscreen" data-on-label="&lt;i class='icon-ok icon-white'>&lt;/i>" data-off-label="&lt;i class='icon-remove'>&lt;/i>">
+          <pre class="language-markup"><code>&lt;input type="checkbox" checked class="switch-large" data-label-icon="icon-fullscreen" data-onlabel="&lt;i class='icon-ok icon-white'>&lt;/i>" data-off-label="&lt;i class='icon-remove'>&lt;/i>">
 &lt;input type="checkbox" checked class="switch-large" data-label-icon="icon-youtube icon-large" data-on-label="&lt;i class='icon-thumbs-up icon-white'>&lt;/i>" data-off-label="&lt;i class='icon-thumbs-down'>&lt;/i>">
-&lt;input type="checkbox" class="switch-large" checked data-label-icon="fui-video" data-on-label="&lt;i class='fui-check icon-white'>&lt;/i>" data-off-label="&lt;i class='fui-cross'>&lt;/i>"></pre>
+&lt;input type="checkbox" class="switch-large" checked data-label-icon="fui-video" data-on-label="&lt;i class='fui-check icon-white'>&lt;/i>" data-off-label="&lt;i class='fui-cross'>&lt;/i>"></code></pre>
           <h2><a name="event-handler-javascript" class="anchor" href="#event-handler-javascript">Event handler <small>JavaScript</small></a></h2>
           <div class="bs-docs-example">
             <input type="checkbox" id="switch-change" checked>
           </div>
-          <pre class="language-javascript">
-$('#switch-change').on('switch-change', function (e, data) {
+          <pre class="language-javascript"><code>$('#switch-change').on('switch-change', function (e, data) {
   var $element = $(data.el),
       value = data.value;
 
   console.log(e, $element, value);
-});</pre>
+});</code></pre>
           <h2><a name="label-event-handler-javascript" class="anchor" href="#label-event-handler-javascript">Label Event handler <small>JavaScript</small></a></h2>
           <div class="bs-docs-example">
             <h5>Label 1</h5>
@@ -180,17 +173,15 @@ $('#switch-change').on('switch-change', function (e, data) {
               </label>
             </div>
           </div>
-          <pre class="language-markup">
-&lt;label id="label-toggle-switch">Click on this Text to change the switch state&lt;/label>
+          <pre class="language-markup"><code>&lt;label id="label-toggle-switch">Click on this Text to change the switch state&lt;/label>
 &lt;input type="checkbox" checked />
 
 &lt;div id="label2-toggle-switch">
 &lt;label class="label-change-switch">Click on this Text to change the switch state
   &lt;input type="checkbox" checked />
 &lt;/label>
-&lt;/div></pre>
-          <pre class="language-javascript">
-$('#label-toggle-switch').on('click', function(e, data) {
+&lt;/div></code></pre>
+          <pre class="language-javascript"><code>$('#label-toggle-switch').on('click', function(e, data) {
     $('.label-toggle-switch').bootstrapSwitch('toggleState');
 });
 $('.label-toggle-switch').on('switch-change', function (e, data) {
@@ -198,7 +189,7 @@ $('.label-toggle-switch').on('switch-change', function (e, data) {
 });
 $('#label2-toggle-switch').on('switch-change', function(e, data) {
     alert(data.value);
-});</pre>
+});</code></pre>
           <h2><a name="toggle-state" class="anchor" href="#toggle-state">Toggle State <small>javascript</small></a></h2>
           <div class="bs-docs-example">
             <input type="checkbox" id="toggle-state-switch" checked>
@@ -209,10 +200,9 @@ $('#label2-toggle-switch').on('switch-change', function(e, data) {
             <div id="toggle-state-switch-button" class="btn btn-default">Toggle me!</div>
             <div id="toggle-state-switch-button-off" class="btn btn-default">OFF!</div>
           </div>
-          <pre class="language-javascript">
-$('#toggle-state-switch').bootstrapSwitch('status'); // true || false
+          <pre class="language-javascript"><code>$('#toggle-state-switch').bootstrapSwitch('status'); // true || false
 $('#toggle-state-switch').bootstrapSwitch('toggleState');
-$('#toggle-state-switch').bootstrapSwitch('setState', false); // true || false</pre>
+$('#toggle-state-switch').bootstrapSwitch('setState', false); // true || false</code></pre>
           <h2><a name="destroy" class="anchor" href="#destroy">Destroy <small>javascript</small></a></h2>
           <div class="bs-docs-example">
             <input type="checkbox" id="destroy-switch" checked >
@@ -220,16 +210,16 @@ $('#toggle-state-switch').bootstrapSwitch('setState', false); // true || false</
             <br>
             <button id="btn-destroy-switch" class="btn btn-default">Destroy me!</button>
           </div>
-          <pre class="language-javascript">$('#destroy-switch').bootstrapSwitch('destroy');</pre>
-          <h2><a name="create" class="anchor" href="#create">Create <small>javascript</small></a></h2>
+          <pre class="language-javascript"><code>$('#destroy-switch').bootstrapSwitch('destroy');</code></pre>
+        <h2><a name="create" class="anchor" href="#create">Create <small>javascript</small></a></h2>
           <div class="bs-docs-example">
             <input id="create-switch" type="checkbox" checked>
             <br>
             <br>
             <div id="btn-create" class="btn btn-default">Create</div>
           </div>
-          <pre class="language-javascript">$('#create-switch').bootstrapSwitch();</pre>
-          <h2><a name="disabled-javascript" class="anchor" href="#disabled-javascript">Disabled <small>javascript</small></a></h2>
+          <pre class="language-javascript"><code>$('#create-switch').bootstrapSwitch();</code></pre>
+        <h2><a name="disabled-javascript" class="anchor" href="#disabled-javascript">Disabled <small>javascript</small></a></h2>
           <div class="bs-docs-example">
             <label for="disable-switch-input">amazing label</label>
             <input type="checkbox" id="disable-switch" checked>
@@ -240,10 +230,9 @@ $('#toggle-state-switch').bootstrapSwitch('setState', false); // true || false</
             <button id="btn-disable-switch" class="btn btn-default">Disable!</button>
             <button id="btn-activate-switch" class="btn btn-default">Activate!</button>
           </div>
-          <pre class="language-javascript">
-$('#disable-switch').bootstrapSwitch('isActive');
+          <pre class="language-javascript"><code>$('#disable-switch').bootstrapSwitch('isActive');
 $('#disable-switch').bootstrapSwitch('toggleActivation');
-$('#disable-switch').bootstrapSwitch('setActive', false);  // true || false</pre>
+$('#disable-switch').bootstrapSwitch('setActive', false);  // true || false</code></pre>
           <h2><a name="radio-javascript" class="anchor" href="#radio-javascript">Radio <small>javascript</small></a></h2>
           <div class="bs-docs-example">
             <div class="form-group">
@@ -255,17 +244,15 @@ $('#disable-switch').bootstrapSwitch('setActive', false);  // true || false</pre
               <input id="option3" type="radio" name="radio1" value="option3" class="radio1 radio-no-uncheck">
             </div>
           </div>
-          <pre class="language-markup">
-&lt;div class="form-group">
+          <pre class="language-markup"><code>&lt;div class="form-group">
   &lt;label for="option1">Option 1&lt;/label>
   &lt;input id="option1" type="radio" name="radio1" value="option1">
   &lt;label for="option2">Option 2&lt;/label>
   &lt;input id="option2" type="radio" name="radio1" value="option2">
   &lt;label for="option3">Option 3&lt;/label>
   &lt;input id="option3" type="radio" name="radio1" value="option3">
-&lt;/div></pre>
-          <pre class="language-javascript">
-$('.radio1').on('switch-change', function () {
+&lt;/div></code></pre>
+          <pre class="language-javascript"><code>$('.radio1').on('switch-change', function () {
     $('.radio1').bootstrapSwitch('toggleRadioState');
 });
 
@@ -277,7 +264,7 @@ $('.radio1').on('switch-change', function () {
 // or
 $('.radio1').on('switch-change', function () {
     $('.radio1').bootstrapSwitch('toggleRadioStateAllowUncheck', false);
-});</pre>
+});</code></pre>
           <h2><a name="radio-javascript-allow-uncheck" class="anchor" href="#radio-javascript-allow-uncheck"><small>javascript (allow radios uncheck)</small></a></h2>
           <div class="bs-docs-example">
             <div class="form-group">
@@ -289,19 +276,17 @@ $('.radio1').on('switch-change', function () {
               <input id="option13" type="radio" name="radio2" value="option13" class="radio2">
             </div>
           </div>
-          <pre class="language-markup">
-&lt;div class="form-group">
-    &lt;label for="option11">Option 1&lt;/label>
-    &lt;input id="option11" type="radio" name="radio2" value="option1">
-    &lt;label for="option12">Option 2&lt;/label>
-    &lt;input id="option12" type="radio" name="radio2" value="option2" checked="checked">
-    &lt;label for="option13">Option 3&lt;/label>
-    &lt;input id="option13" type="radio" name="radio2" value="option3">
-&lt;/div></pre>
-          <pre class="language-javascript">
-$('.radio2').on('switch-change', function () {
+          <pre class="language-markup"><code>&lt;div class="form-group">
+  &lt;label for="option11">Option 1&lt;/label>
+  &lt;input id="option11" type="radio" name="radio2" value="option1">
+  &lt;label for="option12">Option 2&lt;/label>
+  &lt;input id="option12" type="radio" name="radio2" value="option2" checked="checked">
+  &lt;label for="option13">Option 3&lt;/label>
+  &lt;input id="option13" type="radio" name="radio2" value="option3">
+&lt;/div></code></pre>
+          <pre class="language-javascript"><code>$('.radio2').on('switch-change', function () {
     $('.radio2').bootstrapSwitch('toggleRadioStateAllowUncheck', true);
-});</pre>
+});</code></pre>
           <h2><a name="form" class="anchor" href="#form">Form <small>- try to use tab, space and reset button</small></a></h2>
           <div class="bs-docs-example">
             <form class="clearfix" role="form">
@@ -323,8 +308,7 @@ $('.radio2').on('switch-change', function () {
             </form>
             <div ></div>
           </div>
-          <pre class="language-markup">
-&lt;form class="form-horizontal">
+          <pre class="language-markup"><code>&lt;form class="form-horizontal">
   &lt;div class="form-group">
     &lt;label class="control-label" for="inputEmail">Email&lt;/label>
     &lt;input type="text" id="inputEmail" placeholder="Email">
@@ -340,17 +324,16 @@ $('.radio2').on('switch-change', function () {
   &lt;div class="form-actions">
     &lt;button type="reset" class="btn btn-inverse">Reset&lt;/button>
   &lt;/div>
-&lt;/form></pre>
+&lt;/form></code></pre>
         <h2><a name="modal" class="anchor" href="#modal">Modal</a></h2>
         <div class="bs-docs-example">
           <a href="#myModal" role="button" class="btn btn-default" data-toggle="modal">Modal</a>
         </div>
-        <pre class="language-markup">
-&lt;a href="#myModal" role="button" class="btn btn-default" data-toggle="modal">Modal&lt;/a>
+        <pre class="language-markup"><code>&lt;a href="#myModal" role="button" class="btn btn-default" data-toggle="modal">Modal&lt;/a>
 
 &lt;div class="modal-body">
   &lt;input type="checkbox" checked>
-&lt;/div></pre>
+&lt;/div></code></pre>
         <footer class="footer">
           <p>&copy; by <a href="http://larentis.eu" target="_blank">Mattia Larentis</a> (<a href="https://twitter.com/SpiritualGuru">@SpiritualGuru</a>), <a href="http://www.bdmdesign.org/" target="_blank">Peter Stein</a> and <a href="http://www.lostcrew.it/" target="_blank">Emanuele Marchi</a></p>
         </footer>

+ 26 - 6
package.json

@@ -1,7 +1,29 @@
 {
   "name": "bootstrap-switch",
   "description": "Unofficial bootstrap switch",
-  "version": "1.8.0",
+  "version": "2.0.0",
+  "keywords": [
+    "bootstrap",
+    "switch",
+    "js"
+  ],
+  "homepage": "http://www.bootstrap-switch.org",
+  "author": {
+    "name": "Mattia Larentis",
+    "email": "[email protected]",
+    "url": "http://larentis.eu"
+  },
+  "contributors": [
+    {
+      "name": "Emanuele Marchi",
+      "email": "[email protected]",
+      "url": "http://lostcrew.it"
+    },
+    {
+      "name": "Peter Stein",
+      "url": "http://www.bdmdesign.org"
+    }
+  ],
   "main": "static/js/bootstrap-switch.js",
   "scripts": {
     "test": "grunt test"
@@ -10,10 +32,6 @@
     "type": "git",
     "url": "git://github.com/nostalgiaz/bootstrap-switch.git"
   },
-  "keywords": [
-    "bootstrap",
-    "switch"
-  ],
   "license": "Apache Version 2",
   "readmeFilename": "README.md",
   "devDependencies": {
@@ -24,6 +42,8 @@
     "grunt-bump": "0.0.11",
     "grunt-contrib-coffee": "~0.7.0",
     "grunt-contrib-uglify": "~0.2.7",
-    "grunt-contrib-cssmin": "~0.7.0"
+    "grunt-contrib-cssmin": "~0.7.0",
+    "grunt-coffeelint": "0.0.8",
+    "grunt-banner": "~0.2.0"
   }
 }

+ 10 - 23
src/coffee/bootstrap-switch.coffee

@@ -1,16 +1,3 @@
-###! ============================================================
- * bootstrap-switch v1.9.0 by Larentis Mattia @SpiritualGuru
- * http://www.larentis.eu/
- *
- * Enhanced for radiobuttons by Stein, Peter @BdMdesigN
- * http://www.bdmdesign.org/
- *
- * Project site:
- * http://www.bootstrap-switch.org
- * ============================================================
- * Licensed under the Apache License, Version 2.0
- * http://www.apache.org/licenses/LICENSE-2.0
- * ============================================================ ###
 (($) ->
   $.fn.bootstrapSwitch = (method) ->
     methods =
@@ -22,7 +9,7 @@
             html: ->
               html = "ON"
               label = $element.data("on-label")
-              html = label if typeof label isnt "undefined"
+              html = label if label?
               html
           )
           $switchRight = $("<span>",
@@ -30,7 +17,7 @@
             html: ->
               html = "OFF"
               label = $element.data("off-label")
-              html = label if typeof label isnt "undefined"
+              html = label if label?
               html
           )
           $label = $("<label>",
@@ -40,8 +27,8 @@
               icon = $element.data("label-icon")
               label = $element.data("text-label")
 
-              html = "<i class=\"icon " + icon + "\"></i>" if typeof icon isnt "undefined"
-              html = label if typeof label isnt "undefined"
+              html = "<i class=\"icon " + icon + "\"></i>" if icon?
+              html = label if label?
 
               html
           )
@@ -63,8 +50,8 @@
                 $switchRight.addClass cls
 
           # override default
-          $switchLeft.addClass "switch-" + $element.data("on") if $element.data("on") isnt `undefined`
-          $switchRight.addClass "switch-" + $element.data("off") if $element.data("off") isnt `undefined`
+          $switchLeft.addClass "switch-" + $element.data("on") if $element.data("on")?
+          $switchRight.addClass "switch-" + $element.data("off") if $element.data("off")?
 
           # set animated for div
           $div.data("animated", false)
@@ -241,9 +228,9 @@
         $switchLeft = $element.siblings(".switch-left")
         cls = $element.attr("data-on")
 
-        return if typeof value is "undefined"
+        return unless value?
 
-        $switchLeft.removeClass "switch-#{cls}" if typeof cls isnt "undefined"
+        $switchLeft.removeClass "switch-#{cls}" if cls?
         $switchLeft.addClass "switch-#{value}"
         $element
 
@@ -252,9 +239,9 @@
         $switchRight = $element.siblings(".switch-right")
         cls = $element.attr("data-off")
 
-        return if typeof value is "undefined"
+        return unless value?
 
-        $switchRight.removeClass "switch-#{cls}" if typeof cls isnt "undefined"
+        $switchRight.removeClass "switch-#{cls}" if cls?
         $switchRight.addClass "switch-#{value}"
         $element
 

+ 0 - 14
src/less/bootstrap2/bootstrap-switch.less

@@ -1,17 +1,3 @@
-/*! ===========================================================
- * bootstrap-switch v1.9.0 by Larentis Mattia @SpiritualGuru
- * http://www.larentis.eu/
- *
- * Enhanced for radiobuttons by Stein, Peter @BdMdesigN
- * http://www.bdmdesign.org/
- *
- * Project site:
- * http://www.bootstrap-switch.org
- * ============================================================
- * Licensed under the Apache License, Version 2.0
- * http://www.apache.org/licenses/LICENSE-2.0
- * ============================================================ */
-
 @import "variables";
 @import "mixins";
 

+ 1 - 15
src/less/bootstrap3/bootstrap-switch.less

@@ -1,17 +1,3 @@
-/*! ===========================================================
- * bootstrap-switch v1.9.0 by Larentis Mattia @SpiritualGuru
- * http://www.larentis.eu/
- *
- * Enhanced for radiobuttons by Stein, Peter @BdMdesigN
- * http://www.bdmdesign.org/
- *
- * Project site:
- * http://www.bootstrap-switch.org
- * ============================================================
- * Licensed under the Apache License, Version 2.0
- * http://www.apache.org/licenses/LICENSE-2.0
- * ============================================================ */
-
 @import "variables";
 @import "mixins";
 
@@ -94,7 +80,7 @@
     .box-sizing(border-box);
     cursor: pointer;
     position: relative;
-    display: inline-block;
+    display: inline-block !important;
     height: 100%;
     padding-bottom: 4px;
     padding-top: 4px;

Some files were not shown because too many files changed in this diff