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