wishthis/semantic/dist/semantic.min.js

11 lines
278 KiB
JavaScript
Raw Normal View History

2022-01-13 13:00:31 +00:00
/*
2023-08-17 09:47:40 +00:00
* # Fomantic UI - 2.9.2
2022-01-13 13:00:31 +00:00
* https://github.com/fomantic/Fomantic-UI
2023-08-17 09:47:40 +00:00
* https://fomantic-ui.com/
2022-01-13 13:00:31 +00:00
*
2023-08-17 09:47:40 +00:00
* Copyright 2023 Contributors
2022-01-13 13:00:31 +00:00
* Released under the MIT license
2023-08-17 09:47:40 +00:00
* https://opensource.org/licenses/MIT
2022-01-13 13:00:31 +00:00
*
*/
2023-08-17 09:47:40 +00:00
!function(M,O,P){"use strict";function I(e){return null!==e&&e===e.window}function R(e){return"function"==typeof e&&"number"!=typeof e.nodeType}O=void 0!==O&&O.Math===Math?O:globalThis,M.fn.api=function(w){var C,e=R(this)?M(O):M(this),k=e.selector||"",T=Date.now(),D=[],S=w,A="string"==typeof S,E=[].slice.call(arguments,1);return e.each(function(){var a,i,n,e,r,o,f=M.isPlainObject(w)?M.extend(!0,{},M.fn.api.settings,w):M.extend({},M.fn.api.settings),t=f.namespace,s=f.metadata,l=f.selector,c=f.error,d=f.className,u="."+t,p="module-"+t,m=M(this),g=m.closest(l.form),h=f.stateContext?[O,P].indexOf(f.stateContext)<0?M(P).find(f.stateContext):M(f.stateContext):m,v=this,b=h[0],y=m.data(p),x={initialize:function(){A||(o=f.data,x.bind.events()),x.instantiate()},instantiate:function(){x.verbose("Storing instance of module",x),y=x,m.data(p,y)},destroy:function(){x.verbose("Destroying previous module for",v),m.removeData(p).off(u)},bind:{events:function(){var e=x.get.event();e?(x.verbose("Attaching API events to element",e),m.on(e+u,x.event.trigger)):"now"===f.on&&(x.debug("Querying API endpoint immediately"),x.query())}},decode:{json:function(e){if(void 0!==e&&"string"==typeof e)try{e=JSON.parse(e)}catch(e){}return e}},read:{cachedResponse:function(e){var t;if(void 0!==O.Storage)return t=sessionStorage.getItem(e+x.get.normalizedData()),x.debug("Using cached response",e,f.data,t),x.decode.json(t);x.error(c.noStorage)}},write:{cachedResponse:function(e,t){void 0===O.Storage?x.error(c.noStorage):(M.isPlainObject(t)&&(t=JSON.stringify(t)),sessionStorage.setItem(e+x.get.normalizedData(),t),x.verbose("Storing cached response for url",e,f.data,t))}},query:function(){if(x.is.disabled())x.debug("Element is disabled API request aborted");else{if(x.is.loading()){if(!f.interruptRequests)return void x.debug("Cancelling request, previous request is still pending");x.debug("Interrupting previous request"),x.abort()}f.defaultData&&M.extend(!0,f.urlData,x.get.defaultData()),f.serializeForm&&(f.data=x.add.formData(o||f.data)),!1===(i=x.get.settings())?(x.cancelled=!0,x.error(c.beforeSend)):(x.cancelled=!1,(n=x.get.templatedURL())||x.is.mocked()?((n=x.add.urlData(n))||x.is.mocked())&&(i.url=f.base+n,a=M.extend(!0,{},f,{type:f.method||f.type,data:e,url:f.base+n,beforeSend:f.beforeXHR,success:function(){},failure:function(){},complete:function(){}}),x.debug("Querying URL",a.url),x.verbose("Using AJAX settings",a),"local"===f.cache&&x.read.cachedResponse(n)?(x.debug("Response returned from local cache"),x.request=x.create.request(),x.request.resolveWith(b,[x.read.cachedResponse(n)])):f.throttle?f.throttleFirstRequest||x.timer?(x.debug("Throttling request",f.throttle),clearTimeout(x.timer),x.timer=setTimeout(function(){x.timer&&delete x.timer,x.debug("Sending throttled request",e,a.method),x.send.request()},f.throttle)):(x.debug("Sending request",e,a.method),x.send.request(),x.timer=setTimeout(function(){},f.throttle)):(x.debug("Sending request",e,a.method),x.send.request())):x.error(c.missingURL))}},should:{removeError:function(){return!0===f.hideError||"auto"===f.hideError&&!x.is.form()}},is:{disabled:function(){return 0<m.filter(l.disabled).length},expectingJSON:function(){return"json"===f.dataType||"jsonp"===f.dataType},form:function(){return m.is("form")||h.is("form")},mocked:function(){return f.mockResponse||f.mockResponseAsync||f.response||f.responseAsync},input:function(){return m.is("input")},loading:function(){return!!x.request&&"pending"===x.request.state()},abortedRequest:function(e){return e&&void 0!==e.readyState&&0===e.readyState?(x.verbose("XHR request determined to be aborted"),!0):(x.verbose("XHR request was not aborted"),!1)},validResponse:function(e){return x.is.expectingJSON()&&R(f.successTest)?(x.debug("Checking JSON returned success",f.successTest,e),f.successTest(e)?(x.debug("Response passed success test",e),!0):(x.debug("Response failed success test",e),!1)):(x.verbose("Response is not JSON, skipping validation",f.successTest,e),!0)}},was:{cancelled:function(){return x.cancelled||!1},successful:function(){return x.request&&"resol