wishthis/node_modules/fomantic-ui/dist/components/checkbox.min.js

11 lines
12 KiB
JavaScript
Raw Normal View History

2022-01-13 13:00:31 +00:00
/*
2022-05-29 09:24:36 +00:00
* # Fomantic UI - 2.8.8
2022-01-13 13:00:31 +00:00
* https://github.com/fomantic/Fomantic-UI
* http://fomantic-ui.com/
*
2022-05-29 09:24:36 +00:00
* Copyright 2021 Contributors
2022-01-13 13:00:31 +00:00
* Released under the MIT license
* http://opensource.org/licenses/MIT
*
*/
2022-05-29 09:24:36 +00:00
!function(I,E,S,O){"use strict";I.isFunction=I.isFunction||function(e){return"function"==typeof e&&"number"!=typeof e.nodeType},E=void 0!==E&&E.Math==Math?E:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")(),I.fn.checkbox=function(s){var u,e=I(this),b=e.selector||"",y=(new Date).getTime(),C=[],x=s,w="string"==typeof x,D=[].slice.call(arguments,1);return e.each(function(){var e,h,g=I.extend(!0,{},I.fn.checkbox.settings,s),n=g.className,t=g.namespace,p=g.selector,r=g.error,i="."+t,o="module-"+t,f=I(this),a=I(this).children(p.label),k=I(this).children(p.input),m=k[0],c=!1,v=!1,l=f.data(o),d=this;h={initialize:function(){h.verbose("Initializing checkbox",g),h.create.label(),h.bind.events(),h.set.tabbable(),h.hide.input(),h.observeChanges(),h.instantiate(),h.setup()},instantiate:function(){h.verbose("Storing instance of module",h),l=h,f.data(o,h)},destroy:function(){h.verbose("Destroying module"),h.unbind.events(),h.show.input(),f.removeData(o)},fix:{reference:function(){f.is(p.input)&&(h.debug("Behavior called on <input> adjusting invoked element"),f=f.closest(p.checkbox),h.refresh())}},setup:function(){h.set.initialLoad(),h.is.indeterminate()?(h.debug("Initial value is indeterminate"),h.indeterminate()):h.is.checked()?(h.debug("Initial value is checked"),h.check()):(h.debug("Initial value is unchecked"),h.uncheck()),h.remove.initialLoad()},refresh:function(){a=f.children(p.label),k=f.children(p.input),m=k[0]},hide:{input:function(){h.verbose("Modifying <input> z-index to be unselectable"),k.addClass(n.hidden)}},show:{input:function(){h.verbose("Modifying <input> z-index to be selectable"),k.removeClass(n.hidden)}},observeChanges:function(){"MutationObserver"in E&&((e=new MutationObserver(function(e){h.debug("DOM tree modified, updating selector cache"),h.refresh()})).observe(d,{childList:!0,subtree:!0}),h.debug("Setting up mutation observer",e))},attachEvents:function(e,n){var t=I(e);n=I.isFunction(h[n])?h[n]:h.toggle,0<t.length?(h.debug("Attaching checkbox events to element",e,n),t.on("click"+i,n)):h.error(r.notFound)},preventDefaultOnInputTarget:function(){"undefined"!=typeof event&&null!==event&&I(event.target).is(p.input)&&(h.verbose("Preventing default check action after manual check action"),event.preventDefault())},event:{change:function(e){h.should.ignoreCallbacks()||g.onChange.call(m)},click:function(e){var n=I(e.target);n.is(p.input)?h.verbose("Using default check action on initialized checkbox"):n.is(p.link)?h.debug("Clicking link inside checkbox, skipping toggle"):(h.toggle(),k.focus(),e.preventDefault())},keydown:function(e){var n=e.which,t=13,i=32,o=27,a=37,c=38,r=39,l=40,d=h.get.radios(),s=d.index(f),u=d.length,b=!1;if(n==a||n==c?b=(0===s?u:s)-1:n!=r&&n!=l||(b=s===u-1?0:s+1),!h.should.ignoreCallbacks()&&!1!==b){if(!1===g.beforeUnchecked.apply(m))return h.verbose("Option not allowed to be unchecked, cancelling key navigation"),!1;if(!1===g.beforeChecked.apply(I(d[b]).children(p.input)[0]))return h.verbose("Next option should not allow check, cancelling key navigation"),!1}v=n==o?(h.verbose("Escape key pressed blurring field"),k.blur(),!0):!(e.ctrlKey||!(n==i||n==t&&g.enableEnterKey))&&(h.verbose("Enter/space key pressed, toggling checkbox"),h.toggle(),!0)},keyup:function(e){v&&e.preventDefault()}},check:function(){h.should.allowCheck()&&(h.debug("Checking checkbox",k),h.set.checked(),h.should.ignoreCallbacks()||(g.onChecked.call(m),h.trigger.change()),h.preventDefaultOnInputTarget())},uncheck:function(){h.should.allowUncheck()&&(h.debug("Unchecking checkbox"),h.set.unchecked(),h.should.ignoreCallbacks()||(g.onUnchecked.call(m),h.trigger.change()),h.preventDefaultOnInputTarget())},indeterminate:function(){h.should.allowIndeterminate()?h.debug("Checkbox is already indeterminate"):(h.debug("Making checkbox indeterminate"),h.set.indeterminate(),h.should.ignoreCallbacks()||(g.onIndeterminate.call(m),h.trigger.change()))},determinate:function(){h.should.allowDeterminate()?h.debug("Checkbox is already determinate"):(h.debug("Making checkbox determinate"),h.set.determinate(),h.should.ignoreCallb