1/* 2 Checkator jQuery Plugin 3 A plugin for radio and checkbox elements 4 version 1.1, May 16th, 2015 5 by Ingi á Steinamørk 6 7 The MIT License (MIT) 8 9 Copyright (c) 2013 Ingi á Steinamørk 10 11 Permission is hereby granted, free of charge, to any person obtaining a copy of 12 this software and associated documentation files (the "Software"), to deal in 13 the Software without restriction, including without limitation the rights to 14 use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 15 the Software, and to permit persons to whom the Software is furnished to do so, 16 subject to the following conditions: 17 18 The above copyright notice and this permission notice shall be included in all 19 copies or substantial portions of the Software. 20 21 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 23 FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 24 COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 25 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 26 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27*/ 28 29(function($) { 30 $.checkator = function (element, options) { 31 var defaults = { 32 prefix: 'checkator_' 33 }; 34 35 var plugin = this; 36 var type = $(element).attr('type'); 37 var checked = $(element)[0].checked; 38 var wrapper = null; 39 var new_element = null; 40 plugin.settings = {}; 41 42 43 44 // INITIALIZE PLUGIN 45 plugin.init = function () { 46 plugin.settings = $.extend({}, defaults, options); 47 48 wrapper = document.createElement('div'); 49 $(wrapper).addClass(plugin.settings.prefix + 'holder ' + type); 50 $(element).before(wrapper); 51 $(wrapper).append(element); 52 new_element = document.createElement('div'); 53 if (element.id !== undefined) { 54 $(new_element).attr('id', plugin.settings.prefix + element.id); 55 } 56 $(new_element).addClass(plugin.settings.prefix + 'element ' + type + ' ' + (checked ? 'checked ' : '')); 57 58 $(wrapper).css({ 59 width: $(element).outerWidth() + 'px', 60 height: $(element).outerHeight() + 'px', 61 'margin-top': $(element).css('margin-top'), 62 'margin-right': $(element).css('margin-right'), 63 'margin-bottom': $(element).css('margin-bottom'), 64 'margin-left': $(element).css('margin-left'), 65 'float': $(element).css('float'), 66 'display': $(element).css('display') === 'inline' ? 'inline-clock' : $(element).css('display') 67 }); 68 $(element).css({ 69 opacity: 0, 70 margin: 0 71 }); 72 73 $(element).addClass(plugin.settings.prefix + 'source'); 74 $(element).after(new_element); 75 76 }; 77 78 79 // REMOVE PLUGIN AND REVERT SELECT ELEMENT TO ORIGINAL STATE 80 plugin.destroy = function () { 81 $(new_element).remove(); 82 $.removeData(element, 'checkator'); 83 $(element).css({ 84 opacity: '', 85 margin: '' 86 }); 87 $(element).removeClass(plugin.settings.prefix + 'source'); 88 $(element).unwrap(); 89 }; 90 91 92 // Initialize plugin 93 plugin.init(); 94 }; 95 96 $.fn.checkator = function(options) { 97 options = options !== undefined ? options : {}; 98 return this.each(function () { 99 if (typeof(options) === 'object') { 100 if (undefined === $(this).data('checkator')) { 101 var plugin = new $.checkator(this, options); 102 $(this).data('checkator', plugin); 103 } 104 } else if ($(this).data('checkator')[options]) { 105 $(this).data('checkator')[options].apply(this, Array.prototype.slice.call(arguments, 1)); 106 } else { 107 $.error('Method ' + options + ' does not exist in $.checkator'); 108 } 109 }); 110 }; 111 112}(jQuery)); 113 114$(function () { 115 $('.checkator').checkator(); 116});
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.