1/** 2 * Switchable - jQuery plugin to create a simple iOS style switcher for checkboxes. 3 * Copyright (c) 2014, Rogério Taques. 4 * 5 * Licensed under MIT license: 6 * http://www.opensource.org/licenses/mit-license.php 7 * 8 * Permission is hereby granted, free of charge, to any person obtaining a copy of this 9 * software and associated documentation files (the "Software"), to deal in the Software 10 * without restriction, including without limitation the rights to use, copy, modify, merge, 11 * publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons 12 * to whom the Software is furnished to do so, subject to the following conditions: 13 * 14 * The above copyright notice and this permission notice shall be included in all copies or 15 * substantial portions of the Software. 16 * 17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING 18 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 * 23 * @requires jQuery v1.9 or above 24 * @version 1.1 25 * @cat Plugins/Form Validation 26 * @author Rogério Taques ([email protected]) 27 * @see https://github.com/rogeriotaques/switchable 28 */ 29 30(function($){var version='1.0.1',defaults={label_position:'before',checked_color:null,readonly:false,click:null},methods={version:function(){return this.each(function(){$(this).html(version);});},init:function(options){var o=$.extend(defaults,options);return this.each(function(){var me=$(this),wrapper=$('<div />',{'class':'switchable-wrapper'}),switcher=$('<div />',{'class':'switchable-holder','style':'display: inline-block'}),button=$('<div />',{'class':'switchable-switcher'}),label=$('<div />',{'class':'switchable-label','html':(me.data('label')?me.data('label'):'')});button.appendTo(switcher.appendTo(wrapper));me.after(wrapper);if(me.data('label')){if(o.label_position=='before'){switcher.before(label);}else 31{wrapper.append(label);}}me.hide();switcher.toggleClass('switchable-checked',me.is(':checked'));if(o.checked_color){_setCustomColor(switcher,me.is(':checked'),o);}if(!o.readonly){button.on('click',function(e){me.prop('checked',!me.is(':checked'));switcher.toggleClass('switchable-checked',me.is(':checked'));if(o.checked_color){_setCustomColor(switcher,me.is(':checked'),o);}if(o.click&&$.isFunction(o.click)){return o.click(e,me.is(':checked'));}});}else 32{switcher.addClass('switchable-readonly');button.css({'cursor':'not-allowed'});}});}};function _setCustomColor(switcher,is_checked,options){switcher.css({'border-color':(is_checked?options.checked_color:''),'background-color':(is_checked?options.checked_color:'')});}$.fn.switchable=function(method){if(methods[method]){return methods[method].apply(this,Array.prototype.slice.call(arguments,1));}else if(typeof method==='object'||!method){return methods.init.apply(this,arguments);}else{$.error('Method '+method+' does not exist on jQuery.Switchable()');}};})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.