43 lines
1.2 KiB
JavaScript
43 lines
1.2 KiB
JavaScript
function initIcheck(selector)
|
|
{
|
|
var selector = (typeof(selector) != 'undefined') ? selector : '.iCheck';
|
|
console.log('initIcheck');
|
|
$(selector).each(function(){
|
|
// var each element .iCheck
|
|
var $this = $(this),
|
|
skin = $this.attr('data-skin'),
|
|
color = $this.attr('data-color'),
|
|
checkbox, radio, insert = '';
|
|
|
|
if (skin === undefined) {
|
|
checkbox = 'icheckbox_minimal';
|
|
radio = 'iradio_minimal';
|
|
} else {
|
|
checkbox = 'icheckbox_' + skin;
|
|
radio = 'iradio_' + skin;
|
|
}
|
|
|
|
if (color !== undefined) {
|
|
checkbox = checkbox + '-' + color;
|
|
radio = radio + '-' + color;
|
|
}
|
|
|
|
// handle iCheck skin 'line'
|
|
if (skin == 'line') {
|
|
var label = $this.next(),
|
|
label_text = label.text();
|
|
|
|
insert = '<div class="icheck_line-icon"></div>' + label_text;
|
|
label.remove();
|
|
}
|
|
|
|
// initialize
|
|
$this.iCheck({
|
|
checkboxClass: checkbox,
|
|
radioClass: radio,
|
|
insert: insert,
|
|
increaseArea: '30%' // optional
|
|
});
|
|
});
|
|
}
|