/*! dialogs-manager v4.7.1 | (c) kobi zaltzberg | https://github.com/kobizz/dialogs-manager/blob/master/license.txt 2019-01-13 15:53 */ !function(a,b){"use strict";var c={widgetstypes:{},createwidgettype:function(b,d,e){e||(e=this.widget);var f=function(){e.apply(this,arguments)},g=f.prototype=new e(b);return g.types=g.types.concat([b]),a.extend(g,d),g.constructor=f,f.extend=function(a,b){return c.createwidgettype(a,b,f)},f},addwidgettype:function(a,b,c){return b&&b.prototype instanceof this.widget?this.widgetstypes[a]=b:this.widgetstypes[a]=this.createwidgettype(a,b,c)},getwidgettype:function(a){return this.widgetstypes[a]}};c.instance=function(){var b=this,d={},e={},f=function(){d.body=a("body")},g=function(b){var c={classprefix:"dialog",effects:{show:"fadein",hide:"fadeout"}};a.extend(e,c,b)};this.createwidget=function(a,d){var e=c.getwidgettype(a),f=new e(a);return d=d||{},f.init(b,d),f},this.getsettings=function(a){return a?e[a]:object.create(e)},this.init=function(a){return g(a),f(),b},b.init()},c.widget=function(b){var d=this,e={},f={},g={},h=0,i=["refreshposition"],j=function(){var a=[g.window];g.iframe&&a.push(jquery(g.iframe[0].contentwindow)),a.foreach(function(a){e.hide.onesckeypress&&a.on("keyup",u),e.hide.onoutsideclick&&a[0].addeventlistener("click",o,!0),e.hide.onoutsidecontextmenu&&a[0].addeventlistener("contextmenu",o,!0),e.position.autorefresh&&a.on("resize",d.refreshposition)}),(e.hide.onclick||e.hide.onbackgroundclick)&&g.widget.on("click",n)},k=function(b,c){var d=e.effects[b],f=g.widget;if(a.isfunction(d))d.apply(f,c);else{if(!f[d])throw"reference error: the effect "+d+" not found";f[d].apply(f,c)}},l=function(){var b=i.concat(d.getclosuremethods());a.each(b,function(){var a=this,b=d[a];d[a]=function(){b.apply(d,arguments)}})},m=function(a){if(a.my){var b=/left|right/,c=/([+-]\d+)?$/,d=g.iframe.offset(),e=g.iframe[0].contentwindow,f=a.my.split(" "),h=[];1===f.length&&(b.test(f[0])?f.push("center"):f.unshift("center")),f.foreach(function(a,b){var f=a.replace(c,function(a){return a=+a||0,a+=b?d.top-e.scrolly:d.left-e.scrollx,a>=0&&(a="+"+a),a});h.push(f)}),a.my=h.join(" ")}},n=function(b){if(!s(b)){if(e.hide.onclick){if(a(b.target).closest(e.selectors.preventclose).length)return}else if(b.target!==this)return;d.hide()}},o=function(b){s(b)||a(b.target).closest(g.widget).length||d.hide()},p=function(){d.addelement("widget"),d.addelement("header"),d.addelement("message"),d.addelement("window",window),d.addelement("body",document.body),d.addelement("container",e.container),e.iframe&&d.addelement("iframe",e.iframe),e.closebutton&&d.addelement("closebutton",'
');var b=d.getsettings("id");b&&d.setid(b);var c=[];a.each(d.types,function(){c.push(e.classes.globalprefix+"-type-"+this)}),c.push(d.getsettings("classname")),g.widget.addclass(c.join(" "))},q=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,closebuttonclass:g.classprefix+"-close-button-icon",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}},a.extend(!0,e,d.getdefaultsettings(),f),r()},r=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))})},s=function(a){return"click"===a.type&&2===a.button},t=function(a){return a.replace(/([a-z])([a-z])/g,function(){return arguments[1]+"-"+arguments[2].tolowercase()})},u=function(a){var b=27,c=a.which;b===c&&d.hide()},v=function(){var a=[g.window];g.iframe&&a.push(jquery(g.iframe[0].contentwindow)),a.foreach(function(a){e.hide.onesckeypress&&a.off("keyup",u),e.hide.onoutsideclick&&a[0].removeeventlistener("click",o,!0),e.hide.onoutsidecontextmenu&&a[0].removeeventlistener("contextmenu",o,!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=t(b),i=[];return d&&i.push(e.classes.globalprefix+"-"+d),i.push(e.classes.globalprefix+"-"+h),i.push(e.classes.prefix+"-"+h),f.addclass(i.join(" ")),f},this.destroy=function(){return v(),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(){return cleartimeout(h),k("hide",arguments),v(),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),q(a,b),p(),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),this},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=c.addelement(b.name,a("<"+e.tag+">").text(b.text),"button");c.buttons.push(f);var g=function(){d.hide.onbuttonclick&&c.hide(),a.isfunction(b.callback)&&b.callback.call(this,c)};return f.on("click",g),b.hotkey&&(this.hotkeys[b.hotkey]=g),this.getelements("buttonswrapper").append(f),b.focus&&(this.focusedbutton=f),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);