Thomas Grainger 8 年之前
父節點
當前提交
a295540dd4

+ 4 - 1
dist/css/bootstrap2/bootstrap-switch.css

@@ -78,7 +78,6 @@
   box-sizing: border-box;
   cursor: pointer;
   display: inline-block !important;
-  height: 100%;
   padding-top: 4px;
   padding-bottom: 4px;
   padding-left: 8px;
@@ -368,6 +367,9 @@
 .bootstrap-switch .bootstrap-switch-label.active {
   background-color: #cccccc \9;
 }
+.bootstrap-switch span::before {
+  content: "\200b";
+}
 .bootstrap-switch .bootstrap-switch-handle-on {
   -webkit-border-top-left-radius: 4px;
   -moz-border-radius-topleft: 4px;
@@ -392,6 +394,7 @@
   opacity: 0;
   filter: alpha(opacity=0);
   z-index: -1;
+  visibility: hidden;
 }
 .bootstrap-switch input[type='radio'].form-control,
 .bootstrap-switch input[type='checkbox'].form-control {

文件差異過大導致無法顯示
+ 0 - 0
dist/css/bootstrap2/bootstrap-switch.min.css


+ 6 - 2
dist/css/bootstrap3/bootstrap-switch.css

@@ -42,8 +42,8 @@
   -moz-box-sizing: border-box;
   box-sizing: border-box;
   cursor: pointer;
-  display: inline-block !important;
-  height: 100%;
+  display: table-cell;
+  vertical-align: middle;
   padding: 6px 12px;
   font-size: 14px;
   line-height: 20px;
@@ -91,6 +91,9 @@
   color: #333;
   background: #fff;
 }
+.bootstrap-switch span::before {
+  content: "\200b";
+}
 .bootstrap-switch .bootstrap-switch-handle-on {
   border-bottom-left-radius: 3px;
   border-top-left-radius: 3px;
@@ -108,6 +111,7 @@
   z-index: -1;
   opacity: 0;
   filter: alpha(opacity=0);
+  visibility: hidden;
 }
 .bootstrap-switch.bootstrap-switch-mini .bootstrap-switch-handle-on,
 .bootstrap-switch.bootstrap-switch-mini .bootstrap-switch-handle-off,

文件差異過大導致無法顯示
+ 0 - 0
dist/css/bootstrap3/bootstrap-switch.min.css


+ 57 - 20
dist/js/bootstrap-switch.js

@@ -7,13 +7,55 @@
   * @license Apache-2.0
   */
 
-'use strict';
+(function (global, factory) {
+  if (typeof define === "function" && define.amd) {
+    define(['jquery'], factory);
+  } else if (typeof exports !== "undefined") {
+    factory(require('jquery'));
+  } else {
+    var mod = {
+      exports: {}
+    };
+    factory(global.jquery);
+    global.bootstrapSwitch = mod.exports;
+  }
+})(this, function (_jquery) {
+  'use strict';
+
+  var _jquery2 = _interopRequireDefault(_jquery);
+
+  function _interopRequireDefault(obj) {
+    return obj && obj.__esModule ? obj : {
+      default: obj
+    };
+  }
+
+  function _classCallCheck(instance, Constructor) {
+    if (!(instance instanceof Constructor)) {
+      throw new TypeError("Cannot call a class as a function");
+    }
+  }
+
+  var _createClass = function () {
+    function defineProperties(target, props) {
+      for (var i = 0; i < props.length; i++) {
+        var descriptor = props[i];
+        descriptor.enumerable = descriptor.enumerable || false;
+        descriptor.configurable = true;
+        if ("value" in descriptor) descriptor.writable = true;
+        Object.defineProperty(target, descriptor.key, descriptor);
+      }
+    }
 
-var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
+    return function (Constructor, protoProps, staticProps) {
+      if (protoProps) defineProperties(Constructor.prototype, protoProps);
+      if (staticProps) defineProperties(Constructor, staticProps);
+      return Constructor;
+    };
+  }();
 
-function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+  var $ = _jquery2.default || window.jQuery || window.$;
 
-(function ($, window) {
   var BootstrapSwitch = function () {
     function BootstrapSwitch(element) {
       var _this = this;
@@ -430,12 +472,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
         var _this2 = this;
 
         var $handles = this.$on.add(this.$off).add(this.$label).css('width', '');
-        var handleWidth = void 0;
-        if (this.options.handleWidth === 'auto') {
-          handleWidth = Math.round(Math.max(this.$on.width(), this.$off.width()));
-        } else {
-          handleWidth = this.options.handleWidth;
-        }
+        var handleWidth = this.options.handleWidth === 'auto' ? Math.round(Math.max(this.$on.width(), this.$off.width())) : this.options.handleWidth;
         $handles.width(handleWidth);
         this.$label.width(function (index, width) {
           if (_this2.options.labelWidth !== 'auto') {
@@ -694,19 +731,19 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
       args[_key2 - 1] = arguments[_key2];
     }
 
-    var ret = this;
-    this.each(function () {
-      var $this = $(this);
-      var data = $this.data('bootstrap-switch');
-      if (!data) {
-        data = new BootstrapSwitch(this, option);
+    function reducer(ret, next) {
+      var $this = $(next);
+      var existingData = $this.data('bootstrap-switch');
+      var data = existingData || new BootstrapSwitch(next, option);
+      if (!existingData) {
         $this.data('bootstrap-switch', data);
       }
       if (typeof option === 'string') {
-        ret = data[option].apply(data, args);
+        return data[option].apply(data, args);
       }
-    });
-    return ret;
+      return ret;
+    }
+    return Array.prototype.reduce.call(this, reducer, this);
   };
   $.fn.bootstrapSwitch.Constructor = BootstrapSwitch;
   $.fn.bootstrapSwitch.defaults = {
@@ -730,4 +767,4 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
     onInit: function onInit() {},
     onSwitchChange: function onSwitchChange() {}
   };
-})(window.jQuery, window);
+});

文件差異過大導致無法顯示
+ 0 - 0
dist/js/bootstrap-switch.min.js


部分文件因文件數量過多而無法顯示