定制 gaomingcode/icheck 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

gaomingcode/icheck

Composer 安装命令:

composer require gaomingcode/icheck

包简介

Highly customizable checkboxes and radio buttons (jQuery & Zepto).

README 文档

README

GitHub Version Packagist Downloads Github License

Installation

Composer

composer require gaomingcode/icheck

ReadMe from Origin

HTML5 allows specifying indeterminate ("partially" checked) state for checkboxes. iCheck supports this for both checkboxes and radio buttons.

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):

indeterminate="true"
<input type="checkbox" indeterminate="true">
<input type="radio" indeterminate="true">

determinate="false"
<input type="checkbox" determinate="false">
<input type="radio" determinate="false">

indeterminate and determinate methods can be used to toggle indeterminate state.

Callbacks

iCheck provides plenty callbacks, which may be used to handle changes.

Callback name When used
ifClicked user clicked on a customized input or an assigned label
ifChanged input's "checked", "disabled" or "indeterminate" state is changed
ifChecked input's state is changed to "checked"
ifUnchecked "checked" state is removed
ifToggled input's "checked" state is changed
ifDisabled input's state is changed to "disabled"
ifEnabled "disabled" state is removed
ifIndeterminate input's state is changed to "indeterminate"
ifDeterminate "indeterminate" state is removed
ifCreated input is just customized
ifDestroyed customization is just removed

Use on() method to bind them to inputs:

$('input').on('ifChecked', function(event){
  alert(event.type + ' callback');
});

ifCreated callback should be binded before plugin init.

Methods

These methods can be used to make changes programmatically (any selectors can be used):

// change input's state to 'checked'
$('input').iCheck('check');

// remove 'checked' state
$('input').iCheck('uncheck');

// toggle 'checked' state
$('input').iCheck('toggle');

// change input's state to 'disabled'
$('input').iCheck('disable');

// remove 'disabled' state
$('input').iCheck('enable');

// change input's state to 'indeterminate'
$('input').iCheck('indeterminate');

// remove 'indeterminate' state
$('input').iCheck('determinate');

// apply input changes, which were done outside the plugin
$('input').iCheck('update');

// remove all traces of iCheck
$('input').iCheck('destroy');

You may also specify some function, that will be executed on each method call:

$('input').iCheck('check', function(){
  alert('Well done, Sir');
});

Feel free to fork and submit pull-request or submit an issue if you find something not working.

Comparison

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.

There are some CSS3 ways available to style checkboxes and radio buttons, like this one. You have to know about some of the disadvantages of similar methods:

  • inputs are keyboard inaccessible, since display: none or visibility: hidden used to hide them
  • poor browser support
  • multiple bugs on mobile devices
  • tricky, harder to maintain CSS code
  • JavaScript is still needed to fix specific issues

While CSS3 method is quite limited solution, iCheck is made to be an everyday replacement covering most of the tasks.

Browser support

iCheck is verified to work in Internet Explorer 6+, Firefox 2+, Opera 9+, Google Chrome and Safari browsers. Should also work in many others.

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.

Changelog

October 10, 2020

  • iOS 13 support @markusbroman
  • Reformatted changelog @lasseeee
  • Fire change event when toggled @rafatmyo

March 03, 2014

  • Better HiDPI screens support @ddctd143

January 23, 2014 (v2.0 release candidate)

  • Three ways to set an options: global object (window.icheck), data attributes (<input data-checkedClass="checked") and direct JavaScript object ($(input).icheck({ options }))
  • Huge performance boost (takes less than 1s to customize 1000 inputs)
  • Minimized number of function calls (some slow jQuery functions are replaced with a faster vanilla alternatives without using any dependencies)
  • AMD module definition support (both for jQuery and Zepto)
  • Unblocked native events - iCheck 2.x doesn't stop your newly or past binded events from being processed
  • Pointer events support - full support for phones and tablets that use Windows OS (such as Lumia, HP tablets, desktops with a touch screen, etc)
  • WebOS and Firefox OS support
  • 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)
  • Better handling of the indeterminate state
  • Ability to set callbacks in three ways: global object, direct JavaScript object or using bind method ($(input).on(callback))
  • Ability to switch off some of the callbacks when you don't need them (global or per input)
  • Inline styles dropped - iCheck won't add any inline styles to the elements until it's highly needed (cursor or area option)
  • Fast click support - removes a 300ms click delay on mobile devices without any dependencies (iCheck compatible with the fastclick plugin), see the tap option
  • Ability to ignore customization for the selected inputs using init option (if set to false)
  • 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
  • Doesn't store tons of arbitrary data (event in jQuery or Zepto cache), defines customized elements by specific classnames
  • 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
  • Optimized reflows and repaints on init and state changes
  • Better options handling - iCheck will never run a single line of JS to process an options that are off or empty
  • Ability to auto customize the ajax loaded inputs without using any extra code (autoAjax option, on by default)
  • Auto inits on domready using the specified selector (autoInit option) - searches for .icheck by default. Classnames can be changed using the window.classes object
  • Memory usage optimization - uses only a few amount of memory (works well on low-memory devices)
  • Betters callbacks architecture - these are fired only after changes are applied to the input
  • 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)
  • Fixes some issues of the mobile devices
  • Fixes the issues of the wrapper labels, that loose a click ability in some browsers (if no for attribute is set)
  • Some other options and improvements
  • Various bug fixes

Note: extended docs and usage examples will be available later.

December 19, 2013

  • Added Bower support
  • Added to jQuery plugin registry

December 18, 2013

  • Added ARIA attributes support (for VoiceOver and others) @myfreeweb
  • Added Amazon Kindle support @skinofstars
  • Fixed clickable links inside labels @LeGaS
  • Fixed lines separation between labels and inputs
  • Merged two versions of the plugin (jQuery and Zepto) into one
  • Fixed demo links
  • Fixed callbacks @PepijnSenders

License

iCheck plugin is released under the MIT License. Feel free to use it in personal and commercial projects.

gaomingcode/icheck 适用场景与选型建议

gaomingcode/icheck 是一款 基于 CSS 开发的 Composer 扩展包,目前已累计 35 次下载、GitHub Stars 达 0, 最近一次更新时间为 2021 年 06 月 01 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「ui」 「form」 「input」 「custom」 「accessibility」 「field」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 gaomingcode/icheck 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 gaomingcode/icheck 我们能提供哪些服务?
定制开发 / 二次开发

基于 gaomingcode/icheck 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 35
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 6
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 1589
  • 开发语言: CSS

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-06-01