",{"class":e.closebuttonoptions.iconclass});b.append(c),d.addelement("closebutton",b)}var f=d.getsettings("id");f&&d.setid(f);var h=[];a.each(d.types,function(){h.push(e.classes.globalprefix+"-type-"+this)}),h.push(d.getsettings("classname")),g.widget.addclass(h.join(" "))},r=function(c,f){var g=a.extend(!0,{},c.getsettings());e={headermessage:"",message:"",effects:g.effects,classes:{globalprefix:g.classprefix,prefix:g.classprefix+"-"+b,preventscroll:g.classprefix+"-prevent-scroll"},selectors:{preventclose:"."+g.classprefix+"-prevent-close"},container:"body",preventscroll:!1,iframe:null,closebutton:!1,closebuttonoptions:{iconclass:g.classprefix+"-close-button-icon",attributes:{}},position:{element:"widget",my:"center",at:"center",enable:!0,autorefresh:!1},hide:{auto:!1,autodelay:5e3,onclick:!1,onoutsideclick:!0,onoutsidecontextmenu:!1,onbackgroundclick:!0,onesckeypress:!0,ignore:""}},a.extend(!0,e,d.getdefaultsettings(),f),s()},s=function(){a.each(e,function(a){var b=a.match(/^on([a-z].*)/);b&&(b=b[1].charat(0).tolowercase()+b[1].slice(1),d.on(b,this))})},t=function(a){return"click"===a.type&&2===a.button},u=function(a){return a.replace(/([a-z])([a-z])/g,function(){return arguments[1]+"-"+arguments[2].tolowercase()})},v=function(a){var b=27,c=a.which;b===c&&d.hide()},w=function(){var a=[g.window];g.iframe&&a.push(jquery(g.iframe[0].contentwindow)),a.foreach(function(a){e.hide.onesckeypress&&a.off("keyup",v),e.hide.onoutsideclick&&a[0].removeeventlistener("click",p,!0),e.hide.onoutsidecontextmenu&&a[0].removeeventlistener("contextmenu",p,!0),e.position.autorefresh&&a.off("resize",d.refreshposition)}),(e.hide.onclick||e.hide.onbackgroundclick)&&g.widget.off("click",n)};this.addelement=function(b,c,d){var f=g[b]=a(c||""),h=u(b);return d=d?d+" ":"",d+=e.classes.globalprefix+"-"+h,d+=" "+e.classes.prefix+"-"+h,f.addclass(d),f},this.destroy=function(){return w(),g.widget.remove(),d.trigger("destroy"),d},this.getelements=function(a){return a?g[a]:g},this.getsettings=function(a){var b=object.create(e);return a?b[a]:b},this.hide=function(){if(d.isvisible())return cleartimeout(h),k("hide",arguments),w(),e.preventscroll&&d.getelements("body").removeclass(e.classes.preventscroll),d.trigger("hide"),d},this.init=function(a,b){if(!(a instanceof c.instance))throw"the "+d.widgetname+" must to be initialized from an instance of dialogsmanager.instance";return l(),d.trigger("init",b),r(a,b),q(),d.buildwidget(),d.attachevents(),d.trigger("ready"),d},this.isvisible=function(){return g.widget.is(":visible")},this.on=function(b,c){if("object"==typeof b)return a.each(b,function(a){d.on(a,this)}),d;var e=b.split(" ");return e.foreach(function(a){f[a]||(f[a]=[]),f[a].push(c)}),d},this.off=function(a,b){if(!f[a])return d;if(!b)return delete f[a],d;var c=f[a].indexof(b);return-1!==c&&f[a].splice(c,1),d},this.refreshposition=function(){if(e.position.enable){var b=a.extend({},e.position);g[b.of]&&(b.of=g[b.of]),b.of||(b.of=window),e.iframe&&m(b),g[b.element].position(b)}},this.setid=function(a){return g.widget.attr("id",a),d},this.setheadermessage=function(a){return d.getelements("header").html(a),d},this.setmessage=function(a){return g.message.html(a),d},this.setsettings=function(b,c){return jquery.isplainobject(c)?a.extend(!0,e[b],c):e[b]=c,d},this.show=function(){return cleartimeout(h),g.widget.appendto(g.container).hide(),k("show",arguments),d.refreshposition(),e.hide.auto&&(h=settimeout(d.hide,e.hide.autodelay)),j(),e.preventscroll&&d.getelements("body").addclass(e.classes.preventscroll),d.trigger("show"),d},this.trigger=function(b,c){var e="on"+b[0].touppercase()+b.slice(1);d[e]&&d[e](c);var g=f[b];if(g)return a.each(g,function(a,b){b.call(d,c)}),d}},c.widget.prototype.types=[],c.widget.prototype.buildwidget=function(){var a=this.getelements(),b=this.getsettings();a.widget.append(a.header,a.message),this.setheadermessage(b.headermessage),this.setmessage(b.message),this.getsettings("closebutton")&&a.widget.prepend(a.closebutton)},c.widget.prototype.attachevents=function(){var a=this;a.getsettings("closebutton")&&a.getelements("closebutton").on("click",function(){a.hide()})},c.widget.prototype.getdefaultsettings=function(){return{}},c.widget.prototype.getclosuremethods=function(){return[]},c.widget.prototype.onhide=function(){},c.widget.prototype.onshow=function(){},c.widget.prototype.oninit=function(){},c.widget.prototype.onready=function(){},c.widgetstypes.simple=c.widget,c.addwidgettype("buttons",{activekeyup:function(a){var b=9;a.which===b&&a.preventdefault(),this.hotkeys[a.which]&&this.hotkeys[a.which](this)},activekeydown:function(a){if(this.focusedbutton){var b=9;if(a.which===b){a.preventdefault();var c,d=this.focusedbutton.index();a.shiftkey?(c=d-1,c<0&&(c=this.buttons.length-1)):(c=d+1,c>=this.buttons.length&&(c=0)),this.focusedbutton=this.buttons[c].focus()}}},addbutton:function(b){var c=this,d=c.getsettings(),e=jquery.extend(d.button,b),f=b.classes?b.classes+" ":"";f+=d.classes.globalprefix+"-button";var g=c.addelement(b.name,a("<"+e.tag+">").html(b.text),f);c.buttons.push(g);var h=function(){d.hide.onbuttonclick&&c.hide(),a.isfunction(b.callback)&&b.callback.call(this,c)};return g.on("click",h),b.hotkey&&(this.hotkeys[b.hotkey]=h),this.getelements("buttonswrapper").append(g),b.focus&&(this.focusedbutton=g),c},bindhotkeys:function(){this.getelements("window").on({keyup:this.activekeyup,keydown:this.activekeydown})},buildwidget:function(){c.widget.prototype.buildwidget.apply(this,arguments);var a=this.addelement("buttonswrapper");this.getelements("widget").append(a)},getclosuremethods:function(){return["activekeyup","activekeydown"]},getdefaultsettings:function(){return{hide:{onbuttonclick:!0},button:{tag:"button"}}},onhide:function(){this.unbindhotkeys()},oninit:function(){this.buttons=[],this.hotkeys={},this.focusedbutton=null},onshow:function(){this.bindhotkeys(),this.focusedbutton||(this.focusedbutton=this.buttons[0]),this.focusedbutton&&this.focusedbutton.focus()},unbindhotkeys:function(){this.getelements("window").off({keyup:this.activekeyup,keydown:this.activekeydown})}}),c.addwidgettype("lightbox",c.getwidgettype("buttons").extend("lightbox",{getdefaultsettings:function(){var b=c.getwidgettype("buttons").prototype.getdefaultsettings.apply(this,arguments);return a.extend(!0,b,{contentwidth:"auto",contentheight:"auto",position:{element:"widgetcontent",of:"widget",autorefresh:!0}})},buildwidget:function(){c.getwidgettype("buttons").prototype.buildwidget.apply(this,arguments);var a=this.addelement("widgetcontent"),b=this.getelements();a.append(b.header,b.message,b.buttonswrapper),b.widget.html(a),b.closebutton&&a.prepend(b.closebutton)},onready:function(){var a=this.getelements(),b=this.getsettings();"auto"!==b.contentwidth&&a.message.width(b.contentwidth),"auto"!==b.contentheight&&a.message.height(b.contentheight)}})),c.addwidgettype("confirm",c.getwidgettype("lightbox").extend("confirm",{onready:function(){c.getwidgettype("lightbox").prototype.onready.apply(this,arguments);var a=this.getsettings("strings"),b="cancel"===this.getsettings("defaultoption");this.addbutton({name:"cancel",text:a.cancel,callback:function(a){a.trigger("cancel")},focus:b}),this.addbutton({name:"ok",text:a.confirm,callback:function(a){a.trigger("confirm")},focus:!b})},getdefaultsettings:function(){var a=c.getwidgettype("lightbox").prototype.getdefaultsettings.apply(this,arguments);return a.strings={confirm:"ok",cancel:"cancel"},a.defaultoption="cancel",a}})),c.addwidgettype("alert",c.getwidgettype("lightbox").extend("alert",{onready:function(){c.getwidgettype("lightbox").prototype.onready.apply(this,arguments);var a=this.getsettings("strings");this.addbutton({name:"ok",text:a.confirm,callback:function(a){a.trigger("confirm")}})},getdefaultsettings:function(){var a=c.getwidgettype("lightbox").prototype.getdefaultsettings.apply(this,arguments);return a.strings={confirm:"ok"},a}})),b.dialogsmanager=c}("undefined"!=typeof jquery?jquery:"function"==typeof require&&require("jquery"),"undefined"!=typeof module?module.exports:window);