diff --git a/jquery.switchButton.css b/jquery.switchButton.css index e1668dd..5c4a058 100755 --- a/jquery.switchButton.css +++ b/jquery.switchButton.css @@ -1,3 +1,32 @@ +/** + * jquery.switchButton.js v1.0 + * jQuery iPhone-like switch button + * @author Olivier Lance + * + * Copyright (c) Olivier Lance - released under MIT License {{{ + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * }}} + */ + + .switch-button-label { float: left; diff --git a/jquery.switchButton.js b/jquery.switchButton.js index 105aeb2..00d37a7 100755 --- a/jquery.switchButton.js +++ b/jquery.switchButton.js @@ -49,7 +49,8 @@ on_label: "ON", // Text to be displayed when checked off_label: "OFF", // Text to be displayed when unchecked - width: 25, // Width of the button in pixels + size_unit: "px", // Size Unit for the Switch + width: 25, // Width of the button in pixels height: 11, // Height of the button in pixels button_width: 12, // Width of the sliding part in pixels @@ -183,10 +184,10 @@ this.off_label.html(this.options.off_label); // Refresh button's dimensions - this.button_bg.width(this.options.width); - this.button_bg.height(this.options.height); - this.button.width(this.options.button_width); - this.button.height(this.options.height); + this.button_bg.width(this.options.width.concat(this.options.size_unit)); + this.button_bg.height(this.options.height.concat(this.options.size_unit)); + this.button.width(this.options.button_width.concat(this.options.size_unit)); + this.button.height(this.options.height.concat(this.options.size_unit)); }, _initEvents: function() { @@ -258,8 +259,8 @@ this.element.prop("checked", true); this.element.change(); - var dLeft = this.options.width - this.options.button_width; - newLeft = "+=" + dLeft; + var dLeft = this.options.width - this.options.button_width; + newLeft = dLeft + this.options.size_unit; // Update labels states if(this.options.labels_placement == "both")