Your IP : 3.135.195.220


Current Path : /home/bitrix/ext_www/klimatlend.ua/bitrix/js/ui/notification/
Upload File :
Current File : /home/bitrix/ext_www/klimatlend.ua/bitrix/js/ui/notification/ui.notification.stack.min.js

(function(){"use strict";BX.namespace("BX.UI.Notification");BX.UI.Notification.Position={TOP_LEFT:"top-left",TOP_CENTER:"top-center",TOP_RIGHT:"top-right",BOTTOM_LEFT:"bottom-left",BOTTOM_CENTER:"bottom-center",BOTTOM_RIGHT:"bottom-right"};BX.UI.Notification.Stack=function(t){t=BX.type.isPlainObject(t)?t:Object.create(null);this.balloons=[];this.queueStack=[];this.id=BX.type.isNotEmptyString(t.id)?t.id:BX.util.getRandomString(8).toLowerCase();this.position=BX.UI.Notification.Stack.getPositionCode(t.position)?t.position:"top-right";this.spacing=20;this.offsetX=25;this.offsetY=25;this.newestOnTop=false;this.balloonType=BX.UI.Notification.Balloon;this.setOptions(t);BX.addCustomEvent(BX.UI.Notification.Event.getFullName("onClose"),this.handleBalloonClose.bind(this))};BX.UI.Notification.Stack.getPositionCode=function(t){for(var i in BX.UI.Notification.Position){if(BX.UI.Notification.Position[i]===t){return i}}return null};BX.UI.Notification.Stack.prototype={adjustPosition:function(t){var i=0;this.getBalloons().forEach(function(e){if(!t||t===e){switch(this.getPosition()){case BX.UI.Notification.Position.TOP_LEFT:e.getContainer().style.left=this.getOffsetX()+"px";e.getContainer().style.top=i+this.getOffsetY()+"px";break;case BX.UI.Notification.Position.TOP_CENTER:e.getContainer().style.left="50%";e.getContainer().style.transform="translateX(-50%)";e.getContainer().style.top=i+this.getOffsetY()+"px";break;case BX.UI.Notification.Position.TOP_RIGHT:e.getContainer().style.right=this.getOffsetX()+"px";e.getContainer().style.top=i+this.getOffsetY()+"px";break;case BX.UI.Notification.Position.BOTTOM_LEFT:e.getContainer().style.left=this.getOffsetX()+"px";e.getContainer().style.bottom=i+this.getOffsetY()+"px";break;case BX.UI.Notification.Position.BOTTOM_CENTER:e.getContainer().style.left="50%";e.getContainer().style.transform="translateX(-50%)";e.getContainer().style.bottom=i+this.getOffsetY()+"px";break;case BX.UI.Notification.Position.BOTTOM_RIGHT:e.getContainer().style.right=this.getOffsetX()+"px";e.getContainer().style.bottom=i+this.getOffsetY()+"px";break}}i+=this.getSpacing()+e.getHeight()},this)},add:function(t){if(this.getBalloons().length>0&&(this.getQueue().length>0||!this.isBalloonFitToViewport(t))){this.queue(t)}else{this.push(t)}},remove:function(t){this.balloons=this.balloons.filter(function(i){return t!==i})},push:function(t){if(!(t instanceof BX.UI.Notification.Balloon)){throw new Error("'balloon' must be an instance of BX.UI.Notification.Balloon.")}if(this.balloons.indexOf(t)===-1){if(this.isNewestOnTop()){this.balloons.splice(0,0,t)}else{this.balloons.push(t)}}},queue:function(t){if(!(t instanceof BX.UI.Notification.Balloon)){throw new Error("'balloon' must be an instance of BX.UI.Notification.Balloon.")}if(this.queueStack.indexOf(t)===-1){t.setState(BX.UI.Notification.State.QUEUED);this.queueStack.push(t)}},checkQueue:function(){var t=this.queueStack.slice();for(var i=0;i<t.length;i++){var e=t[i];if(!this.isBalloonFitToViewport(e)&&this.getBalloons().length>0){break}e.setState(BX.UI.Notification.State.INIT);this.queueStack.shift();this.push(e);e.show()}},getQueue:function(){return this.queueStack},isBalloonFitToViewport:function(t){var i=document.documentElement.clientHeight;var e=this.getSpacing()+t.getHeight();return this.getHeight()+e<=i},handleBalloonClose:function(t){var i=t.getBalloon();if(i.getStack()!==this){return}this.remove(i);this.adjustPosition();this.checkQueue()},setOptions:function(t){t=t||{};this.setSpacing(t.spacing);this.setOffsetX(t.offsetX);this.setOffsetY(t.offsetY);this.setNewestOnTop(t.newestOnTop);this.setBalloonType(t.balloonType)},getId:function(){return this.id},getBalloons:function(){return this.balloons},getPosition:function(){return this.position},getSpacing:function(){return this.spacing},setSpacing:function(t){if(BX.type.isNumber(t)){this.spacing=t}},getOffsetX:function(){return this.offsetX},setOffsetX:function(t){if(BX.type.isNumber(t)){this.offsetX=t}},getOffsetY:function(){return this.offsetY},setOffsetY:function(t){if(BX.type.isNumber(t)){this.offsetY=t}},getHeight:function(){return this.getBalloons().reduce(function(t,i){return t+i.getHeight()+this.getSpacing()}.bind(this),this.getOffsetY())},getBalloonType:function(t){var i=BX.getClass(t);if(BX.type.isFunction(i)){return i}return this.balloonType||BX.UI.Notification.Balloon},setBalloonType:function(t){if(t instanceof BX.UI.Notification.Balloon){this.balloonType=t}else if(BX.type.isNotEmptyString(t)){var i=BX.getClass(t);if(BX.type.isFunction(i)){this.balloonType=i}}},isNewestOnTop:function(){return this.newestOnTop},setNewestOnTop:function(t){if(BX.type.isBoolean(t)){this.newestOnTop=t}}}})();