PageSourceSearch

https://www.icsa2026.com/inc/assets/global/plugins/icheck/icheck.js

js icsa2026.com collected 2026-10-02 01:32:31 UTC 14,134 bytes, 508 lines download raw bytes

1/*!
2 * iCheck v1.0.2, http://git.io/arlzeA
3 * ===================================
4 * Powerful jQuery and Zepto plugin for checkboxes and radio buttons customization
5 *
6 * (c) 2013 Damir Sultanov, http://fronteed.com
7 * MIT Licensed
8 */
9
10(function($) {
11
12  // Cached vars
13  var _iCheck = 'iCheck',
14    _iCheckHelper = _iCheck + '-helper',
15    _checkbox = 'checkbox',
16    _radio = 'radio',
17    _checked = 'checked',
18    _unchecked = 'un' + _checked,
19    _disabled = 'disabled',
20    _determinate = 'determinate',
21    _indeterminate = 'in' + _determinate,
22    _update = 'update',
23    _type = 'type',
24    _click = 'click',
25    _touch = 'touchbegin.i touchend.i',
26    _add = 'addClass',
27    _remove = 'removeClass',
28    _callback = 'trigger',
29    _label = 'label',
30    _cursor = 'cursor',
31    _mobile = /ipad|iphone|ipod|android|blackberry|windows phone|opera mini|silk/i.test(navigator.userAgent);
32
33  // Plugin init
34  $.fn[_iCheck] = function(options, fire) {
vendor: 13,181 bytes, lines 34-508
34
35    // Walker
36    var handle = 'input[type="' + _checkbox + '"], input[type="' + _radio + '"]',
37      stack = $(),
38      walker = function(object) {
39        object.each(function() {
40          var self = $(this);
41
42          if (self.is(handle)) {
43            stack = stack.add(self);
44          } else {
45            stack = stack.add(self.find(handle));
46          }
47        });
48      };
49
50    // Check if we should operate with some method
51    if (/^(check|uncheck|toggle|indeterminate|determinate|disable|enable|update|destroy)$/i.test(options)) {
52
53      // Normalize method's name
54      options = options.toLowerCase();
55
56      // Find checkboxes and radio buttons
57      walker(this);
58
59      return stack.each(function() {
60        var self = $(this);
61
62        if (options == 'destroy') {
63          tidy(self, 'ifDestroyed');
64        } else {
65          operate(self, true, options);
66        }
67
68        // Fire method's callback
69        if ($.isFunction(fire)) {
70          fire();
71        }
72      });
73
74    // Customization
75    } else if (typeof options == 'object' || !options) {
76
77      // Check if any options were passed
78      var settings = $.extend({
79          checkedClass: _checked,
80          disabledClass: _disabled,
81          indeterminateClass: _indeterminate,
82          labelHover: true
83        }, options),
84
85        selector = settings.handle,
86        hoverClass = settings.hoverClass || 'hover',
87        focusClass = settings.focusClass || 'focus',
88        activeClass = settings.activeClass || 'active',
89        labelHover = !!settings.labelHover,
90        labelHoverClass = settings.labelHoverClass || 'hover',
91
92        // Setup clickable area
93        area = ('' + settings.increaseArea).replace('%', '') | 0;
94
95      // Selector limit
96      if (selector == _checkbox || selector == _radio) {
97        handle = 'input[type="' + selector + '"]';
98      }
99
100      // Clickable area limit
101      if (area < -50) {
102        area = -50;
103      }
104
105      // Walk around the selector
106      walker(this);
107
108      return stack.each(function() {
109        var self = $(this);
110
111        // If already customized
112        tidy(self);
113
114        var node = this,
115          id = node.id,
116
117          // Layer styles
118          offset = -area + '%',
119          size = 100 + (area * 2) + '%',
120          layer = {
121            position: 'absolute',
122            top: offset,
123            left: offset,
124            display: 'block',
125            width: size,
126            height: size,
127            margin: 0,
128            padding: 0,
129            background: '#fff',
130            border: 0,
131            opacity: 0
132          },
133
134          // Choose how to hide input
135          hide = _mobile ? {
136            position: 'absolute',
137            visibility: 'hidden'
138          } : area ? layer : {
139            position: 'absolute',
140            opacity: 0
141          },
142
143          // Get proper class
144          className = node[_type] == _checkbox ? settings.checkboxClass || 'i' + _checkbox : settings.radioClass || 'i' + _radio,
145
146          // Find assigned labels
147          label = $(_label + '[for="' + id + '"]').add(self.closest(_label)),
148
149          // Check ARIA option
150          aria = !!settings.aria,
151
152          // Set ARIA placeholder
153          ariaID = _iCheck + '-' + Math.random().toString(36).substr(2,6),
154
155          // Parent & helper
156          parent = '<div class="' + className + '" ' + (aria ? 'role="' + node[_type] + '" ' : ''),
157          helper;
158
159        // Set ARIA "labelledby"
160        if (aria) {
161          label.each(function() {
162            parent += 'aria-labelledby="';
163
164            if (this.id) {
165              parent += this.id;
166            } else {
167              this.id = ariaID;
168              parent += ariaID;
169            }
170
171            parent += '"';
172          });
173        }
174
175        // Wrap input
176        parent = self.wrap(parent + '/>')[_callback]('ifCreated').parent().append(settings.insert);
177
178        // Layer addition
179        helper = $('<ins class="' + _iCheckHelper + '"/>').css(layer).appendTo(parent);
180
181        // Finalize customization
182        self.data(_iCheck, {o: settings, s: self.attr('style')}).css(hide);
183        !!settings.inheritClass && parent[_add](node.className || '');
184        !!settings.inheritID && id && parent.attr('id', _iCheck + '-' + id);
185        parent.css('position') == 'static' && parent.css('position', 'relative');
186        operate(self, true, _update);
187
188        // Label events
189        if (label.length) {
190          label.on(_click + '.i mouseover.i mouseout.i ' + _touch, function(event) {
191            var type = event[_type],
192              item = $(this);
193
194            // Do nothing if input is disabled
195            if (!node[_disabled]) {
196
197              // Click
198              if (type == _click) {
199                if ($(event.target).is('a')) {
200                  return;
201                }
202                operate(self, false, true);
203
204              // Hover state
205              } else if (labelHover) {
206
207                // mouseout|touchend
208                if (/ut|nd/.test(type)) {
209                  parent[_remove](hoverClass);
210                  item[_remove](labelHoverClass);
211                } else {
212                  parent[_add](hoverClass);
213                  item[_add](labelHoverClass);
214                }
215              }
216
217              if (_mobile) {
218                event.stopPropagation();
219              } else {
220                return false;
221              }
222            }
223          });
224        }
225
226        // Input events
227        self.on(_click + '.i focus.i blur.i keyup.i keydown.i keypress.i', function(event) {
228          var type = event[_type],
229            key = event.keyCode;
230
231          // Click
232          if (type == _click) {
233            return false;
234
235          // Keydown
236          } else if (type == 'keydown' && key == 32) {
237            if (!(node[_type] == _radio && node[_checked])) {
238              if (node[_checked]) {
239                off(self, _checked);
240              } else {
241                on(self, _checked);
242              }
243            }
244
245            return false;
246
247          // Keyup
248          } else if (type == 'keyup' && node[_type] == _radio) {
249            !node[_checked] && on(self, _checked);
250
251          // Focus/blur
252          } else if (/us|ur/.test(type)) {
253            parent[type == 'blur' ? _remove : _add](focusClass);
254          }
255        });
256
257        // Helper events
258        helper.on(_click + ' mousedown mouseup mouseover mouseout ' + _touch, function(event) {
259          var type = event[_type],
260
261            // mousedown|mouseup
262            toggle = /wn|up/.test(type) ? activeClass : hoverClass;
263
264          // Do nothing if input is disabled
265          if (!node[_disabled]) {
266
267            // Click
268            if (type == _click) {
269              operate(self, false, true);
270
271            // Active and hover states
272            } else {
273
274              // State is on
275              if (/wn|er|in/.test(type)) {
276
277                // mousedown|mouseover|touchbegin
278                parent[_add](toggle);
279
280              // State is off
281              } else {
282                parent[_remove](toggle + ' ' + activeClass);
283              }
284
285              // Label hover
286              if (label.length && labelHover && toggle == hoverClass) {
287
288                // mouseout|touchend
289                label[/ut|nd/.test(type) ? _remove : _add](labelHoverClass);
290              }
291            }
292
293            if (_mobile) {
294              event.stopPropagation();
295            } else {
296              return false;
297            }
298          }
299        });
300      });
301    } else {
302      return this;
303    }
304  };
305
306  // Do something with inputs
307  function operate(input, direct, method) {
308    var node = input[0],
309      state = /er/.test(method) ? _indeterminate : /bl/.test(method) ? _disabled : _checked,
310      active = method == _update ? {
311        checked: node[_checked],
312        disabled: node[_disabled],
313        indeterminate: input.attr(_indeterminate) == 'true' || input.attr(_determinate) == 'false'
314      } : node[state];
315
316    // Check, disable or indeterminate
317    if (/^(ch|di|in)/.test(method) && !active) {
318      on(input, state);
319
320    // Uncheck, enable or determinate
321    } else if (/^(un|en|de)/.test(method) && active) {
322      off(input, state);
323
324    // Update
325    } else if (method == _update) {
326
327      // Handle states
328      for (var each in active) {
329        if (active[each]) {
330          on(input, each, true);
331        } else {
332          off(input, each, true);
333        }
334      }
335
336    } else if (!direct || method == 'toggle') {
337
338      // Helper or label was clicked
339      if (!direct) {
340        input[_callback]('ifClicked');
341      }
342
343      // Toggle checked state
344      if (active) {
345        if (node[_type] !== _radio) {
346          off(input, state);
347        }
348      } else {
349        on(input, state);
350      }
351    }
352  }
353
354  // Add checked, disabled or indeterminate state
355  function on(input, state, keep) {
356    var node = input[0],
357      parent = input.parent(),
358      checked = state == _checked,
359      indeterminate = state == _indeterminate,
360      disabled = state == _disabled,
361      callback = indeterminate ? _determinate : checked ? _unchecked : 'enabled',
362      regular = option(input, callback + capitalize(node[_type])),
363      specific = option(input, state + capitalize(node[_type]));
364
365    // Prevent unnecessary actions
366    if (node[state] !== true) {
367
368      // Toggle assigned radio buttons
369      if (!keep && state == _checked && node[_type] == _radio && node.name) {
370        var form = input.closest('form'),
371          inputs = 'input[name="' + node.name + '"]';
372
373        inputs = form.length ? form.find(inputs) : $(inputs);
374
375        inputs.each(function() {
376          if (this !== node && $(this).data(_iCheck)) {
377            off($(this), state);
378          }
379        });
380      }
381
382      // Indeterminate state
383      if (indeterminate) {
384
385        // Add indeterminate state
386        node[state] = true;
387
388        // Remove checked state
389        if (node[_checked]) {
390          off(input, _checked, 'force');
391        }
392
393      // Checked or disabled state
394      } else {
395
396        // Add checked or disabled state
397        if (!keep) {
398          node[state] = true;
399        }
400
401        // Remove indeterminate state
402        if (checked && node[_indeterminate]) {
403          off(input, _indeterminate, false);
404        }
405      }
406
407      // Trigger callbacks
408      callbacks(input, checked, state, keep);
409    }
410
411    // Add proper cursor
412    if (node[_disabled] && !!option(input, _cursor, true)) {
413      parent.find('.' + _iCheckHelper).css(_cursor, 'default');
414    }
415
416    // Add state class
417    parent[_add](specific || option(input, state) || '');
418
419    // Set ARIA attribute
420    if (!!parent.attr('role') && !indeterminate) {
421      parent.attr('aria-' + (disabled ? _disabled : _checked), 'true');
422    }
423
424    // Remove regular state class
425    parent[_remove](regular || option(input, callback) || '');
426  }
427
428  // Remove checked, disabled or indeterminate state
429  function off(input, state, keep) {
430    var node = input[0],
431      parent = input.parent(),
432      checked = state == _checked,
433      indeterminate = state == _indeterminate,
434      disabled = state == _disabled,
435      callback = indeterminate ? _determinate : checked ? _unchecked : 'enabled',
436      regular = option(input, callback + capitalize(node[_type])),
437      specific = option(input, state + capitalize(node[_type]));
438
439    // Prevent unnecessary actions
440    if (node[state] !== false) {
441
442      // Toggle state
443      if (indeterminate || !keep || keep == 'force') {
444        node[state] = false;
445      }
446
447      // Trigger callbacks
448      callbacks(input, checked, callback, keep);
449    }
450
451    // Add proper cursor
452    if (!node[_disabled] && !!option(input, _cursor, true)) {
453      parent.find('.' + _iCheckHelper).css(_cursor, 'pointer');
454    }
455
456    // Remove state class
457    parent[_remove](specific || option(input, state) || '');
458
459    // Set ARIA attribute
460    if (!!parent.attr('role') && !indeterminate) {
461      parent.attr('aria-' + (disabled ? _disabled : _checked), 'false');
462    }
463
464    // Add regular state class
465    parent[_add](regular || option(input, callback) || '');
466  }
467
468  // Remove all traces
469  function tidy(input, callback) {
470    if (input.data(_iCheck)) {
471
472      // Remove everything except input
473      input.parent().html(input.attr('style', input.data(_iCheck).s || ''));
474
475      // Callback
476      if (callback) {
477        input[_callback](callback);
478      }
479
480      // Unbind events
481      input.off('.i').unwrap();
482      $(_label + '[for="' + input[0].id + '"]').add(input.closest(_label)).off('.i');
483    }
484  }
485
486  // Get some option
487  function option(input, state, regular) {
488    if (input.data(_iCheck)) {
489      return input.data(_iCheck).o[state + (regular ? '' : 'Class')];
490    }
491  }
492
493  // Capitalize some string
494  function capitalize(string) {
495    return string.charAt(0).toUpperCase() + string.slice(1);
496  }
497
498  // Executable handlers
499  function callbacks(input, checked, callback, keep) {
500    if (!keep) {
501      if (checked) {
502        input[_callback]('ifToggled');
503      }
504
505      input[_callback]('ifChanged')[_callback]('if' + capitalize(callback));
506    }
507  }
508})(window.jQuery || window.Zepto);

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.