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

11 lines
No EOL
9.1 KiB
JavaScript

/*
* # Fomantic UI - 2.9.3
* https://github.com/fomantic/Fomantic-UI
* https://fomantic-ui.com/
*
* Copyright 2023 Contributors
* Released under the MIT license
* https://opensource.org/licenses/MIT
*
*/
!function(W,e,Y){"use strict";e=void 0!==e&&e.Math===Math?e:globalThis,W.fn.shape=function(m){var v,b=W(this),x=Date.now(),y=[],C=m,S="string"==typeof C,w=[].slice.call(arguments,1);return b.each(function(){var i,n,a=W.isPlainObject(m)?W.extend(!0,{},W.fn.shape.settings,m):W.extend({},W.fn.shape.settings),e=a.namespace,r=a.selector,d=a.error,s=a.className,t="."+e,o="module-"+e,l=W(this),c=l.find(">"+r.sides),u=c.find(">"+r.side),f=!1,g=this,h=l.data(o),p={initialize:function(){p.verbose("Initializing module for",g),p.set.defaultSide(),p.instantiate()},instantiate:function(){p.verbose("Storing instance of module",p),h=p,l.data(o,h)},destroy:function(){p.verbose("Destroying previous module for",g),l.removeData(o).off(t)},refresh:function(){p.verbose("Refreshing selector cache for",g),l=W(g),c=W(this).find(r.sides),u=W(this).find(r.side)},repaint:function(){p.verbose("Forcing repaint event");(c[0]||Y.createElement("div")).offsetWidth},animate:function(e,t){p.verbose("Animating box with properties",e),t=t||function(e){p.verbose("Executing animation callback"),void 0!==e&&e.stopPropagation(),p.reset(),p.set.active()},a.onBeforeChange.call(n[0]),p.verbose("Starting CSS animation"),l.addClass(s.animating),c.css(e).one("transitionend",t),p.set.duration(a.duration),requestAnimationFrame(function(){l.addClass(s.animating),i.addClass(s.hidden)})},queue:function(e){p.debug("Queueing animation of",e),c.one("transitionend",function(){p.debug("Executing queued animation"),setTimeout(function(){l.shape(e)},0)})},reset:function(){p.verbose("Animating states reset"),l.removeClass(s.animating).attr("style","").removeAttr("style"),c.attr("style","").removeAttr("style"),u.attr("style","").removeAttr("style").removeClass(s.hidden),n.removeClass(s.animating).attr("style","").removeAttr("style")},is:{complete:function(){return u.filter("."+s.active)[0]===n[0]},animating:function(){return l.hasClass(s.animating)},hidden:function(){return 0<l.closest(":hidden").length}},set:{defaultSide:function(){i=u.filter("."+a.className.active),n=0<i.next(r.side).length?i.next(r.side):u.first(),f=!1,p.verbose("Active side set to",i),p.verbose("Next side set to",n)},duration:function(e){e=e||a.duration,p.verbose("Setting animation duration",e="number"==typeof e?e+"ms":e),!a.duration&&0!==a.duration||c.add(u).css({"transition-duration":e})},currentStageSize:function(){var e=u.filter("."+a.className.active),t=e.outerWidth(!0),e=e.outerHeight(!0);l.css({width:t,height:e})},stageSize:function(){var e=l.clone().addClass(s.loading),t=e.find(">"+r.sides+">"+r.side),i=t.filter("."+a.className.active),t=f?t.eq(f):0<i.next(r.side).length?i.next(r.side):t.first(),n="next"===a.width?t.outerWidth(!0):"initial"===a.width?l.width():a.width,o="next"===a.height?t.outerHeight(!0):"initial"===a.height?l.height():a.height;i.removeClass(s.active),t.addClass(s.active),e.insertAfter(l),e.remove(),"auto"!==a.width&&(l.css("width",n+a.jitter),p.verbose("Specifying width during animation",n)),"auto"!==a.height&&(l.css("height",o+a.jitter),p.verbose("Specifying height during animation",o))},nextSide:function(e){f=e,n=u.filter(e),f=u.index(n),0===n.length&&(p.set.defaultSide(),p.error(d.side)),p.verbose("Next side manually set to",n)},active:function(){p.verbose("Setting new side to active",n),u.removeClass(s.active),n.addClass(s.active),a.onChange.call(n[0]),p.set.defaultSide()}},flip:{to:function(e,t){var i;p.is.hidden()?p.debug("Module not visible",n):!p.is.complete()||p.is.animating()||a.allowRepeats?(i=p.get.transform[e](),p.is.animating()?p.queue("flip "+e):(p.debug("Flipping "+e,n),p.set.stageSize(),p.stage[t](),p.animate(i))):p.debug("Side already visible",n)},up:function(){p.flip.to("up","above")},down:function(){p.flip.to("down","below")},left:function(){p.flip.to("left","left")},right:function(){p.flip.to("right","right")},over:function(){p.flip.to("over","behind")},back:function(){p.flip.to("back","behind")}},get:{transform:{up:function(){var e=i.outerHeight(!0)/2;return{transform:"translateY("+(n.outerHeight(!0)-e)+"px) translateZ(-"+e+"px) rotateX(-90deg)"}},down:function(){var e=i.outerHeight(!0)/2;return{transform:"translateY(-"+e+"px) translateZ(-"+e+"px) rotateX(90deg)"}},left:function(){var e=i.outerWidth(!0)/2;return{transform:"translateX("+(n.outerWidth(!0)-e)+"px) translateZ(-"+e+"px) rotateY(90deg)"}},right:function(){var e=i.outerWidth(!0)/2;return{transform:"translateX(-"+e+"px) translateZ(-"+e+"px) rotateY(-90deg)"}},over:function(){return{transform:"translateX("+-(i.outerWidth(!0)-n.outerWidth(!0))/2+"px) rotateY(180deg)"}},back:function(){return{transform:"translateX("+-(i.outerWidth(!0)-n.outerWidth(!0))/2+"px) rotateY(-180deg)"}}},nextSide:function(){return 0<i.next(r.side).length?i.next(r.side):u.first()}},stage:{above:function(){var e={origin:(i.outerHeight(!0)-n.outerHeight(!0))/2,depth:{active:n.outerHeight(!0)/2,next:i.outerHeight(!0)/2}};p.verbose("Setting the initial animation position as above",n,e),i.css({transform:"rotateX(0deg)"}),n.addClass(s.animating).css({top:e.origin+"px",transform:"rotateX(90deg) translateZ("+e.depth.next+"px) translateY(-"+e.depth.active+"px)"})},below:function(){var e={origin:(i.outerHeight(!0)-n.outerHeight(!0))/2,depth:{active:n.outerHeight(!0)/2,next:i.outerHeight(!0)/2}};p.verbose("Setting the initial animation position as below",n,e),i.css({transform:"rotateX(0deg)"}),n.addClass(s.animating).css({top:e.origin+"px",transform:"rotateX(-90deg) translateZ("+e.depth.next+"px) translateY("+e.depth.active+"px)"})},left:function(){var e=i.outerWidth(!0),t=n.outerWidth(!0),t={origin:(e-t)/2,depth:{active:t/2,next:e/2}};p.verbose("Setting the initial animation position as left",n,t),i.css({transform:"rotateY(0deg)"}),n.addClass(s.animating).css({left:t.origin+"px",transform:"rotateY(-90deg) translateZ("+t.depth.next+"px) translateX(-"+t.depth.active+"px)"})},right:function(){var e=i.outerWidth(!0),t=n.outerWidth(!0),t={origin:(e-t)/2,depth:{active:t/2,next:e/2}};p.verbose("Setting the initial animation position as right",n,t),i.css({transform:"rotateY(0deg)"}),n.addClass(s.animating).css({left:t.origin+"px",transform:"rotateY(90deg) translateZ("+t.depth.next+"px) translateX("+t.depth.active+"px)"})},behind:function(){var e=i.outerWidth(!0),t=n.outerWidth(!0),t={origin:(e-t)/2,depth:{active:t/2,next:e/2}};p.verbose("Setting the initial animation position as behind",n,t),i.css({transform:"rotateY(0deg)"}),n.addClass(s.animating).css({left:t.origin+"px",transform:"rotateY(-180deg)"})}},setting:function(e,t){if(p.debug("Changing setting",e,t),W.isPlainObject(e))W.extend(!0,a,e);else{if(void 0===t)return a[e];W.isPlainObject(a[e])?W.extend(!0,a[e],t):a[e]=t}},internal:function(e,t){if(W.isPlainObject(e))W.extend(!0,p,e);else{if(void 0===t)return p[e];p[e]=t}},debug:function(){!a.silent&&a.debug&&(a.performance?p.performance.log(arguments):(p.debug=Function.prototype.bind.call(console.info,console,a.name+":"),p.debug.apply(console,arguments)))},verbose:function(){!a.silent&&a.verbose&&a.debug&&(a.performance?p.performance.log(arguments):(p.verbose=Function.prototype.bind.call(console.info,console,a.name+":"),p.verbose.apply(console,arguments)))},error:function(){a.silent||(p.error=Function.prototype.bind.call(console.error,console,a.name+":"),p.error.apply(console,arguments))},performance:{log:function(e){var t,i;a.performance&&(i=(t=Date.now())-(x||t),x=t,y.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:g,"Execution Time":i})),clearTimeout(p.performance.timer),p.performance.timer=setTimeout(function(){p.performance.display()},500)},display:function(){var e=a.name+":",i=0;x=!1,clearTimeout(p.performance.timer),W.each(y,function(e,t){i+=t["Execution Time"]}),e+=" "+i+"ms",1<b.length&&(e+=" ("+b.length+")"),0<y.length&&(console.groupCollapsed(e),console.table?console.table(y):W.each(y,function(e,t){console.log(t.Name+": "+t["Execution Time"]+"ms")}),console.groupEnd()),y=[]}},invoke:function(n,e,t){var o,a,i,r,s=h;return e=e||w,t=t||g,"string"==typeof n&&void 0!==s&&(n=n.split(/[ .]/),o=n.length-1,W.each(n,function(e,t){var i=e!==o?t+n[e+1].charAt(0).toUpperCase()+n[e+1].slice(1):n;if(W.isPlainObject(s[i])&&e!==o)s=s[i];else{if(void 0!==s[i])return a=s[i],!1;{if(!W.isPlainObject(s[t])||e===o)return void 0!==s[t]?a=s[t]:p.error(d.method,n),!1;s=s[t]}}})),"function"==typeof(r=a)&&"number"!=typeof r.nodeType?i=a.apply(t,e):void 0!==a&&(i=a),Array.isArray(v)?v.push(i):void 0!==v?v=[v,i]:void 0!==i&&(v=i),a}};S?(void 0===h&&p.initialize(),0<(e=l.find("input")).length?(e.trigger("blur"),setTimeout(function(){p.invoke(C)},150)):p.invoke(C)):(void 0!==h&&h.invoke("destroy"),p.initialize())}),void 0!==v?v:this},W.fn.shape.settings={name:"Shape",silent:!1,debug:!1,verbose:!1,jitter:0,performance:!0,namespace:"shape",width:"initial",height:"initial",onBeforeChange:function(){},onChange:function(){},allowRepeats:!1,duration:!1,error:{side:"You tried to switch to a side that does not exist.",method:"The method you called is not defined"},className:{animating:"animating",hidden:"hidden",loading:"loading",active:"active"},selector:{sides:".sides",side:".side"}}}(jQuery,window,document);