/* * # Semantic UI * https://github.com/Semantic-Org/Semantic-UI * http://beta.semantic-ui.com/ * * Copyright 2014 Contributors * Released under the MIT license * http://opensource.org/licenses/MIT * */ !function(e,i,n,o){"use strict";e.fn.modal=function(t){var s,a=e(this),c=e(i),r=e(n),l=e("body"),u=a.selector||"",d=(new Date).getTime(),m=[],f=arguments[0],g="string"==typeof f,h=[].slice.call(arguments,1),p=i.requestAnimationFrame||i.mozRequestAnimationFrame||i.webkitRequestAnimationFrame||i.msRequestAnimationFrame||function(e){setTimeout(e,0)};return a.each(function(){var a,b,v,y,k,w,x=e.isPlainObject(t)?e.extend(!0,{},e.fn.modal.settings,t):e.extend({},e.fn.modal.settings),H=x.selector,z=x.className,S=x.namespace,A=x.error,D="."+S,F="module-"+S,C=e(this),T=e(x.context),M=C.find(H.close),O=this,E=C.data(F);w={initialize:function(){return w.verbose("Initializing dimmer",T),e.fn.dimmer===o?void w.error(A.dimmer):(y=T.dimmer({debug:x.debug,dimmerName:"modals",closable:!1,useCSS:!0,duration:{show:.9*x.duration,hide:1.1*x.duration}}),x.detachable&&y.dimmer("add content",C),k=y.dimmer("get dimmer"),b=C.siblings(H.modal),a=b.add(C),w.verbose("Attaching close events",M),M.on("click"+D,w.event.close),c.on("resize"+D,w.event.resize),void w.instantiate())},instantiate:function(){w.verbose("Storing instance of modal"),E=w,C.data(F,E)},destroy:function(){w.verbose("Destroying previous modal"),C.removeData(F).off(D),M.off(D),T.dimmer("destroy")},refresh:function(){w.remove.scrolling(),w.cacheSizes(),w.set.screenHeight(),w.set.type(),w.set.position()},attachEvents:function(i,n){var o=e(i);n=e.isFunction(w[n])?w[n]:w.toggle,o.size()>0?(w.debug("Attaching modal events to element",i,n),o.off(D).on("click"+D,n)):w.error(A.notFound,i)},event:{close:function(){w.verbose("Closing element pressed"),e(this).is(H.approve)?e.proxy(x.onApprove,O)()!==!1?w.hide():w.verbose("Approve callback returned false cancelling hide"):e(this).is(H.deny)?e.proxy(x.onDeny,O)()!==!1?w.hide():w.verbose("Deny callback returned false cancelling hide"):w.hide()},click:function(i){0===e(i.target).closest(H.modal).size()&&(w.debug("Dimmer clicked, hiding all modals"),x.allowMultiple?w.hide():w.hideAll(),i.stopImmediatePropagation())},debounce:function(e,i){clearTimeout(w.timer),w.timer=setTimeout(e,i)},keyboard:function(e){var i=e.which,n=27;i==n&&(x.closable?(w.debug("Escape key pressed hiding modal"),w.hide()):w.debug("Escape key pressed, but closable is set to false"),e.preventDefault())},resize:function(){y.dimmer("is active")&&p(w.refresh)}},toggle:function(){w.is.active()||w.is.animating()?w.hide():w.show()},show:function(i){i=e.isFunction(i)?i:function(){},w.showDimmer(),w.showModal(i)},showModal:function(i){i=e.isFunction(i)?i:function(){},w.is.active()?w.debug("Modal is already visible"):b.filter(":visible").size()>0&&!x.allowMultiple?(w.debug("Other modals visible, queueing show animation"),w.hideOthers(w.showModal)):(e.proxy(x.onShow,O)(),x.transition&&e.fn.transition!==o&&C.transition("is supported")?(w.debug("Showing modal with css animations"),C.transition({debug:x.debug,animation:x.transition+" in",queue:!1,duration:x.duration,onStart:function(){w.cacheSizes(),w.set.position(),w.set.screenHeight(),w.set.type(),w.set.clickaway()},onComplete:function(){e.proxy(x.onVisible,O)(),w.add.keyboardShortcuts(),w.save.focus(),w.set.active(),w.set.autofocus(),i()}})):(w.debug("Showing modal with javascript"),C.fadeIn(x.duration,x.easing,function(){e.proxy(x.onVisible,O)(),w.add.keyboardShortcuts(),w.save.focus(),w.set.active(),i()})))},showDimmer:function(){y.dimmer("is active")?w.debug("Dimmer already visible"):(w.debug("Showing dimmer"),y.dimmer("show"))},hide:function(i){i=e.isFunction(i)?i:function(){},a.filter(":visible").size()<=1&&w.hideDimmer(),w.hideModal(i)},hideDimmer:function(){return y.dimmer("is active")||y.dimmer("is animating")?(w.debug("Hiding dimmer"),w.remove.clickaway(),void y.dimmer("hide",function(){x.transition&&e.fn.transition!==o&&C.transition("is supported")&&w.remove.screenHeight(),w.remove.active()})):void w.debug("Dimmer is not visible cannot hide")},hideModal:function(i){i=e.isFunction(i)?i:function(){},w.debug("Hiding modal"),e.proxy(x.onHide,O)(),x.transition&&e.fn.transition!==o&&C.transition("is supported")?C.transition({debug:x.debug,animation:x.transition+" out",queue:!1,duration:x.duration,onStart:function(){w.remove.keyboardShortcuts()},onComplete:function(){e.proxy(x.onHidden,O)(),w.remove.active(),w.restore.focus(),i()}}):(w.remove.keyboardShortcuts(),C.fadeOut(x.duration,x.easing,function(){e.proxy(x.onHidden,O)(),w.remove.active(),w.restore.focus(),i()}))},hideAll:function(i){i=e.isFunction(i)?i:function(){},a.is(":visible")&&(w.debug("Hiding all visible modals"),w.hideDimmer(),a.filter(":visible").modal("hide modal",i))},hideOthers:function(i){i=e.isFunction(i)?i:function(){},b.is(":visible")&&(w.debug("Hiding other modals",b),b.filter(":visible").modal("hide modal",i))},add:{keyboardShortcuts:function(){w.verbose("Adding keyboard shortcuts"),r.on("keyup"+D,w.event.keyboard)}},save:{focus:function(){v=e(n.activeElement).blur()}},restore:{focus:function(){v&&v.size()>0&&v.focus()}},remove:{active:function(){C.removeClass(z.active)},clickaway:function(){x.closable&&k.off("click"+D)},screenHeight:function(){w.cache.height>w.cache.pageHeight&&(w.debug("Removing page height"),l.css("height",""))},keyboardShortcuts:function(){w.verbose("Removing keyboard shortcuts"),r.off("keyup"+D)},scrolling:function(){y.removeClass(z.scrolling),C.removeClass(z.scrolling)}},cacheSizes:function(){var o=C.outerHeight();0!==o&&(w.cache={pageHeight:e(n).outerHeight(),height:o+x.offset,contextHeight:"body"==x.context?e(i).height():y.height()}),w.debug("Caching modal and container sizes",w.cache)},can:{fit:function(){return w.cache.height0?i:e;n.first().focus()}},clickaway:function(){x.closable&&k.off("click"+D).on("click"+D,w.event.click)},screenHeight:function(){w.cache.height>w.cache.pageHeight&&(w.debug("Modal is taller than page content, resizing page height"),l.css("height",w.cache.height+x.padding))},active:function(){C.addClass(z.active)},scrolling:function(){y.addClass(z.scrolling),C.addClass(z.scrolling)},type:function(){w.can.fit()?(w.verbose("Modal fits on screen"),w.remove.scrolling()):(w.verbose("Modal cannot fit on screen setting to scrolling"),w.set.scrolling())},position:function(){w.verbose("Centering modal on page",w.cache),C.css(w.can.fit()?{top:"",marginTop:-(w.cache.height/2)}:{marginTop:"",top:r.scrollTop()})}},setting:function(i,n){if(w.debug("Changing setting",i,n),e.isPlainObject(i))e.extend(!0,x,i);else{if(n===o)return x[i];x[i]=n}},internal:function(i,n){if(e.isPlainObject(i))e.extend(!0,w,i);else{if(n===o)return w[i];w[i]=n}},debug:function(){x.debug&&(x.performance?w.performance.log(arguments):(w.debug=Function.prototype.bind.call(console.info,console,x.name+":"),w.debug.apply(console,arguments)))},verbose:function(){x.verbose&&x.debug&&(x.performance?w.performance.log(arguments):(w.verbose=Function.prototype.bind.call(console.info,console,x.name+":"),w.verbose.apply(console,arguments)))},error:function(){w.error=Function.prototype.bind.call(console.error,console,x.name+":"),w.error.apply(console,arguments)},performance:{log:function(e){var i,n,o;x.performance&&(i=(new Date).getTime(),o=d||i,n=i-o,d=i,m.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:O,"Execution Time":n})),clearTimeout(w.performance.timer),w.performance.timer=setTimeout(w.performance.display,100)},display:function(){var i=x.name+":",n=0;d=!1,clearTimeout(w.performance.timer),e.each(m,function(e,i){n+=i["Execution Time"]}),i+=" "+n+"ms",u&&(i+=" '"+u+"'"),(console.group!==o||console.table!==o)&&m.length>0&&(console.groupCollapsed(i),console.table?console.table(m):e.each(m,function(e,i){console.log(i.Name+": "+i["Execution Time"]+"ms")}),console.groupEnd()),m=[]}},invoke:function(i,n,t){var a,c,r,l=E;return n=n||h,t=O||t,"string"==typeof i&&l!==o&&(i=i.split(/[\. ]/),a=i.length-1,e.each(i,function(n,t){var s=n!=a?t+i[n+1].charAt(0).toUpperCase()+i[n+1].slice(1):i;if(e.isPlainObject(l[s])&&n!=a)l=l[s];else{if(l[s]!==o)return c=l[s],!1;if(!e.isPlainObject(l[t])||n==a)return l[t]!==o?(c=l[t],!1):!1;l=l[t]}})),e.isFunction(c)?r=c.apply(t,n):c!==o&&(r=c),e.isArray(s)?s.push(r):s!==o?s=[s,r]:r!==o&&(s=r),c}},g?(E===o&&w.initialize(),w.invoke(f)):(E!==o&&w.destroy(),w.initialize())}),s!==o?s:this},e.fn.modal.settings={name:"Modal",namespace:"modal",debug:!1,verbose:!0,performance:!0,allowMultiple:!1,detachable:!0,closable:!0,autofocus:!0,context:"body",duration:500,easing:"easeOutExpo",offset:0,transition:"scale",padding:30,onShow:function(){},onHide:function(){},onVisible:function(){},onHidden:function(){},onApprove:function(){return!0},onDeny:function(){return!0},selector:{close:".close, .actions .button",approve:".actions .positive, .actions .approve, .actions .ok",deny:".actions .negative, .actions .deny, .actions .cancel",modal:".ui.modal"},error:{dimmer:"UI Dimmer, a required component is not included in this page",method:"The method you called is not defined.",notFound:"The element you specified could not be found"},className:{active:"active",scrolling:"scrolling"}}}(jQuery,window,document);