wishthis/semantic/dist/components/shape.min.js
2022-02-23 22:46:34 +01:00

11 lines
No EOL
9.7 KiB
JavaScript

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