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) diff --git a/lib/phast/client/scripts/controls/Window.js b/lib/phast/client/scripts/controls/Window.js index f3b5ae8..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) { @@ -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]); @@ -582,4 +582,4 @@ Window.ShowDialog = function (content, title, buttons, styles, iconName, classNa // happen divWindow.NativeObject.ShowDialog(); }, 100); -}; \ No newline at end of file +}; diff --git a/lib/phast/server/WebControls/Window.inc.php b/lib/phast/server/WebControls/Window.inc.php index 6b2b63e..6a7dfca 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[] = "uwt-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[] = "uwt-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[] = "uwt-loading"; @@ -135,4 +151,4 @@ } } -?> \ No newline at end of file +?>