semantic-ui-checkbox
Advanced tools
Comparing version 1.0.0 to 1.9.0
{ | ||
"name": "semantic-ui-checkbox", | ||
"description": "Checkbox - Semantic UI", | ||
"homepage": "http://beta.semantic-ui.com", | ||
"homepage": "http://www.semantic-ui.com", | ||
"author": { | ||
@@ -9,9 +9,22 @@ "name": "Jack Lukic", | ||
}, | ||
"ignore": ["docs", "node", "server", "spec", "src", "test"], | ||
"keywords": ["semantic", "ui", "css3", "framework"], | ||
"license": ["http://semantic-ui.mit-license.org/"], | ||
"main": ["checkbox.js", "checkbox.css"], | ||
"dependencies": { | ||
"jquery": ">=1.8" | ||
} | ||
"ignore": [ | ||
"docs", | ||
"node", | ||
"server", | ||
"spec", | ||
"src", | ||
"test" | ||
], | ||
"keywords": [ | ||
"semantic", | ||
"ui", | ||
"css3", | ||
"framework" | ||
], | ||
"license": [ | ||
"http://semantic-ui.mit-license.org/" | ||
], | ||
"main": [ | ||
"checkbox.css" | ||
] | ||
} |
119
checkbox.js
@@ -44,3 +44,3 @@ /* | ||
$module = $(this), | ||
$label = $(this).next(selector.label).first(), | ||
$label = $(this).find(selector.label).first(), | ||
$input = $(this).find(selector.input), | ||
@@ -59,10 +59,10 @@ | ||
module.verbose('Initializing checkbox', settings); | ||
$module | ||
.on('click' + eventNamespace, module.toggle) | ||
.on('keydown' + eventNamespace, selector.input, module.event.keydown) | ||
; | ||
module.create.label(); | ||
module.add.events(); | ||
if( module.is.checked() ) { | ||
module.set.checked(); | ||
if(settings.fireOnInit) { | ||
$.proxy(settings.onChecked, $input.get())(); | ||
settings.onChecked.call($input.get()); | ||
} | ||
@@ -73,3 +73,3 @@ } | ||
if(settings.fireOnInit) { | ||
$.proxy(settings.onUnchecked, $input.get())(); | ||
settings.onUnchecked.call($input.get()); | ||
} | ||
@@ -91,13 +91,7 @@ } | ||
destroy: function() { | ||
module.verbose('Destroying previous module'); | ||
module.verbose('Destroying module'); | ||
module.remove.events(); | ||
$module | ||
.off(eventNamespace) | ||
.removeData(moduleNamespace) | ||
; | ||
$input | ||
.off(eventNamespace, module.event.keydown) | ||
; | ||
$label | ||
.off(eventNamespace) | ||
; | ||
}, | ||
@@ -107,3 +101,3 @@ | ||
$module = $(this); | ||
$label = $(this).next(selector.label).first(); | ||
$label = $(this).find(selector.label).first(); | ||
$input = $(this).find(selector.input); | ||
@@ -113,3 +107,3 @@ }, | ||
observeChanges: function() { | ||
if(MutationObserver !== undefined) { | ||
if('MutationObserver' in window) { | ||
observer = new MutationObserver(function(mutations) { | ||
@@ -129,3 +123,3 @@ module.debug('DOM tree modified, updating selector cache'); | ||
var | ||
$toggle = $(selector) | ||
$element = $(selector) | ||
; | ||
@@ -136,5 +130,5 @@ event = $.isFunction(module[event]) | ||
; | ||
if($toggle.size() > 0) { | ||
if($element.length > 0) { | ||
module.debug('Attaching checkbox events to element', selector, event); | ||
$toggle | ||
$element | ||
.on('click' + eventNamespace, event) | ||
@@ -154,2 +148,3 @@ ; | ||
enter : 13, | ||
space : 32, | ||
escape : 27 | ||
@@ -164,5 +159,5 @@ } | ||
} | ||
if(!event.ctrlKey && key == keyCode.enter) { | ||
if(!event.ctrlKey && (key == keyCode.enter || key == keyCode.space)) { | ||
module.verbose('Enter key pressed, toggling checkbox'); | ||
$.proxy(module.toggle, this)(); | ||
module.toggle.call(this); | ||
event.preventDefault(); | ||
@@ -200,23 +195,72 @@ } | ||
$module.addClass(className.checked); | ||
}, | ||
tab: function() { | ||
if( $input.attr('tabindex') === undefined) { | ||
$input | ||
.attr('tabindex', 0) | ||
; | ||
} | ||
} | ||
}, | ||
create: { | ||
label: function() { | ||
if($input.prevAll(selector.label).length > 0) { | ||
$input.prev(selector.label).detach().insertAfter($input); | ||
module.debug('Moving existing label', $label); | ||
} | ||
else if( !module.has.label() ) { | ||
$label = $('<label>').insertAfter($input); | ||
module.debug('Creating label', $label); | ||
} | ||
} | ||
}, | ||
has: { | ||
label: function() { | ||
return ($label.length > 0); | ||
} | ||
}, | ||
add: { | ||
events: function() { | ||
module.verbose('Attaching checkbox events'); | ||
$module | ||
.on('click' + eventNamespace, module.toggle) | ||
.on('keydown' + eventNamespace, selector.input, module.event.keydown) | ||
; | ||
} | ||
}, | ||
remove: { | ||
checked: function() { | ||
$module.removeClass(className.checked); | ||
}, | ||
events: function() { | ||
module.debug('Removing events'); | ||
$module | ||
.off(eventNamespace) | ||
.removeData(moduleNamespace) | ||
; | ||
$input | ||
.off(eventNamespace, module.event.keydown) | ||
; | ||
$label | ||
.off(eventNamespace) | ||
; | ||
} | ||
}, | ||
disable: function() { | ||
enable: function() { | ||
module.debug('Enabling checkbox functionality'); | ||
$module.addClass(className.disabled); | ||
$input.removeProp('disabled'); | ||
$.proxy(settings.onDisabled, $input.get())(); | ||
$module.removeClass(className.disabled); | ||
$input.prop('disabled', false); | ||
settings.onEnabled.call($input.get()); | ||
}, | ||
enable: function() { | ||
disable: function() { | ||
module.debug('Disabling checkbox functionality'); | ||
$module.removeClass(className.disabled); | ||
$module.addClass(className.disabled); | ||
$input.prop('disabled', 'disabled'); | ||
$.proxy(settings.onEnabled, $input.get())(); | ||
settings.onDisabled.call($input.get()); | ||
}, | ||
@@ -231,4 +275,5 @@ | ||
module.set.checked(); | ||
$.proxy(settings.onChange, $input.get())(); | ||
$.proxy(settings.onChecked, $input.get())(); | ||
$input.trigger('blur'); | ||
settings.onChange.call($input.get()); | ||
settings.onChecked.call($input.get()); | ||
}, | ||
@@ -243,4 +288,5 @@ | ||
module.remove.checked(); | ||
$.proxy(settings.onChange, $input.get())(); | ||
$.proxy(settings.onUnchecked, $input.get())(); | ||
$input.trigger('blur'); | ||
settings.onChange.call($input.get()); | ||
settings.onUnchecked.call($input.get()); | ||
}, | ||
@@ -394,2 +440,3 @@ | ||
else { | ||
module.error(error.method, query); | ||
return false; | ||
@@ -426,3 +473,3 @@ } | ||
if(instance !== undefined) { | ||
module.destroy(); | ||
instance.invoke('destroy'); | ||
} | ||
@@ -467,7 +514,7 @@ module.initialize(); | ||
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]', | ||
input : 'input[type="checkbox"], input[type="radio"]', | ||
label : 'label' | ||
@@ -474,0 +521,0 @@ } |
/* | ||
* # Semantic UI | ||
* # Semantic UI - 1.9.0 | ||
* https://github.com/Semantic-Org/Semantic-UI | ||
* http://beta.semantic-ui.com/ | ||
* http://www.semantic-ui.com/ | ||
* | ||
@@ -11,2 +11,2 @@ * Copyright 2014 Contributors | ||
*/ | ||
!function(e,n,o,c){"use strict";e.fn.checkbox=function(n){var o,t=e(this),i=t.selector||"",r=(new Date).getTime(),a=[],s=arguments[0],l="string"==typeof s,u=[].slice.call(arguments,1);return t.each(function(){var t,d,h=e.extend(!0,{},e.fn.checkbox.settings,n),g=h.className,b=h.namespace,f=h.selector,p=h.error,m="."+b,k="module-"+b,v=e(this),y=e(this).next(f.label).first(),x=e(this).find(f.input),C=v.data(k),E=this;d={initialize:function(){d.verbose("Initializing checkbox",h),v.on("click"+m,d.toggle).on("keydown"+m,f.input,d.event.keydown),d.is.checked()?(d.set.checked(),h.fireOnInit&&e.proxy(h.onChecked,x.get())()):(d.remove.checked(),h.fireOnInit&&e.proxy(h.onUnchecked,x.get())()),d.observeChanges(),d.instantiate()},instantiate:function(){d.verbose("Storing instance of module",d),C=d,v.data(k,d)},destroy:function(){d.verbose("Destroying previous module"),v.off(m).removeData(k),x.off(m,d.event.keydown),y.off(m)},refresh:function(){v=e(this),y=e(this).next(f.label).first(),x=e(this).find(f.input)},observeChanges:function(){MutationObserver!==c&&(t=new MutationObserver(function(){d.debug("DOM tree modified, updating selector cache"),d.refresh()}),t.observe(E,{childList:!0,subtree:!0}),d.debug("Setting up mutation observer",t))},attachEvents:function(n,o){var c=e(n);o=e.isFunction(d[o])?d[o]:d.toggle,c.size()>0?(d.debug("Attaching checkbox events to element",n,o),c.on("click"+m,o)):d.error(p.notFound)},event:{keydown:function(n){var o=n.which,c={enter:13,escape:27};o==c.escape&&(d.verbose("Escape key pressed blurring field"),v.blur()),n.ctrlKey||o!=c.enter||(d.verbose("Enter key pressed, toggling checkbox"),e.proxy(d.toggle,this)(),n.preventDefault())}},is:{radio:function(){return v.hasClass(g.radio)},checked:function(){return x.prop("checked")!==c&&x.prop("checked")},unchecked:function(){return!d.is.checked()}},can:{change:function(){return!(v.hasClass(g.disabled)||v.hasClass(g.readOnly)||x.prop("disabled"))},uncheck:function(){return"boolean"==typeof h.uncheckable?h.uncheckable:!d.is.radio()}},set:{checked:function(){v.addClass(g.checked)}},remove:{checked:function(){v.removeClass(g.checked)}},disable:function(){d.debug("Enabling checkbox functionality"),v.addClass(g.disabled),x.removeProp("disabled"),e.proxy(h.onDisabled,x.get())()},enable:function(){d.debug("Disabling checkbox functionality"),v.removeClass(g.disabled),x.prop("disabled","disabled"),e.proxy(h.onEnabled,x.get())()},check:function(){d.debug("Enabling checkbox",x),x.prop("checked",!0).trigger("change"),d.set.checked(),e.proxy(h.onChange,x.get())(),e.proxy(h.onChecked,x.get())()},uncheck:function(){d.debug("Disabling checkbox"),x.prop("checked",!1).trigger("change"),d.remove.checked(),e.proxy(h.onChange,x.get())(),e.proxy(h.onUnchecked,x.get())()},toggle:function(){return d.can.change()?(d.verbose("Determining new checkbox state"),void(d.is.unchecked()?d.check():d.is.checked()&&d.can.uncheck()&&d.uncheck())):(console.log(d.can.change()),void d.debug("Checkbox is read-only or disabled, ignoring toggle"))},setting:function(n,o){if(d.debug("Changing setting",n,o),e.isPlainObject(n))e.extend(!0,h,n);else{if(o===c)return h[n];h[n]=o}},internal:function(n,o){if(e.isPlainObject(n))e.extend(!0,d,n);else{if(o===c)return d[n];d[n]=o}},debug:function(){h.debug&&(h.performance?d.performance.log(arguments):(d.debug=Function.prototype.bind.call(console.info,console,h.name+":"),d.debug.apply(console,arguments)))},verbose:function(){h.verbose&&h.debug&&(h.performance?d.performance.log(arguments):(d.verbose=Function.prototype.bind.call(console.info,console,h.name+":"),d.verbose.apply(console,arguments)))},error:function(){d.error=Function.prototype.bind.call(console.error,console,h.name+":"),d.error.apply(console,arguments)},performance:{log:function(e){var n,o,c;h.performance&&(n=(new Date).getTime(),c=r||n,o=n-c,r=n,a.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:E,"Execution Time":o})),clearTimeout(d.performance.timer),d.performance.timer=setTimeout(d.performance.display,100)},display:function(){var n=h.name+":",o=0;r=!1,clearTimeout(d.performance.timer),e.each(a,function(e,n){o+=n["Execution Time"]}),n+=" "+o+"ms",i&&(n+=" '"+i+"'"),(console.group!==c||console.table!==c)&&a.length>0&&(console.groupCollapsed(n),console.table?console.table(a):e.each(a,function(e,n){console.log(n.Name+": "+n["Execution Time"]+"ms")}),console.groupEnd()),a=[]}},invoke:function(n,t,i){var r,a,s,l=C;return t=t||u,i=E||i,"string"==typeof n&&l!==c&&(n=n.split(/[\. ]/),r=n.length-1,e.each(n,function(o,t){var i=o!=r?t+n[o+1].charAt(0).toUpperCase()+n[o+1].slice(1):n;if(e.isPlainObject(l[i])&&o!=r)l=l[i];else{if(l[i]!==c)return a=l[i],!1;if(!e.isPlainObject(l[t])||o==r)return l[t]!==c?(a=l[t],!1):!1;l=l[t]}})),e.isFunction(a)?s=a.apply(i,t):a!==c&&(s=a),e.isArray(o)?o.push(s):o!==c?o=[o,s]:s!==c&&(o=s),a}},l?(C===c&&d.initialize(),d.invoke(s)):(C!==c&&d.destroy(),d.initialize())}),o!==c?o: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,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(this),x=e(this).find(p.label).first(),C=e(this).find(p.input)},observeChanges:function(){"MutationObserver"in n&&(i=new MutationObserver(function(){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(){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); |
@@ -11,9 +11,10 @@ { | ||
}], | ||
"keywords": ["semantic", "ui", "css", "framework"], | ||
"keywords": [ | ||
"semantic", | ||
"ui", | ||
"css", | ||
"framework" | ||
], | ||
"license": "MIT", | ||
"dependencies": { | ||
"jquery": "x.x.x" | ||
}, | ||
"main": "checkbox.js", | ||
"version": "1.0.0" | ||
"version": "1.9.0" | ||
} |
119
index.js
@@ -46,3 +46,3 @@ /* | ||
$module = $(this), | ||
$label = $(this).next(selector.label).first(), | ||
$label = $(this).find(selector.label).first(), | ||
$input = $(this).find(selector.input), | ||
@@ -61,10 +61,10 @@ | ||
module.verbose('Initializing checkbox', settings); | ||
$module | ||
.on('click' + eventNamespace, module.toggle) | ||
.on('keydown' + eventNamespace, selector.input, module.event.keydown) | ||
; | ||
module.create.label(); | ||
module.add.events(); | ||
if( module.is.checked() ) { | ||
module.set.checked(); | ||
if(settings.fireOnInit) { | ||
$.proxy(settings.onChecked, $input.get())(); | ||
settings.onChecked.call($input.get()); | ||
} | ||
@@ -75,3 +75,3 @@ } | ||
if(settings.fireOnInit) { | ||
$.proxy(settings.onUnchecked, $input.get())(); | ||
settings.onUnchecked.call($input.get()); | ||
} | ||
@@ -93,13 +93,7 @@ } | ||
destroy: function() { | ||
module.verbose('Destroying previous module'); | ||
module.verbose('Destroying module'); | ||
module.remove.events(); | ||
$module | ||
.off(eventNamespace) | ||
.removeData(moduleNamespace) | ||
; | ||
$input | ||
.off(eventNamespace, module.event.keydown) | ||
; | ||
$label | ||
.off(eventNamespace) | ||
; | ||
}, | ||
@@ -109,3 +103,3 @@ | ||
$module = $(this); | ||
$label = $(this).next(selector.label).first(); | ||
$label = $(this).find(selector.label).first(); | ||
$input = $(this).find(selector.input); | ||
@@ -115,3 +109,3 @@ }, | ||
observeChanges: function() { | ||
if(MutationObserver !== undefined) { | ||
if('MutationObserver' in window) { | ||
observer = new MutationObserver(function(mutations) { | ||
@@ -131,3 +125,3 @@ module.debug('DOM tree modified, updating selector cache'); | ||
var | ||
$toggle = $(selector) | ||
$element = $(selector) | ||
; | ||
@@ -138,5 +132,5 @@ event = $.isFunction(module[event]) | ||
; | ||
if($toggle.size() > 0) { | ||
if($element.length > 0) { | ||
module.debug('Attaching checkbox events to element', selector, event); | ||
$toggle | ||
$element | ||
.on('click' + eventNamespace, event) | ||
@@ -156,2 +150,3 @@ ; | ||
enter : 13, | ||
space : 32, | ||
escape : 27 | ||
@@ -166,5 +161,5 @@ } | ||
} | ||
if(!event.ctrlKey && key == keyCode.enter) { | ||
if(!event.ctrlKey && (key == keyCode.enter || key == keyCode.space)) { | ||
module.verbose('Enter key pressed, toggling checkbox'); | ||
$.proxy(module.toggle, this)(); | ||
module.toggle.call(this); | ||
event.preventDefault(); | ||
@@ -202,23 +197,72 @@ } | ||
$module.addClass(className.checked); | ||
}, | ||
tab: function() { | ||
if( $input.attr('tabindex') === undefined) { | ||
$input | ||
.attr('tabindex', 0) | ||
; | ||
} | ||
} | ||
}, | ||
create: { | ||
label: function() { | ||
if($input.prevAll(selector.label).length > 0) { | ||
$input.prev(selector.label).detach().insertAfter($input); | ||
module.debug('Moving existing label', $label); | ||
} | ||
else if( !module.has.label() ) { | ||
$label = $('<label>').insertAfter($input); | ||
module.debug('Creating label', $label); | ||
} | ||
} | ||
}, | ||
has: { | ||
label: function() { | ||
return ($label.length > 0); | ||
} | ||
}, | ||
add: { | ||
events: function() { | ||
module.verbose('Attaching checkbox events'); | ||
$module | ||
.on('click' + eventNamespace, module.toggle) | ||
.on('keydown' + eventNamespace, selector.input, module.event.keydown) | ||
; | ||
} | ||
}, | ||
remove: { | ||
checked: function() { | ||
$module.removeClass(className.checked); | ||
}, | ||
events: function() { | ||
module.debug('Removing events'); | ||
$module | ||
.off(eventNamespace) | ||
.removeData(moduleNamespace) | ||
; | ||
$input | ||
.off(eventNamespace, module.event.keydown) | ||
; | ||
$label | ||
.off(eventNamespace) | ||
; | ||
} | ||
}, | ||
disable: function() { | ||
enable: function() { | ||
module.debug('Enabling checkbox functionality'); | ||
$module.addClass(className.disabled); | ||
$input.removeProp('disabled'); | ||
$.proxy(settings.onDisabled, $input.get())(); | ||
$module.removeClass(className.disabled); | ||
$input.prop('disabled', false); | ||
settings.onEnabled.call($input.get()); | ||
}, | ||
enable: function() { | ||
disable: function() { | ||
module.debug('Disabling checkbox functionality'); | ||
$module.removeClass(className.disabled); | ||
$module.addClass(className.disabled); | ||
$input.prop('disabled', 'disabled'); | ||
$.proxy(settings.onEnabled, $input.get())(); | ||
settings.onDisabled.call($input.get()); | ||
}, | ||
@@ -233,4 +277,5 @@ | ||
module.set.checked(); | ||
$.proxy(settings.onChange, $input.get())(); | ||
$.proxy(settings.onChecked, $input.get())(); | ||
$input.trigger('blur'); | ||
settings.onChange.call($input.get()); | ||
settings.onChecked.call($input.get()); | ||
}, | ||
@@ -245,4 +290,5 @@ | ||
module.remove.checked(); | ||
$.proxy(settings.onChange, $input.get())(); | ||
$.proxy(settings.onUnchecked, $input.get())(); | ||
$input.trigger('blur'); | ||
settings.onChange.call($input.get()); | ||
settings.onUnchecked.call($input.get()); | ||
}, | ||
@@ -396,2 +442,3 @@ | ||
else { | ||
module.error(error.method, query); | ||
return false; | ||
@@ -428,3 +475,3 @@ } | ||
if(instance !== undefined) { | ||
module.destroy(); | ||
instance.invoke('destroy'); | ||
} | ||
@@ -469,7 +516,7 @@ module.initialize(); | ||
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]', | ||
input : 'input[type="checkbox"], input[type="radio"]', | ||
label : 'label' | ||
@@ -476,0 +523,0 @@ } |
{ | ||
"name": "semantic-ui-checkbox", | ||
"version": "1.0.0", | ||
"version": "1.9.0", | ||
"title": "Semantic UI - Checkbox", | ||
@@ -11,3 +11,3 @@ "description": "Single component release of checkbox", | ||
"type": "git", | ||
"url": "git@github.com:Semantic-Org/UI-Checkbox.git" | ||
"url": "https://github.com/Semantic-Org/UI-Checkbox.git" | ||
}, | ||
@@ -17,7 +17,3 @@ "bugs": { | ||
}, | ||
"dependencies": { | ||
"jquery": "x.x.x" | ||
}, | ||
"devDependencies": {}, | ||
"main": "index.js" | ||
"devDependencies": {} | ||
} |
@@ -19,6 +19,12 @@ # Semantic Checkbox | ||
#### To install with Meteor | ||
``` | ||
meteor add semantic:ui-checkbox | ||
``` | ||
## Addendum | ||
This element's definitions (required class names, html structures) are available in the [Beta UI Docs](http://beta.semantic-ui.com) | ||
This element's definitions (required class names, html structures) are available in the [UI Docs](http://www.semantic-ui.com) | ||
Please consider checking out [all the benefits to theming](http://learnsemantic.com/guide/expert.html) before using these stand-alone releases. | ||
Please consider checking out [all the benefits to theming](http://www.learnsemantic.com/guide/expert.html) before using these stand-alone releases. |
@@ -1,3 +0,24 @@ | ||
### Version 1.0.0 - XX XX, 2014 | ||
### UI Changes | ||
- **Form Validation** - Dropdown and checkbox will now validate after interaction with `on: 'blur'` | ||
### Version 1.8.0 - January 23, 2015 | ||
- **Checkbox** - Checkbox now only modifies `input[type="radio"]` and `input[type="checkbox"]` ignoring any other inputs | ||
### Version 1.7.0 - January 14, 2015 | ||
- **Checkbox** - Checkbox now toggles on spacebar when focused (previously only toggled on enter key). | ||
### Version 1.5.0 - December 30, 2014 | ||
- **Checkbox** - Checkboxes now can handle labels with multiple lines of text | ||
### Version 1.2.0 - December 08, 2014 | ||
- **Checkbox** - JS Checkbox now handles several variations of html. Labels can be before inputs, after, or not included at all. This should work better with server side form generation. | ||
- **Form** - Fixes required checkbox asterisks formatting incorrect | ||
### Version 1.0.0 - November 24, 2014 | ||
- **Checkbox** - Checkbox "enable" and "disable" have been replaced with "check" and "uncheck" | ||
@@ -9,2 +30,14 @@ - **Checkbox** - Now correctly handles read-only and disabled, has read-only and disabled states | ||
### Version 0.16.0 - April 22, 2014 | ||
- **Checkbox** - Fixes issue where checkboxes with multiple line labels were appearing formatted incorrectly. | ||
### Version 0.15.5 - April 11, 2014 | ||
- **Checkbox** - Fixes ``ui checkbox`` to obey ``disabled`` property of input | ||
### Version 0.15.3 - April 04, 2014 | ||
- Adds more examples for static checkbox/radio boxes with HTML only | ||
### Version 0.15.0 - Mar 14, 2014 | ||
@@ -14,3 +47,3 @@ | ||
### Version 0.13.1- Feb 28, 2014 | ||
### Version 0.13.1 - Feb 28, 2014 | ||
@@ -17,0 +50,0 @@ - **Checkbox** - Fixes checkbox appearance inside inverted forms |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Wildcard dependency
QualityPackage has a dependency with a floating version range. This can cause issues if the dependency publishes a new major version.
Found 1 instance in 1 package
80437
0
11
1494
1
30
1
- Removedjquery@x.x.x
- Removedjquery@3.7.1(transitive)