You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

1 lines
7.6 KiB

!function(a,b,c,d){a.fn.popup=function(e){var f,g=a(this),h=a.isPlainObject(e)?a.extend(!0,{},a.fn.popup.settings,e):a.fn.popup.settings,i=g.selector||"",j=(new Date).getTime(),k=[],l=arguments[0],m="string"==typeof l,n=[].slice.call(arguments,1);return g.each(function(){var e,g=a(this),o=a(b),p=g.offsetParent(),q=h.inline?g.next(h.selector.popup):o.children(h.selector.popup).last(),r=0,s="."+h.namespace,t=h.namespace+"-module",u=h.selector,v=h.className,w=h.error,x=h.metadata,y=h.namespace,z=this,A=g.data(t);e={initialize:function(){e.debug("Initializing module",g),"hover"==h.on?g.on("mouseenter"+s,e.event.mouseenter).on("mouseleave"+s,e.event.mouseleave):g.on(h.on+""+s,e.event[h.on]),o.on("resize"+s,e.event.resize),e.instantiate()},instantiate:function(){e.verbose("Storing instance of module",e),A=e,g.data(t,A)},refresh:function(){q=h.inline?g.next(u.popup):o.children(u.popup).last(),p=g.offsetParent()},destroy:function(){e.debug("Destroying previous module"),g.off(s).removeData(t)},event:{mouseenter:function(b){var c=this;e.timer=setTimeout(function(){a.proxy(e.toggle,c)(),a(c).hasClass(v.visible)&&b.stopPropagation()},h.delay)},mouseleave:function(){clearTimeout(e.timer),g.is(":visible")&&e.hide()},click:function(b){a.proxy(e.toggle,this)(),a(this).hasClass(v.visible)&&b.stopPropagation()},resize:function(){q.is(":visible")&&e.position()}},create:function(){e.debug("Creating pop-up html");var b=g.data(x.html)||h.html,c=g.data(x.variation)||h.variation,d=g.data(x.title)||h.title,f=g.data(x.content)||g.attr("title")||h.content;b||f||d?(b||(b=h.template({title:d,content:f})),q=a("<div/>").addClass(v.popup).addClass(c).html(b),h.inline?(e.verbose("Inserting popup element inline"),q.insertAfter(g)):(e.verbose("Appending popup element to body"),q.appendTo(a("body"))),a.proxy(h.onInit,q)()):e.error(w.content)},remove:function(){e.debug("Removing popup"),q.remove()},get:{offstagePosition:function(){var c={top:a(b).scrollTop(),bottom:a(b).scrollTop()+a(b).height(),left:0,right:a(b).width()},d={width:q.width(),height:q.outerHeight(),position:q.offset()},e={},f=[];return d.position&&(e={top:d.position.top<c.top,bottom:d.position.top+d.height>c.bottom,right:d.position.left+d.width>c.right,left:d.position.left<c.left}),a.each(e,function(a,b){b&&f.push(a)}),f.length>0?f.join(" "):!1},nextPosition:function(a){switch(a){case"top left":a="bottom left";break;case"bottom left":a="top right";break;case"top right":a="bottom right";break;case"bottom right":a="top center";break;case"top center":a="bottom center";break;case"bottom center":a="right center";break;case"right center":a="left center";break;case"left center":a="top center"}return a}},toggle:function(){g=a(this),e.debug("Toggling pop-up"),e.refresh(),g.hasClass(v.visible)?e.hide():(e.hideAll(),e.show())},position:function(c,d){var f,i,j=(a(b).width(),a(b).height(),g.outerWidth()),k=g.outerHeight(),l=q.width(),m=q.outerHeight(),n=h.inline?g.position():g.offset(),s=h.inline?p.outerWidth():o.outerWidth(),t=h.inline?p.outerHeight():o.outerHeight();switch(c=c||g.data(x.position)||h.position,d=d||g.data(x.arrowOffset)||h.arrowOffset,e.debug("Calculating offset for position",c),c){case"top left":f={top:"auto",bottom:t-n.top+h.distanceAway,left:n.left+d};break;case"top center":f={bottom:t-n.top+h.distanceAway,left:n.left+j/2-l/2+d,top:"auto",right:"auto"};break;case"top right":f={bottom:t-n.top+h.distanceAway,right:s-n.left-j-d,top:"auto",left:"auto"};break;case"left center":f={top:n.top+k/2-m/2,right:s-n.left+h.distanceAway-d,left:"auto",bottom:"auto"};break;case"right center":f={top:n.top+k/2-m/2,left:n.left+j+h.distanceAway+d,bottom:"auto",right:"auto"};break;case"bottom left":f={top:n.top+k+h.distanceAway,left:n.left+d,bottom:"auto",right:"auto"};break;case"bottom center":f={top:n.top+k+h.distanceAway,left:n.left+j/2-l/2+d,bottom:"auto",right:"auto"};break;case"bottom right":f={top:n.top+k+h.distanceAway,right:s-n.left-j-d,left:"auto",bottom:"auto"}}return a.extend(f,{width:q.width()+1}),q.removeAttr("style").removeClass("top right bottom left center").css(f).addClass(c).addClass(v.loading),i=e.get.offstagePosition(),i?(e.debug("Element is outside boundaries ",i),r<h.maxSearchDepth?(c=e.get.nextPosition(c),r++,e.debug("Trying new position: ",c),e.position(c)):(e.error(w.recursion),r=0,!1)):(e.debug("Position is on stage",c),r=0,!0)},show:function(){e.debug("Showing pop-up"),0===q.size()&&e.create(),e.position(),g.addClass(v.visible),q.removeClass(v.loading),"pop"==h.animation&&a.fn.popIn!==d?q.stop().popIn(h.duration,h.easing):q.stop().fadeIn(h.duration,h.easing),"click"==h.on&&h.clicktoClose&&(e.debug("Binding popup close event"),a(c).on("click."+y,e.gracefully.hide)),a.proxy(h.onShow,q)()},hideAll:function(){a(u.popup).filter(":visible").stop().fadeOut(200).prev(g).removeClass(v.visible)},hide:function(){g.removeClass(v.visible),q.is(":visible")&&(e.debug("Hiding pop-up"),"pop"==h.animation&&a.fn.popOut!==d?q.stop().popOut(h.duration,h.easing,function(){q.hide()}):q.stop().fadeOut(h.duration,h.easing)),"click"==h.on&&h.clicktoClose&&a(c).off("click."+y),a.proxy(h.onHide,q)(),h.inline||e.remove()},gracefully:{hide:function(b){0===a(b.target).closest(u.popup).size()&&e.hide()}},setting:function(b,c){return c===d?h[b]:(a.isPlainObject(b)?a.extend(!0,h,b):h[b]=c,void 0)},internal:function(b,c){return c===d?e[b]:(a.isPlainObject(b)?a.extend(!0,e,b):e[b]=c,void 0)},debug:function(){h.debug&&(h.performance?e.performance.log(arguments):e.debug=Function.prototype.bind.call(console.info,console,h.moduleName+":"))},verbose:function(){h.verbose&&h.debug&&(h.performance?e.performance.log(arguments):e.verbose=Function.prototype.bind.call(console.info,console,h.moduleName+":"))},error:function(){e.error=Function.prototype.bind.call(console.warn,console,h.moduleName+":")},performance:{log:function(a){var b,c,d;h.performance&&(b=(new Date).getTime(),d=j||b,c=b-d,j=b,k.push({Element:z,Name:a[0],Arguments:[].slice.call(a,1)||"","Execution Time":c})),clearTimeout(e.performance.timer),e.performance.timer=setTimeout(e.performance.display,100)},display:function(){var b=h.moduleName+":",c=0;j=!1,clearTimeout(e.performance.timer),a.each(k,function(a,b){c+=b["Execution Time"]}),b+=" "+c+"ms",i&&(b+=" '"+i+"'"),(console.group!==d||console.table!==d)&&k.length>0&&(console.groupCollapsed(b),console.table?console.table(k):a.each(k,function(a,b){console.log(b.Name+": "+b["Execution Time"]+"ms")}),console.groupEnd()),k=[]}},invoke:function(b,c,f){var g,h;return c=c||n,f=z||f,"string"==typeof b&&A!==d&&(b=b.split(/[\. ]/),g=b.length-1,a.each(b,function(b,c){a.isPlainObject(A[c])&&b!=g?A=A[c]:A[c]!==d?h=A[c]:e.error(w.method)})),a.isFunction(h)?h.apply(f,c):h||!1}},m?(A===d&&e.initialize(),f=e.invoke(l)):(A!==d&&e.destroy(),e.initialize())}),f?f:this},a.fn.popup.settings={moduleName:"Popup",debug:!0,verbose:!0,performance:!0,namespace:"popup",onInit:function(){},onShow:function(){},onHide:function(){},variation:"",content:!1,html:!1,title:!1,on:"hover",clicktoClose:!0,position:"top center",delay:150,inline:!0,duration:250,easing:"easeOutQuint",animation:"pop",distanceAway:0,arrowOffset:0,maxSearchDepth:10,error:{content:"Your popup has no content specified",method:"The method you called is not defined.",recursion:"Popup attempted to reposition element to fit, but could not find an adequate position."},metadata:{arrowOffset:"arrowOffset",content:"content",html:"html",position:"position",title:"title",variation:"variation"},className:{popup:"ui popup",visible:"visible",loading:"loading"},selector:{popup:".ui.popup"},template:function(a){var b="";return typeof a!==d&&(typeof a.title!==d&&a.title&&(b+='<div class="header">'+a.title+'</div class="header">'),typeof a.content!==d&&a.content&&(b+='<div class="content">'+a.content+"</div>")),b}}}(jQuery,window,document);