-
Notifications
You must be signed in to change notification settings - Fork 4
/
jquery.msgbox.min.js
6 lines (5 loc) · 25.9 KB
/
jquery.msgbox.min.js
1
2
3
4
5
6
/**
* jquery.msgbox v8.0
* http://jmsgbox.com
*/
(function(e,t){var n={Esc:27,Space:32,Left:37,Right:39,Up:38,Down:40,Tab:9,Enter:13};var r={fixed:true,overlay:true,overlayEvent:"flash",id:0,open:false,drag:window,resize:true,title:false,type:"html",content:false,icons:[],buttons:[],buttonEvents:{},keyEvents:{Esc:"close",Space:"play",Left:"prev",Right:"next",Enter:"play"},prefix:"jMsgbox",width:600,height:450,initialWidth:350,initialHeight:220,top:false,left:false,titleHeight:30,footHeight:40,transition:"swing",speed:300,opacity:.9,zIndex:99,lang:"en",minPos:"top",minWidth:200,photoAuto:true,photoSpeed:2500,photoScaled:false,photoFade:500,padding:0,imgError:"Failed to load image.",xhrError:"Failed to load URL.",onOpen:false,onClose:false,onLoad:false,onBeforeClose:false};var i=function(t,n,r,i){r=r||{};i=i||{};return e(document.createElement(t)).addClass(n).attr(i).css(r)};var s=function(){return window.innerHeight?window.innerHeight:e(window).height()};var o=function(t,n){if(!e.msgboxI18N||!e.msgboxI18N[n]||!e.msgboxI18N[n][t])return t;return e.msgboxI18N[n][t]};var u=function(e,t){this.$overlay;this.$wrap;this.$controls;this.$icons={};this.$title;this.$content;this.$loaded;this.$prompt;this.$iframe;this.$foot;this.$img;this.$buttons={};this.$resize;this.$trigger=e;this.options=t;this.v;this.loaded=false;this.minimized=false;this.maximized=false;this.opened=false;this.dragData={};this.resizeData={};this.playing=false;this.titleSpecified=false;this.index=0;this._completeOptions();this._assemble();this._append();this._bindEvents();if(this.options.open)this.open()};u.prototype={_completeOptions:function(){switch(this.options.type){case"confirm":case"prompt":if(this.options.buttons!==null&&this.options.buttons.length==0)this.options.buttons=["OK","Cancel"];if(this.options.icons!==null&&this.options.icons.length==0)this.options.icons=["close"];if(this.options.width==r.width&&this.options.height==r.height){this.options.width=this.options.initialWidth;this.options.height=this.options.initialHeight}break;case"alert":case"warning":case"info":case"error":case"success":if(this.options.buttons!==null&&this.options.buttons.length==0)this.options.buttons=["OK"];if(this.options.icons!==null&&this.options.icons.length==0)this.options.icons=["close"];if(this.options.width==r.width&&this.options.height==r.height){this.options.width=this.options.initialWidth;this.options.height=this.options.initialHeight}break;case"photo":case"image":if(this.$trigger&&!this.options.content)this.options.content=this.$trigger;if(this.options.icons!==null&&this.options.icons.length==0)this.options.icons=["close"];this.options.resize=false;break;case"album":case"gallery":if(this.$trigger&&!this.options.content)this.options.content=this.$trigger.selector;if(this.options.icons!==null&&this.options.icons.length==0)this.options.icons=["prev","play","next","close"];this.options.resize=false;break;default:if(this.options.icons!==null&&this.options.icons.length==0)this.options.icons=["max","close"];break}if(e.inArray(this.options.type,["ajax","iframe"])>-1&&!this.options.content&&this.$trigger){this.options.content=this.$trigger.attr("href")}if(!this.options.width)this.options.width=this.options.initialWidth;if(!this.options.height)this.options.height=this.options.initialHeight;if(!this.options.content&&e.inArray(this.options.type,["ajax","iframe","photo","image","album","gallery"])==-1)this.options.content="jquery.msgbox v "+e.msgbox.version;if(this.options.buttons===null||this.options.buttons.length==0)this.options.footHeight=0;if(this.$trigger)this.options.id=0;if(this.options.title)this.titleSpecified=true;if(this.options.photoFade===true)this.options.photoFade=r.photoFade;if(this.options.photoFade===false)this.options.photoFade=0;e.msgboxI18N=e.msgboxI18N||{};e.msgboxI18N.en=e.msgboxI18N.en||{};e.msgboxI18N.en.xhrError=e.msgboxI18N.en.xhrError||this.options.xhrError;e.msgboxI18N.en.imgError=e.msgboxI18N.en.imgError||this.options.imgError},_assemble:function(){this.$overlay=i("div",this.options.prefix+"-overlay",{position:"fixed",top:0,left:0,height:"100%",width:"100%",opacity:this.options.opacity,display:"none"});var t=this.options.top!==false?this.options.top:(s()-this.options.initialHeight)/2-this.options.titleHeight;var n=this.options.left!==false?this.options.left:(e(window).width()-this.options.initialWidth)/2;this.$wrap=i("span",this.options.prefix+"-wrap",{display:"none",width:this.options.initialWidth,height:this.options.initialHeight,position:this.options.fixed?"fixed":"absolute",overflow:"hidden",top:this.options.fixed?t:t+e(window).scrollTop(),left:this.options.fixed?n:n+e(window).scrollLeft()});this.$title=i("div",this.options.prefix+"-title",{position:"relative",height:this.options.titleHeight,cursor:this.options.drag?"move":"auto"});if(this.options.title)this.$title.html(this.options.title);var r={display:"inline-block"};this.$icons.prev=i("a",this.options.prefix+"-prev",r,{href:"javascript:;",title:o("Prev",this.options.lang)});this.$icons.next=i("a",this.options.prefix+"-next",r,{href:"javascript:;",title:o("Next",this.options.lang)});this.$icons.play=i("a",this.options.prefix+"-play",r,{href:"javascript:;",title:o("Play/Pause",this.options.lang)});this.$icons.min=i("a",this.options.prefix+"-min",r,{href:"javascript:;",title:o("Minimize",this.options.lang)});this.$icons.max=i("a",this.options.prefix+"-max",r,{href:"javascript:;",title:o("Maximize",this.options.lang)});this.$icons.close=i("a",this.options.prefix+"-close",r,{href:"javascript:;",title:o("Close",this.options.lang)});this.$controls=i("span",this.options.prefix+"-controls",{position:"absolute",height:"100%"});if(this.options.icons!==null){for(var u=0;u<this.options.icons.length;u++){this.$controls.append(this.$icons[this.options.icons[u]])}}var a={type:"button"};this.$buttons.OK=i("input",this.options.prefix+"-ok",{},a);this.$buttons.Cancel=i("input",this.options.prefix+"-cancel",{},a);this.$buttons.OK.val(o("OK",this.options.lang));this.$buttons.Cancel.val(o("Cancel",this.options.lang));this.$foot=i("div",this.options.prefix+"-foot",{position:"relative",height:this.options.footHeight,"line-height":this.options.footHeight});if(this.options.buttons!==null){var f=0;for(var u=0;u<this.options.buttons.length;u++){if(!this.$buttons[this.options.buttons[u]])this.$buttons[this.options.buttons[u]]=i("input",this.options.prefix+"-button-"+ ++f,{},a).val(this.options.buttons[u]);this.$foot.append(this.$buttons[this.options.buttons[u]])}}this.$resize=i("a",this.options.prefix+"-resize",{cursor:"se-resize",position:"absolute",bottom:"0px",right:"0px",display:"inline-block"},{href:"javascript:;"});if(!e.support.boxSizing){this.$resize.css({right:"5px",bottom:"5px"})}this.$content=i("div",this.options.prefix+"-content",{overflow:"hidden",position:"relative"});this.$prompt=i("input",this.options.prefix+"-prompt-input",{},{type:"text"});this.$loaded=i("div",this.options.prefix+"-loaded",{padding:this.options.padding,width:"100%",height:"100%",overflow:e.inArray(this.options.type,["photo","image","album","gallery"])==-1?"auto":"hidden"});this.$loading=i("div",this.options.prefix+"-loading",{height:"100%",width:"100%"})},_append:function(){if(this.options.overlay)e(document.body).append(this.$overlay);e(document.body).append(this.$wrap.append(this.$title.append(this.$controls),this.$content.append(this.$loaded)));if(this.options.buttons!==null&&this.options.buttons.length>0){this.$foot.appendTo(this.$wrap);if(this.options.resize)this.$resize.appendTo(this.$foot)}else{if(this.options.resize)this.$resize.appendTo(this.$content)}},_bindEvents:function(){var r=this;if(this.$trigger){this.$trigger.bind("click."+this.options.prefix,function(e){e.preventDefault();r.focus()})}this.enableResize();this.enableDrag();if(this.options.overlay&&this.options.overlayEvent){var i=false;if(e.isFunction(this.options.overlayEvent))i=this.options.overlayEvent;else if(e.isFunction(this[this.options.overlayEvent])){i=this[this.options.overlayEvent]}if(i)this.$overlay.bind("click."+this.options.prefix,function(){i.apply(r)})}switch(this.options.type){case"confirm":if(!this.options.buttonEvents.OK){this.options.buttonEvents.OK=function(){this.close(function(){this.v=true})}}if(!this.options.buttonEvents.Cancel){this.options.buttonEvents.Cancel=function(){this.close(function(){this.v=false})}}break;case"prompt":if(!this.options.buttonEvents.OK){this.options.buttonEvents.OK=function(){this.close(function(){this.v=this.$prompt.val()})}}if(!this.options.buttonEvents.Cancel){this.options.buttonEvents.Cancel=function(){this.close(function(){this.v=t})}}break;default:if(!this.options.buttonEvents.OK){this.options.buttonEvents.OK="close"}break}e.each(this.options.buttonEvents,function(t,n){if(!e.isFunction(n))n=e.isFunction(r[n])?r[n]:false;if(!n)return;r.$buttons[t].bind("click."+r.options.prefix,function(){n.apply(r)})});e.each(this.$icons,function(e,t){var n;switch(e){case"close":n=function(e){e.stopPropagation();r.close()};t.bind("click."+r.options.prefix,n);break;case"max":n=function(e){e.stopPropagation();r.max()};t.unbind("click.max."+r.options.prefix).one("click.max."+r.options.prefix,n);break;case"min":n=function(e){e.stopPropagation();r.min()};t.unbind("click.min."+r.options.prefix).one("click.min."+r.options.prefix,n);break;case"play":n=function(e){e.stopPropagation();r.play()};t.bind("click.play."+r.options.prefix,n);break;case"prev":n=function(e){e.stopPropagation();r.prev()};t.bind("click.prev."+r.options.prefix,n);break;case"next":n=function(e){e.stopPropagation();r.next()};t.bind("click.next."+r.options.prefix,n);break}});this.$wrap.bind("mousedown."+r.options.prefix,function(){e(this).css("z-index",++e.msgbox._zIndex);e.msgbox._focused=r});e.each(this.options.keyEvents,function(t,i){t=n[t]||t;if(!t)return;if(!e.isFunction(i))i=e.isFunction(r[i])?r[i]:false;if(!i)return;e(document).bind("keydown."+r.options.prefix,function(n){if(n.keyCode!==t)return;if(e.msgbox._focused!=r)return;i.apply(r)})})},_loadImg:function(n,r){if(!n||n.length==0)return;var s=this;this.$loading=i("div",this.options.prefix+"-loading",{height:"100%",width:"100%"}).appendTo(this.$loaded);if(!this.titleSpecified)this.title(n.attr("title"));var u=function(){s.$loading.remove();s.$loading=t;if(s.options.photoScaled){var e=s.options.height-s.options.titleHeight-s.options.footHeight;var n=s.$img.outerHeight(true);var i=s.$img.outerWidth(true);var o=1;if(n>e)o=e/n;if(i*o>s.options.width)o=s.options.width/i;var u=i*o,a=n*o;s.$img.css({position:"absolute",width:i*o+"px",height:n*o+"px"});if(a<=e)s.$img.css("top",(e-a)/2+"px");if(u<=s.options.width)s.$img.css("left",(s.options.width-u)/2+"px")}else{s.options.height=s.$img.outerHeight(true)+s.options.titleHeight+s.options.footHeight;s.options.width=s.$img.outerWidth(true)}s.$img.fadeIn(s.options.photoFade);s.loaded=true;if(s.options.onLoad)s.options.onLoad.apply(s);if(r)r.apply(s)};if(!this.$img){this.$img=i("img",this.options.prefix+"-photo");e.each(["alt","longdesc","aria-describedby"],function(e,t){var r=n.attr(t)||n.attr("data-"+t)||"";s.$img.attr(t,r)});this.$img.hide().appendTo(this.$loaded).error(function(){s.$loading.remove();s.$loading=t;s.loaded=true;s.content(o("imgError",s.options.lang))})}this.$img.hide().unbind("load."+this.options.prefix).bind("load."+this.options.prefix,u);setTimeout(function(){s.$img.attr("src",n.attr("href"))},1)},_load:function(n){if(this.loaded)return;switch(this.options.type){case"text":this.$loaded.text(this.options.content);this.loaded=true;if(n)n.apply(this);if(this.options.onLoad)this.options.onLoad.apply(this);break;case"html":var r=e.type(this.options.content)==="object"?this.options.content.show():this.options.content;this.$loaded.append(r);this.loaded=true;if(n)n.apply(this);if(this.options.onLoad)this.options.onLoad.apply(this);break;case"alert":case"warning":case"info":case"error":case"success":case"confirm":var r=e.type(this.options.content)==="object"?this.options.content.show():this.options.content;this.$loaded.append(r).addClass(this.options.prefix+"-shortcut "+this.options.prefix+"-"+this.options.type);this.loaded=true;if(n)n.apply(this);if(this.options.onLoad)this.options.onLoad.apply(this);break;case"prompt":var r=e.type(this.options.content)==="object"?this.options.content.show():this.options.content;this.$loaded.append(r).append(this.$prompt).addClass(this.options.prefix+"-shortcut "+this.options.prefix+"-"+this.options.type);this.loaded=true;if(n)n.apply(this);if(this.options.onLoad)this.options.onLoad.apply(this);break;case"ajax":this.$loading=i("div",this.options.prefix+"-loading",{height:"100%",width:"100%"}).appendTo(this.$content);var s=this;this.$loaded.load(this.options.content,function(e,r){s.$loading.remove();s.$loading=t;s.$loaded.appendTo(s.$content);if(r=="error")s.$loaded.html(o("xhrError",s.options.lang));s.loaded=true;if(n)n.apply(s);if(s.options.onLoad)s.options.onLoad.apply(s)});break;case"photo":case"image":var u=e(this.options.content);this._loadImg(u,n);break;case"album":case"gallery":var a=this.$trigger?this.$trigger.index(this.options.content):0;this.index=a<0?0:a;var u=e(this.options.content).eq(this.index);var s=this;this._loadImg(u,function(){s.$img.unbind("click."+s.options.prefix).bind("click."+s.options.prefix,function(){s.next()});if(n)n.apply(s)});break;case"iframe":var f=i("div",this.options.prefix+"-loading",{height:this.$content.innerHeight()+"px",width:"100%"}).appendTo(this.$content);if(!this.options.title){this.title(o("Loading",this.options.lang)+" ...");this.options.title=false}var s=this;this.$iframe=i("iframe",this.options.prefix+"-iframe",{height:"100%",width:"100%",border:"none",display:"none"},{frameborder:0,marginheight:"0px",marginwidth:"0px",scrolling:"auto",src:this.options.content}).appendTo(s.$loaded).one("load",function(){f.remove();s.$iframe.show();if(!s.options.title){var t="";try{t=e("title",s.$iframe.contents()).text()}catch(r){}s.title(t)}s.loaded=true;if(s.options.onLoad)s.options.onLoad.apply(s);if(n)n.apply(s)});break}},_restoreFromMin:function(e){if(!this.minimized)return;var t=this;this.animate(this.minimized,function(){t.minimized=false;t.$icons.min.removeClass(t.options.prefix+"-restore");t.$wrap.css("position",t.options.fixed?"fixed":"absolute");t.$icons.min.unbind("click.min."+t.options.prefix).one("click.min."+t.options.prefix,function(){t.min()});t.enableDrag();t.enableResize();if(e)e.apply(t)})},_min:function(e,t){if(this.minimized)return;var n={width:parseInt(this.$wrap.css("width")),height:parseInt(this.$wrap.css("height")),top:parseInt(this.$wrap.css("top")),left:parseInt(this.$wrap.css("left"))};var r=this;this.animate(e,function(){r.minimized=n;r.$icons.min.addClass(r.options.prefix+"-restore");r.$wrap.css("position","fixed");r.$icons.min.unbind("click.restore."+r.options.prefix).one("click.restore."+r.options.prefix,function(){r.restore()});if(!this.$trigger)r.disableDrag();r.disableResize();if(t)t.apply(r)})},enableDrag:function(){if(this.options.drag===false)return;var n=this;this.$title.css("cursor","move").bind("mousedown.drag."+this.options.prefix,function(r){n.dragData.x=r.pageX;n.dragData.y=r.pageY;n.dragData.top=parseInt(n.$wrap.css("top"));n.dragData.left=parseInt(n.$wrap.css("left"));n.dragData.width=parseInt(n.$wrap.css("width"));n.dragData.height=parseInt(n.$wrap.css("height"));e(document).one("mouseup.drag."+n.options.prefix,function(t){n.dragData={};e(this).unbind(" mousemove.drag."+n.options.prefix)}).bind("mousemove.drag."+n.options.prefix,function(r){r.preventDefault();if(e.isEmptyObject(n.dragData))return;var i=n.dragData.left+r.pageX-n.dragData.x;var s=n.dragData.top+r.pageY-n.dragData.y;var o=n.dragData.width;var u=n.dragData.height;var a=e(n.options.drag);if(a.length>0){var f=a.offset();if(!f)f={left:0,top:0};if(!n.options.fixed){f.left+=e(window).scrollLeft();f.top+=e(window).scrollTop()}var l=f.left;var c=f.top;var h=f.left+a.innerWidth();var p=f.top+a.innerHeight();i=i<=l?l:i;i=i+o>h?h-o:i;s=s+u>p?p-u:s;s=s<=c?c:s}n.animate({width:o,height:u,top:s,left:i},t,0)})})},disableDrag:function(){this.$title.css("cursor","auto").unbind("mousedown.drag."+this.options.prefix)},enableResize:function(){if(this.options.resize===false)return;var n=this;this.$resize.show().bind("mousedown.resize."+this.options.prefix,function(r){n.resizeData.x=r.pageX;n.resizeData.y=r.pageY;n.resizeData.width=parseInt(n.$wrap.css("width"));n.resizeData.height=parseInt(n.$wrap.css("height"));n.resizeData.top=parseInt(n.$wrap.css("top"));n.resizeData.left=parseInt(n.$wrap.css("left"));e(document).bind("mouseup.resize."+n.options.prefix,function(t){n.resizeData={};e(this).unbind("mouseup.resize."+n.options.prefix+" mousemove.resize."+n.options.prefix)}).bind("mousemove.resize."+n.options.prefix,function(r){r.preventDefault();if(e.isEmptyObject(n.resizeData))return;var i=n.resizeData.width+r.pageX-n.resizeData.x;var s=n.resizeData.height+r.pageY-n.resizeData.y;i=i<n.options.resize.width?n.options.resize.width:i;s=s<n.options.resize.height?n.options.resize.height:s;n.animate({width:i,height:s,top:n.resizeData.top,left:n.resizeData.left},t,0)})})},disableResize:function(){this.$resize.hide().unbind("mousedown.resize."+this.options.prefix)},animate:function(n,r,i){n=n||{};n=e.extend({},{top:this.options.top,left:this.options.left,width:this.options.width,height:this.options.height,opacity:1},n);if(i===t)i=this.options.speed;var o=(s()-n.height)/2-this.options.titleHeight;var u=(e(window).width()-n.width)/2;o=o<0?0:o;if(n.top===false)n.top=this.options.fixed?o:o+e(window).scrollTop();if(n.left===false)n.left=this.options.fixed?u:u+e(window).scrollLeft();var a=this;this.$overlay.fadeTo(i,this.options.opacity);var f=function(){a.$content.height(a.$wrap.height()-a.options.titleHeight-a.options.footHeight)};this.$wrap.dequeue().animate(n,{duration:i,complete:function(){f();if(r)r.apply(a)},step:f,easing:this.options.transition})},flash:function(t,n,r){t=t||.3;n=n||100;var i=this;this.$title.fadeTo(0,t).delay(n).fadeTo(0,1).delay(n).fadeTo(0,t).delay(n).fadeTo(0,1).queue(function(){if(r)r.apply(i);e(this).dequeue()})},play:function(e){if(this.options.type!="album"&&this.options.type!="gallery")return;if(this.playing&&this.playing!=-1&&this.playing!=-2){this.pause();return}var t=this;this.$icons.play.removeClass(this.options.prefix+"-pause");this.playing=setTimeout(function(){t.next(e)},t.options.photoSpeed)},pause:function(){if(this.options.type!="album"&&this.options.type!="gallery")return;if(!this.playing||this.playing===-1||this.playing===-2)return;if(this.playing){clearTimeout(this.playing);this.playing=-1}var e=this;this.$icons.play.addClass(this.options.prefix+"-pause")},next:function(t){if(this.options.type!="album"&&this.options.type!="gallery")return;this.index++;this.index=this.index>=e(this.options.content).length?0:this.index;var n=e(this.options.content).eq(this.index);var r=this;if(r.playing&&r.playing!=-1&&r.playing!=-2)clearTimeout(r.playing);this._loadImg(n,function(){if(r.playing&&r.playing!=-1&&r.playing!=-2){r.playing=setTimeout(function(){r.next(t)},r.options.photoSpeed)}r.animate();if(t)t.apply(r)})},prev:function(t,n){if(this.options.type!="album"&&this.options.type!="gallery")return;this.index--;this.index=this.index>=e(this.options.content).length?0:this.index;var r=e(this.options.content).eq(this.index);var i=this;if(i.playing&&i.playing!=-1&&i.playing!=-2)clearTimeout(i.playing);this._loadImg(r,function(){if(i.playing&&i.playing!=-1&&i.playing!=-2){i.playing=setTimeout(function(){i.next(n)},i.options.photoSpeed)}i.animate();if(n)n.apply(i)})},open:function(n){if(this.opened)return;this.$overlay.show().css("z-index",++e.msgbox._zIndex);this.$wrap.show().css("z-index",e.msgbox._zIndex);this.options.titleHeight=this.$title.outerHeight(true);this.$title.css({"line-height":this.options.titleHeight+"px"});if(this.options.footHeight>0){this.options.footHeight=this.$foot.outerHeight(true);this.$foot.css({"line-height":this.options.footHeight+"px"})}this.$content.height(this.$wrap.height()-this.options.titleHeight-this.options.footHeight);if(this.options.resize===true){this.options.resize={width:this.options.minWidth,height:this.options.buttons!==null&&this.options.buttons.length>0?this.options.titleHeight+this.options.footHeight+5:this.options.titleHeight+5}}var r=this;var i=function(){r.opened=true;e.msgbox._focused=r;if(r.options.onOpen)r.options.onOpen.apply(r);if(n)n.apply(r)};var s=function(){if((r.options.type=="album"||r.options.type=="gallery")&&r.options.photoAuto&&r.options.photoSpeed&&(!r.playing||r.playing==-2)){r.play()}};if(this.loaded){this.animate(t,function(){i();s()})}else{this._load(function(){r.animate(t,i);s()})}},val:function(){return this.v},close:function(t){if(!this.opened)return;if(this.options.onBeforeClose&&this.options.onBeforeClose.apply(this)===false)return;if(this.playing&&this.playing!=-1&&this.playing!=-2){clearTimeout(this.playing);this.playing=-2}var n=this;var r=function(e){n.animate({width:n.options.initialWidth,height:n.options.initialHeight,opacity:0},function(){n.$overlay.fadeOut("fast",function(){n.opened=false;n.$wrap.hide();n.$overlay.hide();if(e)e.apply(n);if(n.options.onClose)n.options.onClose.apply(n)})})};if(!this.$trigger&&this.minimized)e.msgbox._arrangeMin(this,"out",function(){r(t)});else r(t)},remove:function(){if(this.$trigger)this.$trigger.unbind("click."+this.options.prefix);this.$overlay.remove();this.$wrap.remove()},title:function(n){if(n===t)return this.options.title;this.options.title=n;var r=this;this.$title.contents().filter(function(){return this.nodeType==3||!e(this).is(r.$controls)}).remove();this.$title.prepend(n);return this},reload:function(e){this.loaded=false;if(this.options.type=="iframe"){this.$iframe.remove()}else{if(this.$loaded)this.$loaded.remove()}this._load(e)},focus:function(n){this.$overlay.css("z-index",++e.msgbox._zIndex);this.$wrap.css("z-index",e.msgbox._zIndex);var r=this;if(!this.opened){this.open(n)}else if(this.minimized){this.restore(function(){e.msgbox._focused=r;if(n)n.apply(r)})}else{this.flash(t,t,function(){e.msgbox._focused=r;if(n)n.apply(r)})}},restore:function(t){if(this.minimized){this.$trigger?this._restoreFromMin(t):e.msgbox._arrangeMin(this,"out",t)}else if(this.maximized){var n=this;this.animate(this.maximized,function(){n.maximized=false;n.$icons.max.removeClass(n.options.prefix+"-restore");n.$wrap.css("position",n.options.fixed?"fixed":"absolute");n.$icons.max.unbind("click.max."+n.options.prefix).one("click.max."+n.options.prefix,function(){n.max()});n.enableDrag();n.enableResize();if(t)t.apply(n)})}},min:function(t){if(this.minimized){this.restore(t)}else{this.$trigger?this._min({width:this.options.minWidth,height:this.options.titleHeight}):e.msgbox._arrangeMin(this,"in",t)}},max:function(t){if(this.maximized){this.restore(t);return}var n=this,r=e.extend({},this.minized);if(this.minimized){this.minimized={top:0,left:0,width:e(window).width(),height:s()};e.msgbox._arrangeMin(this,"out",function(){n.maximized=r;n.$icons.max.addClass(n.options.prefix+"-restore");n.$wrap.css("position","fixed");n.$icons.max.unbind("click.restore."+n.options.prefix).one("click.restore."+n.options.prefix,function(){n.restore()});n.disableDrag();n.disableResize();if(t)t.apply(n)})}else{var r={width:parseInt(this.$wrap.css("width")),height:parseInt(this.$wrap.css("height")),top:parseInt(this.$wrap.css("top")),left:parseInt(this.$wrap.css("left"))};var n=this;this.animate({top:0,left:0,width:e(window).width(),height:s()},function(){n.maximized=r;n.$icons.max.addClass(n.options.prefix+"-restore");n.$wrap.css("position","fixed");n.$icons.max.unbind("click.restore."+n.options.prefix).one("click.restore."+n.options.prefix,function(){n.restore()});n.disableDrag();n.disableResize();if(t)t.apply(n)})}},content:function(e){var n=this;if(e===t){return this.$loaded.html()}else{this.$loaded.html(e)}return true}};e.fn.msgbox=function(t){if(typeof t=="object"){t=e.extend(true,{},r,t);var n=e(this).selector;return this.each(function(){var r=e(this);r.selector=n;var i=new u(r,t);e(this).data("msgbox."+t.id,i)})}else{t=t||0;var i=e(this).data("msgbox."+t);return i}return this};e.msgbox=function(n){if(typeof n=="object"){var i=n.open===t?true:n.open;n=e.extend(true,{},r,n);var s=e(document.body).data("msgbox."+n.id);if(s){s.focus()}else{s=new u(false,n);e(document.body).data("msgbox."+n.id,s);if(i)s.open()}return s}else{n=n||0;var s=e(document.body).data("msgbox."+n);return s}};e.extend(e.msgbox,{defaults:function(t){e.extend(r,t);e.msgbox._zIndex=r.zIndex},version:"8.0",_focused:null,_zIndex:r.zIndex,closeAll:function(t){var n=e(document.body).data();var r=e({});e.each(n,function(e,t){if(e.indexOf("msgbox.")===0&&t.opened){r.queue("closeAll",function(e){t.close(e)})}});if(t)r.queue("closeAll",t);r.dequeue("closeAll")},restoreAll:function(t){var n=e(document.body).data();var r=e({});e.each(n,function(e,t){if(e.indexOf("msgbox.")===0&&t.minimized){r.queue("restoreAll",function(e){t.restore(e)})}});if(t)r.queue("restoreAll",t);r.dequeue("restoreAll")},minAll:function(t){var n=e(document.body).data();var r=e({});e.each(n,function(e,t){if(e.indexOf("msgbox.")===0&&!t.minimized){r.queue("minAll",function(e){t.min(e)})}});if(t)r.queue("minAll",t);r.dequeue("minAll")},_arrangeMin:function(t,n,r){var i=e(document.body).data();if(!i)return;var o=[],u=0,a=0,f=[],l=3,c=e({});e.each(i,function(e,n){if(e.indexOf("msgbox.")===0&&(n.minimized||e=="msgbox."+t.options.id)&&n.options.minPos==t.options.minPos){o[e]=n;f.push(e);u+=n.options.minWidth+l}});f.sort();a=e.inArray("msgbox."+t.options.id,f);if(n=="in"){var h=1,p=0,d;if(u>e(window).width())h=e(window).width()/u;d=t.options.minWidth*h;e.each(f,function(e,n){if(e==a){c.queue("min",function(e){t._min({left:p,top:t.options.minPos=="bottom"?s()-t.options.titleHeight:0,width:d,height:t.options.titleHeight},function(){p+=d+l;e()})})}else{var r=o[n].options.minWidth*h;c.queue("min",function(e){o[n].animate({left:p,top:o[n].options.minPos=="bottom"?s()-o[n].options.titleHeight:0,width:r,height:o[n].options.titleHeight},function(){p+=r+l;e()},50)})}})}else{u-=t.options.minWidth;var h=1;if(u>e(window).width())h=e(window).width()/u;var p=0;c.queue("min",function(e){t._restoreFromMin(e)});e.each(f,function(e,n){if(e!=a)c.queue("min",function(e){var r=o[n].options.minWidth*h;o[n].animate({left:p,top:t.options.minPos=="bottom"?s()-o[n].options.titleHeight:0,width:r,height:o[n].options.titleHeight},e,50);p+=r+l})})}if(r){c.queue("min",r)}c.dequeue("min")}})})(jQuery,undefined)