diff --git a/Source/jBox.js b/Source/jBox.js index 4875b18..a2594a3 100644 --- a/Source/jBox.js +++ b/Source/jBox.js @@ -396,7 +396,7 @@ function jBox(type, options) { if (this.options.draggable) { // Get the handle where jBox will be dragged with - var handle = (this.options.draggable == 'title') && this.titleContainer ? this.titleContainer : (this.options.draggable.length ? this.options.draggable : this.wrapper); + var handle = (this.options.draggable == 'title') && this.titleContainer ? this.titleContainer : ($(this.options.draggable).length ? $(this.options.draggable) : this.wrapper); // Add mouse events handle.addClass('jBox-draggable').on('mousedown', function (ev) diff --git a/Source/jBox.min.js b/Source/jBox.min.js index a26980a..652c312 100644 --- a/Source/jBox.min.js +++ b/Source/jBox.min.js @@ -1,2 +1,2 @@ -function jBox(t,i){return this.options={id:null,width:"auto",height:"auto",minWidth:null,minHeight:null,maxWidth:null,maxHeight:null,responsiveWidth:!0,responsiveHeight:!0,responsiveMinWidth:100,responsiveMinHeight:100,attach:null,trigger:"click",preventDefault:!1,title:null,content:null,getTitle:null,getContent:null,isolateScroll:!0,ajax:{url:null,data:"",reload:!1,getURL:"data-url",getData:"data-ajax",setContent:!0,spinner:!0,spinnerDelay:300,spinnerReposition:!0},target:null,position:{x:"center",y:"center"},outside:null,offset:0,attributes:{x:"left",y:"top"},fixed:!1,adjustPosition:!0,adjustTracker:!1,adjustDistance:5,reposition:!0,repositionOnOpen:!0,repositionOnContent:!0,pointer:!1,pointTo:"target",fade:180,animation:null,transition:!1,theme:"Default",addClass:null,overlay:!1,zIndex:1e4,delayOpen:0,delayClose:0,closeOnEsc:!1,closeOnClick:!1,closeOnMouseleave:!1,closeButton:!1,appendTo:jQuery("body"),createOnInit:!1,blockScroll:!1,draggable:!1,dragOver:!0,autoClose:!1,preloadAudio:!0,audio:null,volume:100,onInit:null,onAttach:null,onPosition:null,onCreated:null,onOpen:null,onClose:null,onCloseComplete:null},this._pluginOptions={Tooltip:{getContent:"title",trigger:"mouseenter",position:{x:"center",y:"top"},outside:"y",pointer:!0},Mouse:{responsiveWidth:!1,responsiveHeight:!1,adjustPosition:"flip",target:"mouse",trigger:"mouseenter",position:{x:"right",y:"bottom"},outside:"xy",offset:5},Modal:{target:jQuery(window),fixed:!0,blockScroll:!0,closeOnEsc:!0,closeOnClick:"overlay",closeButton:"title",overlay:!0,animation:"zoomIn"}},this.options=jQuery.extend(!0,this.options,this._pluginOptions[t]?this._pluginOptions[t]:jBox._pluginOptions[t],i),"string"==jQuery.type(t)&&(this.type=t),this._fireEvent=function(t,i){this.options["_"+t]&&this.options["_"+t].bind(this)(i),this.options[t]&&this.options[t].bind(this)(i)},null===this.options.id&&(this.options.id="jBox"+jBox._getUniqueID()),this.id=this.options.id,("center"==this.options.position.x&&"x"==this.options.outside||"center"==this.options.position.y&&"y"==this.options.outside)&&(this.options.outside=null),"target"==this.options.pointTo&&(!this.options.outside||"xy"==this.options.outside)&&(this.options.pointer=!1),this.options.offset="object"!=jQuery.type(this.options.offset)?{x:this.options.offset,y:this.options.offset}:jQuery.extend({x:0,y:0},this.options.offset),this.options.adjustDistance="object"!=jQuery.type(this.options.adjustDistance)?{top:this.options.adjustDistance,right:this.options.adjustDistance,bottom:this.options.adjustDistance,left:this.options.adjustDistance}:jQuery.extend({top:5,left:5,right:5,bottom:5},this.options.adjustDistance),this.outside=this.options.outside&&"xy"!=this.options.outside?this.options.position[this.options.outside]:!1,this.align=this.outside?this.outside:"center"!=this.options.position.y&&"number"!=jQuery.type(this.options.position.y)?this.options.position.x:"center"!=this.options.position.x&&"number"!=jQuery.type(this.options.position.x)?this.options.position.y:this.options.attributes.x,this._getOpp=function(t){return{left:"right",right:"left",top:"bottom",bottom:"top",x:"y",y:"x"}[t]},this._getXY=function(t){return{left:"x",right:"x",top:"y",bottom:"y",center:"x"}[t]},this._getTL=function(t){return{left:"left",right:"left",top:"top",bottom:"top",center:"left",x:"left",y:"top"}[t]},this._getInt=function(t,i){return"auto"==t?"auto":t&&"string"==jQuery.type(t)&&"%"==t.slice(-1)?jQuery(window)["height"==i?"innerHeight":"innerWidth"]()*parseInt(t.replace("%",""))/100:t},this._createSVG=function(t,i){var o=document.createElementNS("http://www.w3.org/2000/svg",t);return jQuery.each(i,function(t,i){o.setAttribute(i[0],i[1]||"")}),o},this._isolateScroll=function(t){t&&t.length&&t.on("DOMMouseScroll.jBoxIsolateScroll mousewheel.jBoxIsolateScroll",function(i){var o=i.wheelDelta||i.originalEvent&&i.originalEvent.wheelDelta||-i.detail,s=this.scrollTop+t.outerHeight()-this.scrollHeight>=0,e=this.scrollTop<=0;(0>o&&s||o>0&&e)&&i.preventDefault()})},this._create=function(){if(!this.wrapper){if(this.wrapper=jQuery("
",{id:this.id,"class":"jBox-wrapper"+(this.type?" jBox-"+this.type:"")+(this.options.theme?" jBox-"+this.options.theme:"")+(this.options.addClass?" "+this.options.addClass:"")}).css({position:this.options.fixed?"fixed":"absolute",display:"none",opacity:0,zIndex:this.options.zIndex}).data("jBox",this),this.options.closeOnMouseleave&&this.wrapper.on("mouseleave",function(t){!this.source||!(t.relatedTarget==this.source[0]||-1!==jQuery.inArray(this.source[0],jQuery(t.relatedTarget).parents("*")))&&this.close()}.bind(this)),"box"==this.options.closeOnClick&&this.wrapper.on("touchend click",function(){this.close({ignoreDelay:!0})}.bind(this)),this.container=jQuery('
').appendTo(this.wrapper),this.content=jQuery('
').appendTo(this.container),this.options.isolateScroll&&this._isolateScroll(this.content),this.options.closeButton){var t=this._createSVG("svg",[["viewBox","0 0 24 24"]]);t.appendChild(this._createSVG("path",[["d","M22.2,4c0,0,0.5,0.6,0,1.1l-6.8,6.8l6.9,6.9c0.5,0.5,0,1.1,0,1.1L20,22.3c0,0-0.6,0.5-1.1,0L12,15.4l-6.9,6.9c-0.5,0.5-1.1,0-1.1,0L1.7,20c0,0-0.5-0.6,0-1.1L8.6,12L1.7,5.1C1.2,4.6,1.7,4,1.7,4L4,1.7c0,0,0.6-0.5,1.1,0L12,8.5l6.8-6.8c0.5-0.5,1.1,0,1.1,0L22.2,4z"]])),this.closeButton=jQuery('
').on("touchend click",function(){this.close({ignoreDelay:!0})}.bind(this)).append(t),("box"==this.options.closeButton||this.options.closeButton===!0&&!this.options.overlay&&!this.options.title)&&(this.wrapper.addClass("jBox-closeButton-box"),this.closeButton.appendTo(this.container))}if(this.wrapper.appendTo(this.options.appendTo),this.wrapper.find(".jBox-closeButton").length&&jQuery.each(["top","right","bottom","left"],function(t,i){this.wrapper.find(".jBox-closeButton").css(i)&&"auto"!=this.wrapper.find(".jBox-closeButton").css(i)&&(this.options.adjustDistance[i]=Math.max(this.options.adjustDistance[i],this.options.adjustDistance[i]+-1*((parseInt(this.wrapper.find(".jBox-closeButton").css(i))||0)+(parseInt(this.container.css("border-"+i+"-width"))||0))))}.bind(this)),this.options.pointer){if(this.pointer={position:"target"!=this.options.pointTo?this.options.pointTo:this._getOpp(this.outside),xy:this._getXY("target"!=this.options.pointTo?this.options.pointTo:this.outside),align:"center",offset:0},this.pointer.element=jQuery('
').appendTo(this.wrapper),this.pointer.dimensions={x:this.pointer.element.outerWidth(),y:this.pointer.element.outerHeight()},"string"==jQuery.type(this.options.pointer)){var i=this.options.pointer.split(":");i[0]&&(this.pointer.align=i[0]),i[1]&&(this.pointer.offset=parseInt(i[1]))}this.pointer.alignAttribute="x"==this.pointer.xy?"bottom"==this.pointer.align?"bottom":"top":"right"==this.pointer.align?"right":"left",this.wrapper.css("padding-"+this.pointer.position,this.pointer.dimensions[this.pointer.xy]),this.pointer.element.css(this.pointer.alignAttribute,"center"==this.pointer.align?"50%":0).css("margin-"+this.pointer.alignAttribute,this.pointer.offset),this.pointer.margin={},this.pointer.margin["margin-"+this.pointer.alignAttribute]=this.pointer.offset,"center"==this.pointer.align&&this.pointer.element.css("transform","translate("+("y"==this.pointer.xy?this.pointer.dimensions.x*-.5+"px":0)+", "+("x"==this.pointer.xy?this.pointer.dimensions.y*-.5+"px":0)+")"),this.pointer.element.css("x"==this.pointer.xy?"width":"height",parseInt(this.pointer.dimensions[this.pointer.xy])+parseInt(this.container.css("border-"+this.pointer.alignAttribute+"-width"))),this.wrapper.addClass("jBox-pointerPosition-"+this.pointer.position)}if(this.setContent(this.options.content,!0),this.setTitle(this.options.title,!0),this.options.draggable){var o="title"==this.options.draggable&&this.titleContainer?this.titleContainer:this.options.draggable.length?this.options.draggable:this.wrapper;o.addClass("jBox-draggable").on("mousedown",function(t){if(2!=t.button&&!jQuery(t.target).hasClass("jBox-noDrag")&&!jQuery(t.target).parents(".jBox-noDrag").length){this.options.dragOver&&this.wrapper.css("zIndex")<=jBox.zIndexMax&&(jBox.zIndexMax+=1,this.wrapper.css("zIndex",jBox.zIndexMax));var i=this.wrapper.outerHeight(),o=this.wrapper.outerWidth(),s=this.wrapper.offset().top+i-t.pageY,e=this.wrapper.offset().left+o-t.pageX;jQuery(document).on("mousemove.jBox-draggable-"+this.id,function(t){this.wrapper.offset({top:t.pageY+s-i,left:t.pageX+e-o})}.bind(this)),t.preventDefault()}}.bind(this)).on("mouseup",function(){jQuery(document).off("mousemove.jBox-draggable-"+this.id)}.bind(this)),jBox.zIndexMax=jBox.zIndexMax?Math.max(jBox.zIndexMax,this.options.zIndex):this.options.zIndex}this._fireEvent("onCreated")}},this.options.createOnInit&&this._create(),this.options.attach&&this.attach(),this._attachEvents=function(){this.options.closeOnEsc&&jQuery(document).on("keyup.jBox-"+this.id,function(t){27==t.keyCode&&this.close({ignoreDelay:!0})}.bind(this)),(this.options.closeOnClick===!0||"body"==this.options.closeOnClick)&&jQuery(document).on("touchend.jBox-"+this.id+" click.jBox-"+this.id,function(t){this.blockBodyClick||"body"==this.options.closeOnClick&&(t.target==this.wrapper[0]||this.wrapper.has(t.target).length)||this.close({ignoreDelay:!0})}.bind(this)),(this.options.adjustPosition||this.options.reposition)&&!this.fixed&&this.outside&&(this.options.adjustTracker&&jQuery(window).on("scroll.jBox-"+this.id,function(){this.position()}.bind(this)),(this.options.adjustPosition||this.options.reposition)&&jQuery(window).on("resize.jBox-"+this.id,function(){this.position()}.bind(this))),"mouse"==this.options.target&&jQuery("body").on("mousemove.jBox-"+this.id,function(t){this.position({mouseTarget:{top:t.pageY,left:t.pageX}})}.bind(this))},this._detachEvents=function(){this.options.closeOnEsc&&jQuery(document).off("keyup.jBox-"+this.id),(this.options.closeOnClick===!0||"body"==this.options.closeOnClick)&&jQuery(document).off("touchend.jBox-"+this.id+" click.jBox-"+this.id),this.options.adjustTracker&&jQuery(window).off("scroll.jBox-"+this.id),(this.options.adjustPosition||this.options.reposition)&&jQuery(window).off("resize.jBox-"+this.id),"mouse"==this.options.target&&jQuery("body").off("mousemove.jBox-"+this.id)},this._showOverlay=function(){this.overlay||(this.overlay=jQuery('
').addClass("jBox-overlay"+(this.type?" jBox-overlay-"+this.type:"")).css({display:"none",opacity:0,zIndex:this.options.zIndex-1}).appendTo(this.options.appendTo),("overlay"==this.options.closeButton||this.options.closeButton===!0)&&this.overlay.append(this.closeButton),"overlay"==this.options.closeOnClick&&this.overlay.on("touchend click",function(){this.close({ignoreDelay:!0})}.bind(this)),jQuery("#"+this.id+"-overlay .jBox-closeButton").length&&(this.options.adjustDistance.top=Math.max(jQuery("#"+this.id+"-overlay .jBox-closeButton").outerHeight(),this.options.adjustDistance.top))),"block"!=this.overlay.css("display")&&(this.options.fade?this.overlay.stop()&&this.overlay.animate({opacity:1},{queue:!1,duration:this.options.fade,start:function(){this.overlay.css({display:"block"})}.bind(this)}):this.overlay.css({display:"block",opacity:1}))},this._hideOverlay=function(){this.overlay&&(this.options.fade?this.overlay.stop()&&this.overlay.animate({opacity:0},{queue:!1,duration:this.options.fade,complete:function(){this.overlay.css({display:"none"})}.bind(this)}):this.overlay.css({display:"none",opacity:0}))},this._exposeDimensions=function(){this.wrapper.css({top:-1e4,left:-1e4,right:"auto",bottom:"auto"});var t={x:this.wrapper.outerWidth(),y:this.wrapper.outerHeight()};return this.wrapper.css({top:"auto",left:"auto"}),t},this._setTitleWidth=function(){if(!this.titleContainer)return null;if("none"==this.wrapper.css("display")){this.wrapper.css("display","block");var t=this.content.outerWidth();this.wrapper.css("display","none")}else var t=this.content.outerWidth();this.titleContainer.css({maxWidth:t||null})},this._generateAnimationCSS=function(){"object"!=jQuery.type(this.options.animation)&&(this.options.animation={pulse:{open:"pulse",close:"zoomOut"},zoomIn:{open:"zoomIn",close:"zoomIn"},zoomOut:{open:"zoomOut",close:"zoomOut"},move:{open:"move",close:"move"},slide:{open:"slide",close:"slide"},flip:{open:"flip",close:"flip"},tada:{open:"tada",close:"zoomOut"}}[this.options.animation]),this.options.animation.open&&(this.options.animation.open=this.options.animation.open.split(":")),this.options.animation.close&&(this.options.animation.close=this.options.animation.close.split(":")),this.options.animation.openDirection=this.options.animation.open?this.options.animation.open[1]:null,this.options.animation.closeDirection=this.options.animation.close?this.options.animation.close[1]:null,this.options.animation.open&&(this.options.animation.open=this.options.animation.open[0]),this.options.animation.close&&(this.options.animation.close=this.options.animation.close[0]),this.options.animation.open&&(this.options.animation.open+="Open"),this.options.animation.close&&(this.options.animation.close+="Close");var t={pulse:{duration:350,css:[["0%","scale(1)"],["50%","scale(1.1)"],["100%","scale(1)"]]},zoomInOpen:{duration:this.options.fade||180,css:[["0%","scale(0.9)"],["100%","scale(1)"]]},zoomInClose:{duration:this.options.fade||180,css:[["0%","scale(1)"],["100%","scale(0.9)"]]},zoomOutOpen:{duration:this.options.fade||180,css:[["0%","scale(1.1)"],["100%","scale(1)"]]},zoomOutClose:{duration:this.options.fade||180,css:[["0%","scale(1)"],["100%","scale(1.1)"]]},moveOpen:{duration:this.options.fade||180,positions:{top:{"0%":-12},right:{"0%":12},bottom:{"0%":12},left:{"0%":-12}},css:[["0%","translate%XY(%Vpx)"],["100%","translate%XY(0px)"]]},moveClose:{duration:this.options.fade||180,timing:"ease-in",positions:{top:{"100%":-12},right:{"100%":12},bottom:{"100%":12},left:{"100%":-12}},css:[["0%","translate%XY(0px)"],["100%","translate%XY(%Vpx)"]]},slideOpen:{duration:400,positions:{top:{"0%":-400},right:{"0%":400},bottom:{"0%":400},left:{"0%":-400}},css:[["0%","translate%XY(%Vpx)"],["100%","translate%XY(0px)"]]},slideClose:{duration:400,timing:"ease-in",positions:{top:{"100%":-400},right:{"100%":400},bottom:{"100%":400},left:{"100%":-400}},css:[["0%","translate%XY(0px)"],["100%","translate%XY(%Vpx)"]]},flipOpen:{duration:600,css:[["0%","perspective(400px) rotateX(90deg)"],["40%","perspective(400px) rotateX(-15deg)"],["70%","perspective(400px) rotateX(15deg)"],["100%","perspective(400px) rotateX(0deg)"]]},flipClose:{duration:this.options.fade||300,css:[["0%","perspective(400px) rotateX(0deg)"],["100%","perspective(400px) rotateX(90deg)"]]},tada:{duration:800,css:[["0%","scale(1)"],["10%, 20%","scale(0.9) rotate(-3deg)"],["30%, 50%, 70%, 90%","scale(1.1) rotate(3deg)"],["40%, 60%, 80%","scale(1.1) rotate(-3deg)"],["100%","scale(1) rotate(0)"]]}};jQuery.each(["pulse","tada"],function(i,o){t[o+"Open"]=t[o+"Close"]=t[o]});var i=function(i,o){return keyframe_css="@keyframes jBox-"+this.id+"-animation-"+this.options.animation[i]+"-"+i+(o?"-"+o:"")+" {",jQuery.each(t[this.options.animation[i]].css,function(s,e){var n=o?e[1].replace("%XY",this._getXY(o).toUpperCase()):e[1];t[this.options.animation[i]].positions&&(n=n.replace("%V",t[this.options.animation[i]].positions[o][e[0]])),keyframe_css+=e[0]+" {transform:"+n+";}"}.bind(this)),keyframe_css+="}",keyframe_css+=".jBox-"+this.id+"-animation-"+this.options.animation[i]+"-"+i+(o?"-"+o:"")+" {",keyframe_css+="animation-duration: "+t[this.options.animation[i]].duration+"ms;",keyframe_css+="animation-name: jBox-"+this.id+"-animation-"+this.options.animation[i]+"-"+i+(o?"-"+o:"")+";",keyframe_css+=t[this.options.animation[i]].timing?"animation-timing-function: "+t[this.options.animation[i]].timing+";":"",keyframe_css+="}"}.bind(this);this._animationCSS="",jQuery.each(["open","close"],function(o,s){return this.options.animation[s]&&t[this.options.animation[s]]&&("close"!=s||this.options.fade)?void(t[this.options.animation[s]].positions?jQuery.each(["top","right","bottom","left"],function(t,o){this._animationCSS+=i(s,o)}):this._animationCSS+=i(s)):""}.bind(this))},this.options.animation&&this._generateAnimationCSS(),this._blockBodyClick=function(){this.blockBodyClick=!0,setTimeout(function(){this.blockBodyClick=!1}.bind(this),10)},this._animate=function(t){if(!t&&(t=this.isOpen?"open":"close"),!this.options.fade&&"close"==t)return null;var i=this.options.animation[t+"Direction"]||("center"!=this.align?this.align:this.options.attributes.x);this.flipped&&this._getXY(i)==this._getXY(this.align)&&(i=this._getOpp(i));var o="jBox-"+this.id+"-animation-"+this.options.animation[t]+"-"+t+" jBox-"+this.id+"-animation-"+this.options.animation[t]+"-"+t+"-"+i;this.wrapper.addClass(o);var s=1e3*parseFloat(this.wrapper.css("animation-duration"));"close"==t&&(s=Math.min(s,this.options.fade)),setTimeout(function(){this.wrapper.removeClass(o)}.bind(this),s)},this._abortAnimation=function(){var t="jBox-"+this.id+"-animation",i=this.wrapper.attr("class").split(" ").filter(function(i){return 0!==i.lastIndexOf(t,0)});this.wrapper.attr("class",i.join(" "))},(this.options.responsiveWidth||this.options.responsiveHeight)&&jQuery(window).on("resize.responsivejBox-"+this.id,function(){this.isOpen&&this.position()}.bind(this)),"string"===jQuery.type(this.options.preloadAudio)&&(this.options.preloadAudio=[this.options.preloadAudio]),"string"===jQuery.type(this.options.audio)&&(this.options.audio={open:this.options.audio}),"number"===jQuery.type(this.options.volume)&&(this.options.volume={open:this.options.volume,close:this.options.volume}),this.options.preloadAudio===!0&&this.options.audio&&(this.options.preloadAudio=[],jQuery.each(this.options.audio,function(t,i){this.options.preloadAudio.push(i+".mp3"),this.options.preloadAudio.push(i+".ogg")}.bind(this))),this.options.preloadAudio.length&&jQuery.each(this.options.preloadAudio,function(t,i){var o=new Audio;o.src=i,o.preload="auto"}),this._fireEvent("onInit"),this}function jBoxPlugin(t,i){jBox._pluginOptions[t]=i}jBox.prototype.attach=function(t,i){return!t&&(t=jQuery(this.options.attach.selector||this.options.attach)),!i&&(i=this.options.trigger),t&&t.length&&jQuery.each(t,function(t,o){o=jQuery(o),o.data("jBox-attached-"+this.id)||("title"==this.options.getContent&&void 0!=o.attr("title")&&o.data("jBox-getContent",o.attr("title")).removeAttr("title"),this.attachedElements||(this.attachedElements=[]),this.attachedElements.push(o[0]),o.on(i+".jBox-attach-"+this.id,function(t){if(this.timer&&clearTimeout(this.timer),"mouseenter"!=i||!this.isOpen||this.source[0]!=o[0]){if(this.isOpen&&this.source&&this.source[0]!=o[0])var s=!0;this.source=o,!this.options.target&&(this.target=o),"click"==i&&this.options.preventDefault&&t.preventDefault(),this["click"!=i||s?"open":"toggle"]()}}.bind(this)),"mouseenter"==this.options.trigger&&o.on("mouseleave",function(t){(!this.options.closeOnMouseleave||t.relatedTarget!=this.wrapper[0]&&!jQuery(t.relatedTarget).parents("#"+this.id).length)&&this.close()}.bind(this)),o.data("jBox-attached-"+this.id,i),this._fireEvent("onAttach",o))}.bind(this)),this},jBox.prototype.detach=function(t){return!t&&(t=this.attachedElements||[]),t&&t.length&&jQuery.each(t,function(t,i){i=jQuery(i),i.data("jBox-attached-"+this.id)&&(i.off(i.data("jBox-attached-"+this.id)+".jBox-attach-"+this.id),i.data("jBox-attached-"+this.id,null)),this.attachedElements=jQuery.grep(this.attachedElements,function(t){return t!=i[0]})}.bind(this)),this},jBox.prototype.setTitle=function(t,i){if(null==t||void 0==t)return this;!this.wrapper&&this._create();var o=this.wrapper.outerHeight(),s=this.wrapper.outerWidth();return this.title||(this.titleContainer=jQuery('
'),this.title=jQuery("
").appendTo(this.titleContainer),this.wrapper.addClass("jBox-hasTitle"),("title"==this.options.closeButton||this.options.closeButton===!0&&!this.options.overlay)&&(this.wrapper.addClass("jBox-closeButton-title"),this.closeButton.appendTo(this.titleContainer)),this.titleContainer.insertBefore(this.content),this._setTitleWidth()),this.title.html(t),s!=this.wrapper.outerWidth()&&this._setTitleWidth(),!i&&this.options.repositionOnContent&&(o!=this.wrapper.outerHeight()||s!=this.wrapper.outerWidth())&&this.position(),this},jBox.prototype.setContent=function(t,i){if(null==t||void 0==t)return this;!this.wrapper&&this._create();var o=this.wrapper.outerHeight(),s=this.wrapper.outerWidth();switch(this.content.children("[data-jbox-content-appended]").appendTo("body").css({display:"none"}),jQuery.type(t)){case"string":this.content.html(t);break;case"object":this.content.html(""),t.attr("data-jbox-content-appended",1).appendTo(this.content).css({display:"block"})}return s!=this.wrapper.outerWidth()&&this._setTitleWidth(),!i&&this.options.repositionOnContent&&(o!=this.wrapper.outerHeight()||s!=this.wrapper.outerWidth())&&this.position(),this},jBox.prototype.setDimensions=function(t,i,o){!this.wrapper&&this._create(),this.content.css(t,this._getInt(i)),"width"==t&&this._setTitleWidth(),(void 0==o||o)&&this.position()},jBox.prototype.setWidth=function(t,i){this.setDimensions("width",t,i)},jBox.prototype.setHeight=function(t,i){this.setDimensions("height",t,i)},jBox.prototype.position=function(t){!t&&(t={}),t=jQuery.extend(!0,this.options,t),this.target=t.target||this.target||jQuery(window),this.content.css({width:this._getInt(t.width,"width"),height:this._getInt(t.height,"height"),minWidth:this._getInt(t.minWidth,"width"),minHeight:this._getInt(t.minHeight,"height"),maxWidth:this._getInt(t.maxWidth,"width"),maxHeight:this._getInt(t.maxHeight,"height")}),this._setTitleWidth();var i=this._exposeDimensions();"mouse"!=this.target&&!this.target.data("jBox-"+this.id+"-fixed")&&this.target.data("jBox-"+this.id+"-fixed",this.target[0]==jQuery(window)[0]||"fixed"!=this.target.css("position")&&this.target.parents().filter(function(){return"fixed"==jQuery(this).css("position")}).length<=0?"static":"fixed");var o={x:jQuery(window).outerWidth(),y:jQuery(window).outerHeight(),top:t.fixed&&this.target.data("jBox-"+this.id+"-fixed")?0:jQuery(window).scrollTop(),left:t.fixed&&this.target.data("jBox-"+this.id+"-fixed")?0:jQuery(window).scrollLeft()};o.bottom=o.top+o.y,o.right=o.left+o.x;try{var s=this.target.offset()}catch(e){var s={top:0,left:0}}"mouse"!=this.target&&"fixed"==this.target.data("jBox-"+this.id+"-fixed")&&t.fixed&&(s.top=s.top-jQuery(window).scrollTop(),s.left=s.left-jQuery(window).scrollLeft());var n={x:"mouse"==this.target?12:this.target.outerWidth(),y:"mouse"==this.target?20:this.target.outerHeight(),top:"mouse"==this.target&&t.mouseTarget?t.mouseTarget.top:s?s.top:0,left:"mouse"==this.target&&t.mouseTarget?t.mouseTarget.left:s?s.left:0},a=t.outside&&!("center"==t.position.x&&"center"==t.position.y),r={x:o.x-t.adjustDistance.left-t.adjustDistance.right,y:o.y-t.adjustDistance.top-t.adjustDistance.bottom,left:a?n.left-jQuery(window).scrollLeft()-t.adjustDistance.left:0,right:a?o.x-n.left+jQuery(window).scrollLeft()-n.x-t.adjustDistance.right:0,top:a?n.top-jQuery(window).scrollTop()-this.options.adjustDistance.top:0,bottom:a?o.y-n.top+jQuery(window).scrollTop()-n.y-t.adjustDistance.bottom:0},h={x:"x"!=t.outside&&"xy"!=t.outside||"number"==jQuery.type(t.position.x)?null:t.position.x,y:"y"!=t.outside&&"xy"!=t.outside||"number"==jQuery.type(t.position.y)?null:t.position.y},p={x:!1,y:!1};if(h.x&&i.x>r[h.x]&&r[this._getOpp(h.x)]>r[h.x]&&(h.x=this._getOpp(h.x))&&(p.x=!0),h.y&&i.y>r[h.y]&&r[this._getOpp(h.y)]>r[h.y]&&(h.y=this._getOpp(h.y))&&(p.y=!0),t.responsiveWidth||t.responsiveHeight){var l=function(){if(t.responsiveWidth&&i.x>r[h.x||"x"]){var o=r[h.x||"x"]-(this.pointer&&a&&"x"==t.outside?this.pointer.dimensions.x:0)-parseInt(this.container.css("border-left-width"))-parseInt(this.container.css("border-right-width"));this.content.css({width:o>this.options.responsiveMinWidth?o:null,minWidth:or[h.y]&&r[this._getOpp(h.y)]>r[h.y]&&(h.y=this._getOpp(h.y))&&(p.y=!0);var d=function(){if(t.responsiveHeight&&i.y>r[h.y||"y"]){var o=function(){if(!this.titleContainer)return 0;if("none"==this.wrapper.css("display")){this.wrapper.css("display","block");var t=this.titleContainer.outerHeight();this.wrapper.css("display","none")}else var t=this.titleContainer.outerHeight();return t||0}.bind(this),s=r[h.y||"y"]-(this.pointer&&a&&"y"==t.outside?this.pointer.dimensions.y:0)-o()-parseInt(this.container.css("border-top-width"))-parseInt(this.container.css("border-bottom-width"));this.content.css({height:s>this.options.responsiveMinHeight?s:null}),this._setTitleWidth()}i=this._exposeDimensions()}.bind(this);t.responsiveHeight&&d(),t.responsiveHeight&&!p.x&&h.x&&i.x>r[h.x]&&r[this._getOpp(h.x)]>r[h.x]&&(h.x=this._getOpp(h.x))&&(p.x=!0),t.adjustPosition&&"move"!=t.adjustPosition&&(p.x&&l(),p.y&&d())}var c={},u=function(o){if("number"==jQuery.type(t.position[o]))return void(c[t.attributes[o]]=t.position[o]);var s=t.attributes[o]="x"==o?"left":"top";return c[s]=n[s],"center"==t.position[o]?(c[s]+=Math.ceil((n[o]-i[o])/2),void("mouse"!=this.target&&this.target[0]&&this.target[0]==jQuery(window)[0]&&(c[s]+=.5*(t.adjustDistance[s]-t.adjustDistance[this._getOpp(s)])))):(s!=t.position[o]&&(c[s]+=n[o]-i[o]),void((t.outside==o||"xy"==t.outside)&&(c[s]+=i[o]*(s!=t.position[o]?1:-1))))}.bind(this);if(u("x"),u("y"),this.pointer&&"target"==t.pointTo&&"number"!=jQuery.type(t.position.x)&&"number"!=jQuery.type(t.position.y)){var g=0;switch(this.pointer.align){case"center":"center"!=t.position[this._getOpp(t.outside)]&&(g+=i[this._getOpp(t.outside)]/2);break;default:switch(t.position[this._getOpp(t.outside)]){case"center":g+=(i[this._getOpp(t.outside)]/2-this.pointer.dimensions[this._getOpp(t.outside)]/2)*(this.pointer.align==this._getTL(this.pointer.align)?1:-1);break;default:g+=this.pointer.align!=t.position[this._getOpp(t.outside)]?this.dimensions[this._getOpp(t.outside)]*(-1!==jQuery.inArray(this.pointer.align,["top","left"])?1:-1)+this.pointer.dimensions[this._getOpp(t.outside)]/2*(-1!==jQuery.inArray(this.pointer.align,["top","left"])?-1:1):this.pointer.dimensions[this._getOpp(t.outside)]/2*(-1!==jQuery.inArray(this.pointer.align,["top","left"])?1:-1)}}g*=t.position[this._getOpp(t.outside)]==this.pointer.alignAttribute?-1:1,g+=this.pointer.offset*(this.pointer.align==this._getOpp(this._getTL(this.pointer.align))?1:-1),c[this._getTL(this._getOpp(this.pointer.xy))]+=g}if(c[t.attributes.x]+=t.offset.x,c[t.attributes.y]+=t.offset.y,this.wrapper.css(c),t.adjustPosition){this.positionAdjusted&&(this.pointer&&this.wrapper.css("padding",0).css("padding-"+this._getOpp(this.outside),this.pointer.dimensions[this._getXY(this.outside)]).removeClass("jBox-pointerPosition-"+this._getOpp(this.pointer.position)).addClass("jBox-pointerPosition-"+this.pointer.position),this.pointer&&this.pointer.element.attr("class","jBox-pointer jBox-pointer-"+this._getOpp(this.outside)).css(this.pointer.margin),this.positionAdjusted=!1,this.flipped=!1);var m=o.top>c.top-(t.adjustDistance.top||0),f=o.rightc.left-(t.adjustDistance.left||0),j=x?"left":f?"right":null,b=m?"top":y?"bottom":null,v=j||b;if(v){var B=function(o){this.wrapper.css(this._getTL(o),c[this._getTL(o)]+(i[this._getXY(o)]+t.offset[this._getXY(o)]*("top"==o||"left"==o?-2:2)+n[this._getXY(o)])*("top"==o||"left"==o?1:-1)),this.pointer&&this.wrapper.removeClass("jBox-pointerPosition-"+this.pointer.position).addClass("jBox-pointerPosition-"+this._getOpp(this.pointer.position)).css("padding",0).css("padding-"+o,this.pointer.dimensions[this._getXY(o)]),this.pointer&&this.pointer.element.attr("class","jBox-pointer jBox-pointer-"+o),this.positionAdjusted=!0,this.flipped=!0}.bind(this);p.x&&B(this.options.position.x),p.y&&B(this.options.position.y);var w="x"==this._getXY(this.outside)?b:j;if(this.pointer&&"target"==t.pointTo&&"flip"!=t.adjustPosition&&this._getXY(w)==this._getOpp(this._getXY(this.outside))){if("center"==this.pointer.align)var _=i[this._getXY(w)]/2-this.pointer.dimensions[this._getOpp(this.pointer.xy)]/2-parseInt(this.pointer.element.css("margin-"+this.pointer.alignAttribute))*(w!=this._getTL(w)?-1:1);else var _=w==this.pointer.alignAttribute?parseInt(this.pointer.element.css("margin-"+this.pointer.alignAttribute)):i[this._getXY(w)]-parseInt(this.pointer.element.css("margin-"+this.pointer.alignAttribute))-this.pointer.dimensions[this._getXY(w)];spaceDiff=w==this._getTL(w)?o[this._getTL(w)]-c[this._getTL(w)]+t.adjustDistance[w]:-1*(o[this._getOpp(this._getTL(w))]-c[this._getTL(w)]-t.adjustDistance[w]-i[this._getXY(w)]),w==this._getOpp(this._getTL(w))&&c[this._getTL(w)]-spaceDiff=spaceDiff&&spaceDiff>0&&(this.pointer.element.css("margin-"+this.pointer.alignAttribute,parseInt(this.pointer.element.css("margin-"+this.pointer.alignAttribute))-spaceDiff*(w!=this.pointer.alignAttribute?-1:1)),this.wrapper.css(this._getTL(w),c[this._getTL(w)]+spaceDiff*(w!=this._getTL(w)?-1:1)),this.positionAdjusted=!0)}}}return this._fireEvent("onPosition"),this},jBox.prototype.open=function(t){if(!t&&(t={}),this.isDestroyed)return!1;if(!this.wrapper&&this._create(),!this._styles&&(this._styles=jQuery("