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