blue-twilight/public/semantic-ui/components/modal.min.js

10 lines
11 KiB
JavaScript
Raw Normal View History

/*!
* # Semantic UI 2.2.9 - Modal
* http://github.com/semantic-org/semantic-ui/
*
*
* Released under the MIT license
* http://opensource.org/licenses/MIT
*
*/
!function(e,i,n,t){"use strict";i=void 0!==i&&i.Math==Math?i:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")(),e.fn.modal=function(t){var o,a=e(this),r=e(i),s=e(n),c=e("body"),l=a.selector||"",d=(new Date).getTime(),u=[],m=arguments[0],f="string"==typeof m,g=[].slice.call(arguments,1),h=i.requestAnimationFrame||i.mozRequestAnimationFrame||i.webkitRequestAnimationFrame||i.msRequestAnimationFrame||function(e){setTimeout(e,0)};return a.each(function(){var a,v,b,p,y,k,w,M,S,C=e.isPlainObject(t)?e.extend(!0,{},e.fn.modal.settings,t):e.extend({},e.fn.modal.settings),F=C.selector,A=C.className,D=C.namespace,H=C.error,T="."+D,x="module-"+D,z=e(this),O=e(C.context),q=z.find(F.close),E=this,j=z.data(x);S={initialize:function(){S.verbose("Initializing dimmer",O),S.create.id(),S.create.dimmer(),S.refreshModals(),S.bind.events(),C.observeChanges&&S.observeChanges(),S.instantiate()},instantiate:function(){S.verbose("Storing instance of modal"),j=S,z.data(x,j)},create:{dimmer:function(){var i={debug:C.debug,dimmerName:"modals",duration:{show:C.duration,hide:C.duration}},n=e.extend(!0,i,C.dimmerSettings);if(C.inverted&&(n.variation=void 0!==n.variation?n.variation+" inverted":"inverted"),void 0===e.fn.dimmer)return void S.error(H.dimmer);S.debug("Creating dimmer with settings",n),p=O.dimmer(n),C.detachable?(S.verbose("Modal is detachable, moving content into dimmer"),p.dimmer("add content",z)):S.set.undetached(),C.blurring&&p.addClass(A.blurring),y=p.dimmer("get dimmer")},id:function(){w=(Math.random().toString(16)+"000000000").substr(2,8),k="."+w,S.verbose("Creating unique id for element",w)}},destroy:function(){S.verbose("Destroying previous modal"),z.removeData(x).off(T),r.off(k),y.off(k),q.off(T),O.dimmer("destroy")},observeChanges:function(){"MutationObserver"in i&&(M=new MutationObserver(function(e){S.debug("DOM tree modified, refreshing"),S.refresh()}),M.observe(E,{childList:!0,subtree:!0}),S.debug("Setting up mutation observer",M))},refresh:function(){S.remove.scrolling(),S.cacheSizes(),S.set.screenHeight(),S.set.type(),S.set.position()},refreshModals:function(){v=z.siblings(F.modal),a=v.add(z)},attachEvents:function(i,n){var t=e(i);n=e.isFunction(S[n])?S[n]:S.toggle,t.length>0?(S.debug("Attaching modal events to element",i,n),t.off(T).on("click"+T,n)):S.error(H.notFound,i)},bind:{events:function(){S.verbose("Attaching events"),z.on("click"+T,F.close,S.event.close).on("click"+T,F.approve,S.event.approve).on("click"+T,F.deny,S.event.deny),r.on("resize"+k,S.event.resize)}},get:{id:function(){return(Math.random().toString(16)+"000000000").substr(2,8)}},event:{approve:function(){if(C.onApprove.call(E,e(this))===!1)return void S.verbose("Approve callback returned false cancelling hide");S.hide()},deny:function(){if(C.onDeny.call(E,e(this))===!1)return void S.verbose("Deny callback returned false cancelling hide");S.hide()},close:function(){S.hide()},click:function(i){var t=e(i.target),o=t.closest(F.modal).length>0,a=e.contains(n.documentElement,i.target);!o&&a&&(S.debug("Dimmer clicked, hiding all modals"),S.is.active()&&(S.remove.clickaway(),C.allowMultiple?S.hide():S.hideAll()))},debounce:function(e,i){clearTimeout(S.timer),S.timer=setTimeout(e,i)},keyboard:function(e){27==e.which&&(C.closable?(S.debug("Escape key pressed hiding modal"),S.hide()):S.debug("Escape key pressed, but closable is set to false"),e.preventDefault())},resize:function(){p.dimmer("is active")&&h(S.refresh)}},toggle:function(){S.is.active()||S.is.animating()?S.hide():S.show()},show:function(i){i=e.isFunction(i)?i:function(){},S.refreshModals(),S.showModal(i)},hide:function(i){i=e.isFunction(i)?i:function(){},S.refreshModals(),S.hideModal(i)},showModal:function(i){i=e.isFunction(i)?i:function(){},S.is.animating()||!S.is.active()?(S.showDimmer(),S.cacheSizes(),S.set.position(),S.set.screenHeight(),S.set.type(),S.set.clickaway(),!C.allowMultiple&&S.others.active()?S.hideOthers(S.showModal):(C.onShow.call(E),C.transition&&void 0!==e.fn.transition&&z.transition("is supported")?(S.debug("Showing modal with css animations"),z.transition({debug