github.com/insionng/yougam@v0.0.0-20170714101924-2bc18d833463/public/libs/icheck/README.md (about)

     1  # [iCheck plugin](http://fronteed.com/iCheck/) <sup>[1.0.2](#march-03-2014)</sup>
     2  #### Highly customizable checkboxes and radio buttons for jQuery and Zepto.
     3  
     4  Refer to the [iCheck website](http://fronteed.com/iCheck/) for examples.
     5  
     6  **Note: [iCheck v2.0](https://github.com/fronteed/iCheck/tree/2.x-beta) is on the way**, it got a huge performance boost, many new options and methods. It's in a release candidate state, so you may try to use it. Feel free to submit an issue if you find something not working.
     7  
     8  ![Skins](http://fronteed.com/iCheck/examples.png)
     9  
    10  
    11  Features
    12  --------
    13  
    14  * **Identical inputs across different browsers and devices** — both [desktop and mobile](#browser-support)
    15  * **Touch devices support** — iOS, Android, BlackBerry, Windows Phone, Amazon Kindle
    16  * **Keyboard accessible inputs** — `Tab`, `Spacebar`, `Arrow up/down` and other shortcuts
    17  * **Customization freedom** — use any HTML and CSS to style inputs (try [6 Retina-ready skins](http://fronteed.com/iCheck/))
    18  * **jQuery and Zepto** JavaScript libraries support from single file
    19  * **Screenreader accessible inputs** &mdash; [ARIA](https://developer.mozilla.org/en-US/docs/Accessibility/ARIA) attributes for VoiceOver and others
    20  * **Lightweight size** — 1 kb gzipped
    21  
    22  -----
    23  
    24  * [32 options](#options) to customize checkboxes and radio buttons
    25  * [11 callbacks](#callbacks) to handle changes
    26  * [9 methods](#methods) to make changes programmatically
    27  * Saves changes to original inputs, [works carefully](#initialize) with any selectors
    28  
    29  
    30  How it works
    31  ------------
    32  
    33  iCheck works with checkboxes and radio buttons like a constructor. **It wraps each input with a div**, which may be customized by you or using one of the [available skins](http://fronteed.com/iCheck/). You may also place inside that div some HTML code or text using `insert` option.
    34  
    35  For this HTML:
    36  
    37  ```html
    38  <label>
    39    <input type="checkbox" name="quux[1]" disabled>
    40    Foo
    41  </label>
    42  
    43  <label for="baz[1]">Bar</label>
    44  <input type="radio" name="quux[2]" id="baz[1]" checked>
    45  
    46  <label for="baz[2]">Bar</label>
    47  <input type="radio" name="quux[2]" id="baz[2]">
    48  ```
    49  
    50  With default options you'll get nearly this:
    51  
    52  ```html
    53  <label>
    54    <div class="icheckbox disabled">
    55      <input type="checkbox" name="quux[1]" disabled>
    56    </div>
    57    Foo
    58  </label>
    59  
    60  <label for="baz[1]">Bar</label>
    61  <div class="iradio checked">
    62    <input type="radio" name="quux[2]" id="baz[1]" checked>
    63  </div>
    64  
    65  <label for="baz[2]">Bar</label>
    66  <div class="iradio">
    67    <input type="radio" name="quux[2]" id="baz[2]">
    68  </div>
    69  ```
    70  
    71  **By default, iCheck doesn't provide any CSS styles for wrapper divs** (if you don't use [skins](http://fronteed.com/iCheck/)).
    72  
    73  
    74  Options
    75  -------
    76  
    77  These options are default:
    78  
    79  ```js
    80  {
    81    // 'checkbox' or 'radio' to style only checkboxes or radio buttons, both by default
    82    handle: '',
    83  
    84    // base class added to customized checkboxes
    85    checkboxClass: 'icheckbox',
    86  
    87    // base class added to customized radio buttons
    88    radioClass: 'iradio',
    89  
    90    // class added on checked state (input.checked = true)
    91    checkedClass: 'checked',
    92  
    93      // if not empty, used instead of 'checkedClass' option (input type specific)
    94      checkedCheckboxClass: '',
    95      checkedRadioClass: '',
    96  
    97    // if not empty, added as class name on unchecked state (input.checked = false)
    98    uncheckedClass: '',
    99  
   100      // if not empty, used instead of 'uncheckedClass' option (input type specific)
   101      uncheckedCheckboxClass: '',
   102      uncheckedRadioClass: '',
   103  
   104    // class added on disabled state (input.disabled = true)
   105    disabledClass: 'disabled',
   106  
   107      // if not empty, used instead of 'disabledClass' option (input type specific)
   108      disabledCheckboxClass: '',
   109      disabledRadioClass: '',
   110  
   111    // if not empty, added as class name on enabled state (input.disabled = false)
   112    enabledClass: '',
   113  
   114      // if not empty, used instead of 'enabledClass' option (input type specific)
   115      enabledCheckboxClass: '',
   116      enabledRadioClass: '',
   117  
   118    // class added on indeterminate state (input.indeterminate = true)
   119    indeterminateClass: 'indeterminate',
   120  
   121      // if not empty, used instead of 'indeterminateClass' option (input type specific)
   122      indeterminateCheckboxClass: '',
   123      indeterminateRadioClass: '',
   124  
   125    // if not empty, added as class name on determinate state (input.indeterminate = false)
   126    determinateClass: '',
   127  
   128      // if not empty, used instead of 'determinateClass' option (input type specific)
   129      determinateCheckboxClass: '',
   130      determinateRadioClass: '',
   131  
   132    // class added on hover state (pointer is moved onto input)
   133    hoverClass: 'hover',
   134  
   135    // class added on focus state (input has gained focus)
   136    focusClass: 'focus',
   137  
   138    // class added on active state (mouse button is pressed on input)
   139    activeClass: 'active',
   140  
   141    // adds hoverClass to customized input on label hover and labelHoverClass to label on input hover
   142    labelHover: true,
   143  
   144      // class added to label if labelHover set to true
   145      labelHoverClass: 'hover',
   146  
   147    // increase clickable area by given % (negative number to decrease)
   148    increaseArea: '',
   149  
   150    // true to set 'pointer' CSS cursor over enabled inputs and 'default' over disabled
   151    cursor: false,
   152  
   153    // set true to inherit original input's class name
   154    inheritClass: false,
   155  
   156    // if set to true, input's id is prefixed with 'iCheck-' and attached
   157    inheritID: false,
   158  
   159    // set true to activate ARIA support
   160    aria: false,
   161  
   162    // add HTML code or text inside customized input
   163    insert: ''
   164  }
   165  ```
   166  
   167  There's no need to copy and paste all of them, you can just mention the ones you need:
   168  
   169  ```js
   170  $('input').iCheck({
   171    labelHover: false,
   172    cursor: true
   173  });
   174  ```
   175  
   176  You can choose any class names and style them as you want.
   177  
   178  
   179  Initialize
   180  ----------
   181  
   182  Just include `icheck.js` after [jQuery v1.7+](http://jquery.com) (or [Zepto](http://github.com/madrobby/zepto#zepto-modules) [polyfill, event, data]).
   183  
   184  iCheck supports any selectors, but handles only checkboxes and radio buttons:
   185  
   186  ```js
   187  // customize all inputs (will search for checkboxes and radio buttons)
   188  $('input').iCheck();
   189  
   190  // handle inputs only inside $('.block')
   191  $('.block input').iCheck();
   192  
   193  // handle only checkboxes inside $('.test')
   194  $('.test input').iCheck({
   195    handle: 'checkbox'
   196  });
   197  
   198  // handle .vote class elements (will search inside the element, if it's not an input)
   199  $('.vote').iCheck();
   200  
   201  // you can also change options after inputs are customized
   202  $('input.some').iCheck({
   203    // different options
   204  });
   205  ```
   206  
   207  Indeterminate
   208  ---------
   209  
   210  HTML5 allows specifying [indeterminate](http://css-tricks.com/indeterminate-checkboxes/) ("partially" checked) state for checkboxes. iCheck supports this for both checkboxes and radio buttons.
   211  
   212  You can make an input indeterminate through HTML using additional attributes (supported by iCheck). Both do the same job, but `indeterminate="true"` may not work in some browsers (like IE7):
   213  
   214  ```html
   215  indeterminate="true"
   216  <input type="checkbox" indeterminate="true">
   217  <input type="radio" indeterminate="true">
   218  
   219  determinate="false"
   220  <input type="checkbox" determinate="false">
   221  <input type="radio" determinate="false">
   222  ```
   223  
   224  `indeterminate` and `determinate` [methods](#methods) can be used to toggle indeterminate state.
   225  
   226  Callbacks
   227  ---------
   228  
   229  iCheck provides plenty callbacks, which may be used to handle changes.
   230  
   231  <table>
   232    <thead>
   233      <tr>
   234        <th>Callback name</th>
   235        <th>When used</th>
   236      </tr>
   237    </thead>
   238    <tbody>
   239      <tr>
   240        <td>ifClicked</td>
   241        <td>user clicked on a customized input or an assigned label</td>
   242      </tr>
   243      <tr>
   244        <td>ifChanged</td>
   245        <td>input's "checked", "disabled" or "indeterminate" state is changed</td>
   246      </tr>
   247      <tr>
   248        <td>ifChecked</td>
   249        <td>input's state is changed to "checked"</td>
   250      </tr>
   251      <tr>
   252        <td>ifUnchecked</td>
   253        <td>"checked" state is removed</td>
   254      </tr>
   255      <tr>
   256        <td>ifToggled</td>
   257        <td>input's "checked" state is changed</td>
   258      </tr>
   259      <tr>
   260        <td>ifDisabled</td>
   261        <td>input's state is changed to "disabled"</td>
   262      </tr>
   263      <tr>
   264        <td>ifEnabled</td>
   265        <td>"disabled" state is removed</td>
   266      </tr>
   267      <tr>
   268        <td>ifIndeterminate</td>
   269        <td>input's state is changed to "indeterminate"</td>
   270      </tr>
   271      <tr>
   272        <td>ifDeterminate</td>
   273        <td>"indeterminate" state is removed</td>
   274      </tr>
   275      <tr>
   276        <td>ifCreated</td>
   277        <td>input is just customized</td>
   278      </tr>
   279      <tr>
   280        <td>ifDestroyed</td>
   281        <td>customization is just removed</td>
   282      </tr>
   283    </tbody>
   284  </table>
   285  
   286  Use `on()` method to bind them to inputs:
   287  
   288  ```js
   289  $('input').on('ifChecked', function(event){
   290    alert(event.type + ' callback');
   291  });
   292  ```
   293  
   294  `ifCreated` callback should be binded before plugin init.
   295  
   296  
   297  Methods
   298  -------
   299  
   300  These methods can be used to make changes programmatically (any selectors can be used):
   301  
   302  ```js
   303  // change input's state to 'checked'
   304  $('input').iCheck('check');
   305  
   306  // remove 'checked' state
   307  $('input').iCheck('uncheck');
   308  
   309  // toggle 'checked' state
   310  $('input').iCheck('toggle');
   311  
   312  // change input's state to 'disabled'
   313  $('input').iCheck('disable');
   314  
   315  // remove 'disabled' state
   316  $('input').iCheck('enable');
   317  
   318  // change input's state to 'indeterminate'
   319  $('input').iCheck('indeterminate');
   320  
   321  // remove 'indeterminate' state
   322  $('input').iCheck('determinate');
   323  
   324  // apply input changes, which were done outside the plugin
   325  $('input').iCheck('update');
   326  
   327  // remove all traces of iCheck
   328  $('input').iCheck('destroy');
   329  ```
   330  
   331  You may also specify some function, that will be executed on each method call:
   332  
   333  ```js
   334  $('input').iCheck('check', function(){
   335    alert('Well done, Sir');
   336  });
   337  ```
   338  
   339  Feel free to fork and submit pull-request or submit an issue if you find something not working.
   340  
   341  
   342  Comparison
   343  ----------
   344  
   345  iCheck is created to avoid routine of reinventing the wheel when working with checkboxes and radio buttons. It provides an expected identical result for the huge number of browsers, devices and their versions. Callbacks and methods can be used to easily handle and make changes at customized inputs.
   346  
   347  There are some CSS3 ways available to style checkboxes and radio buttons, like [this one](http://webdesign.tutsplus.com/tutorials/htmlcss-tutorials/quick-tip-easy-css3-checkboxes-and-radio-buttons/). You have to know about some of the disadvantages of similar methods:
   348  
   349  * inputs are keyboard inaccessible, since `display: none` or `visibility: hidden` used to hide them
   350  * poor browser support
   351  * multiple bugs on mobile devices
   352  * tricky, harder to maintain CSS code
   353  * JavaScript is still needed to fix specific issues
   354  
   355  While CSS3 method is quite limited solution, iCheck is made to be an everyday replacement covering most of the tasks.
   356  
   357  
   358  Browser support
   359  ---------------
   360  
   361  iCheck is verified to work in Internet Explorer 6+, Firefox 2+, Opera 9+, Google Chrome and Safari browsers. Should also work in many others.
   362  
   363  Mobile browsers (like Opera mini, Chrome mobile, Safari mobile, Android browser, Silk and others) are also supported. Tested on iOS (iPad, iPhone, iPod), Android, BlackBerry and Windows Phone devices.
   364  
   365  
   366  Changelog
   367  ---------------
   368  
   369  ### March 03, 2014
   370  
   371  * Better HiDPI screens support @ddctd143
   372  
   373  ### January 23, 2014 ([v2.0 release candidate](https://github.com/fronteed/iCheck/tree/2.x-beta))
   374  
   375  * Three ways to set an options: global object (`window.icheck`), data attributes (`<input data-checkedClass="checked"`) and direct JavaScript object (`$(input).icheck({ options })`)
   376  * Huge performance boost (takes less than 1s to customize 1000 inputs)
   377  * Minimized number of function calls (some slow jQuery functions are replaced with a faster vanilla alternatives without using any dependencies)
   378  * AMD module definition support (both for jQuery and Zepto)
   379  * Unblocked native events - iCheck 2.x doesn't stop your newly or past binded events from being processed
   380  * Pointer events support - full support for phones and tablets that use Windows OS (such as Lumia, HP tablets, desktops with a touch screen, etc)
   381  * WebOS and Firefox OS support
   382  * New methods: `$(input).icheck('data')` to get all the options were used for customization (also stores a current states values - `checked`, `disabled` and `indeterminate`), `$('input').icheck('styler')` to get a wrapper div (that's used for customization)
   383  * Better handling of the `indeterminate` state
   384  * Ability to set callbacks in three ways: global object, direct JavaScript object or using bind method (`$(input).on(callback)`)
   385  * Ability to switch off some of the callbacks when you don't need them (global or per input)
   386  * Inline styles dropped - iCheck won't add any inline styles to the elements until it's highly needed (`cursor` or `area` option)
   387  * Fast click support - removes a 300ms click delay on mobile devices without any dependencies (iCheck compatible with the `fastclick` plugin), see the `tap` option
   388  * Ability to ignore customization for the selected inputs using `init` option (if set to `false`) 
   389  * Optimized event bindings - iCheck binds only a few global events for the all inputs (doesn't increase on elements addition), instead of a couple for the each customized element
   390  * Doesn't store tons of arbitrary data (event in jQuery or Zepto cache), defines customized elements by specific classnames 
   391  * Extra `ins` tag is dropped (less DOM modifications), iCheck wraps each input with a single `div` and doesn't use any extra markup for the any option
   392  * Optimized reflows and repaints on init and state changes 
   393  * Better options handling - iCheck will never run a single line of JS to process an options that are off or empty 
   394  * Ability to auto customize the ajax loaded inputs without using any extra code (`autoAjax` option, on by default)
   395  * Auto inits on domready using the specified selector (`autoInit` option) - searches for `.icheck` by default. Classnames can be changed using the `window.classes` object
   396  * Memory usage optimization - uses only a few amount of memory (works well on low-memory devices)
   397  * Betters callbacks architecture - these are fired only after changes are applied to the input
   398  * Ability to set a mirror classes between the inputs and assigned labels using the `hoverLabelClass`, `focusLabelClass`, `activeLabelClass`, `checkedLabelClass`, `disabledLabelClass` and `indeterminateLabelClass` options (`mirror` option should be set to `true` to make this happen)
   399  * Fixes some issues of the mobile devices
   400  * Fixes the issues of the wrapper labels, that loose a click ability in some browsers (if no `for` attribute is set)
   401  * Some other options and improvements
   402  * Various bug fixes
   403  
   404  Note: extended docs and usage examples will be available later.
   405  
   406  ### December 19, 2013
   407  
   408  * Added Bower support
   409  * Added to jQuery plugin registry
   410  
   411  ### December 18, 2013
   412  
   413  * Added ARIA attributes support (for VoiceOver and others) @myfreeweb
   414  * Added Amazon Kindle support @skinofstars
   415  * Fixed clickable links inside labels @LeGaS
   416  * Fixed lines separation between labels and inputs
   417  * Merged two versions of the plugin (jQuery and Zepto) into one
   418  * Fixed demo links
   419  * Fixed callbacks @PepijnSenders
   420  
   421  
   422  License
   423  -------
   424  iCheck plugin is released under the [MIT License](http://en.wikipedia.org/wiki/MIT_License). Feel free to use it in personal and commercial projects.