<?php
CJSCore::Init(['popup']);
?>
<button id="openPopup">Открыть popup</button>
BX.ready(function () {
var popup = new BX.PopupWindow(
"full-example-popup", // ID popup
BX("openPopup"), // bindElement (привязка)
{
/* === ОСНОВНЫЕ === */
content: `
<div style="padding:20px">
<h3>Полный popup</h3>
<p>Пример со всеми параметрами</p>
<input type="text" placeholder="Поле ввода">
</div>
`,
width: 500,
height: 300,
min_width: 300,
min_height: 150,
max_width: 800,
max_height: 600,
zIndex: 1000,
titleBar: {
content: BX.create("span", {
html: "Заголовок Popup"
})
},
closeIcon: {
right: "10px",
top: "10px"
},
/* === ПОВЕДЕНИЕ === */
autoHide: false,
closeByEsc: true,
draggable: true,
resizable: true,
cacheable: false,
lightShadow: false,
darkMode: false,
/* === OVERLAY === */
overlay: {
backgroundColor: "black",
opacity: 50
},
/* === ПОЗИЦИОНИРОВАНИЕ === */
offsetTop: 0,
offsetLeft: 0,
angle: false,
angleOffset: 0,
anglePosition: "top",
/* === АНИМАЦИЯ === */
animation: "fading",
animationDuration: 200,
/* === КНОПКИ === */
buttons: [
new BX.PopupWindowButton({
text: "Сохранить",
className: "ui-btn ui-btn-success",
events: {
click: function () {
alert("Сохранено");
this.popupWindow.close();
}
}
}),
new BX.PopupWindowButton({
text: "Применить",
className: "ui-btn ui-btn-primary",
events: {
click: function () {
alert("Применено");
}
}
}),
new BX.PopupWindowButtonLink({
text: "Отмена",
className: "ui-btn ui-btn-link",
events: {
click: function () {
this.popupWindow.close();
}
}
})
],
/* === СОБЫТИЯ === */
events: {
onPopupShow: function () {
console.log("Popup открыт");
},
onPopupClose: function () {
console.log("Popup закрыт");
},
onPopupDestroy: function () {
console.log("Popup уничтожен");
}
}
}
);
BX("openPopup").onclick = function ()
{
popup.show();
};
});