| Current Path : /home/lejardintz/www/media/foundry/3.1/scripts/ |
| Current File : /home/lejardintz/www/media/foundry/3.1/scripts/popbox.min.js |
!function(){var moduleFactory=function($){var module=this;$.require().script("ui/position").done(function(){var exports=function(){$.fn.popbox=function(options){if($.isPlainObject(options))return this.each(function(){var button=$(this),popbox=Popbox.get(button);popbox?popbox.update(options):popbox=new Popbox(button,options)}),this;if($.isString(options)){var ret,button=$(this[0]),popbox=Popbox.get(button)||new Popbox(button),method=popbox[options];return $.isFunction(method)&&(ret=method.apply(popbox,$.makeArray(arguments).slice(1))),ret||this
}return this};var Popbox=function(button,options){var popbox=this;button.data("popbox",popbox),$.isString(options)&&(options={content:options});var elementOptions={},content=button.attr("data-popbox"),toggle=button.attr("data-popbox-toggle"),position=button.attr("data-popbox-position"),collision=button.attr("data-popbox-collision"),type=button.attr("data-popbox-type"),id=button.attr("data-popbox-id");content&&(elementOptions.content=content),toggle&&(elementOptions.toggle=toggle),type&&(elementOptions.type=type),position&&(elementOptions.position=position),collision&&(elementOptions.collision=collision),id&&(elementOptions.id=id),void 0===content&&button.attr("data-popbox",""),popbox.update($.extend(!0,{},Popbox.defaultOptions,{tooltip:$(),loader:$('<div class="popbox loading" data-popbox-tooltip><div class="arrow"></div></div>'),uid:$.uid(),button:button},elementOptions,options))
};Popbox.defaultOptions={content:"",id:null,type:"",enabled:!1,wait:!1,locked:!1,exclusive:!1,hideTimer:null,hideDelay:50,toggle:"hover",position:"bottom",collision:"flip",cache:!0},Popbox.get=function(el){var popbox=$(el).data("popbox");return popbox instanceof Popbox?popbox:void 0},Popbox.toggleEvent=navigator.userAgent.match(/iPhone|iPad|iPod/i)?"touchstart":"click",$.extend(Popbox.prototype,{positions:"top top-left top-right top-center bottom bottom-left bottom-right bottom-center left left-top left-bottom left-center right right-top right-bottom right-center",update:function(options){var popbox=this;
if($.extend(!0,popbox,options),$.isModule(popbox.content))return popbox.wait=!0,$.module(popbox.content).done(function(options){$.isPlainObject(options)&&popbox.update(options),$.isFunction(options)&&popbox.update({content:options})}).fail(function(){popbox.update({content:"Unable to load tooltip content."})}).always(function(){popbox.wait=!1}),void 0;$.isString(popbox.content)&&(popbox.content=$.Deferred().resolve(popbox.content));var position=popbox.position;if($.isString(position)){var x1,y1,x2,y2,pos=position.split("-");
switch(pos[0]){case"top":case"bottom":x1=x2=pos[1]||"center",y1="top"==pos[0]?"bottom":"top",y2="top"==pos[0]?"top":"bottom";break;case"left":case"right":y1=y2=pos[1]||"center",x1="left"==pos[0]?"right":"left",x2="left"==pos[0]?"left":"right"}popbox.position={classname:position,my:x1+" "+y1,at:x2+" "+y2,using:function(coords,feedback){var tooltip=$(this),classname=popbox.position.classname,top=coords.top,left=coords.left;switch(pos[0]){case"top":case"bottom":var vertical=feedback.vertical;vertical==pos[0]&&(classname=classname.replace(/top|bottom/gi,"top"==vertical?"bottom":"top")),top="top"==vertical?top+10:top-10;
break;case"left":case"right":var horizontal=feedback.horizontal;feedback.horizontal==pos[0]&&(classname=classname.replace(/left|right/gi,"left"==feedback.horizontal?"right":"left")),left="left"==horizontal?left+10:left-10}tooltip.css({top:top+"px",left:left+"px"}).removeClass(popbox.positions).addClass(classname)}}}$.extend(popbox.position,{of:popbox.button,collision:popbox.collision}),popbox.loader.attr({id:popbox.id,"data-popbox-tooltip":popbox.type}).addClass("popbox-"+popbox.type),popbox.enabled&&popbox.show()
},trigger:function(event,args){this.tooltip.trigger(event,args),this.button.trigger(event,args)},show:function(){var popbox=this;if(popbox.enabled=!0,!popbox.wait){if(clearTimeout(popbox.hideTimer),popbox.exclusive&&$("[data-popbox-tooltip]").each(function(){var popbox=Popbox.get($(this));popbox&&popbox.hide()}),"click"==popbox.toggle){var doc=$(document),hideOnClick=Popbox.toggleEvent+".popbox."+popbox.uid;doc.off(hideOnClick).on(hideOnClick,function(event){var targets=$(event.target).parents().andSelf();targets.filter(popbox.button).length>0||targets.filter(popbox.tooltip).length>0||(doc.off(hideOnClick),popbox.hide())
})}if(popbox.tooltip.length>0)return popbox.tooltip.appendTo("body").position(popbox.position),popbox.trigger("popboxActivate",[popbox]),void 0;if($.isFunction(popbox.content)){var options=popbox.content(popbox);if(popbox.update(options),popbox.wait)return}$.isDeferred(popbox.content)&&("pending"==popbox.content.state()&&popbox.loader.appendTo("body").position(popbox.position),popbox.content.always(function(){popbox.wait=!1}).done(function(html){if(!(popbox.tooltip.length>0)&&popbox.enabled){popbox.loader.detach();
var tooltip=$.buildHTML(html);if(tooltip.filter("[data-popbox-tooltip]").length<1){var content=tooltip;tooltip=$('<div class="popbox" data-popbox-tooltip><div class="arrow"></div><div class="popbox-content" data-popbox-content></div></div>').attr({id:popbox.id,"data-popbox-tooltip":popbox.type}).addClass("popbox-"+popbox.type).appendTo("body"),tooltip.find("[data-popbox-content]").append(content)}else tooltip=tooltip.appendTo("body").filter("[data-popbox-tooltip]");popbox.tooltip=tooltip.data("popbox",popbox).position(popbox.position),popbox.trigger("popboxActivate",[popbox])
}}).fail(function(){popbox.update({content:"Unable to load tooltip content."})}))}},hide:function(force){var popbox=this;popbox.enabled=!1,clearTimeout(popbox.hideTimer),popbox.loader.detach();var hide=function(){(!popbox.locked||force)&&(popbox.tooltip.detach(),popbox.trigger("popboxDeactivate",[popbox]),popbox.cache||popbox.destroy())};popbox.hideTimer=setTimeout(hide,popbox.hideDelay)},destroy:function(){this.button.removeData("popbox")},widget:function(){return this}}),$(document).on(Popbox.toggleEvent+".popbox","[data-popbox]",function(){var popbox=$(this).popbox("widget");
popbox.enabled?popbox.hide():popbox.show()}).on("mouseover.popbox","[data-popbox]",function(){var popbox=$(this).popbox("widget");"hover"==popbox.toggle&&popbox.show()}).on("mouseout.popbox","[data-popbox]",function(){var popbox=$(this).popbox("widget");"hover"==popbox.toggle&&popbox.hide()}).on("mouseover.popbox.tooltip","[data-popbox-tooltip]",function(){var popbox=Popbox.get(this);popbox&&"hover"===popbox.toggle&&(popbox.locked=!0,clearTimeout(popbox.hideTimer))}).on("mouseout.popbox.tooltip","[data-popbox-tooltip]",function(){var popbox=Popbox.get(this);
popbox&&"hover"===popbox.toggle&&(popbox.locked=!1,popbox.hide())}).on("click.popbox.close","[data-popbox-close]",function(){var popbox=Popbox.get($(this).parents("[data-popbox-tooltip]"));popbox&&popbox.hide()})};exports(),module.resolveWith(exports)})};FD31.module("popbox",moduleFactory)}();