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
8.0 KiB

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