BX.UI.Notification - IlyaKovanov/lib GitHub Wiki

подключение библиотеки

<?CJSCore::Init("ui.notification"); ?>

script.js

BX.UI.Notification.Center.notify({
  content: message,
  title: "Уведомление",
  type: "success",
  autoHide: true,
  delay: 3000, // Уведомление будет отображаться 3 секунды
  closeButton: false,
  actions: [
     {
       title: "Отмена",
       events: {
         click: function(event, balloon, action) {
            balloon.close();
         }
       } 
     }
  ]
});

переопределение стилей

     class MyBalloon extends BX.UI.Notification.Balloon
        {
            /**
            * @protected
            * @return {Element}
            */
            render()
            {
                var content = this.getContent();
                return BX.create("div", {
                    props: {
                        className: "my-balloon"
                    },
                html: BX.type.isDomNode(content) ? null : content,
                children: BX.type.isDomNode(content) ? [content] : []
                })
                    }    
        }
            BX.UI.Notification.Center.notify({
                content: "Custom Balloon",
                type: "MyBalloon",
                render: function() {
                    return BX.create("div", {
                        props: {
                            className: "my-balloon"
                        },
                    html: this.getContent() + "  " + this.getData().time
                    })
                },
                data: {
                    time: Date.now()
                }     
            });