Current Path : /var/www/www-root/data/www/www.monolith-realty.ru/bitrix/js/ui/alerts/ |
Current File : /var/www/www-root/data/www/www.monolith-realty.ru/bitrix/js/ui/alerts/ui.alerts.min.js |
(function(){"use strict";BX.namespace("BX.UI.Alert");BX.UI.Alert=function(t){this.options=t||{};this.container=null;this.text=null;this.icon=null;this.textNode=null;this.closeBtn=false;this.closeNode=null;this.animated=false;this.color=BX.UI.Alert.Color.PRIMARY;this.size=BX.UI.Alert.Size.MEDIUM;this.setText(t.text);this.setAnimation(t.animated);this.setInline(t.inline);this.setTextCenter(t.textCenter);this.setIcon(t.icon);this.setColor(t.color);this.setSize(t.size)};BX.UI.Alert.Color={DEFAULT:"ui-alert-default",DANGER:"ui-alert-danger",SUCCESS:"ui-alert-success",PRIMARY:"ui-alert-primary",WARNING:"ui-alert-warning"};BX.UI.Alert.Size={MEDIUM:"ui-alert-md",SMALL:"ui-alert-xs"};BX.UI.Alert.Icon={WARNING:"ui-alert-icon-warning",DANGER:"ui-alert-icon-danger",INFO:"ui-alert-icon-info"};BX.UI.Alert.prototype={setColor:function(t){if(BX.type.isNotEmptyString(t)){BX.removeClass(this.getContainer(),this.color);this.color=t;BX.addClass(this.getContainer(),this.color)}},setSize:function(t){if(BX.type.isNotEmptyString(t)){BX.removeClass(this.getContainer(),this.size);this.size=t;BX.addClass(this.getContainer(),this.size)}},setText:function(t){if(BX.type.isNotEmptyString(t)){this.text=t}},getText:function(){return this.text},setIcon:function(t){if(BX.type.isNotEmptyString(t)){BX.removeClass(this.getContainer(),this.icon);this.icon=t;BX.addClass(this.getContainer(),this.icon)}},setTextCenter:function(t){if(BX.type.isBoolean(t)){this.textCenter=t;if(this.textCenter===true){BX.addClass(this.getContainer(),"ui-alert-text-center")}else{BX.removeClass(this.getContainer(),"ui-alert-text-center")}}},setInline:function(t){if(BX.type.isBoolean(t)){this.inline=t;if(this.inline===true){BX.addClass(this.getContainer(),"ui-alert-inline")}else{BX.removeClass(this.getContainer(),"ui-alert-inline")}}},getTextNode:function(){if(this.textNode===null){this.textNode=BX.create("div",{props:{className:"ui-alert-message"},html:this.getText()})}return this.textNode},getCloseBtn:function(){if(this.closeNode===null&&this.options.closeBtn===true){this.closeNode=BX.create("span",{props:{className:"ui-alert-close-btn"},events:{click:this.handleCloseBtnClick.bind(this)}})}return this.closeNode},handleCloseBtnClick:function(){if(this.animated===true){this.animateClosing()}else{BX.remove(this.container)}},animateClosing:function(){this.container.style.overflow="hidden";var t=BX.pos(this.container);this.container.style.height=t.height+"px";setTimeout(function(){this.container.style.height=0;this.container.style.paddingTop=0;this.container.style.paddingBottom=0;this.container.style.marginBottom=0;this.container.style.opacity=0}.bind(this),10);setTimeout(function(){BX.remove(this.container)}.bind(this),260)},setAnimation:function(t){if(BX.type.isBoolean(t)){this.animated=t}},getContainer:function(){if(this.container!==null){return this.container}if(this.animated===true){var t=0;var e=0;var i=0;var n=0;var s=0;var o="hidden"}this.container=BX.create("div",{props:{className:"ui-alert"},style:{"max-height":t,overflow:o,"padding-top":i,"padding-bottom":e,"margin-bottom":n,opacity:s},children:[this.getTextNode(),this.getCloseBtn()]});if(this.animated===true){setTimeout(function(){this.container.style.maxHeight="500px";this.container.style.removeProperty("padding-top");this.container.style.removeProperty("padding-bottom");this.container.style.removeProperty("margin-bottom");this.container.style.opacity=1}.bind(this),10);setTimeout(function(){this.container.style.removeProperty("overflow");this.container.style.removeProperty("max-height");this.container.style.removeProperty("opacity")}.bind(this),260)}return this.container}}})();