From 078f5707036dd147d5047df232897bc23f424a3a Mon Sep 17 00:00:00 2001 From: Herschdorfer Date: Fri, 3 Feb 2017 11:07:02 +0100 Subject: [PATCH 1/3] added licence --- jquery.switchButton.css | 81 ++++++++++++++++++++++++++--------------- 1 file changed, 51 insertions(+), 30 deletions(-) diff --git a/jquery.switchButton.css b/jquery.switchButton.css index e1668dd..6539d39 100755 --- a/jquery.switchButton.css +++ b/jquery.switchButton.css @@ -1,44 +1,65 @@ +/** + * 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; - - font-size: 10pt; - cursor: pointer; + float: left; + font-size: 10pt; + cursor: pointer; } .switch-button-label.off { - color: #adadad; + color: #adadad; } .switch-button-label.on { - color: #0088CC; + color: #0088CC; } .switch-button-background { - float: left; - position: relative; - - background: #ccc; - border: 1px solid #aaa; - - margin: 1px 10px; - - -webkit-border-radius: 4px; - -moz-border-radius: 4px; - border-radius: 4px; - - cursor: pointer; + float: left; + position: relative; + background: #ccc; + border: 1px solid #aaa; + margin: 1px 10px; + -webkit-border-radius: 4px; + -moz-border-radius: 4px; + border-radius: 4px; + cursor: pointer; } .switch-button-button { - position: absolute; - - left: -1px; - top : -1px; - - background: #FAFAFA; - border: 1px solid #aaa; - - -webkit-border-radius: 4px; - -moz-border-radius: 4px; - border-radius: 4px; + position: absolute; + left: -1px; + top: -1px; + background: #FAFAFA; + border: 1px solid #aaa; + -webkit-border-radius: 4px; + -moz-border-radius: 4px; + border-radius: 4px; } From 08acac435dcac0ef73268c5f1fc20c7f24c85bf4 Mon Sep 17 00:00:00 2001 From: Herschdorfer Date: Fri, 3 Feb 2017 11:09:08 +0100 Subject: [PATCH 2/3] revert my formatting --- jquery.switchButton.css | 52 ++++++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 22 deletions(-) diff --git a/jquery.switchButton.css b/jquery.switchButton.css index 6539d39..5c4a058 100755 --- a/jquery.switchButton.css +++ b/jquery.switchButton.css @@ -28,38 +28,46 @@ .switch-button-label { - float: left; - font-size: 10pt; - cursor: pointer; + float: left; + + font-size: 10pt; + cursor: pointer; } .switch-button-label.off { - color: #adadad; + color: #adadad; } .switch-button-label.on { - color: #0088CC; + color: #0088CC; } .switch-button-background { - float: left; - position: relative; - background: #ccc; - border: 1px solid #aaa; - margin: 1px 10px; - -webkit-border-radius: 4px; - -moz-border-radius: 4px; - border-radius: 4px; - cursor: pointer; + float: left; + position: relative; + + background: #ccc; + border: 1px solid #aaa; + + margin: 1px 10px; + + -webkit-border-radius: 4px; + -moz-border-radius: 4px; + border-radius: 4px; + + cursor: pointer; } .switch-button-button { - position: absolute; - left: -1px; - top: -1px; - background: #FAFAFA; - border: 1px solid #aaa; - -webkit-border-radius: 4px; - -moz-border-radius: 4px; - border-radius: 4px; + position: absolute; + + left: -1px; + top : -1px; + + background: #FAFAFA; + border: 1px solid #aaa; + + -webkit-border-radius: 4px; + -moz-border-radius: 4px; + border-radius: 4px; } From eda543a523fceeac1571737f86990ade0031bcbf Mon Sep 17 00:00:00 2001 From: Herschdorfer Date: Fri, 3 Feb 2017 14:00:17 +0100 Subject: [PATCH 3/3] added support for different scaling sizes --- jquery.switchButton.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) 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")