/*! * # Semantic UI 2.0.0 - Checkbox * http://github.com/semantic-org/semantic-ui/ * * * Copyright 2015 Contributors * Released under the MIT license * http://opensource.org/licenses/MIT * */ !function(e,n,t,o){"use strict";e.fn.checkbox=function(t){var c,i=e(this),a=i.selector||"",r=(new Date).getTime(),l=[],s=arguments[0],u="string"==typeof s,d=[].slice.call(arguments,1);return i.each(function(){var i,b,h=e.extend(!0,{},e.fn.checkbox.settings,t),g=h.className,f=h.namespace,p=h.selector,m=h.error,k="."+f,v="module-"+f,y=e(this),x=e(this).find(p.label),C=e(this).find(p.input),D=y.data(v),E=this;b={initialize:function(){b.verbose("Initializing checkbox",h),b.create.label(),b.add.events(),b.set.tabbable(),b.setup(),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)},setup:function(){b.is.checked()?(b.debug("Setting initial value to checked"),b.set.checked(),h.fireOnInit&&h.onChecked.call(C[0])):(b.debug("Setting initial value to unchecked"),b.remove.checked(),h.fireOnInit&&h.onUnchecked.call(C[0]))},refresh:function(){x=y.find(p.label),C=y.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"),C.blur(),e.preventDefault()),e.ctrlKey||n!=t.enter&&n!=t.space||(b.verbose("Enter key pressed, toggling checkbox"),b.toggle(),e.preventDefault())}},get:{radios:function(){return e('input[name="'+b.get.name()+'"]').closest(p.checkbox)},name:function(){return C.attr("name")}},is:{radio:function(){return C.hasClass(g.radio)||"radio"==C.attr("type")},checked:function(){return C.prop("checked")!==o&&C.prop("checked")},unchecked:function(){return!b.is.checked()}},can:{change:function(){return!(y.hasClass(g.disabled)||y.hasClass(g.readOnly)||C.prop("disabled"))},uncheck:function(){return"boolean"==typeof h.uncheckable?h.uncheckable:!b.is.radio()}},set:{checked:function(){var e;b.is.radio()&&(e=b.get.radios(),b.debug("Unchecking other radios",e),e.removeClass(g.checked)),y.addClass(g.checked)},tabbable: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("