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