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.
11 lines
14 KiB
11 lines
14 KiB
/*
|
|
* # Semantic UI - 1.7.0
|
|
* https://github.com/Semantic-Org/Semantic-UI
|
|
* http://www.semantic-ui.com/
|
|
*
|
|
* Copyright 2014 Contributors
|
|
* Released under the MIT license
|
|
* http://opensource.org/licenses/MIT
|
|
*
|
|
*/
|
|
!function(e,t,o,i){"use strict";e.fn.popup=function(n){var r,s=e(this),a=e(o),l=s.selector||"",p=("ontouchstart"in o.documentElement,(new Date).getTime()),u=[],c=arguments[0],d="string"==typeof c,f=[].slice.call(arguments,1);return s.each(function(){var o,s,g,h=e.isPlainObject(n)?e.extend(!0,{},e.fn.popup.settings,n):e.extend({},e.fn.popup.settings),m=h.selector,b=h.className,v=h.error,y=h.metadata,w=h.namespace,P="."+h.namespace,T="module-"+w,C=e(this),k=e(h.context),x=h.target?e(h.target):C,O=e(t),S=e("body"),j=0,A=!1,R=this,E=C.data(T);g={initialize:function(){g.debug("Initializing module",C),g.refresh(),"click"==h.on?C.on("click"+P,g.toggle):g.get.startEvent()&&C.on(g.get.startEvent()+P,g.event.start).on(g.get.endEvent()+P,g.event.end),h.target&&g.debug("Target set to element",x),O.on("resize"+P,g.event.resize),g.exists()?h.hoverable&&g.bind.popup():g.create(),g.instantiate()},instantiate:function(){g.verbose("Storing instance of module",g),E=g,C.data(T,E)},refresh:function(){h.popup?o=e(h.popup):h.inline&&(o=x.next(h.selector.popup)),h.popup?(o.addClass(b.loading),s=C.offsetParent(),o.offsetParent()[0]!==s[0]&&(g.debug("Moving popup to the same offset parent as activating element"),o.detach().appendTo(s)),o.removeClass(b.loading)):s=h.inline?x.offsetParent():S,s.is("html")&&(g.debug("Page is popups offset parent"),s=S)},reposition:function(){g.refresh(),g.set.position()},destroy:function(){g.debug("Destroying previous module"),o&&!h.preserve&&g.removePopup(),clearTimeout(g.hideTimer),clearTimeout(g.showTimer),C.off(P).removeData(T)},event:{start:function(){var t=e.isPlainObject(h.delay)?h.delay.show:h.delay;clearTimeout(g.hideTimer),g.showTimer=setTimeout(function(){!g.is.hidden()||g.is.active()&&g.is.dropdown()||g.show()},t)},end:function(){var t=e.isPlainObject(h.delay)?h.delay.hide:h.delay;clearTimeout(g.showTimer),g.hideTimer=setTimeout(function(){g.is.visible()&&g.hide()},t)},resize:function(){g.is.visible()&&g.set.position()}},create:function(){var t=C.data(y.html)||h.html,i=C.data(y.variation)||h.variation,n=C.data(y.title)||h.title,r=C.data(y.content)||C.attr("title")||h.content;t||r||n?(g.debug("Creating pop-up html"),t||(t=h.templates.popup({title:n,content:r})),o=e("<div/>").addClass(b.popup).addClass(i).html(t),i&&o.addClass(i),h.inline?(g.verbose("Inserting popup element inline",o),o.insertAfter(C)):(g.verbose("Appending popup element to body",o),o.appendTo(k)),h.hoverable&&g.bind.popup(),h.onCreate.call(o,R)):0!==x.next(h.selector.popup).length?(g.verbose("Pre-existing popup found, reverting to inline"),h.inline=!0,g.refresh(),h.hoverable&&g.bind.popup()):g.debug("No content specified skipping display",R)},toggle:function(){g.debug("Toggling pop-up"),g.is.hidden()?(g.debug("Popup is hidden, showing pop-up"),g.unbind.close(),g.hideAll(),g.show()):(g.debug("Popup is visible, hiding pop-up"),g.hide())},show:function(t){t=e.isFunction(t)?t:function(){},g.debug("Showing pop-up",h.transition),h.preserve||h.popup||g.refresh(),g.exists()||g.create(),o&&g.set.position()&&(g.save.conditions(),g.animate.show(t))},hide:function(t){t=e.isFunction(t)?t:function(){},g.remove.visible(),g.unbind.close(),g.is.visible()&&(g.restore.conditions(),g.animate.hide(t))},hideAll:function(){e(m.popup).filter(":visible").popup("hide")},hideGracefully:function(t){t&&0===e(t.target).closest(m.popup).length?(g.debug("Click occurred outside popup hiding popup"),g.hide()):g.debug("Click was inside popup, keeping popup open")},exists:function(){return o?h.inline||h.popup?g.has.popup():o.closest(k).length>=1?!0:!1:!1},removePopup:function(){g.debug("Removing popup",o),g.has.popup()&&o.remove(),h.onRemove.call(o,R)},save:{conditions:function(){g.cache={title:C.attr("title")},g.cache.title&&C.removeAttr("title"),g.verbose("Saving original attributes",g.cache.title)}},restore:{conditions:function(){return g.cache&&g.cache.title&&(C.attr("title",g.cache.title),g.verbose("Restoring original attributes",g.cache.title)),!0}},animate:{show:function(t){t=e.isFunction(t)?t:function(){},h.transition&&e.fn.transition!==i&&C.transition("is supported")?(g.set.visible(),o.transition({animation:h.transition+" in",queue:!1,debug:h.debug,verbose:h.verbose,duration:h.duration,onComplete:function(){g.bind.close(),t.call(o,R),h.onVisible.call(o,R)}})):(g.set.visible(),o.stop().fadeIn(h.duration,h.easing,function(){g.bind.close(),t.call(o,R),h.onVisible.call(o,R)})),h.onShow.call(o,R)},hide:function(t){t=e.isFunction(t)?t:function(){},g.debug("Hiding pop-up"),h.transition&&e.fn.transition!==i&&C.transition("is supported")?o.transition({animation:h.transition+" out",queue:!1,duration:h.duration,debug:h.debug,verbose:h.verbose,onComplete:function(){g.reset(),t.call(o,R),h.onHidden.call(o,R)}}):o.stop().fadeOut(h.duration,h.easing,function(){g.reset(),t.call(o,R),h.onHidden.call(o,R)}),h.onHide.call(o,R)}},get:{startEvent:function(){return"hover"==h.on?"mouseenter":"focus"==h.on?"focus":!1},endEvent:function(){return"hover"==h.on?"mouseleave":"focus"==h.on?"blur":!1},offstagePosition:function(i){var i=i||!1,n={top:e(t).scrollTop(),bottom:e(t).scrollTop()+e(t).height(),left:0,right:e(t).width()},r={width:o.width(),height:o.height(),offset:o.offset()},s={},a=[];return r.offset&&i&&(g.verbose("Checking if outside viewable area",r.offset),s={top:r.offset.top<n.top,bottom:r.offset.top+r.height>n.bottom,right:r.offset.left+r.width>n.right,left:r.offset.left<n.left}),e.each(s,function(e,t){t&&a.push(e)}),a.length>0?a.join(" "):!1},positions:function(){return{"top left":!1,"top center":!1,"top right":!1,"bottom left":!1,"bottom center":!1,"bottom right":!1,"left center":!1,"right center":!1}},nextPosition:function(e){var t=e.split(" "),o=t[0],i=t[1],n={top:"bottom",bottom:"top",left:"right",right:"left"},r={left:"center",center:"right",right:"left"},s={"top left":"top center","top center":"top right","top right":"right center","right center":"bottom right","bottom right":"bottom center","bottom center":"bottom left","bottom left":"left center","left center":"top left"},a="top"==o||"bottom"==o,l=!1,p=!1,u=!1;return A||(g.verbose("All available positions available"),A=g.get.positions()),g.debug("Recording last position tried",e),A[e]=!0,"opposite"===h.prefer&&(u=[n[o],i],u=u.join(" "),l=A[u]===!0,g.debug("Trying opposite strategy",u)),"adjacent"===h.prefer&&a&&(u=[o,r[i]],u=u.join(" "),p=A[u]===!0,g.debug("Trying adjacent strategy",u)),(p||l)&&(g.debug("Using backup position",u),u=s[e]),u}},set:{position:function(n,r){var a,l,p,u=(e(t).width(),e(t).height(),x.outerWidth()),c=x.outerHeight(),d=o.outerWidth(),f=o.outerHeight(),m=s.outerWidth(),w=s.outerHeight(),P=h.distanceAway,T=x[0],k=h.inline?parseInt(t.getComputedStyle(T).getPropertyValue("margin-top"),10):0,O=h.inline?parseInt(t.getComputedStyle(T).getPropertyValue(g.is.rtl()?"margin-right":"margin-left"),10):0,S=h.inline||h.popup?x.position():x.offset();switch(n=n||C.data(y.position)||h.position,r=r||C.data(y.offset)||h.offset,j==h.maxSearchDepth&&h.lastResort&&(g.debug("Using last resort position to display",h.lastResort),n=h.lastResort),h.inline&&(g.debug("Adding targets margin to calculation"),"left center"==n||"right center"==n?(r+=k,P+=-O):"top left"==n||"top center"==n||"top right"==n?(r+=O,P-=k):(r+=O,P+=k)),g.debug("Calculating popup positioning",n),a=n,g.is.rtl()&&(a=a.replace(/left|right/g,function(e){return"left"==e?"right":"left"}),g.debug("RTL: Popup positioning updated",a)),a){case"top left":l={top:"auto",bottom:w-S.top+P,left:S.left+r,right:"auto"};break;case"top center":l={bottom:w-S.top+P,left:S.left+u/2-d/2+r,top:"auto",right:"auto"};break;case"top right":l={bottom:w-S.top+P,right:m-S.left-u-r,top:"auto",left:"auto"};break;case"left center":l={top:S.top+c/2-f/2+r,right:m-S.left+P,left:"auto",bottom:"auto"};break;case"right center":l={top:S.top+c/2-f/2+r,left:S.left+u+P,bottom:"auto",right:"auto"};break;case"bottom left":l={top:S.top+c+P,left:S.left+r,bottom:"auto",right:"auto"};break;case"bottom center":l={top:S.top+c+P,left:S.left+u/2-d/2+r,bottom:"auto",right:"auto"};break;case"bottom right":l={top:S.top+c+P,right:m-S.left-u-r,left:"auto",bottom:"auto"}}if(l===i&&g.error(v.invalidPosition,n),g.debug("Calculated popup positioning values",l),o.css(l).removeClass(b.position).addClass(n).addClass(b.loading),p=g.get.offstagePosition(n)){if(g.debug("Popup cant fit into viewport",p),j<h.maxSearchDepth)return j++,n=g.get.nextPosition(n),g.debug("Trying new position",n),o?g.set.position(n):!1;if(!h.lastResort)return g.debug("Popup could not find a position in view",o),g.error(v.cannotPlace),g.remove.attempts(),g.remove.loading(),g.reset(),!1}return g.debug("Position is on stage",n),g.remove.attempts(),g.set.fluidWidth(),g.remove.loading(),!0},fluidWidth:function(){h.setFluidWidth&&o.hasClass(b.fluid)&&o.css("width",s.width())},visible:function(){C.addClass(b.visible)}},remove:{loading:function(){o.removeClass(b.loading)},visible:function(){C.removeClass(b.visible)},attempts:function(){g.verbose("Resetting all searched positions"),j=0,A=!1}},bind:{popup:function(){g.verbose("Allowing hover events on popup to prevent closing"),o&&g.has.popup()&&o.on("mouseenter"+P,g.event.start).on("mouseleave"+P,g.event.end)},close:function(){(h.hideOnScroll===!0||"auto"==h.hideOnScroll&&"click"!=h.on)&&(a.one("touchmove"+P,g.hideGracefully).one("scroll"+P,g.hideGracefully),k.one("touchmove"+P,g.hideGracefully).one("scroll"+P,g.hideGracefully)),"click"==h.on&&h.closable&&(g.verbose("Binding popup close event to document"),a.on("click"+P,function(e){g.verbose("Pop-up clickaway intent detected"),g.hideGracefully.call(R,e)}))}},unbind:{close:function(){(h.hideOnScroll===!0||"auto"==h.hideOnScroll&&"click"!=h.on)&&(a.off("scroll"+P,g.hide),k.off("scroll"+P,g.hide)),"click"==h.on&&h.closable&&(g.verbose("Removing close event from document"),a.off("click"+P))}},has:{popup:function(){return o.length>0}},is:{active:function(){return C.hasClass(b.active)},animating:function(){return o&&o.is(":animated")||o.hasClass(b.animating)},visible:function(){return o&&o.is(":visible")},dropdown:function(){return C.hasClass(b.dropdown)},hidden:function(){return!g.is.visible()},rtl:function(){return"rtl"==C.css("direction")}},reset:function(){g.remove.visible(),h.preserve||h.popup?e.fn.transition!==i&&o.transition("remove transition"):g.removePopup()},setting:function(t,o){if(e.isPlainObject(t))e.extend(!0,h,t);else{if(o===i)return h[t];h[t]=o}},internal:function(t,o){if(e.isPlainObject(t))e.extend(!0,g,t);else{if(o===i)return g[t];g[t]=o}},debug:function(){h.debug&&(h.performance?g.performance.log(arguments):(g.debug=Function.prototype.bind.call(console.info,console,h.name+":"),g.debug.apply(console,arguments)))},verbose:function(){h.verbose&&h.debug&&(h.performance?g.performance.log(arguments):(g.verbose=Function.prototype.bind.call(console.info,console,h.name+":"),g.verbose.apply(console,arguments)))},error:function(){g.error=Function.prototype.bind.call(console.error,console,h.name+":"),g.error.apply(console,arguments)},performance:{log:function(e){var t,o,i;h.performance&&(t=(new Date).getTime(),i=p||t,o=t-i,p=t,u.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:R,"Execution Time":o})),clearTimeout(g.performance.timer),g.performance.timer=setTimeout(g.performance.display,100)},display:function(){var t=h.name+":",o=0;p=!1,clearTimeout(g.performance.timer),e.each(u,function(e,t){o+=t["Execution Time"]}),t+=" "+o+"ms",l&&(t+=" '"+l+"'"),(console.group!==i||console.table!==i)&&u.length>0&&(console.groupCollapsed(t),console.table?console.table(u):e.each(u,function(e,t){console.log(t.Name+": "+t["Execution Time"]+"ms")}),console.groupEnd()),u=[]}},invoke:function(t,o,n){var s,a,l,p=E;return o=o||f,n=R||n,"string"==typeof t&&p!==i&&(t=t.split(/[\. ]/),s=t.length-1,e.each(t,function(o,n){var r=o!=s?n+t[o+1].charAt(0).toUpperCase()+t[o+1].slice(1):t;if(e.isPlainObject(p[r])&&o!=s)p=p[r];else{if(p[r]!==i)return a=p[r],!1;if(!e.isPlainObject(p[n])||o==s)return p[n]!==i?(a=p[n],!1):!1;p=p[n]}})),e.isFunction(a)?l=a.apply(n,o):a!==i&&(l=a),e.isArray(r)?r.push(l):r!==i?r=[r,l]:l!==i&&(r=l),a}},d?(E===i&&g.initialize(),g.invoke(c)):(E!==i&&g.destroy(),g.initialize())}),r!==i?r:this},e.fn.popup.settings={name:"Popup",debug:!1,verbose:!0,performance:!0,namespace:"popup",onCreate:function(){},onRemove:function(){},onShow:function(){},onVisible:function(){},onHide:function(){},onHidden:function(){},variation:"",content:!1,html:!1,title:!1,on:"hover",closable:!0,hideOnScroll:"auto",context:"body",position:"top left",prefer:"opposite",lastResort:!1,delay:{show:30,hide:0},setFluidWidth:!0,target:!1,popup:!1,inline:!1,preserve:!0,hoverable:!1,duration:200,easing:"easeOutQuint",transition:"scale",distanceAway:0,offset:0,maxSearchDepth:20,error:{invalidPosition:"The position you specified is not a valid position",cannotPlace:"No visible position could be found for the popup",method:"The method you called is not defined."},metadata:{content:"content",html:"html",offset:"offset",position:"position",title:"title",variation:"variation"},className:{active:"active",animating:"animating",dropdown:"dropdown",fluid:"fluid",loading:"loading",popup:"ui popup",position:"top left center bottom right",visible:"visible"},selector:{popup:".ui.popup"},templates:{escape:function(e){var t=/[&<>"'`]/g,o=/[&<>"'`]/,i={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},n=function(e){return i[e]};return o.test(e)?e.replace(t,n):e},popup:function(t){var o="",n=e.fn.popup.settings.templates.escape;return typeof t!==i&&(typeof t.title!==i&&t.title&&(t.title=n(t.title),o+='<div class="header">'+t.title+"</div>"),typeof t.content!==i&&t.content&&(t.content=n(t.content),o+='<div class="content">'+t.content+"</div>")),o}}},e.extend(e.easing,{easeOutQuad:function(e,t,o,i,n){return-i*(t/=n)*(t-2)+o}})}(jQuery,window,document);
|