/* ======================= Prime Graphic User Interface Custom Box Extension Framework Library V2.0 Author: Stefano zorzetto Date: 2023-02-09 MosaicoGroup Copyright 2019 ======================= */ if ($MWGUI != null) { function TMWGUICustomBox(Rows, Column, Options = null) { let Me = {}; Me.CloneOptions = { ...Options }; let Contestual = false; if (Me.CloneOptions != null) { if (Me.CloneOptions.hasOwnProperty("CreateReferenceContestualWindow")) { if (Me.CloneOptions["CreateReferenceContestualWindow"] == true) { Contestual = true; } } } if (!Contestual) { if (window != $MWGUI.MainWindow) { return new $MWGUI.MainWindow.TMWGUICustomBox(Rows, Column, Options); } } switch (parseInt(Rows)) { case 2: { Me.Row = "resgui-2row"; break; } case 3: { Me.Row = "resgui-3row"; break; } case 4: { Me.Row = "resgui-4row"; break; } case 5: { Me.Row = "resgui-5row"; break; } case 6: { Me.Row = "resgui-6row"; break; } case 7: { Me.Row = "resgui-7row"; break; } case 8: { Me.Row = "resgui-8row"; break; } case 9: { Me.Row = "resgui-9row"; break; } case 10: { Me.Row = "resgui-10row"; break; } case 11: { Me.Row = "resgui-11row"; break; } case 12: { Me.Row = "resgui-12row"; break; } case 13: { Me.Row = "resgui-13row"; break; } case 14: { Me.Row = "resgui-14row"; break; } case 15: { Me.Row = "resgui-15row"; break; } case 16: { Me.Row = "resgui-16row"; break; } case 17: { Me.Row = "resgui-17row"; break; } case 18: { Me.Row = "resgui-18row"; break; } default: { Me.Row = "resgui-19row"; break; } } switch (parseInt(Column)) { case 2: { Me.Column = "resgui-2column"; break; } case 3: { Me.Column = "resgui-3column"; break; } case 4: { Me.Column = "resgui-4column"; break; } case 5: { Me.Column = "resgui-5column"; break; } case 6: { Me.Column = "resgui-6column"; break; } case 7: { Me.Column = "resgui-7column"; break; } case 8: { Me.Column = "resgui-8column"; break; } case 9: { Me.Column = "resgui-9column"; break; } case 10: { Me.Column = "resgui-10column"; break; } case 11: { Me.Column = "resgui-11column"; break; } case 12: { Me.Column = "resgui-12column"; break; } case 13: { Me.Column = "resgui-13column"; break; } case 14: { Me.Column = "resgui-14column"; break; } case 15: { Me.Column = "resgui-15column"; break; } case 16: { Me.Column = "resgui-16column"; break; } case 17: { Me.Column = "resgui-17column"; break; } case 18: { Me.Column = "resgui-18column"; break; } case 19: { Me.Column = "resgui-19column"; break; } case 20: { Me.Column = "resgui-20column"; break; } case 21: { Me.Column = "resgui-21column"; break; } case 22: { Me.Column = "resgui-22column"; break; } case 23: { Me.Column = "resgui-23column"; break; } case 24: { Me.Column = "resgui-24column"; break; } case 25: { Me.Column = "resgui-25column"; break; } case 26: { Me.Column = "resgui-26column"; break; } case 27: { Me.Column = "resgui-27column"; break; } case 28: { Me.Column = "resgui-28column"; break; } case 29: { Me.Column = "resgui-29column"; break; } case 30: { Me.Column = "resgui-30column"; break; } default: { Me.Column = "resgui-31column"; break; } } //Commons Me.CustomBoxMinimizedContainer; if (Me.CloneOptions != null) { if (Me.CloneOptions.hasOwnProperty("STECustomBox")) { Me.CustomBoxMinimizedContainer = $MWGUI.MainDocument.getElementById("CustomBoxMinimizedContainerSTE"); Me.CustomBoxMinimizedContainer.style.zIndex = 1500; Me.CustomBoxMinimizedContainer.style.display = "flex"; Me.CustomBoxMinimizedContainer.style.flexDirection = "column-reverse"; Me.CustomBoxMinimizedContainer.style.alignItems = "flex-start"; Me.CustomBoxMinimizedContainer.style.position = "fixed"; Me.CustomBoxMinimizedContainer.style.width = "100%"; Me.CustomBoxMinimizedContainer.style.height = "100%"; Me.CustomBoxMinimizedContainer.style.pointerEvents = "none"; } else { Me.CustomBoxMinimizedContainer = $MWGUI.MainDocument.getElementById("CustomBoxMinimizedContainer"); Me.CustomBoxMinimizedContainer.style.zIndex = 3; } } else { Me.CustomBoxMinimizedContainer = $MWGUI.MainDocument.getElementById("CustomBoxMinimizedContainer"); Me.CustomBoxMinimizedContainer.style.zIndex = 3; } Me.CustomBoxMinimizedContainerContestualized = null; Me.UseContestualizedWindow = false; Me.EnabledMinimize = false; Me.Minimized = false; Me.EnabledHide = false; Me.EnabledHideButton = null; Me.document = document; Me.window = window; //Custombox if (parent && parent.hasOwnProperty("$MWGUI") && parent.$MWGUI.hasOwnProperty("MainDocument")) Me.Background = parent.$MWGUI.MainDocument.createElement("div"); else Me.Background = $MWGUI.MainDocument.createElement("div"); Me.Background.onclick = function (ev) { ev.stopPropagation(); } Me.Background.OrinalClassName = Me.Row + " " + Me.Column + " column-direction CustomBoxForm CustomBoxFormEntry"; Me.Background.className = "CustomBoxMain"; Me.Background.Me = Me; Me.CustomBox = $MWGUI.MainDocument.createElement("div"); Me.CustomBox.className = Me.Row + " " + Me.Column + " column-direction CustomBoxForm CustomBoxFormEntry"; Me.Background.appendChild(Me.CustomBox); Me.CustomBox.Background = Me.Background; Me.Title = $MWGUI.MainDocument.createElement("div"); Me.Title.className = "CustomBoxTitleRow"; Me.Title.onclick = function (ev) { ev.stopPropagation(); } Me.CustomBox.appendChild(Me.Title); Me.Title.ButtonContainer = null; Me.Title.TitleContainer = null; Me.Title.CustomButtons == null; Me.Body = $MWGUI.MainDocument.createElement("div"); Me.Body.className = " relative-full-width"; Me.Body.style.height = "calc(100% - var(--resgui-1row))"; Me.CustomBox.appendChild(Me.Body); Me.CustomBoxIsOpen = false; //MINIMIZEDBOX Me.MinimizedBox = $MWGUI.MainDocument.createElement("div"); Me.MinimizedBox.className = "resgui-1row resgui-5column column-direction CustomBoxForm CustomBoxFormEntry"; Me.MinimizedBox.style.zIndex = 700; Me.MinimizedBox.style.pointerEvents = "auto"; Me.MinimizedBox.Title = $MWGUI.MainDocument.createElement("div"); Me.MinimizedBox.Title.className = "CustomBoxTitleRow"; Me.MinimizedBox.onclick = function (ev) { ev.stopPropagation(); } Me.MinimizedBox.appendChild(Me.MinimizedBox.Title); Me.MinimizedBox.ButtonContainer = null; Me.MinimizedBox.TitleContainer = null; Me.Open = function (Callback, PreCallback = null) { $MWGUI.MainBody.appendChild(this.Background); this.CustomBoxIsOpen = true; this.CallbackResult = Callback; if (PreCallback) PreCallback(); } Me.Close = function (Result, ForceClose = false) { let Continue = true; if (this.hasOwnProperty("CustomBeforeClose") && ForceClose == false) { this.CustomBeforeClose(this, function (Continue) { if (Continue) { Me.CustomBox.className = Me.CustomBox.className.replace(new RegExp(" CustomBoxFormEntry", "g"), ""); Me.CustomBox.className += " CustomBoxFormExit"; if (Me.Background && Me.CustomBoxIsOpen) { $MWGUI.MainBody.removeChild(Me.Background); if (Me.UseContestualizedWindow == true) { let CustomBoxMinimizedContainer = Me.document.getElementById("CustomBoxMinimizedContainer") if (CustomBoxMinimizedContainer.contains(Me.CustomBox)) CustomBoxMinimizedContainer.removeChild(Me.CustomBox); } else { /*let CustomBoxMinimizedContainer = $MWGUI.MainDocument.getElementById("CustomBoxMinimizedContainer") if (CustomBoxMinimizedContainer.contains(Me.CustomBox)) CustomBoxMinimizedContainer.removeChild(Me.CustomBox);*/ if (Me.CustomBoxMinimizedContainer.contains(Me.CustomBox)) Me.CustomBoxMinimizedContainer.removeChild(Me.CustomBox); } if (Me.Minimized == true) { Me.MinimizedBox.remove() } } Me.CustomBoxIsOpen = false; let BackGrounds = $MWGUI.MainDocument.getElementsByClassName("CustomBoxMain"); for (let Index = BackGrounds.length - 1; Index == 0; Index--) { if (BackGrounds[Index].hasOwnProperty("Me")) { if (BackGrounds[Index].Me.document.parentNode == null && BackGrounds[Index].Me.UseContestualizedWindow == true) { BackGrounds[Index].Me.Close(); } } } if (Me.hasOwnProperty("CustomAfterClose")) { Me.CustomAfterClose(Me); } setTimeout(() => { let BackGroundsNew = $MWGUI.MainDocument.getElementsByClassName("CustomBoxMain"); if (BackGroundsNew.length > 0) { for (let INdex in BackGroundsNew) { if (BackGroundsNew[INdex].hasOwnProperty("Me")) { if (BackGroundsNew[INdex].Me == Me) { BackGroundsNew[INdex].remove(); } } } } }, 2500); if (Me.CallbackResult != null) { Me.CallbackResult(Me, Result); } } }); } else { this.CustomBox.className = this.CustomBox.className.replace(new RegExp(" CustomBoxFormEntry", "g"), ""); this.CustomBox.className += " CustomBoxFormExit"; if (this.Background && this.CustomBoxIsOpen) { $MWGUI.MainBody.removeChild(this.Background); if (this.UseContestualizedWindow == true) { let CustomBoxMinimizedContainer = this.document.getElementById("CustomBoxMinimizedContainer") if (CustomBoxMinimizedContainer.contains(this.CustomBox)) CustomBoxMinimizedContainer.removeChild(this.CustomBox); } else { /*let CustomBoxMinimizedContainer = $MWGUI.MainDocument.getElementById("CustomBoxMinimizedContainer") if (CustomBoxMinimizedContainer.contains(this.CustomBox)) CustomBoxMinimizedContainer.removeChild(this.CustomBox);*/ if (Me.CustomBoxMinimizedContainer.contains(Me.CustomBox)) Me.CustomBoxMinimizedContainer.removeChild(Me.CustomBox); } if (this.Minimized == true) { this.MinimizedBox.remove() } } this.CustomBoxIsOpen = false; let BackGrounds = $MWGUI.MainDocument.getElementsByClassName("CustomBoxMain"); for (let Index = BackGrounds.length - 1; Index == 0; Index--) { if (BackGrounds[Index].hasOwnProperty("Me")) { if (BackGrounds[Index].Me.document.parentNode == null && BackGrounds[Index].Me.UseContestualizedWindow == true) { BackGrounds[Index].Me.Close(); } } } if (this.hasOwnProperty("CustomAfterClose") && ForceClose == false) { this.CustomAfterClose(this); } setTimeout(() => { let BackGroundsNew = $MWGUI.MainDocument.getElementsByClassName("CustomBoxMain"); if (BackGroundsNew.length > 0) { for (let INdex in BackGroundsNew) { if (BackGroundsNew[INdex].hasOwnProperty("Me")) { if (BackGroundsNew[INdex].Me == Me) { BackGroundsNew[INdex].remove(); } } } } }, 5000); if (this.CallbackResult != null) { this.CallbackResult(this, Result); } } } Me.CountElementInContest = function () { return this.document.getElementsByClassName("CustomBoxMain").length; } Me.addCustomIconInTitle = function (srcIcon, IsHideAndShow = false) { let Icon = null; if (Me.Title.ButtonContainer != null) { if (Me.Title.ButtonContainer.CustomContainer != null) { Icon = document.createElement("img"); Icon.src = srcIcon; Icon.className = "icon-image"; Icon.style.cursor = "pointer"; Icon.style.marginRight = "var(--resgui-quartercolumn)"; Me.Title.ButtonContainer.CustomContainer.appendChild(Icon); if (IsHideAndShow) { Me.HideShowButton = Icon; } } } return Icon; } Me.ChangeTitles = function (NewTitle) { if (this.TitleSpan) { this.TitleSpan.innerHTML = NewTitle; if (this.EnabledMinimize == true) { Me.MinimizedBox.TitleSpan.innerHTML = NewTitle; Me.MinimizedBox.title = NewTitle; } } } Me.Minimize = function () { if (this.EnabledMinimize == true) { if (this.Minimized == false) { let ThisInstance = this; if (this.hasOwnProperty("CustomBeforeMinimize")) { this.CustomBeforeMinimize(this, function (Continue) { if (Continue) { Me.Minimized = true; if (Me.UseContestualizedWindow == true && Me.CustomBoxMinimizedContainerContestualized != null) { Me.CustomBoxMinimizedContainerContestualized.appendChild(Me.MinimizedBox); } else { Me.CustomBoxMinimizedContainer.appendChild(Me.MinimizedBox); } Me.Background.style.display = "none"; if (Me.hasOwnProperty("CustomAfterMinimize")) Me.CustomAfterMinimize(Me); } }) } else { this.Minimized = true; if (this.UseContestualizedWindow == true && this.CustomBoxMinimizedContainerContestualized != null) { this.CustomBoxMinimizedContainerContestualized.appendChild(this.MinimizedBox); } else { this.CustomBoxMinimizedContainer.appendChild(this.MinimizedBox); } this.Background.style.display = "none"; if (Me.hasOwnProperty("CustomAfterMinimize")) Me.CustomAfterMinimize(Me); } } } } Me.Maximize = function () { if (this.EnabledMinimize == true) { if (this.Minimized == true) { if (this.hasOwnProperty("CustomBeforeMaximize")) { this.CustomBeforeMaximize(this, function (Continue) { if (Continue) { Me.Minimized = false; Me.Background.style.display = "flex"; Me.MinimizedBox.remove(); if (Me.hasOwnProperty("CustomAfterMaximize")) Me.CustomAfterMaximize(Me); } }); } else { this.Minimized = false; this.Background.style.display = "flex"; Me.MinimizedBox.remove(); if (Me.hasOwnProperty("CustomAfterMaximize")) Me.CustomAfterMaximize(Me); } } } } Me.MinimizeAllCustomBoxes = function () { let BackGrounds = this.document.getElementsByClassName("CustomBoxMain"); for (let Index in BackGrounds) { if (BackGrounds[Index].hasOwnProperty("Me")) { BackGrounds[Index].Me.Minimize() } } } Me.SetHideShowButton = function (Button) { Me.HideShowButton = Button; } Me.Hide = function () { if (Me.EnabledHide == true && this.EnabledMinimize == true) { if (this.Minimized == true) { this.Background.style.display = "none"; this.MinimizedBox.remove(); } } } Me.HideAllCustomBoxes = function () { //let BackGrounds = this.document.getElementsByClassName("CustomBoxMain"); let BackGrounds = $MWGUI.MainDocument.getElementsByClassName("CustomBoxMain"); for (let Index in BackGrounds) { if (BackGrounds[Index].hasOwnProperty("Me")) { BackGrounds[Index].Me.Hide() } } } Me.HideAllCustomBoxesByParent = function (ParentDocument) { //let BackGrounds = this.document.getElementsByClassName("CustomBoxMain"); let BackGrounds = $MWGUI.MainDocument.getElementsByClassName("CustomBoxMain"); for (let Index in BackGrounds) { if (BackGrounds[Index].hasOwnProperty("Me")) { if (BackGrounds[Index].Me.document.parentNode != null) { if (BackGrounds[Index].Me.document.parentNode == ParentDocument) BackGrounds[Index].Me.Hide() } else if (BackGrounds[Index].Me.document == ParentDocument) BackGrounds[Index].Me.Hide() } } } Me.Show = function () { if (this.EnabledHide == true) { if (this.Minimized == true) { this.Background.style.display = "none"; if (this.UseContestualizedWindow == true && this.CustomBoxMinimizedContainerContestualized != null) { this.CustomBoxMinimizedContainerContestualized.appendChild(this.MinimizedBox); } else { this.CustomBoxMinimizedContainer.appendChild(this.MinimizedBox); } } else { this.Background.style.display = "flex"; } } } Me.ShowAllCustomBoxes = function () { //let BackGrounds = this.document.getElementsByClassName("CustomBoxMain"); let BackGrounds = $MWGUI.MainDocument.getElementsByClassName("CustomBoxMain"); for (let Index in BackGrounds) { if (BackGrounds[Index].hasOwnProperty("Me")) { BackGrounds[Index].Me.Show() } } } Me.ShowAllCustomBoxesByParent = function (ParentDocument) { //let BackGrounds = this.document.getElementsByClassName("CustomBoxMain"); let BackGrounds = $MWGUI.MainDocument.getElementsByClassName("CustomBoxMain"); for (let Index in BackGrounds) { if (BackGrounds[Index].hasOwnProperty("Me")) { if (BackGrounds[Index].Me.document.parentNode != null) { if (BackGrounds[Index].Me.document.parentNode == ParentDocument) BackGrounds[Index].Me.Show() } else if (BackGrounds[Index].Me.document == ParentDocument) BackGrounds[Index].Me.Show() } } } Me.Drag = function (elmnt) { if (this.EnabledDrag == true) { function dragElement(elmnt) { var pos1 = 0, pos2 = 0, pos3 = elmnt.offsetLeft, pos4 = elmnt.offsetTop; elmnt.addEventListener("mousedown", dragMouseDown); elmnt.style.position = "absolute"; let ParentBox; let MeBox; function dragMouseDown(e) { if (Me.Minimized == true) { if (e.button == 0) { if (Me.UseContestualizedWindow == true && Me.CustomBoxMinimizedContainerContestualized != null) { Me.CustomBoxMinimizedContainerContestualized.style.pointerEvents = "auto"; ParentBox = Me.CustomBoxMinimizedContainerContestualized.getBoundingClientRect(); } else { Me.CustomBoxMinimizedContainer.style.pointerEvents = "auto"; ParentBox = Me.CustomBoxMinimizedContainer.getBoundingClientRect(); } //console.log(ParentBox); MeBox = elmnt.getBoundingClientRect(); e = e || window.event; e.preventDefault(); pos3 = e.clientX; pos4 = e.clientY; Me.document.addEventListener("mouseup", onmouseleave); Me.document.addEventListener("mouseleave", onmouseleave); Me.document.addEventListener("pointermove", elementDrag); } } } function onmouseleave(e) { e = e || window.event; e.preventDefault(); if (e != undefined) { if (e.clientX - MeBox.width <= 0) { elmnt.style.left = `0px`; } if (e.clientX + MeBox.width >= ParentBox.right) { elmnt.style.left = `${ParentBox.right - MeBox.width}px`; } if (e.clientY - MeBox.height <= 0) { elmnt.style.top = `0px`; } if (e.clientY + MeBox.height >= ParentBox.bottom) { elmnt.style.top = `${ParentBox.bottom - MeBox.height}px`; } } closeDragElement(); if (Me.UseContestualizedWindow == true && Me.CustomBoxMinimizedContainerContestualized != null) { Me.CustomBoxMinimizedContainerContestualized.style.pointerEvents = "none"; } else { Me.CustomBoxMinimizedContainer.style.pointerEvents = "none"; } } function elementDrag(e) { /*e = e || window.event; e.preventDefault(); pos1 = pos3 - e.clientX; pos2 = pos4 - e.clientY; pos3 = e.clientX; pos4 = e.clientY; elmnt.style.top = (elmnt.offsetTop - pos2) + "px"; elmnt.style.left = (elmnt.offsetLeft - pos1) + "px";*/ e = e || window.event; e.preventDefault(); if (e.clientX >= ParentBox.right || e.clientX <= ParentBox.left) { if (e.clientX >= ParentBox.right) { elmnt.style.left = `${ParentBox.right - MeBox.width}px`; } if (e.clientX <= ParentBox.left) elmnt.style.left = `0px`; onmouseleave(); return; } if (e.clientY >= ParentBox.bottom || e.clientY <= ParentBox.top) { if (e.clientY >= ParentBox.bottom) { elmnt.style.top = `${ParentBox.bottom - MeBox.height}px`; } if (e.clientY <= ParentBox.top) elmnt.style.top = `0px`; onmouseleave(); return; } pos1 = pos3 - e.clientX; pos2 = pos4 - e.clientY; pos3 = e.clientX; pos4 = e.clientY; elmnt.style.top = (elmnt.offsetTop - pos2) + "px"; elmnt.style.left = (elmnt.offsetLeft - pos1) + "px"; } function closeDragElement() { Me.document.removeEventListener("mouseup", onmouseleave); Me.document.removeEventListener("mouseleave", onmouseleave); Me.document.removeEventListener("pointermove", elementDrag); } } dragElement(elmnt); } } if (Me.CloneOptions != null) { if (Contestual) { Me.UseContestualizedWindow = true; let Documents = document.getElementById("CustomBoxMinimizedContainer"); if (Documents == null) { let CustomBoxMinimizedContainerContestualized = document.createElement("div"); CustomBoxMinimizedContainerContestualized.id = "CustomBoxMinimizedContainer"; CustomBoxMinimizedContainerContestualized.style.zIndex = 600; CustomBoxMinimizedContainerContestualized.onclick = function (ev) { ev.stopPropagation() } document.body.appendChild(CustomBoxMinimizedContainerContestualized); Me.CustomBoxMinimizedContainerContestualized = CustomBoxMinimizedContainerContestualized; } else Me.CustomBoxMinimizedContainerContestualized = Documents; } if (Me.CloneOptions.hasOwnProperty("ZIndex")) { Me.Background.style.zIndex = Me.CloneOptions.ZIndex; } if (Me.CloneOptions.hasOwnProperty("TitleColor")) { var ColorDiv = document.createElement("div"); ColorDiv.className = "resgui-quartercolumn relative-full-height"; ColorDiv.style.backgroundColor = Me.CloneOptions["TitleColor"]; Me.Title.appendChild(ColorDiv); Me.TitleColor = ColorDiv; if (Me.CloneOptions.hasOwnProperty("EnableMinimize")) { if (Me.CloneOptions["EnableMinimize"]) { var ColorDivMinimized = document.createElement("div"); ColorDivMinimized.className = "resgui-quartercolumn relative-full-height"; ColorDivMinimized.style.backgroundColor = Me.CloneOptions["TitleColor"]; Me.MinimizedBox.Title.appendChild(ColorDivMinimized); Me.MinimizedBox.TitleColor = ColorDivMinimized; } } } if (Me.CloneOptions.hasOwnProperty("TitleSpan")) { if (Me.Title.TitleContainer == null && Me.Title.ButtonContainer == null && Column >= 6) { Me.Title.TitleContainer = document.createElement("div"); Me.Title.TitleContainer.className = `resgui-full-height `; Me.Title.TitleContainer.style.width = "100%" Me.Title.appendChild(Me.Title.TitleContainer); Me.Title.ButtonContainer = document.createElement("div"); Me.Title.ButtonContainer.className = "resgui-full-height justify-content-space-around"; Me.Title.ButtonContainer.style.minWidth = "var(--resgui-3column)" Me.Title.appendChild(Me.Title.ButtonContainer); Me.Title.ButtonContainer.CustomContainer = document.createElement("div"); Me.Title.ButtonContainer.CustomContainer.className = `resgui-full-height row-direction`; Me.Title.ButtonContainer.appendChild(Me.Title.ButtonContainer.CustomContainer); } var spanTitle = document.createElement("span"); spanTitle.style.marginLeft = "var(--resgui-halfcolumn)"; spanTitle.innerHTML = Me.CloneOptions["TitleSpan"]; if (Me.Title.TitleContainer != null) Me.Title.TitleContainer.appendChild(spanTitle); else Me.Title.appendChild(spanTitle); Me.TitleSpan = spanTitle; } if (Me.CloneOptions.hasOwnProperty("EnableMinimize")) { if (Me.CloneOptions["EnableMinimize"]) { Me.EnabledMinimize = true; if (Me.Title.TitleContainer == null && Me.Title.ButtonContainer == null && Column >= 6) { Me.Title.TitleContainer = document.createElement("div"); Me.Title.TitleContainer.className = `resgui-full-height`; Me.Title.appendChild(Me.Title.TitleContainer); Me.Title.ButtonContainer = document.createElement("div"); Me.Title.ButtonContainer.className = "resgui-full-height justify-content-space-around"; Me.Title.ButtonContainer.style.minWidth = "var(--resgui-3column)" Me.Title.appendChild(Me.Title.ButtonContainer); Me.Title.ButtonContainer.CustomContainer = document.createElement("div"); Me.Title.ButtonContainer.CustomContainer.className = `resgui-full-height row-direction`; Me.Title.ButtonContainer.appendChild(Me.Title.ButtonContainer.CustomContainer); } Me.MinimizedBox.TitleContainer = document.createElement("div"); Me.MinimizedBox.TitleContainer.className = `resgui-full-height resgui-3column`; Me.MinimizedBox.Title.appendChild(Me.MinimizedBox.TitleContainer); Me.MinimizedBox.ButtonContainer = document.createElement("div"); Me.MinimizedBox.ButtonContainer.className = "resgui-full-height resgui-2column justify-content-space-around"; Me.MinimizedBox.Title.appendChild(Me.MinimizedBox.ButtonContainer); if (Me.CloneOptions.hasOwnProperty("TitleSpan")) { var spanTitleMinimized = document.createElement("span"); spanTitleMinimized.style.marginLeft = "var(--resgui-halfcolumn)"; spanTitleMinimized.innerHTML = Me.CloneOptions["TitleSpan"]; Me.MinimizedBox.TitleContainer.appendChild(spanTitleMinimized); Me.MinimizedBox.TitleSpan = spanTitleMinimized; Me.MinimizedBox.title = Me.CloneOptions["TitleSpan"]; } let imgMinimize = document.createElement("img"); imgMinimize.className = "icon-image"; imgMinimize.src = `../../../../../../../../../../../../../../../../../../images/flags/Test/minimize.png`; imgMinimize.style.cursor = "pointer"; imgMinimize.style.marginRight = "var(--resgui-quartercolumn)"; imgMinimize.statusMinimize = false; imgMinimize.CustomBox = Me.CustomBox; imgMinimize.Background = Me.Background; imgMinimize.Me = Me; imgMinimize.onclick = function (ev) { ev.stopPropagation(); this.Me.Minimize(); if (Me.UseContestualizedWindow == true) { if (Me.HideShowButton != null) { Me.HideShowButton.OnHideFunction = false; Me.HideShowButton.click(); } } else { $MWGUI.IconHideShowCustomBoxes.OnHideFunction = false; $MWGUI.IconHideShowCustomBoxes.click(); } }; if (Me.Title.ButtonContainer != null) Me.Title.ButtonContainer.appendChild(imgMinimize); else Me.Title.appendChild(imgMinimize); let imgMinimizeMinimizedBox = document.createElement("img"); imgMinimizeMinimizedBox.className = "icon-image"; imgMinimizeMinimizedBox.src = `../../../../../../../images/icons/box.png`; imgMinimizeMinimizedBox.style.cursor = "pointer"; imgMinimizeMinimizedBox.style.marginRight = "var(--resgui-quartercolumn)"; imgMinimizeMinimizedBox.Background = Me.Background; imgMinimizeMinimizedBox.MinimizedBox = Me.MinimizedBox; imgMinimizeMinimizedBox.Me = Me; imgMinimizeMinimizedBox.onclick = function (ev) { ev.stopPropagation(); this.Me.Maximize(); }; imgMinimizeMinimizedBox.onmousedown = function (e) { e.stopPropagation(); } Me.MinimizedBox.ButtonContainer.appendChild(imgMinimizeMinimizedBox); } } if (Me.CloneOptions.hasOwnProperty("EnableClose")) { if (Me.CloneOptions["EnableClose"]) { if (Me.Title.TitleContainer == null && Me.Title.ButtonContainer == null && Column >= 6) { Me.Title.TitleContainer = document.createElement("div"); Me.Title.TitleContainer.className = `resgui-full-height`; Me.Title.appendChild(Me.Title.TitleContainer); Me.Title.ButtonContainer = document.createElement("div"); Me.Title.ButtonContainer.className = "resgui-full-height justify-content-space-around"; Me.Title.ButtonContainer.style.minWidth = "var(--resgui-3column)" Me.Title.appendChild(Me.Title.ButtonContainer); Me.Title.ButtonContainer.CustomContainer = document.createElement("div"); Me.Title.ButtonContainer.CustomContainer.className = `resgui-full-height row-direction`; Me.Title.ButtonContainer.appendChild(Me.Title.ButtonContainer.CustomContainer); } let spanClose = document.createElement("span"); spanClose.innerHTML = "×"; spanClose.style.fontSize = "var(--resgui-font-height-xl)"; spanClose.style.cursor = "pointer"; spanClose.style.marginRight = "var(--resgui-quartercolumn)"; spanClose.Me = Me; spanClose.onclick = function (ev) { ev.stopPropagation(); if (this.Me.UseContestualizedWindow == true) { if (this.Me.HideShowButton != null) { this.Me.HideShowButton.OnHideFunction = false; this.Me.HideShowButton.click(); } } else { $MWGUI.IconHideShowCustomBoxes.OnHideFunction = false; $MWGUI.IconHideShowCustomBoxes.click(); } this.Me.Close() }; if (Me.Title.ButtonContainer != null) Me.Title.ButtonContainer.appendChild(spanClose); else Me.Title.appendChild(spanClose); if (Me.EnabledMinimize == true) { let spanCloseMinimizedBox = document.createElement("span"); spanCloseMinimizedBox.innerHTML = "×"; spanCloseMinimizedBox.style.fontSize = "var(--resgui-font-height-xl)"; spanCloseMinimizedBox.style.cursor = "pointer"; spanCloseMinimizedBox.style.marginRight = "var(--resgui-quartercolumn)"; spanCloseMinimizedBox.Me = Me; spanCloseMinimizedBox.onclick = function (ev) { ev.stopPropagation(); if (Me.UseContestualizedWindow == true) { if (Me.HideShowButton != null) { Me.HideShowButton.OnHideFunction = false; Me.HideShowButton.click(); } } else { $MWGUI.IconHideShowCustomBoxes.OnHideFunction = false; $MWGUI.IconHideShowCustomBoxes.click(); } this.Me.Close(); }; spanCloseMinimizedBox.onmousedown = function (e) { e.stopPropagation(); } Me.MinimizedBox.ButtonContainer.appendChild(spanCloseMinimizedBox); } } } if (Me.CloneOptions.hasOwnProperty("EnableHide")) { if (Me.CloneOptions["EnableHide"]) { Me.EnabledHide = true; Me.HideShowButton = null; if (Me.UseContestualizedWindow == true) { Me.document.body.onclick = function () { if (Me.HideShowButton != null) { Me.HideShowButton.OnHideFunction = true; Me.HideShowButton.click(); } } $MWGUI.MainFrame.onclick = function () { if (Me.HideShowButton != null) { Me.HideShowButton.OnHideFunction = true; Me.HideShowButton.click(); } } } else { Me.document.body.onclick = function () { $MWGUI.IconHideShowCustomBoxes.OnHideFunction = true; $MWGUI.IconHideShowCustomBoxes.click(); } $MWGUI.MainFrame.onclick = function () { $MWGUI.IconHideShowCustomBoxes.OnHideFunction = true; $MWGUI.IconHideShowCustomBoxes.click(); } } } } if (Me.CloneOptions.hasOwnProperty("CreateHideButton")) { if (Me.CloneOptions["CreateHideButton"]) { if (Me.Title.ButtonContainer != null) { if (Me.Title.ButtonContainer.CustomContainer != null) { let Icon = document.createElement("img"); Icon.src = "../../../../../../../../../../../../../../../images/icons/windowsOpen.png"; Icon.className = "icon-image"; Icon.style.cursor = "pointer"; Icon.style.marginRight = "var(--resgui-quartercolumn)"; Icon.Me = Me; Icon.addEventListener("click", function (e) { e.stopPropagation(); if (!this.hasOwnProperty("OnHideFunction")) { this.OnHideFunction = true; } let BackGrounds = $MWGUI.MainDocument.getElementsByClassName("CustomBoxMain"); if (BackGrounds.length > 0) { let CanContinue = false; for (let Index in BackGrounds) { if (BackGrounds[Index].hasOwnProperty("Me")) { if (this.Me.Body.children.length > 0) { if (BackGrounds[Index].Me.document == this.Me.Body.children[0].contentDocument) CanContinue = true; } } } if (CanContinue) { if (this.OnHideFunction == true) { this.OnHideFunction = false; this.className += " InternalAnimationPulse" this.src = "../../../../../../../../../../../../../images/icons/windowsClose.png" if (BackGrounds.length > 0) { for (let index in BackGrounds) { if (BackGrounds[index].hasOwnProperty("Me")) { BackGrounds[index].Me.HideAllCustomBoxesByParent(BackGrounds[index].Me.document); } } } } else { this.OnHideFunction = true; this.className = "icon-image-button"; this.src = "../../../../../../../../../../../../../images/icons/windowsOpen.png" if (BackGrounds.length > 0) { for (let index in BackGrounds) { if (BackGrounds[index].hasOwnProperty("Me")) { BackGrounds[index].Me.ShowAllCustomBoxesByParent(BackGrounds[index].Me.document); } } } } } } }) Me.Title.ButtonContainer.CustomContainer.appendChild(Icon); Me.HideShowButton = Icon; } } } } if (Me.CloneOptions.hasOwnProperty("StartMinimizeLeft")) { if (Me.CloneOptions.StartMinimizeLeft == false) { var ParentBox; if (Me.UseContestualizedWindow == true && Me.CustomBoxMinimizedContainerContestualized != null) { ParentBox = Me.CustomBoxMinimizedContainerContestualized.getBoundingClientRect(); } else { ParentBox = Me.CustomBoxMinimizedContainer.getBoundingClientRect(); } //Me.MinimizedBox.style.left = `${ParentBox.right - Me.MinimizedBox.width}px`; Me.MinimizedBox.style.left = `calc(${ParentBox.right}px - var(--resgui-5column))`; } } if (Me.CloneOptions.hasOwnProperty("StartMinimizeTop")) { if (Me.CloneOptions.StartMinimizeTop == false) { var ParentBox; if (Me.UseContestualizedWindow == true && Me.CustomBoxMinimizedContainerContestualized != null) { ParentBox = Me.CustomBoxMinimizedContainerContestualized.getBoundingClientRect(); } else { ParentBox = Me.CustomBoxMinimizedContainer.getBoundingClientRect(); } //Me.MinimizedBox.style.top = `${ParentBox.bottom - var(--resgui-1row)}px`; Me.MinimizedBox.style.top = `${ParentBox.top}px`; } } if (Me.CloneOptions.hasOwnProperty("EnableDrag")) { if (Me.CloneOptions["EnableDrag"] == true) { if (Me.EnabledMinimize == true) { Me.EnabledDrag = true; Me.Drag(Me.MinimizedBox) } } } if (Me.CloneOptions.hasOwnProperty("CustomClose")) { Me.Close = Me.CloneOptions.CustomClose; } if (Me.CloneOptions.hasOwnProperty("CustomBeforeClose")) { Me.CustomBeforeClose = Me.CloneOptions.CustomBeforeClose; } if (Me.CloneOptions.hasOwnProperty("CustomAfterClose")) { Me.CustomAfterClose = Me.CloneOptions.CustomAfterClose; } if (Me.CloneOptions.hasOwnProperty("CustomMinimize")) { Me.Minimize = Me.CloneOptions.CustomMinimize; } if (Me.CloneOptions.hasOwnProperty("CustomBeforeMinimize")) { Me.CustomBeforeMinimize = Me.CloneOptions.CustomBeforeMinimize; } if (Me.CloneOptions.hasOwnProperty("CustomAfterMinimize")) { Me.CustomAfterMinimize = Me.CloneOptions.CustomAfterMinimize; } if (Me.CloneOptions.hasOwnProperty("CustomMaximize")) { Me.Maximize = Me.CloneOptions.CustomMaximize; } if (Me.CloneOptions.hasOwnProperty("CustomBeforeMaximize")) { Me.CustomBeforeMaximize = Me.CloneOptions.CustomBeforeMaximize; } if (Me.CloneOptions.hasOwnProperty("CustomAfterMaximize")) { Me.CustomAfterMaximize = Me.CloneOptions.CustomAfterMaximize; } if (Me.CloneOptions.hasOwnProperty("OnLoadFunction")) { // attacco img display none su custombox // attacco la funzione ricevuta al onload dell img } if ((!Me.CloneOptions.hasOwnProperty("EnableMinimize") || !Me.CloneOptions["EnableMinimize"]) && (!Me.CloneOptions.hasOwnProperty("EnableClose") || !Me.CloneOptions["EnableClose"]) && Me.Title && Me.Title.ButtonContainer) Me.Title.ButtonContainer.style.display = "none"; } return Me; } } else console.log("This library is an extention of MW.GUI.js Framework. Add script reference to this library!!!");