Jelajahi Sumber

updated packages, enforced single quote, added coffeelint rules, ported gulpfile to coffee, updated gulp tasks

Emanuele Marchi 11 tahun lalu
induk
melakukan
6c5ea9e8a3
8 mengubah file dengan 448 tambahan dan 301 penghapusan
  1. 5 1
      bower.json
  2. 127 0
      coffeelint.json
  3. 92 93
      dist/js/bootstrap-switch.js
  4. 0 0
      dist/js/bootstrap-switch.min.js
  5. 115 0
      gulpfile.coffee
  6. 2 107
      gulpfile.js
  7. 10 8
      package.json
  8. 97 92
      src/coffee/bootstrap-switch.coffee

+ 5 - 1
bower.json

@@ -9,11 +9,15 @@
   "ignore": [
     "docs",
     "test",
+    "src",
     "CNAME",
+    "coffeelint.json",
     "composer.json",
     "CONTRIBUTING.md",
+    "gulpfile.coffee",
     "gulpfile.js",
-    "index.html"
+    "index.html",
+    "package.json"
   ],
   "dependencies": {
     "jquery": ">=1.9.0"

+ 127 - 0
coffeelint.json

@@ -0,0 +1,127 @@
+{
+    "coffeescript_error": {
+        "level": "error"
+    },
+    "arrow_spacing": {
+        "name": "arrow_spacing",
+        "level": "ignore"
+    },
+    "no_tabs": {
+        "name": "no_tabs",
+        "level": "error"
+    },
+    "no_trailing_whitespace": {
+        "name": "no_trailing_whitespace",
+        "level": "error",
+        "allowed_in_comments": false,
+        "allowed_in_empty_lines": false
+    },
+    "max_line_length": {
+        "name": "max_line_length",
+        "value": 120,
+        "level": "error",
+        "limitComments": true
+    },
+    "line_endings": {
+        "name": "line_endings",
+        "level": "warn",
+        "value": "unix"
+    },
+    "no_trailing_semicolons": {
+        "name": "no_trailing_semicolons",
+        "level": "error"
+    },
+    "indentation": {
+        "name": "indentation",
+        "value": 2,
+        "level": "error"
+    },
+    "camel_case_classes": {
+        "name": "camel_case_classes",
+        "level": "error"
+    },
+    "colon_assignment_spacing": {
+        "name": "colon_assignment_spacing",
+        "level": "ignore",
+        "spacing": {
+            "left": 0,
+            "right": 0
+        }
+    },
+    "no_implicit_braces": {
+        "name": "no_implicit_braces",
+        "level": "ignore",
+        "strict": true
+    },
+    "no_plusplus": {
+        "name": "no_plusplus",
+        "level": "ignore"
+    },
+    "no_throwing_strings": {
+        "name": "no_throwing_strings",
+        "level": "error"
+    },
+    "no_backticks": {
+        "name": "no_backticks",
+        "level": "error"
+    },
+    "no_implicit_parens": {
+        "name": "no_implicit_parens",
+        "strict": true,
+        "level": "ignore"
+    },
+    "no_empty_param_list": {
+        "name": "no_empty_param_list",
+        "level": "error"
+    },
+    "no_stand_alone_at": {
+        "name": "no_stand_alone_at",
+        "level": "ignore"
+    },
+    "space_operators": {
+        "name": "space_operators",
+        "level": "ignore"
+    },
+    "duplicate_key": {
+        "name": "duplicate_key",
+        "level": "error"
+    },
+    "empty_constructor_needs_parens": {
+        "name": "empty_constructor_needs_parens",
+        "level": "ignore"
+    },
+    "cyclomatic_complexity": {
+        "name": "cyclomatic_complexity",
+        "value": 10,
+        "level": "ignore"
+    },
+    "newlines_after_classes": {
+        "name": "newlines_after_classes",
+        "value": 3,
+        "level": "error"
+    },
+    "no_unnecessary_fat_arrows": {
+        "name": "no_unnecessary_fat_arrows",
+        "level": "error"
+    },
+    "missing_fat_arrows": {
+        "name": "missing_fat_arrows",
+        "level": "ignore"
+    },
+    "non_empty_constructor_needs_parens": {
+        "name": "non_empty_constructor_needs_parens",
+        "level": "ignore"
+    },
+    "no_unnecessary_double_quotes": {
+        "name": "no_unnecessary_double_quotes",
+        "level": "error"
+    },
+    "no_debugger": {
+        "name": "no_debugger",
+        "level": "warn"
+    },
+    "no_interpolation_in_single_quotes": {
+        "name": "no_interpolation_in_single_quotes",
+        "level": "ignore"
+    }
+}

+ 92 - 93
dist/js/bootstrap-switch.js

@@ -23,31 +23,29 @@
   var __slice = [].slice;
 
   (function($, window) {
-    "use strict";
+    'use strict';
     var BootstrapSwitch;
     BootstrapSwitch = (function() {
-      BootstrapSwitch.prototype.name = "bootstrap-switch";
-
       function BootstrapSwitch(element, options) {
         if (options == null) {
           options = {};
         }
         this.$element = $(element);
         this.options = $.extend({}, $.fn.bootstrapSwitch.defaults, options, {
-          state: this.$element.is(":checked"),
-          size: this.$element.data("size"),
-          animate: this.$element.data("animate"),
-          disabled: this.$element.is(":disabled"),
-          readonly: this.$element.is("[readonly]"),
-          onColor: this.$element.data("on-color"),
-          offColor: this.$element.data("off-color"),
-          onText: this.$element.data("on-text"),
-          offText: this.$element.data("off-text"),
-          labelText: this.$element.data("label-text"),
-          baseClass: this.$element.data("base-class"),
-          wrapperClass: this.$element.data("wrapper-class")
+          state: this.$element.is(':checked'),
+          size: this.$element.data('size'),
+          animate: this.$element.data('animate'),
+          disabled: this.$element.is(':disabled'),
+          readonly: this.$element.is('[readonly]'),
+          onColor: this.$element.data('on-color'),
+          offColor: this.$element.data('off-color'),
+          onText: this.$element.data('on-text'),
+          offText: this.$element.data('off-text'),
+          labelText: this.$element.data('label-text'),
+          baseClass: this.$element.data('base-class'),
+          wrapperClass: this.$element.data('wrapper-class')
         });
-        this.$wrapper = $("<div>", {
+        this.$wrapper = $('<div>', {
           "class": (function(_this) {
             return function() {
               var classes;
@@ -65,42 +63,42 @@
               if (_this.options.readonly) {
                 classes.push("" + _this.options.baseClass + "-readonly");
               }
-              if (_this.$element.attr("id")) {
-                classes.push("" + _this.options.baseClass + "-id-" + (_this.$element.attr("id")));
+              if (_this.$element.attr('id')) {
+                classes.push("" + _this.options.baseClass + "-id-" + (_this.$element.attr('id')));
               }
-              return classes.join(" ");
+              return classes.join(' ');
             };
           })(this)()
         });
-        this.$container = $("<div>", {
+        this.$container = $('<div>', {
           "class": "" + this.options.baseClass + "-container"
         });
-        this.$on = $("<span>", {
+        this.$on = $('<span>', {
           html: this.options.onText,
           "class": "" + this.options.baseClass + "-handle-on " + this.options.baseClass + "-" + this.options.onColor
         });
-        this.$off = $("<span>", {
+        this.$off = $('<span>', {
           html: this.options.offText,
           "class": "" + this.options.baseClass + "-handle-off " + this.options.baseClass + "-" + this.options.offColor
         });
-        this.$label = $("<label>", {
-          "for": this.$element.attr("id"),
+        this.$label = $('<label>', {
+          "for": this.$element.attr('id'),
           html: this.options.labelText,
           "class": "" + this.options.baseClass + "-label"
         });
-        this.$element.on("init.bootstrapSwitch", (function(_this) {
+        this.$element.on('init.bootstrapSwitch', (function(_this) {
           return function() {
             return _this.options.onInit.apply(element, arguments);
           };
         })(this));
-        this.$element.on("switchChange.bootstrapSwitch", (function(_this) {
+        this.$element.on('switchChange.bootstrapSwitch', (function(_this) {
           return function() {
             return _this.options.onSwitchChange.apply(element, arguments);
           };
         })(this));
         this.$container = this.$element.wrap(this.$container).parent();
         this.$wrapper = this.$container.wrap(this.$wrapper).parent();
-        this.$element.before(this.$on).before(this.$label).before(this.$off).trigger("init.bootstrapSwitch");
+        this.$element.before(this.$on).before(this.$label).before(this.$off).trigger('init.bootstrapSwitch');
         this._elementHandlers();
         this._handleHandlers();
         this._labelHandlers();
@@ -110,14 +108,14 @@
       BootstrapSwitch.prototype._constructor = BootstrapSwitch;
 
       BootstrapSwitch.prototype.state = function(value, skip) {
-        if (typeof value === "undefined") {
+        if (typeof value === 'undefined') {
           return this.options.state;
         }
         if (this.options.disabled || this.options.readonly) {
           return this.$element;
         }
         value = !!value;
-        this.$element.prop("checked", value).trigger("change.bootstrapSwitch", skip);
+        this.$element.prop('checked', value).trigger('change.bootstrapSwitch', skip);
         return this.$element;
       };
 
@@ -125,11 +123,11 @@
         if (this.options.disabled || this.options.readonly) {
           return this.$element;
         }
-        return this.$element.prop("checked", !this.options.state).trigger("change.bootstrapSwitch", skip);
+        return this.$element.prop('checked', !this.options.state).trigger('change.bootstrapSwitch', skip);
       };
 
       BootstrapSwitch.prototype.size = function(value) {
-        if (typeof value === "undefined") {
+        if (typeof value === 'undefined') {
           return this.options.size;
         }
         if (this.options.size != null) {
@@ -143,46 +141,46 @@
       };
 
       BootstrapSwitch.prototype.animate = function(value) {
-        if (typeof value === "undefined") {
+        if (typeof value === 'undefined') {
           return this.options.animate;
         }
         value = !!value;
-        this.$wrapper[value ? "addClass" : "removeClass"]("" + this.options.baseClass + "-animate");
+        this.$wrapper[value ? 'addClass' : 'removeClass']("" + this.options.baseClass + "-animate");
         this.options.animate = value;
         return this.$element;
       };
 
       BootstrapSwitch.prototype.disabled = function(value) {
-        if (typeof value === "undefined") {
+        if (typeof value === 'undefined') {
           return this.options.disabled;
         }
         value = !!value;
-        this.$wrapper[value ? "addClass" : "removeClass"]("" + this.options.baseClass + "-disabled");
-        this.$element.prop("disabled", value);
+        this.$wrapper[value ? 'addClass' : 'removeClass']("" + this.options.baseClass + "-disabled");
+        this.$element.prop('disabled', value);
         this.options.disabled = value;
         return this.$element;
       };
 
       BootstrapSwitch.prototype.toggleDisabled = function() {
-        this.$element.prop("disabled", !this.options.disabled);
+        this.$element.prop('disabled', !this.options.disabled);
         this.$wrapper.toggleClass("" + this.options.baseClass + "-disabled");
         this.options.disabled = !this.options.disabled;
         return this.$element;
       };
 
       BootstrapSwitch.prototype.readonly = function(value) {
-        if (typeof value === "undefined") {
+        if (typeof value === 'undefined') {
           return this.options.readonly;
         }
         value = !!value;
-        this.$wrapper[value ? "addClass" : "removeClass"]("" + this.options.baseClass + "-readonly");
-        this.$element.prop("readonly", value);
+        this.$wrapper[value ? 'addClass' : 'removeClass']("" + this.options.baseClass + "-readonly");
+        this.$element.prop('readonly', value);
         this.options.readonly = value;
         return this.$element;
       };
 
       BootstrapSwitch.prototype.toggleReadonly = function() {
-        this.$element.prop("readonly", !this.options.readonly);
+        this.$element.prop('readonly', !this.options.readonly);
         this.$wrapper.toggleClass("" + this.options.baseClass + "-readonly");
         this.options.readonly = !this.options.readonly;
         return this.$element;
@@ -191,7 +189,7 @@
       BootstrapSwitch.prototype.onColor = function(value) {
         var color;
         color = this.options.onColor;
-        if (typeof value === "undefined") {
+        if (typeof value === 'undefined') {
           return color;
         }
         if (color != null) {
@@ -205,7 +203,7 @@
       BootstrapSwitch.prototype.offColor = function(value) {
         var color;
         color = this.options.offColor;
-        if (typeof value === "undefined") {
+        if (typeof value === 'undefined') {
           return color;
         }
         if (color != null) {
@@ -217,7 +215,7 @@
       };
 
       BootstrapSwitch.prototype.onText = function(value) {
-        if (typeof value === "undefined") {
+        if (typeof value === 'undefined') {
           return this.options.onText;
         }
         this.$on.html(value);
@@ -226,7 +224,7 @@
       };
 
       BootstrapSwitch.prototype.offText = function(value) {
-        if (typeof value === "undefined") {
+        if (typeof value === 'undefined') {
           return this.options.offText;
         }
         this.$off.html(value);
@@ -235,7 +233,7 @@
       };
 
       BootstrapSwitch.prototype.labelText = function(value) {
-        if (typeof value === "undefined") {
+        if (typeof value === 'undefined') {
           return this.options.labelText;
         }
         this.$label.html(value);
@@ -248,52 +246,52 @@
       };
 
       BootstrapSwitch.prototype.wrapperClass = function(value) {
-        if (typeof value === "undefined") {
+        if (typeof value === 'undefined') {
           return this.options.wrapperClass;
         }
         if (!value) {
           value = $.fn.bootstrapSwitch.defaults.wrapperClass;
         }
-        this.$wrapper.removeClass(this._getClasses(this.options.wrapperClass).join(" "));
-        this.$wrapper.addClass(this._getClasses(value).join(" "));
+        this.$wrapper.removeClass(this._getClasses(this.options.wrapperClass).join(' '));
+        this.$wrapper.addClass(this._getClasses(value).join(' '));
         this.options.wrapperClass = value;
         return this.$element;
       };
 
       BootstrapSwitch.prototype.destroy = function() {
         var $form;
-        $form = this.$element.closest("form");
+        $form = this.$element.closest('form');
         if ($form.length) {
-          $form.off("reset.bootstrapSwitch").removeData("bootstrap-switch");
+          $form.off('reset.bootstrapSwitch').removeData('bootstrap-switch');
         }
         this.$container.children().not(this.$element).remove();
-        this.$element.unwrap().unwrap().off(".bootstrapSwitch").removeData("bootstrap-switch");
+        this.$element.unwrap().unwrap().off('.bootstrapSwitch').removeData('bootstrap-switch');
         return this.$element;
       };
 
       BootstrapSwitch.prototype._elementHandlers = function() {
         return this.$element.on({
-          "change.bootstrapSwitch": (function(_this) {
+          'change.bootstrapSwitch': (function(_this) {
             return function(e, skip) {
               var checked;
               e.preventDefault();
               e.stopPropagation();
               e.stopImmediatePropagation();
-              checked = _this.$element.is(":checked");
+              checked = _this.$element.is(':checked');
               if (checked === _this.options.state) {
                 return;
               }
               _this.options.state = checked;
               _this.$wrapper.removeClass(checked ? "" + _this.options.baseClass + "-off" : "" + _this.options.baseClass + "-on").addClass(checked ? "" + _this.options.baseClass + "-on" : "" + _this.options.baseClass + "-off");
               if (!skip) {
-                if (_this.$element.is(":radio")) {
-                  $("[name='" + (_this.$element.attr('name')) + "']").not(_this.$element).prop("checked", false).trigger("change.bootstrapSwitch", true);
+                if (_this.$element.is(':radio')) {
+                  $("[name='" + (_this.$element.attr('name')) + "']").not(_this.$element).prop('checked', false).trigger('change.bootstrapSwitch', true);
                 }
-                return _this.$element.trigger("switchChange.bootstrapSwitch", [checked]);
+                return _this.$element.trigger('switchChange.bootstrapSwitch', [checked]);
               }
             };
           })(this),
-          "focus.bootstrapSwitch": (function(_this) {
+          'focus.bootstrapSwitch': (function(_this) {
             return function(e) {
               e.preventDefault();
               e.stopPropagation();
@@ -301,7 +299,7 @@
               return _this.$wrapper.addClass("" + _this.options.baseClass + "-focused");
             };
           })(this),
-          "blur.bootstrapSwitch": (function(_this) {
+          'blur.bootstrapSwitch': (function(_this) {
             return function(e) {
               e.preventDefault();
               e.stopPropagation();
@@ -309,7 +307,7 @@
               return _this.$wrapper.removeClass("" + _this.options.baseClass + "-focused");
             };
           })(this),
-          "keydown.bootstrapSwitch": (function(_this) {
+          'keydown.bootstrapSwitch': (function(_this) {
             return function(e) {
               if (!e.which || _this.options.disabled || _this.options.readonly) {
                 return;
@@ -337,30 +335,31 @@
       };
 
       BootstrapSwitch.prototype._handleHandlers = function() {
-        this.$on.on("click.bootstrapSwitch", (function(_this) {
+        this.$on.on('click.bootstrapSwitch', (function(_this) {
           return function(e) {
             _this.state(false);
-            return _this.$element.trigger("focus.bootstrapSwitch");
+            return _this.$element.trigger('focus.bootstrapSwitch');
           };
         })(this));
-        return this.$off.on("click.bootstrapSwitch", (function(_this) {
+        return this.$off.on('click.bootstrapSwitch', (function(_this) {
           return function(e) {
             _this.state(true);
-            return _this.$element.trigger("focus.bootstrapSwitch");
+            return _this.$element.trigger('focus.bootstrapSwitch');
           };
         })(this));
       };
 
       BootstrapSwitch.prototype._labelHandlers = function() {
         return this.$label.on({
-          "mousemove.bootstrapSwitch touchmove.bootstrapSwitch": (function(_this) {
+          'mousemove.bootstrapSwitch touchmove.bootstrapSwitch': (function(_this) {
             return function(e) {
-              var left, percent, right;
+              var left, pageX, percent, right;
               if (!_this.drag) {
                 return;
               }
               e.preventDefault();
-              percent = (((e.pageX || e.originalEvent.touches[0].pageX) - _this.$wrapper.offset().left) / _this.$wrapper.width()) * 100;
+              pageX = e.pageX || e.originalEvent.touches[0].pageX;
+              percent = ((pageX - _this.$wrapper.offset().left) / _this.$wrapper.width()) * 100;
               left = 25;
               right = 75;
               if (percent < left) {
@@ -368,11 +367,11 @@
               } else if (percent > right) {
                 percent = right;
               }
-              _this.$container.css("margin-left", "" + (percent - right) + "%");
-              return _this.$element.trigger("focus.bootstrapSwitch");
+              _this.$container.css('margin-left', "" + (percent - right) + "%");
+              return _this.$element.trigger('focus.bootstrapSwitch');
             };
           })(this),
-          "mousedown.bootstrapSwitch touchstart.bootstrapSwitch": (function(_this) {
+          'mousedown.bootstrapSwitch touchstart.bootstrapSwitch': (function(_this) {
             return function(e) {
               if (_this.drag || _this.options.disabled || _this.options.readonly) {
                 return;
@@ -382,26 +381,26 @@
               if (_this.options.animate) {
                 _this.$wrapper.removeClass("" + _this.options.baseClass + "-animate");
               }
-              return _this.$element.trigger("focus.bootstrapSwitch");
+              return _this.$element.trigger('focus.bootstrapSwitch');
             };
           })(this),
-          "mouseup.bootstrapSwitch touchend.bootstrapSwitch": (function(_this) {
+          'mouseup.bootstrapSwitch touchend.bootstrapSwitch': (function(_this) {
             return function(e) {
               if (!_this.drag) {
                 return;
               }
               e.preventDefault();
               _this.drag = false;
-              _this.$element.prop("checked", parseInt(_this.$container.css("margin-left"), 10) > -(_this.$container.width() / 6)).trigger("change.bootstrapSwitch");
-              _this.$container.css("margin-left", "");
+              _this.$element.prop('checked', parseInt(_this.$container.css('margin-left'), 10) > -(_this.$container.width() / 6)).trigger('change.bootstrapSwitch');
+              _this.$container.css('margin-left', '');
               if (_this.options.animate) {
                 return _this.$wrapper.addClass("" + _this.options.baseClass + "-animate");
               }
             };
           })(this),
-          "mouseleave.bootstrapSwitch": (function(_this) {
+          'mouseleave.bootstrapSwitch': (function(_this) {
             return function(e) {
-              return _this.$label.trigger("mouseup.bootstrapSwitch");
+              return _this.$label.trigger('mouseup.bootstrapSwitch');
             };
           })(this)
         });
@@ -409,19 +408,19 @@
 
       BootstrapSwitch.prototype._formHandler = function() {
         var $form;
-        $form = this.$element.closest("form");
-        if ($form.data("bootstrap-switch")) {
+        $form = this.$element.closest('form');
+        if ($form.data('bootstrap-switch')) {
           return;
         }
-        return $form.on("reset.bootstrapSwitch", function() {
+        return $form.on('reset.bootstrapSwitch', function() {
           return window.setTimeout(function() {
-            return $form.find("input").filter(function() {
-              return $(this).data("bootstrap-switch");
+            return $form.find('input').filter(function() {
+              return $(this).data('bootstrap-switch');
             }).each(function() {
-              return $(this).bootstrapSwitch("state", this.checked);
+              return $(this).bootstrapSwitch('state', this.checked);
             });
           }, 1);
-        }).data("bootstrap-switch", true);
+        }).data('bootstrap-switch', true);
       };
 
       BootstrapSwitch.prototype._getClasses = function(classes) {
@@ -447,11 +446,11 @@
       this.each(function() {
         var $this, data;
         $this = $(this);
-        data = $this.data("bootstrap-switch");
+        data = $this.data('bootstrap-switch');
         if (!data) {
-          $this.data("bootstrap-switch", data = new BootstrapSwitch(this, option));
+          $this.data('bootstrap-switch', data = new BootstrapSwitch(this, option));
         }
-        if (typeof option === "string") {
+        if (typeof option === 'string') {
           return ret = data[option].apply(data, args);
         }
       });
@@ -464,13 +463,13 @@
       animate: true,
       disabled: false,
       readonly: false,
-      onColor: "primary",
-      offColor: "default",
-      onText: "ON",
-      offText: "OFF",
-      labelText: "&nbsp;",
-      baseClass: "bootstrap-switch",
-      wrapperClass: "wrapper",
+      onColor: 'primary',
+      offColor: 'default',
+      onText: 'ON',
+      offText: 'OFF',
+      labelText: '&nbsp;',
+      baseClass: 'bootstrap-switch',
+      wrapperClass: 'wrapper',
       onInit: function() {},
       onSwitchChange: function() {}
     };

File diff ditekan karena terlalu besar
+ 0 - 0
dist/js/bootstrap-switch.min.js


+ 115 - 0
gulpfile.coffee

@@ -0,0 +1,115 @@
+gulp = require 'gulp'
+plugins = require('gulp-load-plugins')()
+pkg = require './package.json'
+name = pkg.name
+
+SOURCE_PATH = './src'
+DIST_PATH = './dist'
+DOCS_PATH = './docs'
+SERVER_HOST = 'localhost'
+SERVER_PORT = 3000
+BANNER = """
+  /* ========================================================================
+   * <%= pkg.name %> - v<%= pkg.version %>
+   * <%= pkg.homepage %>
+   * ========================================================================
+   * Copyright 2012-2013 <%= pkg.author.name %>
+   *
+   * ========================================================================
+   * 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.
+   * ========================================================================
+   */
+
+
+  """
+
+gulp.task 'coffee', ->
+  gulp
+  .src "#{SOURCE_PATH}/coffee/#{name}.coffee"
+  .pipe plugins.changed "#{DIST_PATH}/js"
+  .pipe plugins.coffeelint './coffeelint.json'
+  .pipe plugins.coffeelint.reporter()
+    .on 'error', plugins.util.log
+  .pipe plugins.coffee()
+    .on 'error', plugins.util.log
+  .pipe plugins.header BANNER, pkg: pkg
+  .pipe gulp.dest "#{DIST_PATH}/js"
+  .pipe plugins.uglify()
+  .pipe plugins.header BANNER, pkg: pkg
+  .pipe plugins.rename suffix: '.min'
+  .pipe gulp.dest "#{DIST_PATH}/js"
+
+gulp.task 'less-bootstrap2', ->
+  gulp
+  .src "#{SOURCE_PATH}/less/bootstrap2/build.less"
+  .pipe plugins.changed "#{DIST_PATH}/css/bootstrap2"
+  .pipe plugins.less()
+    .on 'error', plugins.util.log
+  .pipe plugins.header BANNER, pkg: pkg
+  .pipe plugins.rename basename: name
+  .pipe gulp.dest "#{DIST_PATH}/css/bootstrap2"
+  .pipe plugins.less compress: true, cleancss: true
+  .pipe plugins.header BANNER, pkg: pkg
+  .pipe plugins.rename suffix: '.min'
+  .pipe gulp.dest "#{DIST_PATH}/css/bootstrap2"
+
+gulp.task 'less-bootstrap3', ->
+  gulp
+  .src "#{SOURCE_PATH}/less/bootstrap3/build.less"
+  .pipe plugins.changed "#{DIST_PATH}/css/bootstrap3"
+  .pipe plugins.less()
+  .pipe plugins.header BANNER, pkg: pkg
+  .pipe plugins.rename basename: name
+  .pipe gulp.dest "#{DIST_PATH}/css/bootstrap3"
+  .pipe plugins.less compress: true, cleancss: true
+  .pipe plugins.header BANNER, pkg: pkg
+  .pipe plugins.rename suffix: '.min'
+  .pipe gulp.dest "#{DIST_PATH}/css/bootstrap3"
+
+gulp.task 'docs', ->
+  gulp
+  .src "#{DOCS_PATH}/index.jade"
+  .pipe plugins.changed './'
+  .pipe plugins.jade pretty: true
+  .pipe gulp.dest './'
+
+gulp.task 'connect', ['docs'], ->
+  plugins.connect.server
+    root: [__dirname]
+    host: SERVER_HOST
+    port: SERVER_PORT
+    livereload: true
+
+gulp.task 'open', ['connect'], ->
+  gulp
+  .src './index.html'
+  .pipe plugins.open '', url: "http://#{SERVER_HOST}:#{SERVER_PORT}"
+
+gulp.task 'watch', ['connect'], ->
+  gulp.watch "#{SOURCE_PATH}/coffee/#{name}.coffee", ['coffee']
+  gulp.watch "#{SOURCE_PATH}/less/bootstrap2/*.less", ['less-bootstrap2']
+  gulp.watch "#{SOURCE_PATH}/less/bootstrap3/*.less", ['less-bootstrap3']
+  gulp.watch "#{DOCS_PATH}/index.jade", ['docs']
+  gulp.watch [
+    "#{DIST_PATH}/js/**/*.js"
+    "#{DIST_PATH}/css/**/*.css"
+    './index.html'
+  ]
+  .on 'change', (event) ->
+    gulp.src event.path
+    .pipe plugins.connect.reload()
+
+gulp.task 'server', ['connect', 'open', 'watch']
+gulp.task 'less', ['less-bootstrap2', 'less-bootstrap3']
+gulp.task 'dist', ['coffee', 'less']
+gulp.task 'default', ['dist', 'docs', 'server']

+ 2 - 107
gulpfile.js

@@ -1,107 +1,2 @@
-var gulp = require('gulp');
-var plugins = require('gulp-load-plugins')();
-var pkg = require('./package.json');
-var name = pkg.name;
-var banner = [
-  '/* ========================================================================',
-  ' * <%= pkg.name %> - v<%= pkg.version %>',
-  ' * <%= pkg.homepage %>',
-  ' * ========================================================================',
-  ' * Copyright 2012-2013 <%= pkg.author.name %>',
-  ' *',
-  ' * ========================================================================',
-  ' * 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.',
-  ' * ========================================================================',
-  ' */',
-  '',
-  ''].join('\n');
-
-gulp.task('coffee', function() {
-  gulp.src('src/coffee/' + name + '.coffee')
-    .pipe(plugins.coffeelint({
-      indentation: 2,
-      no_trailing_semicolons: true,
-      no_trailing_whitespace: true
-    }))
-    .pipe(plugins.coffee()).on('error', plugins.util.log)
-    .pipe(plugins.header(banner, { pkg: pkg }))
-    .pipe(gulp.dest('dist/js'))
-    .pipe(plugins.uglify())
-    .pipe(plugins.header(banner, { pkg: pkg }))
-    .pipe(plugins.rename({ suffix: '.min' }))
-    .pipe(gulp.dest('dist/js'));
-});
-
-gulp.task('less-bootstrap2', function() {
-  gulp.src('src/less/bootstrap2/build.less')
-    .pipe(plugins.less())
-    .pipe(plugins.header(banner, { pkg: pkg }))
-    .pipe(plugins.rename({ basename: name }))
-    .pipe(gulp.dest('dist/css/bootstrap2'))
-    .pipe(plugins.less({
-      compress: true,
-      cleancss: true
-    }))
-    .pipe(plugins.header(banner, { pkg: pkg }))
-    .pipe(plugins.rename({ suffix: '.min' }))
-    .pipe(gulp.dest('dist/css/bootstrap2'));
-});
-
-gulp.task('less-bootstrap3', function() {
-  gulp.src('src/less/bootstrap3/build.less')
-    .pipe(plugins.less())
-    .pipe(plugins.header(banner, { pkg: pkg }))
-    .pipe(plugins.rename({ basename: name }))
-    .pipe(gulp.dest('dist/css/bootstrap3'))
-    .pipe(plugins.less({
-      compress: true,
-      cleancss: true
-    }))
-    .pipe(plugins.header(banner, { pkg: pkg }))
-    .pipe(plugins.rename({ suffix: '.min' }))
-    .pipe(gulp.dest('dist/css/bootstrap3'));
-});
-
-gulp.task('docs', function() {
-  gulp.src('docs/index.jade')
-    .pipe(plugins.jade({ pretty: true }))
-    .pipe(gulp.dest('./'));
-});
-
-gulp.task('connect', ['docs'], plugins.connect.server({
-  root: [__dirname],
-  open: true
-}));
-
-gulp.task('watch', ['connect'], function() {
-  gulp.watch('src/coffee/' + name + '.coffee', ['coffee']).on('change', function(data) {
-    gulp.src(data.path).pipe(plugins.connect.reload());
-  });
-
-  gulp.watch('src/less/bootstrap2/*.less', ['less-bootstrap2']).on('change', function(data) {
-    gulp.src(data.path).pipe(plugins.connect.reload());
-  });
-
-  gulp.watch('src/less/bootstrap3/*.less', ['less-bootstrap3']).on('change', function(data) {
-    gulp.src(data.path).pipe(plugins.connect.reload());
-  });
-
-  gulp.watch('docs/index.jade', ['docs']).on('change', function(data) {
-    gulp.src(data.path).pipe(plugins.connect.reload());
-  });
-
-});
-
-gulp.task('less', ['less-bootstrap2', 'less-bootstrap3']);
-gulp.task('build', ['coffee', 'less']);
-gulp.task('default', ['connect', 'build', 'docs', 'watch']);
+require('coffee-script/register');
+require('./gulpfile.coffee');

+ 10 - 8
package.json

@@ -37,18 +37,20 @@
   "license": "Apache Version 2",
   "readmeFilename": "README.md",
   "devDependencies": {
-    "gulp-coffee": "~1.4.1",
+    "gulp-coffee": "~1.4.2",
     "gulp-util": "~2.2.14",
     "gulp-header": "~1.0.2",
     "gulp-uglify": "~0.2.1",
-    "gulp-coffeelint": "~0.2.2",
-    "gulp": "~3.5.5",
-    "gulp-less": "~1.2.2",
-    "gulp-rename": "~1.0.0",
+    "gulp-coffeelint": "~0.3.2",
+    "gulp": "~3.6.1",
+    "gulp-less": "~1.2.3",
+    "gulp-rename": "~1.2.0",
     "gulp-open": "~0.2.8",
-    "gulp-load-plugins": "~0.3.0",
-    "gulp-jade": "~0.4.2",
+    "gulp-load-plugins": "~0.5.0",
+    "gulp-jade": "~0.5.0",
     "run-sequence": "~0.3.6",
-    "gulp-connect": "~1.0.7"
+    "gulp-connect": "~2.0.5",
+    "coffee-script": "~1.7.1",
+    "gulp-changed": "~0.3.0"
   }
 }

+ 97 - 92
src/coffee/bootstrap-switch.coffee

@@ -1,25 +1,23 @@
 do ($ = window.jQuery, window) ->
-  "use strict"
+  'use strict'
 
   class BootstrapSwitch
-    name: "bootstrap-switch"
-
     constructor: (element, options = {}) ->
       @$element = $ element
       @options = $.extend {}, $.fn.bootstrapSwitch.defaults, options,
-        state: @$element.is ":checked"
-        size: @$element.data "size"
-        animate: @$element.data "animate"
-        disabled: @$element.is ":disabled"
-        readonly: @$element.is "[readonly]"
-        onColor: @$element.data "on-color"
-        offColor: @$element.data "off-color"
-        onText: @$element.data "on-text"
-        offText: @$element.data "off-text"
-        labelText: @$element.data "label-text"
-        baseClass: @$element.data "base-class"
-        wrapperClass: @$element.data "wrapper-class"
-      @$wrapper = $ "<div>",
+        state: @$element.is ':checked'
+        size: @$element.data 'size'
+        animate: @$element.data 'animate'
+        disabled: @$element.is ':disabled'
+        readonly: @$element.is '[readonly]'
+        onColor: @$element.data 'on-color'
+        offColor: @$element.data 'off-color'
+        onText: @$element.data 'on-text'
+        offText: @$element.data 'off-text'
+        labelText: @$element.data 'label-text'
+        baseClass: @$element.data 'base-class'
+        wrapperClass: @$element.data 'wrapper-class'
+      @$wrapper = $ '<div>',
         class: do =>
           classes = ["#{@options.baseClass}"].concat @_getClasses @options.wrapperClass
 
@@ -28,24 +26,24 @@ do ($ = window.jQuery, window) ->
           classes.push "#{@options.baseClass}-animate" if @options.animate
           classes.push "#{@options.baseClass}-disabled" if @options.disabled
           classes.push "#{@options.baseClass}-readonly" if @options.readonly
-          classes.push "#{@options.baseClass}-id-#{@$element.attr("id")}" if @$element.attr "id"
-          classes.join " "
-      @$container = $ "<div>",
+          classes.push "#{@options.baseClass}-id-#{@$element.attr('id')}" if @$element.attr 'id'
+          classes.join ' '
+      @$container = $ '<div>',
         class: "#{@options.baseClass}-container"
-      @$on = $ "<span>",
+      @$on = $ '<span>',
         html: @options.onText,
         class: "#{@options.baseClass}-handle-on #{@options.baseClass}-#{@options.onColor}"
-      @$off = $ "<span>",
+      @$off = $ '<span>',
         html: @options.offText,
         class: "#{@options.baseClass}-handle-off #{@options.baseClass}-#{@options.offColor}"
-      @$label = $ "<label>",
-        for: @$element.attr "id"
+      @$label = $ '<label>',
+        for: @$element.attr 'id'
         html: @options.labelText
         class: "#{@options.baseClass}-label"
 
       # set up events
-      @$element.on "init.bootstrapSwitch", => @options.onInit.apply element, arguments
-      @$element.on "switchChange.bootstrapSwitch", => @options.onSwitchChange.apply element, arguments
+      @$element.on 'init.bootstrapSwitch', => @options.onInit.apply element, arguments
+      @$element.on 'switchChange.bootstrapSwitch', => @options.onSwitchChange.apply element, arguments
 
       # reassign elements after dom modification
       @$container = @$element.wrap(@$container).parent()
@@ -56,33 +54,33 @@ do ($ = window.jQuery, window) ->
       .before(@$on)
       .before(@$label)
       .before(@$off)
-      .trigger "init.bootstrapSwitch"
+      .trigger 'init.bootstrapSwitch'
 
       @_elementHandlers()
       @_handleHandlers()
       @_labelHandlers()
       @_formHandler()
 
-      # TODO: @$label.hasClass "label-change-switch" in toggleState
+      # TODO: @$label.hasClass 'label-change-switch' in toggleState
 
     _constructor: BootstrapSwitch
 
     state: (value, skip) ->
-      return @options.state if typeof value is "undefined"
+      return @options.state if typeof value is 'undefined'
       return @$element if @options.disabled or @options.readonly
 
       value = not not value
 
-      @$element.prop("checked", value).trigger "change.bootstrapSwitch", skip
+      @$element.prop('checked', value).trigger 'change.bootstrapSwitch', skip
       @$element
 
     toggleState: (skip) ->
       return @$element if @options.disabled or @options.readonly
 
-      @$element.prop("checked", not @options.state).trigger "change.bootstrapSwitch", skip
+      @$element.prop('checked', not @options.state).trigger 'change.bootstrapSwitch', skip
 
     size: (value) ->
-      return @options.size if typeof value is "undefined"
+      return @options.size if typeof value is 'undefined'
 
       @$wrapper.removeClass "#{@options.baseClass}-#{@options.size}" if @options.size?
       @$wrapper.addClass "#{@options.baseClass}-#{value}" if value
@@ -90,42 +88,42 @@ do ($ = window.jQuery, window) ->
       @$element
 
     animate: (value) ->
-      return @options.animate if typeof value is "undefined"
+      return @options.animate if typeof value is 'undefined'
 
       value = not not value
 
-      @$wrapper[if value then "addClass" else "removeClass"]("#{@options.baseClass}-animate")
+      @$wrapper[if value then 'addClass' else 'removeClass']("#{@options.baseClass}-animate")
       @options.animate = value
       @$element
 
     disabled: (value) ->
-      return @options.disabled if typeof value is "undefined"
+      return @options.disabled if typeof value is 'undefined'
 
       value = not not value
 
-      @$wrapper[if value then "addClass" else "removeClass"]("#{@options.baseClass}-disabled")
-      @$element.prop "disabled", value
+      @$wrapper[if value then 'addClass' else 'removeClass']("#{@options.baseClass}-disabled")
+      @$element.prop 'disabled', value
       @options.disabled = value
       @$element
 
     toggleDisabled: ->
-      @$element.prop "disabled", not @options.disabled
+      @$element.prop 'disabled', not @options.disabled
       @$wrapper.toggleClass "#{@options.baseClass}-disabled"
       @options.disabled = not @options.disabled
       @$element
 
     readonly: (value) ->
-      return @options.readonly if typeof value is "undefined"
+      return @options.readonly if typeof value is 'undefined'
 
       value = not not value
 
-      @$wrapper[if value then "addClass" else "removeClass"]("#{@options.baseClass}-readonly")
-      @$element.prop "readonly", value
+      @$wrapper[if value then 'addClass' else 'removeClass']("#{@options.baseClass}-readonly")
+      @$element.prop 'readonly', value
       @options.readonly = value
       @$element
 
     toggleReadonly: ->
-      @$element.prop "readonly", not @options.readonly
+      @$element.prop 'readonly', not @options.readonly
       @$wrapper.toggleClass "#{@options.baseClass}-readonly"
       @options.readonly = not @options.readonly
       @$element
@@ -133,7 +131,7 @@ do ($ = window.jQuery, window) ->
     onColor: (value) ->
       color = @options.onColor
 
-      return color if typeof value is "undefined"
+      return color if typeof value is 'undefined'
 
       @$on.removeClass "#{@options.baseClass}-#{color}" if color?
       @$on.addClass "#{@options.baseClass}-#{value}"
@@ -143,7 +141,7 @@ do ($ = window.jQuery, window) ->
     offColor: (value) ->
       color = @options.offColor
 
-      return color if typeof value is "undefined"
+      return color if typeof value is 'undefined'
 
       @$off.removeClass "#{@options.baseClass}-#{color}" if color?
       @$off.addClass "#{@options.baseClass}-#{value}"
@@ -151,21 +149,21 @@ do ($ = window.jQuery, window) ->
       @$element
 
     onText: (value) ->
-      return @options.onText if typeof value is "undefined"
+      return @options.onText if typeof value is 'undefined'
 
       @$on.html value
       @options.onText = value
       @$element
 
     offText: (value) ->
-      return @options.offText if typeof value is "undefined"
+      return @options.offText if typeof value is 'undefined'
 
       @$off.html value
       @options.offText = value
       @$element
 
     labelText: (value) ->
-      return @options.labelText if typeof value is "undefined"
+      return @options.labelText if typeof value is 'undefined'
 
       @$label.html value
       @options.labelText = value
@@ -175,31 +173,31 @@ do ($ = window.jQuery, window) ->
       @options.baseClass
 
     wrapperClass: (value) ->
-      return @options.wrapperClass if typeof value is "undefined"
+      return @options.wrapperClass if typeof value is 'undefined'
 
       value = $.fn.bootstrapSwitch.defaults.wrapperClass unless value
 
-      @$wrapper.removeClass @_getClasses(@options.wrapperClass).join " "
-      @$wrapper.addClass @_getClasses(value).join " "
+      @$wrapper.removeClass @_getClasses(@options.wrapperClass).join ' '
+      @$wrapper.addClass @_getClasses(value).join ' '
       @options.wrapperClass = value
       @$element
 
     destroy: ->
-      $form = @$element.closest "form"
+      $form = @$element.closest 'form'
 
-      $form.off("reset.bootstrapSwitch").removeData "bootstrap-switch" if $form.length
+      $form.off('reset.bootstrapSwitch').removeData 'bootstrap-switch' if $form.length
       @$container.children().not(@$element).remove()
-      @$element.unwrap().unwrap().off(".bootstrapSwitch").removeData "bootstrap-switch"
+      @$element.unwrap().unwrap().off('.bootstrapSwitch').removeData 'bootstrap-switch'
       @$element
 
     _elementHandlers: ->
       @$element.on
-        "change.bootstrapSwitch": (e, skip) =>
+        'change.bootstrapSwitch': (e, skip) =>
           e.preventDefault()
           e.stopPropagation()
           e.stopImmediatePropagation()
 
-          checked = @$element.is ":checked"
+          checked = @$element.is ':checked'
 
           return if checked is @options.state
 
@@ -209,24 +207,28 @@ do ($ = window.jQuery, window) ->
           .addClass if checked then "#{@options.baseClass}-on" else "#{@options.baseClass}-off"
 
           unless skip
-            $("[name='#{@$element.attr('name')}']").not(@$element).prop("checked", false).trigger "change.bootstrapSwitch", true if @$element.is ":radio"
-            @$element.trigger "switchChange.bootstrapSwitch", [checked]
-
-        "focus.bootstrapSwitch": (e) =>
+            if @$element.is ':radio'
+              $("[name='#{@$element.attr('name')}']")
+              .not(@$element)
+              .prop('checked', false)
+              .trigger 'change.bootstrapSwitch', true
+            @$element.trigger 'switchChange.bootstrapSwitch', [checked]
+
+        'focus.bootstrapSwitch': (e) =>
           e.preventDefault()
           e.stopPropagation()
           e.stopImmediatePropagation()
 
           @$wrapper.addClass "#{@options.baseClass}-focused"
 
-        "blur.bootstrapSwitch": (e) =>
+        'blur.bootstrapSwitch': (e) =>
           e.preventDefault()
           e.stopPropagation()
           e.stopImmediatePropagation()
 
           @$wrapper.removeClass "#{@options.baseClass}-focused"
 
-        "keydown.bootstrapSwitch": (e) =>
+        'keydown.bootstrapSwitch': (e) =>
           return if not e.which or @options.disabled or @options.readonly
 
           switch e.which
@@ -250,22 +252,23 @@ do ($ = window.jQuery, window) ->
               @state true
 
     _handleHandlers: ->
-      @$on.on "click.bootstrapSwitch", (e) =>
+      @$on.on 'click.bootstrapSwitch', (e) =>
         @state false
-        @$element.trigger "focus.bootstrapSwitch"
+        @$element.trigger 'focus.bootstrapSwitch'
 
-      @$off.on "click.bootstrapSwitch", (e) =>
+      @$off.on 'click.bootstrapSwitch', (e) =>
         @state true
-        @$element.trigger "focus.bootstrapSwitch"
+        @$element.trigger 'focus.bootstrapSwitch'
 
     _labelHandlers: ->
       @$label.on
-        "mousemove.bootstrapSwitch touchmove.bootstrapSwitch": (e) =>
+        'mousemove.bootstrapSwitch touchmove.bootstrapSwitch': (e) =>
           return unless @drag
 
           e.preventDefault()
 
-          percent = (((e.pageX or e.originalEvent.touches[0].pageX) - @$wrapper.offset().left) / @$wrapper.width()) * 100
+          pageX = e.pageX or e.originalEvent.touches[0].pageX
+          percent = ((pageX - @$wrapper.offset().left) / @$wrapper.width()) * 100
           left = 25
           right = 75
 
@@ -274,45 +277,47 @@ do ($ = window.jQuery, window) ->
           else if percent > right
             percent = right
 
-          @$container.css "margin-left", "#{percent - right}%"
-          @$element.trigger "focus.bootstrapSwitch"
+          @$container.css 'margin-left', "#{percent - right}%"
+          @$element.trigger 'focus.bootstrapSwitch'
 
-        "mousedown.bootstrapSwitch touchstart.bootstrapSwitch": (e) =>
+        'mousedown.bootstrapSwitch touchstart.bootstrapSwitch': (e) =>
           return if @drag or @options.disabled or @options.readonly
 
           e.preventDefault()
 
           @drag = true
           @$wrapper.removeClass "#{@options.baseClass}-animate" if @options.animate
-          @$element.trigger "focus.bootstrapSwitch"
+          @$element.trigger 'focus.bootstrapSwitch'
 
-        "mouseup.bootstrapSwitch touchend.bootstrapSwitch": (e) =>
+        'mouseup.bootstrapSwitch touchend.bootstrapSwitch': (e) =>
           return unless @drag
 
           e.preventDefault()
 
           @drag = false
-          @$element.prop("checked", parseInt(@$container.css("margin-left"), 10) > -(@$container.width() / 6)).trigger "change.bootstrapSwitch"
-          @$container.css "margin-left", ""
+          @$element
+          .prop('checked', parseInt(@$container.css('margin-left'), 10) > -(@$container.width() / 6))
+          .trigger 'change.bootstrapSwitch'
+          @$container.css 'margin-left', ''
           @$wrapper.addClass "#{@options.baseClass}-animate" if @options.animate
 
-        "mouseleave.bootstrapSwitch": (e) =>
-          @$label.trigger "mouseup.bootstrapSwitch"
+        'mouseleave.bootstrapSwitch': (e) =>
+          @$label.trigger 'mouseup.bootstrapSwitch'
 
     _formHandler: ->
-      $form = @$element.closest "form"
+      $form = @$element.closest 'form'
 
-      return if $form.data "bootstrap-switch"
+      return if $form.data 'bootstrap-switch'
 
       $form
-      .on "reset.bootstrapSwitch", ->
+      .on 'reset.bootstrapSwitch', ->
         window.setTimeout ->
           $form
-          .find("input")
-          .filter( -> $(@).data "bootstrap-switch")
-          .each -> $(@).bootstrapSwitch "state", @checked
+          .find('input')
+          .filter( -> $(@).data 'bootstrap-switch')
+          .each -> $(@).bootstrapSwitch 'state', @checked
         , 1
-      .data "bootstrap-switch", true
+      .data 'bootstrap-switch', true
 
     _getClasses: (classes) ->
       return ["#{@options.baseClass}-#{classes}"] unless $.isArray classes
@@ -326,10 +331,10 @@ do ($ = window.jQuery, window) ->
     ret = @
     @each ->
       $this = $ @
-      data = $this.data "bootstrap-switch"
+      data = $this.data 'bootstrap-switch'
 
-      $this.data "bootstrap-switch", data = new BootstrapSwitch @, option unless data
-      ret = data[option].apply data, args if typeof option is "string"
+      $this.data 'bootstrap-switch', data = new BootstrapSwitch @, option unless data
+      ret = data[option].apply data, args if typeof option is 'string'
     ret
 
   $.fn.bootstrapSwitch.Constructor = BootstrapSwitch
@@ -339,13 +344,13 @@ do ($ = window.jQuery, window) ->
     animate: true
     disabled: false
     readonly: false
-    onColor: "primary"
-    offColor: "default"
-    onText: "ON"
-    offText: "OFF"
-    labelText: "&nbsp;"
-    baseClass: "bootstrap-switch"
-    wrapperClass: "wrapper"
+    onColor: 'primary'
+    offColor: 'default'
+    onText: 'ON'
+    offText: 'OFF'
+    labelText: '&nbsp;'
+    baseClass: 'bootstrap-switch'
+    wrapperClass: 'wrapper'
     onInit: ->
     onSwitchChange: ->
 

Beberapa file tidak ditampilkan karena terlalu banyak file yang berubah dalam diff ini