From 38d295200f32036edcc38c07cf689e1331048d59 Mon Sep 17 00:00:00 2001 From: Michael Becker Date: Tue, 28 May 2024 16:14:12 -0400 Subject: [PATCH 1/4] update class name --- lib/phast/client/scripts/controls/Window.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/phast/client/scripts/controls/Window.js b/lib/phast/client/scripts/controls/Window.js index f3b5ae8..d2911d9 100644 --- a/lib/phast/client/scripts/controls/Window.js +++ b/lib/phast/client/scripts/controls/Window.js @@ -405,7 +405,7 @@ window.addEventListener("mouseup", function(e) }); window.addEventListener("load", function(e) { - var items = document.getElementsByClassName("Window"); + var items = document.getElementsByClassName("uwt-window"); for (var i = 0; i < items.length; i++) { items[i].NativeObject = new Window(items[i]); From 5214c5d20e9dfa081e44fac28eba87b40c8c6b0b Mon Sep 17 00:00:00 2001 From: Michael Becker Date: Tue, 28 May 2024 16:17:30 -0400 Subject: [PATCH 2/4] update class name --- lib/phast/client/scripts/controls/Window.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/phast/client/scripts/controls/Window.js b/lib/phast/client/scripts/controls/Window.js index d2911d9..bfa7590 100644 --- a/lib/phast/client/scripts/controls/Window.js +++ b/lib/phast/client/scripts/controls/Window.js @@ -271,7 +271,7 @@ function Window(parentElement) } var Window = this.ParentElement; - Window.className = "Window Visible"; + Window.className = "uwt-window uwt-visible"; if (this.mvarContentURL != null) { @@ -582,4 +582,4 @@ Window.ShowDialog = function (content, title, buttons, styles, iconName, classNa // happen divWindow.NativeObject.ShowDialog(); }, 100); -}; \ No newline at end of file +}; From bc40da48be7641e071b87485526842925fc68643 Mon Sep 17 00:00:00 2001 From: Michael Becker Date: Tue, 28 May 2024 16:18:04 -0400 Subject: [PATCH 3/4] provide ability to override entire content of Window --- lib/phast/server/WebControls/Window.inc.php | 22 ++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/lib/phast/server/WebControls/Window.inc.php b/lib/phast/server/WebControls/Window.inc.php index d4c1f42..36f309c 100644 --- a/lib/phast/server/WebControls/Window.inc.php +++ b/lib/phast/server/WebControls/Window.inc.php @@ -22,6 +22,11 @@ public $HeaderControls; public $ContentControls; public $FooterControls; + + + public $Content; + + private $__Content; public function __construct() { @@ -30,6 +35,7 @@ $this->TagName = "div"; $this->ClassList[] = "Window"; $this->ParseChildElements = true; + $this->__Content = null; } protected function OnInitialize() @@ -40,6 +46,9 @@ protected function RenderBeginTag() { + $this->__Content = $this->Content; + $this->Content = null; + switch($this->HorizontalAlignment) { case HorizontalAlignment::Left: @@ -89,11 +98,18 @@ $divInnerContent = new HTMLControl("div"); $divInnerContent->ClassList[] = "Content"; - foreach ($this->ContentControls as $ctl) + if ($this->__Content !== null) { - $divInnerContent->Controls[] = $ctl; + $divInnerContent->Content = $this->__Content; + } + else + { + foreach ($this->ContentControls as $ctl) + { + $divInnerContent->Controls[] = $ctl; + } + $divContent->Controls[] = $divInnerContent; } - $divContent->Controls[] = $divInnerContent; $divLoading = new HTMLControl("div"); $divLoading->ClassList[] = "Loading"; From 18cda016bcbf1c985173c0bd951de1c088fec8f4 Mon Sep 17 00:00:00 2001 From: Michael Becker Date: Tue, 28 May 2024 16:18:38 -0400 Subject: [PATCH 4/4] implement dropdown wrapper to easily stylize HTML SELECT controls --- lib/phast/client/scripts/controls/DropDown.js | 152 ++++++++++++++++++ 1 file changed, 152 insertions(+) diff --git a/lib/phast/client/scripts/controls/DropDown.js b/lib/phast/client/scripts/controls/DropDown.js index 045f90e..d423c9e 100644 --- a/lib/phast/client/scripts/controls/DropDown.js +++ b/lib/phast/client/scripts/controls/DropDown.js @@ -1,7 +1,159 @@ function DropDownWrapper(parentElement) { this.ParentElement = parentElement; + this.ParentContainer = this.ParentElement.parentElement; + this.SelectElement = this.ParentElement; + + this.ShowPopupMenu = function() + { + for (var i = 0; i < this.SelectElement.options.length; i++) + { + if (this.InputElement.value == "" || this.SelectElement.options[i].label.toLowerCase().indexOf(this.InputElement.value.toLowerCase()) != -1) + { + System.ClassList.Add(this.SelectElement.options[i].li, "uwt-visible"); + } + else + { + System.ClassList.Remove(this.SelectElement.options[i].li, "uwt-visible"); + } + } + System.ClassList.Add(this.MenuElement, "uwt-visible"); + }; + this.HidePopupMenu = function() + { + System.ClassList.Remove(this.MenuElement, "uwt-visible"); + }; + + var div = document.createElement("div"); + div.className = "uwt-combobox"; + div.ni = this; + div.tabIndex = 0; + + this.ParentElement.replaceWith(div); + div.appendChild(this.SelectElement); + + var input = document.createElement("input"); + input.id = this.SelectElement.id + "_input"; + input.ni = this; + input.type = "text"; + input.addEventListener("focus", function() + { + this.ni.InputElement._prev_value = this.ni.InputElement.value; + this.ni.InputElement.value = ""; + this.ni.ShowPopupMenu(); + }); + input.addEventListener("blur", function() + { + this.ni.InputElement.value = this.ni.InputElement._prev_value; + if (!this.ni.SelectElement.hasAttribute("multiple")) + { + this.ni.HidePopupMenu(); + } + }); + input.addEventListener("keydown", function(e) + { + if (e.keyCode == KeyboardKeys.Enter) + { + this.__accepted = true; + //this.ni.SetValue(this.ni.GetHighlightedOption().value); + this.ni.HidePopupMenu(); + this.parentElement.focus(); + + e.preventDefault(); + e.stopPropagation(); + return false; + } + }); + input.addEventListener("keyup", function(e) + { + if (this.__accepted == true) + { + this.__accepted = false; + + e.preventDefault(); + e.stopPropagation(); + return false; + } + if (e.keyCode == KeyboardKeys.Escape) + { + this.ni.HidePopupMenu(); + } + else + { + this.ni.ShowPopupMenu(); + } + }); + div.appendChild(input); + this.InputElement = input; + + var ul = document.createElement("ul"); + this.MenuElement = ul; + ul.className = "uwt-menu uwt-popup"; + for (var i = 0; i < this.SelectElement.options.length; i++) + { + var li = document.createElement("li"); + li.className = "uwt-menu-item uwt-menu-item-command uwt-visible"; + this.SelectElement.options[i].li = li; + + var a = document.createElement("a"); + a.href = "#"; + + var spanTitle = document.createElement("span"); + spanTitle.className = "uwt-title"; + spanTitle.innerHTML = this.SelectElement.options[i].label; + a.appendChild(spanTitle); + + var spanDescription = document.createElement("span"); + spanDescription.className = "uwt-description"; + spanDescription.innerHTML = ""; + a.appendChild(spanDescription); + + if (this.SelectElement.options[i].hasAttribute("data-description")) + { + spanDescription.innerHTML = this.SelectElement.options[i].getAttribute("data-description"); + } + a.option = this.SelectElement.options[i]; + a.ni = this; + a.addEventListener("click", function() + { + this.ni.InputElement.value = this.option.label; + + if (this.ni.SelectElement.hasAttribute("multiple")) + { + } + else + { + this.ni.SelectElement.value = this.option.value; + + for (var j = 0; j < this.ni.MenuElement.children.length; j++) + { + if (this.ni.MenuElement.children[j].children[0] == this) + { + System.ClassList.Add(this.ni.MenuElement.children[j], "uwt-selected"); + } + else + { + System.ClassList.Remove(this.ni.MenuElement.children[j], "uwt-selected"); + } + } + System.ClassList.Remove(this.ni.MenuElement, "uwt-visible"); + } + }); + li.appendChild(a); + + + if (i == this.SelectElement.selectedIndex) + { + this.InputElement.value = a.option.label; + System.ClassList.Add(li, "uwt-selected"); + } + + ul.appendChild(li); + } + div.appendChild(ul); + + this.ParentElement.style.display = "none"; } function DropDown(id)