New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

semantic-ui-checkbox

Package Overview
Dependencies
Maintainers
1
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

semantic-ui-checkbox - npm Package Compare versions

Comparing version 1.12.3 to 2.0.2

428

checkbox.js
/*!
* # Semantic UI 1.12.3 - Checkbox
* # Semantic UI 2.0.2 - Checkbox
* http://github.com/semantic-org/semantic-ui/
*
*
* Copyright 2014 Contributors
* Copyright 2015 Contributors
* Released under the MIT license

@@ -44,4 +44,4 @@ * http://opensource.org/licenses/MIT

$module = $(this),
$label = $(this).find(selector.label).first(),
$input = $(this).find(selector.input),
$label = $(this).children(selector.label),
$input = $(this).children(selector.input),

@@ -61,19 +61,10 @@ instance = $module.data(moduleNamespace),

module.create.label();
module.add.events();
module.bind.events();
if( module.is.checked() ) {
module.set.checked();
if(settings.fireOnInit) {
settings.onChecked.call($input.get());
}
}
else {
module.remove.checked();
if(settings.fireOnInit) {
settings.onUnchecked.call($input.get());
}
}
module.set.tabbable();
module.hide.input();
module.observeChanges();
module.instantiate();
module.setup();
},

@@ -91,14 +82,62 @@

module.verbose('Destroying module');
module.remove.events();
$module
.removeData(moduleNamespace)
;
module.unbind.events();
module.show.input();
$module.removeData(moduleNamespace);
},
fix: {
reference: function() {
if( $module.is(selector.input) ) {
module.debug('Behavior called on <input> adjusting invoked element');
$module = $module.closest(selector.checkbox);
module.refresh();
}
}
},
setup: function() {
if( module.is.indeterminate() ) {
module.debug('Initial value is indeterminate');
module.set.indeterminate();
if(settings.fireOnInit) {
settings.onIndeterminate.call($input[0]);
settings.onChange.call($input[0]);
}
}
else if( module.is.checked() ) {
module.debug('Initial value is checked');
module.set.checked();
if(settings.fireOnInit) {
settings.onChecked.call($input[0]);
settings.onChange.call($input[0]);
}
}
else {
module.debug('Initial value is unchecked');
module.set.unchecked();
if(settings.fireOnInit) {
settings.onUnchecked.call($input[0]);
settings.onChange.call($input[0]);
}
}
},
refresh: function() {
$module = $(element);
$label = $(element).find(selector.label).first();
$input = $(element).find(selector.input);
$label = $module.children(selector.label);
$input = $module.children(selector.input);
},
hide: {
input: function() {
module.verbose('Modfying <input> z-index to be unselectable');
$input.addClass(className.hidden);
}
},
show: {
input: function() {
module.verbose('Modfying <input> z-index to be selectable');
$input.removeClass(className.hidden);
}
},
observeChanges: function() {

@@ -138,2 +177,9 @@ if('MutationObserver' in window) {

event: {
click: function(event) {
if( $(event.target).is(selector.input) ) {
module.verbose('Using default check action on initialized checkbox');
return;
}
module.toggle();
},
keydown: function(event) {

@@ -148,11 +194,10 @@ var

;
if( key == keyCode.escape) {
if(key == keyCode.escape) {
module.verbose('Escape key pressed blurring field');
$module
.blur()
;
$input.blur();
event.preventDefault();
}
if(!event.ctrlKey && (key == keyCode.enter || key == keyCode.space)) {
module.verbose('Enter key pressed, toggling checkbox');
module.toggle.call(this);
module.toggle();
event.preventDefault();

@@ -163,9 +208,100 @@ }

check: function() {
if( !module.is.indeterminate() && module.is.checked() ) {
module.debug('Checkbox is already checked');
return;
}
module.debug('Checking checkbox', $input);
module.set.checked();
settings.onChecked.call($input[0]);
settings.onChange.call($input[0]);
},
uncheck: function() {
if( !module.is.indeterminate() && module.is.unchecked() ) {
module.debug('Checkbox is already unchecked');
return;
}
module.debug('Unchecking checkbox');
module.set.unchecked();
settings.onUnchecked.call($input[0]);
settings.onChange.call($input[0]);
},
indeterminate: function() {
if( module.is.indeterminate() ) {
module.debug('Checkbox is already indeterminate');
return;
}
module.debug('Making checkbox indeterminate');
module.set.indeterminate();
settings.onIndeterminate.call($input[0]);
settings.onChange.call($input[0]);
},
determinate: function() {
if( module.is.determinate() ) {
module.debug('Checkbox is already determinate');
return;
}
module.debug('Making checkbox determinate');
module.set.determinate();
settings.onDeterminate.call($input[0]);
settings.onChange.call($input[0]);
},
enable: function() {
if( module.is.enabled() ) {
module.debug('Checkbox is already enabled');
return;
}
module.debug('Enabling checkbox');
module.set.enabled();
settings.onEnable.call($input[0]);
},
disable: function() {
if( module.is.disabled() ) {
module.debug('Checkbox is already disabled');
return;
}
module.debug('Disabling checkbox');
module.set.disabled();
settings.onDisable.call($input[0]);
},
get: {
radios: function() {
var
name = module.get.name()
;
return $('input[name="' + name + '"]').closest(selector.checkbox);
},
otherRadios: function() {
return module.get.radios().not($module);
},
name: function() {
return $input.attr('name');
}
},
is: {
radio: function() {
return $module.hasClass(className.radio);
return ($input.hasClass(className.radio) || $input.attr('type') == 'radio');
},
indeterminate: function() {
return $input.prop('indeterminate') !== undefined && $input.prop('indeterminate');
},
checked: function() {
return $input.prop('checked') !== undefined && $input.prop('checked');
},
disabled: function() {
return $input.prop('disabled') !== undefined && $input.prop('disabled');
},
enabled: function() {
return !module.is.disabled();
},
determinate: function() {
return !module.is.indeterminate();
},
unchecked: function() {

@@ -178,3 +314,3 @@ return !module.is.checked();

change: function() {
return !( $module.hasClass(className.disabled) || $module.hasClass(className.readOnly) || $input.prop('disabled') );
return !( $module.hasClass(className.disabled) || $module.hasClass(className.readOnly) || $input.prop('disabled') || $input.prop('readonly') );
},

@@ -191,9 +327,99 @@ uncheck: function() {

checked: function() {
$module.addClass(className.checked);
module.verbose('Setting class to checked');
$module
.removeClass(className.indeterminate)
.addClass(className.checked)
;
if( module.is.radio() ) {
module.uncheckOthers();
}
if(!module.is.indeterminate() && module.is.checked()) {
module.debug('Input is already checked, skipping input property change');
return;
}
module.verbose('Setting state to checked', $input[0]);
$input
.prop('indeterminate', false)
.prop('checked', true)
;
module.trigger.change();
},
tab: function() {
unchecked: function() {
module.verbose('Removing checked class');
$module
.removeClass(className.indeterminate)
.removeClass(className.checked)
;
if(!module.is.indeterminate() && module.is.unchecked() ) {
module.debug('Input is already unchecked');
return;
}
module.debug('Setting state to unchecked');
$input
.prop('indeterminate', false)
.prop('checked', false)
;
module.trigger.change();
},
indeterminate: function() {
module.verbose('Setting class to indeterminate');
$module
.addClass(className.indeterminate)
;
if( module.is.indeterminate() ) {
module.debug('Input is already indeterminate, skipping input property change');
return;
}
module.debug('Setting state to indeterminate');
$input
.prop('indeterminate', true)
;
module.trigger.change();
},
determinate: function() {
module.verbose('Removing indeterminate class');
$module
.removeClass(className.indeterminate)
;
if( module.is.determinate() ) {
module.debug('Input is already determinate, skipping input property change');
return;
}
module.debug('Setting state to determinate');
$input
.prop('indeterminate', false)
;
},
disabled: function() {
module.verbose('Setting class to disabled');
$module
.addClass(className.disabled)
;
if( module.is.disabled() ) {
module.debug('Input is already disabled, skipping input property change');
return;
}
module.debug('Setting state to disabled');
$input
.prop('disabled', 'disabled')
;
module.trigger.change();
},
enabled: function() {
module.verbose('Removing disabled class');
$module.removeClass(className.disabled);
if( module.is.enabled() ) {
module.debug('Input is already enabled, skipping input property change');
return;
}
module.debug('Setting state to enabled');
$input
.prop('disabled', false)
;
module.trigger.change();
},
tabbable: function() {
module.verbose('Adding tabindex to checkbox');
if( $input.attr('tabindex') === undefined) {
$input
.attr('tabindex', 0)
;
$input.attr('tabindex', 0);
}

@@ -203,2 +429,12 @@ }

trigger: {
change: function() {
module.verbose('Triggering change event from programmatic change');
$input
.trigger('change')
;
}
},
create: {

@@ -223,7 +459,7 @@ label: function() {

add: {
bind: {
events: function() {
module.verbose('Attaching checkbox events');
$module
.on('click' + eventNamespace, module.toggle)
.on('click' + eventNamespace, module.event.click)
.on('keydown' + eventNamespace, selector.input, module.event.keydown)

@@ -234,6 +470,3 @@ ;

remove: {
checked: function() {
$module.removeClass(className.checked);
},
unbind: {
events: function() {

@@ -243,62 +476,27 @@ module.debug('Removing events');

.off(eventNamespace)
.removeData(moduleNamespace)
;
$input
.off(eventNamespace, module.event.keydown)
;
$label
.off(eventNamespace)
;
}
},
enable: function() {
module.debug('Enabling checkbox functionality');
$module.removeClass(className.disabled);
$input.prop('disabled', false);
settings.onEnabled.call($input.get());
},
disable: function() {
module.debug('Disabling checkbox functionality');
$module.addClass(className.disabled);
$input.prop('disabled', 'disabled');
settings.onDisabled.call($input.get());
},
check: function() {
module.debug('Enabling checkbox', $input);
$input
.prop('checked', true)
.trigger('change')
uncheckOthers: function() {
var
$radios = module.get.otherRadios()
;
module.set.checked();
$input.trigger('blur');
settings.onChange.call($input.get());
settings.onChecked.call($input.get());
module.debug('Unchecking other radios', $radios);
$radios.removeClass(className.checked);
},
uncheck: function() {
module.debug('Disabling checkbox');
$input
.prop('checked', false)
.trigger('change')
;
module.remove.checked();
$input.trigger('blur');
settings.onChange.call($input.get());
settings.onUnchecked.call($input.get());
},
toggle: function(event) {
toggle: function() {
if( !module.can.change() ) {
console.log(module.can.change());
module.debug('Checkbox is read-only or disabled, ignoring toggle');
if(!module.is.radio()) {
module.debug('Checkbox is read-only or disabled, ignoring toggle');
}
return;
}
module.verbose('Determining new checkbox state');
if( module.is.unchecked() ) {
if( module.is.indeterminate() || module.is.unchecked() ) {
module.debug('Currently unchecked');
module.check();
}
else if( module.is.checked() && module.can.uncheck() ) {
module.debug('Currently checked');
module.uncheck();

@@ -376,3 +574,3 @@ }

clearTimeout(module.performance.timer);
module.performance.timer = setTimeout(module.performance.display, 100);
module.performance.timer = setTimeout(module.performance.display, 500);
},

@@ -487,33 +685,41 @@ display: function() {

name : 'Checkbox',
namespace : 'checkbox',
name : 'Checkbox',
namespace : 'checkbox',
debug : false,
verbose : true,
performance : true,
debug : false,
verbose : true,
performance : true,
// delegated event context
uncheckable : 'auto',
fireOnInit : true,
uncheckable : 'auto',
fireOnInit : false,
onChange : function(){},
onChecked : function(){},
onUnchecked : function(){},
onEnabled : function(){},
onDisabled : function(){},
onChange : function(){},
className : {
checked : 'checked',
disabled : 'disabled',
radio : 'radio',
readOnly : 'read-only'
onChecked : function(){},
onUnchecked : function(){},
onDeterminate : function() {},
onIndeterminate : function() {},
onEnabled : function(){},
onDisabled : function(){},
className : {
checked : 'checked',
indeterminate : 'indeterminate',
disabled : 'disabled',
hidden : 'hidden',
radio : 'radio',
readOnly : 'read-only'
},
error : {
method : 'The method you called is not defined'
method : 'The method you called is not defined'
},
selector : {
input : 'input[type="checkbox"], input[type="radio"]',
label : 'label'
checkbox : '.ui.checkbox',
label : 'label, .box',
input : 'input[type="checkbox"], input[type="radio"]',
}

@@ -520,0 +726,0 @@

/*!
* # Semantic UI 1.12.3 - Checkbox
* # Semantic UI 2.0.2 - Checkbox
* http://github.com/semantic-org/semantic-ui/
*
*
* Copyright 2014 Contributors
* Copyright 2015 Contributors
* Released under the MIT license

@@ -11,2 +11,2 @@ * http://opensource.org/licenses/MIT

*/
!function(e,n,t,o){"use strict";e.fn.checkbox=function(t){var c,i=e(this),r=i.selector||"",a=(new Date).getTime(),l=[],s=arguments[0],u="string"==typeof s,d=[].slice.call(arguments,1);return i.each(function(){var i,b,g=e.extend(!0,{},e.fn.checkbox.settings,t),h=g.className,f=g.namespace,p=g.selector,m=g.error,k="."+f,v="module-"+f,y=e(this),x=e(this).find(p.label).first(),C=e(this).find(p.input),D=y.data(v),E=this;b={initialize:function(){b.verbose("Initializing checkbox",g),b.create.label(),b.add.events(),b.is.checked()?(b.set.checked(),g.fireOnInit&&g.onChecked.call(C.get())):(b.remove.checked(),g.fireOnInit&&g.onUnchecked.call(C.get())),b.observeChanges(),b.instantiate()},instantiate:function(){b.verbose("Storing instance of module",b),D=b,y.data(v,b)},destroy:function(){b.verbose("Destroying module"),b.remove.events(),y.removeData(v)},refresh:function(){y=e(E),x=e(E).find(p.label).first(),C=e(E).find(p.input)},observeChanges:function(){"MutationObserver"in n&&(i=new MutationObserver(function(e){b.debug("DOM tree modified, updating selector cache"),b.refresh()}),i.observe(E,{childList:!0,subtree:!0}),b.debug("Setting up mutation observer",i))},attachEvents:function(n,t){var o=e(n);t=e.isFunction(b[t])?b[t]:b.toggle,o.length>0?(b.debug("Attaching checkbox events to element",n,t),o.on("click"+k,t)):b.error(m.notFound)},event:{keydown:function(e){var n=e.which,t={enter:13,space:32,escape:27};n==t.escape&&(b.verbose("Escape key pressed blurring field"),y.blur()),e.ctrlKey||n!=t.enter&&n!=t.space||(b.verbose("Enter key pressed, toggling checkbox"),b.toggle.call(this),e.preventDefault())}},is:{radio:function(){return y.hasClass(h.radio)},checked:function(){return C.prop("checked")!==o&&C.prop("checked")},unchecked:function(){return!b.is.checked()}},can:{change:function(){return!(y.hasClass(h.disabled)||y.hasClass(h.readOnly)||C.prop("disabled"))},uncheck:function(){return"boolean"==typeof g.uncheckable?g.uncheckable:!b.is.radio()}},set:{checked:function(){y.addClass(h.checked)},tab:function(){C.attr("tabindex")===o&&C.attr("tabindex",0)}},create:{label:function(){C.prevAll(p.label).length>0?(C.prev(p.label).detach().insertAfter(C),b.debug("Moving existing label",x)):b.has.label()||(x=e("<label>").insertAfter(C),b.debug("Creating label",x))}},has:{label:function(){return x.length>0}},add:{events:function(){b.verbose("Attaching checkbox events"),y.on("click"+k,b.toggle).on("keydown"+k,p.input,b.event.keydown)}},remove:{checked:function(){y.removeClass(h.checked)},events:function(){b.debug("Removing events"),y.off(k).removeData(v),C.off(k,b.event.keydown),x.off(k)}},enable:function(){b.debug("Enabling checkbox functionality"),y.removeClass(h.disabled),C.prop("disabled",!1),g.onEnabled.call(C.get())},disable:function(){b.debug("Disabling checkbox functionality"),y.addClass(h.disabled),C.prop("disabled","disabled"),g.onDisabled.call(C.get())},check:function(){b.debug("Enabling checkbox",C),C.prop("checked",!0).trigger("change"),b.set.checked(),C.trigger("blur"),g.onChange.call(C.get()),g.onChecked.call(C.get())},uncheck:function(){b.debug("Disabling checkbox"),C.prop("checked",!1).trigger("change"),b.remove.checked(),C.trigger("blur"),g.onChange.call(C.get()),g.onUnchecked.call(C.get())},toggle:function(e){return b.can.change()?(b.verbose("Determining new checkbox state"),void(b.is.unchecked()?b.check():b.is.checked()&&b.can.uncheck()&&b.uncheck())):(console.log(b.can.change()),void b.debug("Checkbox is read-only or disabled, ignoring toggle"))},setting:function(n,t){if(b.debug("Changing setting",n,t),e.isPlainObject(n))e.extend(!0,g,n);else{if(t===o)return g[n];g[n]=t}},internal:function(n,t){if(e.isPlainObject(n))e.extend(!0,b,n);else{if(t===o)return b[n];b[n]=t}},debug:function(){g.debug&&(g.performance?b.performance.log(arguments):(b.debug=Function.prototype.bind.call(console.info,console,g.name+":"),b.debug.apply(console,arguments)))},verbose:function(){g.verbose&&g.debug&&(g.performance?b.performance.log(arguments):(b.verbose=Function.prototype.bind.call(console.info,console,g.name+":"),b.verbose.apply(console,arguments)))},error:function(){b.error=Function.prototype.bind.call(console.error,console,g.name+":"),b.error.apply(console,arguments)},performance:{log:function(e){var n,t,o;g.performance&&(n=(new Date).getTime(),o=a||n,t=n-o,a=n,l.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:E,"Execution Time":t})),clearTimeout(b.performance.timer),b.performance.timer=setTimeout(b.performance.display,100)},display:function(){var n=g.name+":",t=0;a=!1,clearTimeout(b.performance.timer),e.each(l,function(e,n){t+=n["Execution Time"]}),n+=" "+t+"ms",r&&(n+=" '"+r+"'"),(console.group!==o||console.table!==o)&&l.length>0&&(console.groupCollapsed(n),console.table?console.table(l):e.each(l,function(e,n){console.log(n.Name+": "+n["Execution Time"]+"ms")}),console.groupEnd()),l=[]}},invoke:function(n,t,i){var r,a,l,s=D;return t=t||d,i=E||i,"string"==typeof n&&s!==o&&(n=n.split(/[\. ]/),r=n.length-1,e.each(n,function(t,c){var i=t!=r?c+n[t+1].charAt(0).toUpperCase()+n[t+1].slice(1):n;if(e.isPlainObject(s[i])&&t!=r)s=s[i];else{if(s[i]!==o)return a=s[i],!1;if(!e.isPlainObject(s[c])||t==r)return s[c]!==o?(a=s[c],!1):(b.error(m.method,n),!1);s=s[c]}})),e.isFunction(a)?l=a.apply(i,t):a!==o&&(l=a),e.isArray(c)?c.push(l):c!==o?c=[c,l]:l!==o&&(c=l),a}},u?(D===o&&b.initialize(),b.invoke(s)):(D!==o&&D.invoke("destroy"),b.initialize())}),c!==o?c:this},e.fn.checkbox.settings={name:"Checkbox",namespace:"checkbox",debug:!1,verbose:!0,performance:!0,uncheckable:"auto",fireOnInit:!0,onChange:function(){},onChecked:function(){},onUnchecked:function(){},onEnabled:function(){},onDisabled:function(){},className:{checked:"checked",disabled:"disabled",radio:"radio",readOnly:"read-only"},error:{method:"The method you called is not defined"},selector:{input:'input[type="checkbox"], input[type="radio"]',label:"label"}}}(jQuery,window,document);
!function(e,n,t,i){"use strict";e.fn.checkbox=function(t){var o,r=e(this),a=r.selector||"",c=(new Date).getTime(),d=[],s=arguments[0],l="string"==typeof s,u=[].slice.call(arguments,1);return r.each(function(){var r,b,g=e.extend(!0,{},e.fn.checkbox.settings,t),h=g.className,p=g.namespace,m=g.selector,f=g.error,k="."+p,v="module-"+p,y=e(this),x=e(this).children(m.label),C=e(this).children(m.input),I=y.data(v),O=this;b={initialize:function(){b.verbose("Initializing checkbox",g),b.create.label(),b.bind.events(),b.set.tabbable(),b.hide.input(),b.observeChanges(),b.instantiate(),b.setup()},instantiate:function(){b.verbose("Storing instance of module",b),I=b,y.data(v,b)},destroy:function(){b.verbose("Destroying module"),b.unbind.events(),b.show.input(),y.removeData(v)},fix:{reference:function(){y.is(m.input)&&(b.debug("Behavior called on <input> adjusting invoked element"),y=y.closest(m.checkbox),b.refresh())}},setup:function(){b.is.indeterminate()?(b.debug("Initial value is indeterminate"),b.set.indeterminate(),g.fireOnInit&&(g.onIndeterminate.call(C[0]),g.onChange.call(C[0]))):b.is.checked()?(b.debug("Initial value is checked"),b.set.checked(),g.fireOnInit&&(g.onChecked.call(C[0]),g.onChange.call(C[0]))):(b.debug("Initial value is unchecked"),b.set.unchecked(),g.fireOnInit&&(g.onUnchecked.call(C[0]),g.onChange.call(C[0])))},refresh:function(){x=y.children(m.label),C=y.children(m.input)},hide:{input:function(){b.verbose("Modfying <input> z-index to be unselectable"),C.addClass(h.hidden)}},show:{input:function(){b.verbose("Modfying <input> z-index to be selectable"),C.removeClass(h.hidden)}},observeChanges:function(){"MutationObserver"in n&&(r=new MutationObserver(function(e){b.debug("DOM tree modified, updating selector cache"),b.refresh()}),r.observe(O,{childList:!0,subtree:!0}),b.debug("Setting up mutation observer",r))},attachEvents:function(n,t){var i=e(n);t=e.isFunction(b[t])?b[t]:b.toggle,i.length>0?(b.debug("Attaching checkbox events to element",n,t),i.on("click"+k,t)):b.error(f.notFound)},event:{click:function(n){return e(n.target).is(m.input)?void b.verbose("Using default check action on initialized checkbox"):void b.toggle()},keydown:function(e){var n=e.which,t={enter:13,space:32,escape:27};n==t.escape&&(b.verbose("Escape key pressed blurring field"),C.blur(),e.preventDefault()),e.ctrlKey||n!=t.enter&&n!=t.space||(b.verbose("Enter key pressed, toggling checkbox"),b.toggle(),e.preventDefault())}},check:function(){return!b.is.indeterminate()&&b.is.checked()?void b.debug("Checkbox is already checked"):(b.debug("Checking checkbox",C),b.set.checked(),g.onChecked.call(C[0]),void g.onChange.call(C[0]))},uncheck:function(){return!b.is.indeterminate()&&b.is.unchecked()?void b.debug("Checkbox is already unchecked"):(b.debug("Unchecking checkbox"),b.set.unchecked(),g.onUnchecked.call(C[0]),void g.onChange.call(C[0]))},indeterminate:function(){return b.is.indeterminate()?void b.debug("Checkbox is already indeterminate"):(b.debug("Making checkbox indeterminate"),b.set.indeterminate(),g.onIndeterminate.call(C[0]),void g.onChange.call(C[0]))},determinate:function(){return b.is.determinate()?void b.debug("Checkbox is already determinate"):(b.debug("Making checkbox determinate"),b.set.determinate(),g.onDeterminate.call(C[0]),void g.onChange.call(C[0]))},enable:function(){return b.is.enabled()?void b.debug("Checkbox is already enabled"):(b.debug("Enabling checkbox"),b.set.enabled(),void g.onEnable.call(C[0]))},disable:function(){return b.is.disabled()?void b.debug("Checkbox is already disabled"):(b.debug("Disabling checkbox"),b.set.disabled(),void g.onDisable.call(C[0]))},get:{radios:function(){var n=b.get.name();return e('input[name="'+n+'"]').closest(m.checkbox)},otherRadios:function(){return b.get.radios().not(y)},name:function(){return C.attr("name")}},is:{radio:function(){return C.hasClass(h.radio)||"radio"==C.attr("type")},indeterminate:function(){return C.prop("indeterminate")!==i&&C.prop("indeterminate")},checked:function(){return C.prop("checked")!==i&&C.prop("checked")},disabled:function(){return C.prop("disabled")!==i&&C.prop("disabled")},enabled:function(){return!b.is.disabled()},determinate:function(){return!b.is.indeterminate()},unchecked:function(){return!b.is.checked()}},can:{change:function(){return!(y.hasClass(h.disabled)||y.hasClass(h.readOnly)||C.prop("disabled")||C.prop("readonly"))},uncheck:function(){return"boolean"==typeof g.uncheckable?g.uncheckable:!b.is.radio()}},set:{checked:function(){return b.verbose("Setting class to checked"),y.removeClass(h.indeterminate).addClass(h.checked),b.is.radio()&&b.uncheckOthers(),!b.is.indeterminate()&&b.is.checked()?void b.debug("Input is already checked, skipping input property change"):(b.verbose("Setting state to checked",C[0]),C.prop("indeterminate",!1).prop("checked",!0),void b.trigger.change())},unchecked:function(){return b.verbose("Removing checked class"),y.removeClass(h.indeterminate).removeClass(h.checked),!b.is.indeterminate()&&b.is.unchecked()?void b.debug("Input is already unchecked"):(b.debug("Setting state to unchecked"),C.prop("indeterminate",!1).prop("checked",!1),void b.trigger.change())},indeterminate:function(){return b.verbose("Setting class to indeterminate"),y.addClass(h.indeterminate),b.is.indeterminate()?void b.debug("Input is already indeterminate, skipping input property change"):(b.debug("Setting state to indeterminate"),C.prop("indeterminate",!0),void b.trigger.change())},determinate:function(){return b.verbose("Removing indeterminate class"),y.removeClass(h.indeterminate),b.is.determinate()?void b.debug("Input is already determinate, skipping input property change"):(b.debug("Setting state to determinate"),void C.prop("indeterminate",!1))},disabled:function(){return b.verbose("Setting class to disabled"),y.addClass(h.disabled),b.is.disabled()?void b.debug("Input is already disabled, skipping input property change"):(b.debug("Setting state to disabled"),C.prop("disabled","disabled"),void b.trigger.change())},enabled:function(){return b.verbose("Removing disabled class"),y.removeClass(h.disabled),b.is.enabled()?void b.debug("Input is already enabled, skipping input property change"):(b.debug("Setting state to enabled"),C.prop("disabled",!1),void b.trigger.change())},tabbable:function(){b.verbose("Adding tabindex to checkbox"),C.attr("tabindex")===i&&C.attr("tabindex",0)}},trigger:{change:function(){b.verbose("Triggering change event from programmatic change"),C.trigger("change")}},create:{label:function(){C.prevAll(m.label).length>0?(C.prev(m.label).detach().insertAfter(C),b.debug("Moving existing label",x)):b.has.label()||(x=e("<label>").insertAfter(C),b.debug("Creating label",x))}},has:{label:function(){return x.length>0}},bind:{events:function(){b.verbose("Attaching checkbox events"),y.on("click"+k,b.event.click).on("keydown"+k,m.input,b.event.keydown)}},unbind:{events:function(){b.debug("Removing events"),y.off(k)}},uncheckOthers:function(){var e=b.get.otherRadios();b.debug("Unchecking other radios",e),e.removeClass(h.checked)},toggle:function(){return b.can.change()?void(b.is.indeterminate()||b.is.unchecked()?(b.debug("Currently unchecked"),b.check()):b.is.checked()&&b.can.uncheck()&&(b.debug("Currently checked"),b.uncheck())):void(b.is.radio()||b.debug("Checkbox is read-only or disabled, ignoring toggle"))},setting:function(n,t){if(b.debug("Changing setting",n,t),e.isPlainObject(n))e.extend(!0,g,n);else{if(t===i)return g[n];g[n]=t}},internal:function(n,t){if(e.isPlainObject(n))e.extend(!0,b,n);else{if(t===i)return b[n];b[n]=t}},debug:function(){g.debug&&(g.performance?b.performance.log(arguments):(b.debug=Function.prototype.bind.call(console.info,console,g.name+":"),b.debug.apply(console,arguments)))},verbose:function(){g.verbose&&g.debug&&(g.performance?b.performance.log(arguments):(b.verbose=Function.prototype.bind.call(console.info,console,g.name+":"),b.verbose.apply(console,arguments)))},error:function(){b.error=Function.prototype.bind.call(console.error,console,g.name+":"),b.error.apply(console,arguments)},performance:{log:function(e){var n,t,i;g.performance&&(n=(new Date).getTime(),i=c||n,t=n-i,c=n,d.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:O,"Execution Time":t})),clearTimeout(b.performance.timer),b.performance.timer=setTimeout(b.performance.display,500)},display:function(){var n=g.name+":",t=0;c=!1,clearTimeout(b.performance.timer),e.each(d,function(e,n){t+=n["Execution Time"]}),n+=" "+t+"ms",a&&(n+=" '"+a+"'"),(console.group!==i||console.table!==i)&&d.length>0&&(console.groupCollapsed(n),console.table?console.table(d):e.each(d,function(e,n){console.log(n.Name+": "+n["Execution Time"]+"ms")}),console.groupEnd()),d=[]}},invoke:function(n,t,r){var a,c,d,s=I;return t=t||u,r=O||r,"string"==typeof n&&s!==i&&(n=n.split(/[\. ]/),a=n.length-1,e.each(n,function(t,o){var r=t!=a?o+n[t+1].charAt(0).toUpperCase()+n[t+1].slice(1):n;if(e.isPlainObject(s[r])&&t!=a)s=s[r];else{if(s[r]!==i)return c=s[r],!1;if(!e.isPlainObject(s[o])||t==a)return s[o]!==i?(c=s[o],!1):(b.error(f.method,n),!1);s=s[o]}})),e.isFunction(c)?d=c.apply(r,t):c!==i&&(d=c),e.isArray(o)?o.push(d):o!==i?o=[o,d]:d!==i&&(o=d),c}},l?(I===i&&b.initialize(),b.invoke(s)):(I!==i&&I.invoke("destroy"),b.initialize())}),o!==i?o:this},e.fn.checkbox.settings={name:"Checkbox",namespace:"checkbox",debug:!1,verbose:!0,performance:!0,uncheckable:"auto",fireOnInit:!1,onChange:function(){},onChecked:function(){},onUnchecked:function(){},onDeterminate:function(){},onIndeterminate:function(){},onEnabled:function(){},onDisabled:function(){},className:{checked:"checked",indeterminate:"indeterminate",disabled:"disabled",hidden:"hidden",radio:"radio",readOnly:"read-only"},error:{method:"The method you called is not defined"},selector:{checkbox:".ui.checkbox",label:"label, .box",input:'input[type="checkbox"], input[type="radio"]'}}}(jQuery,window,document);

@@ -18,3 +18,3 @@ {

"license": "MIT",
"version": "1.12.3"
"version": "2.0.2"
}
/*!
* # Semantic UI 1.12.3 - Checkbox
* # Semantic UI 2.0.2 - Checkbox
* http://github.com/semantic-org/semantic-ui/
*
*
* Copyright 2014 Contributors
* Copyright 2015 Contributors
* Released under the MIT license

@@ -45,4 +45,4 @@ * http://opensource.org/licenses/MIT

$module = $(this),
$label = $(this).find(selector.label).first(),
$input = $(this).find(selector.input),
$label = $(this).children(selector.label),
$input = $(this).children(selector.input),

@@ -62,19 +62,10 @@ instance = $module.data(moduleNamespace),

module.create.label();
module.add.events();
module.bind.events();
if( module.is.checked() ) {
module.set.checked();
if(settings.fireOnInit) {
settings.onChecked.call($input.get());
}
}
else {
module.remove.checked();
if(settings.fireOnInit) {
settings.onUnchecked.call($input.get());
}
}
module.set.tabbable();
module.hide.input();
module.observeChanges();
module.instantiate();
module.setup();
},

@@ -92,14 +83,62 @@

module.verbose('Destroying module');
module.remove.events();
$module
.removeData(moduleNamespace)
;
module.unbind.events();
module.show.input();
$module.removeData(moduleNamespace);
},
fix: {
reference: function() {
if( $module.is(selector.input) ) {
module.debug('Behavior called on <input> adjusting invoked element');
$module = $module.closest(selector.checkbox);
module.refresh();
}
}
},
setup: function() {
if( module.is.indeterminate() ) {
module.debug('Initial value is indeterminate');
module.set.indeterminate();
if(settings.fireOnInit) {
settings.onIndeterminate.call($input[0]);
settings.onChange.call($input[0]);
}
}
else if( module.is.checked() ) {
module.debug('Initial value is checked');
module.set.checked();
if(settings.fireOnInit) {
settings.onChecked.call($input[0]);
settings.onChange.call($input[0]);
}
}
else {
module.debug('Initial value is unchecked');
module.set.unchecked();
if(settings.fireOnInit) {
settings.onUnchecked.call($input[0]);
settings.onChange.call($input[0]);
}
}
},
refresh: function() {
$module = $(element);
$label = $(element).find(selector.label).first();
$input = $(element).find(selector.input);
$label = $module.children(selector.label);
$input = $module.children(selector.input);
},
hide: {
input: function() {
module.verbose('Modfying <input> z-index to be unselectable');
$input.addClass(className.hidden);
}
},
show: {
input: function() {
module.verbose('Modfying <input> z-index to be selectable');
$input.removeClass(className.hidden);
}
},
observeChanges: function() {

@@ -139,2 +178,9 @@ if('MutationObserver' in window) {

event: {
click: function(event) {
if( $(event.target).is(selector.input) ) {
module.verbose('Using default check action on initialized checkbox');
return;
}
module.toggle();
},
keydown: function(event) {

@@ -149,11 +195,10 @@ var

;
if( key == keyCode.escape) {
if(key == keyCode.escape) {
module.verbose('Escape key pressed blurring field');
$module
.blur()
;
$input.blur();
event.preventDefault();
}
if(!event.ctrlKey && (key == keyCode.enter || key == keyCode.space)) {
module.verbose('Enter key pressed, toggling checkbox');
module.toggle.call(this);
module.toggle();
event.preventDefault();

@@ -164,9 +209,100 @@ }

check: function() {
if( !module.is.indeterminate() && module.is.checked() ) {
module.debug('Checkbox is already checked');
return;
}
module.debug('Checking checkbox', $input);
module.set.checked();
settings.onChecked.call($input[0]);
settings.onChange.call($input[0]);
},
uncheck: function() {
if( !module.is.indeterminate() && module.is.unchecked() ) {
module.debug('Checkbox is already unchecked');
return;
}
module.debug('Unchecking checkbox');
module.set.unchecked();
settings.onUnchecked.call($input[0]);
settings.onChange.call($input[0]);
},
indeterminate: function() {
if( module.is.indeterminate() ) {
module.debug('Checkbox is already indeterminate');
return;
}
module.debug('Making checkbox indeterminate');
module.set.indeterminate();
settings.onIndeterminate.call($input[0]);
settings.onChange.call($input[0]);
},
determinate: function() {
if( module.is.determinate() ) {
module.debug('Checkbox is already determinate');
return;
}
module.debug('Making checkbox determinate');
module.set.determinate();
settings.onDeterminate.call($input[0]);
settings.onChange.call($input[0]);
},
enable: function() {
if( module.is.enabled() ) {
module.debug('Checkbox is already enabled');
return;
}
module.debug('Enabling checkbox');
module.set.enabled();
settings.onEnable.call($input[0]);
},
disable: function() {
if( module.is.disabled() ) {
module.debug('Checkbox is already disabled');
return;
}
module.debug('Disabling checkbox');
module.set.disabled();
settings.onDisable.call($input[0]);
},
get: {
radios: function() {
var
name = module.get.name()
;
return $('input[name="' + name + '"]').closest(selector.checkbox);
},
otherRadios: function() {
return module.get.radios().not($module);
},
name: function() {
return $input.attr('name');
}
},
is: {
radio: function() {
return $module.hasClass(className.radio);
return ($input.hasClass(className.radio) || $input.attr('type') == 'radio');
},
indeterminate: function() {
return $input.prop('indeterminate') !== undefined && $input.prop('indeterminate');
},
checked: function() {
return $input.prop('checked') !== undefined && $input.prop('checked');
},
disabled: function() {
return $input.prop('disabled') !== undefined && $input.prop('disabled');
},
enabled: function() {
return !module.is.disabled();
},
determinate: function() {
return !module.is.indeterminate();
},
unchecked: function() {

@@ -179,3 +315,3 @@ return !module.is.checked();

change: function() {
return !( $module.hasClass(className.disabled) || $module.hasClass(className.readOnly) || $input.prop('disabled') );
return !( $module.hasClass(className.disabled) || $module.hasClass(className.readOnly) || $input.prop('disabled') || $input.prop('readonly') );
},

@@ -192,9 +328,99 @@ uncheck: function() {

checked: function() {
$module.addClass(className.checked);
module.verbose('Setting class to checked');
$module
.removeClass(className.indeterminate)
.addClass(className.checked)
;
if( module.is.radio() ) {
module.uncheckOthers();
}
if(!module.is.indeterminate() && module.is.checked()) {
module.debug('Input is already checked, skipping input property change');
return;
}
module.verbose('Setting state to checked', $input[0]);
$input
.prop('indeterminate', false)
.prop('checked', true)
;
module.trigger.change();
},
tab: function() {
unchecked: function() {
module.verbose('Removing checked class');
$module
.removeClass(className.indeterminate)
.removeClass(className.checked)
;
if(!module.is.indeterminate() && module.is.unchecked() ) {
module.debug('Input is already unchecked');
return;
}
module.debug('Setting state to unchecked');
$input
.prop('indeterminate', false)
.prop('checked', false)
;
module.trigger.change();
},
indeterminate: function() {
module.verbose('Setting class to indeterminate');
$module
.addClass(className.indeterminate)
;
if( module.is.indeterminate() ) {
module.debug('Input is already indeterminate, skipping input property change');
return;
}
module.debug('Setting state to indeterminate');
$input
.prop('indeterminate', true)
;
module.trigger.change();
},
determinate: function() {
module.verbose('Removing indeterminate class');
$module
.removeClass(className.indeterminate)
;
if( module.is.determinate() ) {
module.debug('Input is already determinate, skipping input property change');
return;
}
module.debug('Setting state to determinate');
$input
.prop('indeterminate', false)
;
},
disabled: function() {
module.verbose('Setting class to disabled');
$module
.addClass(className.disabled)
;
if( module.is.disabled() ) {
module.debug('Input is already disabled, skipping input property change');
return;
}
module.debug('Setting state to disabled');
$input
.prop('disabled', 'disabled')
;
module.trigger.change();
},
enabled: function() {
module.verbose('Removing disabled class');
$module.removeClass(className.disabled);
if( module.is.enabled() ) {
module.debug('Input is already enabled, skipping input property change');
return;
}
module.debug('Setting state to enabled');
$input
.prop('disabled', false)
;
module.trigger.change();
},
tabbable: function() {
module.verbose('Adding tabindex to checkbox');
if( $input.attr('tabindex') === undefined) {
$input
.attr('tabindex', 0)
;
$input.attr('tabindex', 0);
}

@@ -204,2 +430,12 @@ }

trigger: {
change: function() {
module.verbose('Triggering change event from programmatic change');
$input
.trigger('change')
;
}
},
create: {

@@ -224,7 +460,7 @@ label: function() {

add: {
bind: {
events: function() {
module.verbose('Attaching checkbox events');
$module
.on('click' + eventNamespace, module.toggle)
.on('click' + eventNamespace, module.event.click)
.on('keydown' + eventNamespace, selector.input, module.event.keydown)

@@ -235,6 +471,3 @@ ;

remove: {
checked: function() {
$module.removeClass(className.checked);
},
unbind: {
events: function() {

@@ -244,62 +477,27 @@ module.debug('Removing events');

.off(eventNamespace)
.removeData(moduleNamespace)
;
$input
.off(eventNamespace, module.event.keydown)
;
$label
.off(eventNamespace)
;
}
},
enable: function() {
module.debug('Enabling checkbox functionality');
$module.removeClass(className.disabled);
$input.prop('disabled', false);
settings.onEnabled.call($input.get());
},
disable: function() {
module.debug('Disabling checkbox functionality');
$module.addClass(className.disabled);
$input.prop('disabled', 'disabled');
settings.onDisabled.call($input.get());
},
check: function() {
module.debug('Enabling checkbox', $input);
$input
.prop('checked', true)
.trigger('change')
uncheckOthers: function() {
var
$radios = module.get.otherRadios()
;
module.set.checked();
$input.trigger('blur');
settings.onChange.call($input.get());
settings.onChecked.call($input.get());
module.debug('Unchecking other radios', $radios);
$radios.removeClass(className.checked);
},
uncheck: function() {
module.debug('Disabling checkbox');
$input
.prop('checked', false)
.trigger('change')
;
module.remove.checked();
$input.trigger('blur');
settings.onChange.call($input.get());
settings.onUnchecked.call($input.get());
},
toggle: function(event) {
toggle: function() {
if( !module.can.change() ) {
console.log(module.can.change());
module.debug('Checkbox is read-only or disabled, ignoring toggle');
if(!module.is.radio()) {
module.debug('Checkbox is read-only or disabled, ignoring toggle');
}
return;
}
module.verbose('Determining new checkbox state');
if( module.is.unchecked() ) {
if( module.is.indeterminate() || module.is.unchecked() ) {
module.debug('Currently unchecked');
module.check();
}
else if( module.is.checked() && module.can.uncheck() ) {
module.debug('Currently checked');
module.uncheck();

@@ -377,3 +575,3 @@ }

clearTimeout(module.performance.timer);
module.performance.timer = setTimeout(module.performance.display, 100);
module.performance.timer = setTimeout(module.performance.display, 500);
},

@@ -488,33 +686,41 @@ display: function() {

name : 'Checkbox',
namespace : 'checkbox',
name : 'Checkbox',
namespace : 'checkbox',
debug : false,
verbose : true,
performance : true,
debug : false,
verbose : true,
performance : true,
// delegated event context
uncheckable : 'auto',
fireOnInit : true,
uncheckable : 'auto',
fireOnInit : false,
onChange : function(){},
onChecked : function(){},
onUnchecked : function(){},
onEnabled : function(){},
onDisabled : function(){},
onChange : function(){},
className : {
checked : 'checked',
disabled : 'disabled',
radio : 'radio',
readOnly : 'read-only'
onChecked : function(){},
onUnchecked : function(){},
onDeterminate : function() {},
onIndeterminate : function() {},
onEnabled : function(){},
onDisabled : function(){},
className : {
checked : 'checked',
indeterminate : 'indeterminate',
disabled : 'disabled',
hidden : 'hidden',
radio : 'radio',
readOnly : 'read-only'
},
error : {
method : 'The method you called is not defined'
method : 'The method you called is not defined'
},
selector : {
input : 'input[type="checkbox"], input[type="radio"]',
label : 'label'
checkbox : '.ui.checkbox',
label : 'label, .box',
input : 'input[type="checkbox"], input[type="radio"]',
}

@@ -521,0 +727,0 @@

@@ -5,3 +5,3 @@

summary : 'Semantic UI - Checkbox: Single component release',
version : '1.12.3',
version : '2.0.2',
git : 'git://github.com/Semantic-Org/UI-Checkbox.git',

@@ -8,0 +8,0 @@ });

{
"name": "semantic-ui-checkbox",
"version": "1.12.3",
"version": "2.0.2",
"title": "Semantic UI - Checkbox",

@@ -5,0 +5,0 @@ "description": "Single component release of checkbox",

@@ -0,1 +1,20 @@

### Version 2.0.1 - July 6, 2015
- **Checkbox** - Fixed issue in chrome where radio checkbox would appear incorrectly when no default value was selected [#2505](https://github.com/Semantic-Org/Semantic-UI/issues/2505)
- **Checkbox** - Fixed issue where radio checkbox were not properly receiving `checked` class [#2506](https://github.com/Semantic-Org/Semantic-UI/issues/2506)
### Version 2.0.0 - June 30, 2015
- **Checkbox** - Checkbox `fireOnInit` now defaults to false. Checkboxes now also *do not require javascript* to function.
- **Checkbox** - Checkbox no longer require javascript to function.
- **Checkbox** - Added support for `indeterminate` checkboxes, along with new stylings.
- **Checkbox** - Now includes separate behaviors for triggering state changes without invoking callbacks `set checked` vs `checked`
- **Checkbox** - Checkbox will now gracefully correct behaviors invoked on the child input element instead of the `ui checkbox`.
- **Checkbox** - Reduced kb size of icon font
- **Checkbox** - Fix `disabled checkbox` sometimes displaying hand cursor
- **Checkbox** - Fixes nested `dropdown` inside `checkbox` causing issues
- **Checkbox** - Fix `:focus` styles only applying if checkbox is unchecked
- **Form Validation** - Fixed `clear` and `reset` causing validation error to appear on checkbox if empty rule was set on checkbox.
- **Checkbox** - Toggle now uses `@primaryColor`
### Version 1.10.0 - February 23, 2015

@@ -2,0 +21,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc