core/skin/assets/plugins/notifications/js/lobibox.min.js

1 line
26 KiB
JavaScript
Raw Normal View History

2022-12-11 13:55:49 +05:00
var Lobibox=Lobibox||{};!function(){function LobiboxPrompt(type,options){this.$input=null,this.$type="prompt",this.$promptType=type,options=$.extend({},Lobibox.prompt.DEFAULT_OPTIONS,options),this.$options=this._processInput(options),this._init(),this.debug(this)}function LobiboxConfirm(options){this.$type="confirm",this.$options=this._processInput(options),this._init(),this.debug(this)}function LobiboxAlert(type,options){this.$type=type,this.$options=this._processInput(options),this._init(),this.debug(this)}function LobiboxProgress(options){this.$type="progress",this.$progressBarElement=null,this.$options=this._processInput(options),this.$progress=0,this._init(),this.debug(this)}function LobiboxWindow(type,options){this.$type=type,this.$options=this._processInput(options),this._init(),this.debug(this)}Lobibox.counter=0,Lobibox.prompt=function(type,options){return new LobiboxPrompt(type,options)},Lobibox.confirm=function(options){return new LobiboxConfirm(options)},Lobibox.progress=function(options){return new LobiboxProgress(options)},Lobibox.error={},Lobibox.success={},Lobibox.warning={},Lobibox.info={},Lobibox.alert=function(type,options){return["success","error","warning","info"].indexOf(type)>-1?new LobiboxAlert(type,options):void 0},Lobibox.window=function(options){return new LobiboxWindow("window",options)};var LobiboxBase={$type:null,$el:null,$options:null,debug:function(){this.$options.debug&&window.console.debug.apply(window.console,arguments)},_processInput:function(options){if($.isArray(options.buttons)){for(var btns={},i=0;i<options.buttons.length;i++)btns[options.buttons[i]]=Lobibox.base.OPTIONS.buttons[options.buttons[i]];options.buttons=btns}options.customBtnClass=options.customBtnClass?options.customBtnClass:Lobibox.base.DEFAULTS.customBtnClass;for(var i in options.buttons)if(options.buttons.hasOwnProperty(i)){var btn=options.buttons[i];btn=$.extend({},Lobibox.base.OPTIONS.buttons[i],btn),btn["class"]||(btn["class"]=options.customBtnClass),options.buttons[i]=btn}return options=$.extend({},Lobibox.base.DEFAULTS,options),void 0===options.showClass&&(options.showClass=Lobibox.base.OPTIONS.showClass),void 0===options.hideClass&&(options.hideClass=Lobibox.base.OPTIONS.hideClass),void 0===options.baseClass&&(options.baseClass=Lobibox.base.OPTIONS.baseClass),void 0===options.delayToRemove&&(options.delayToRemove=Lobibox.base.OPTIONS.delayToRemove),options.iconClass||(options.iconClass=Lobibox.base.OPTIONS.icons[options.iconSource][this.$type]),options},_init:function(){var me=this;me._createMarkup(),me.setTitle(me.$options.title),me.$options.draggable&&!me._isMobileScreen()&&(me.$el.addClass("draggable"),me._enableDrag()),me.$options.closeButton&&me._addCloseButton(),me.$options.closeOnEsc&&$(document).on("keyup.lobibox",function(ev){27===ev.which&&me.destroy()}),me.$options.baseClass&&me.$el.addClass(me.$options.baseClass),me.$options.showClass&&(me.$el.removeClass(me.$options.hideClass),me.$el.addClass(me.$options.showClass)),me.$el.data("lobibox",me)},_calculatePosition:function(position){var top,me=this;top="top"===position?30:"bottom"===position?$(window).outerHeight()-me.$el.outerHeight()-30:($(window).outerHeight()-me.$el.outerHeight())/2;var left=($(window).outerWidth()-me.$el.outerWidth())/2;return{left:left,top:top}},_createButton:function(type,op){var me=this,btn=$("<button></button>").addClass(op["class"]).attr("data-type",type).html(op.text);return me.$options.callback&&"function"==typeof me.$options.callback&&btn.on("click.lobibox",function(ev){var bt=$(this);me._onButtonClick(me.$options.buttons[type],type),me.$options.callback(me,bt.data("type"),ev)}),btn.click(function(){me._onButtonClick(me.$options.buttons[type],type)}),btn},_onButtonClick:function(buttonOptions,type){var me=this;("ok"===type&&"prompt"===me.$type&&me.isValid()||"prompt"!==me.$type||"ok"!==type)&&buttonOptions&&buttonOptions.closeOnClick&&me.destroy()},_generateButtons:function(){var me=this,btns=[];for(var i in me.$options.buttons)if(me.$options.buttons.hasOwnProperty(i)){var op=me.$options.buttons[i],btn=me._createButton(i,