various fixes and improvements

This commit is contained in:
Michael Becker 2024-01-19 13:25:39 -05:00
parent ff4c6be547
commit b12271ce21
7 changed files with 174 additions and 59 deletions

View File

@ -174,6 +174,10 @@ MouseEventArgs.FromNativeEventArgs = function(e)
function KeyboardKeys() function KeyboardKeys()
{ {
}; };
/**
* The TAB key.
*/
KeyboardKeys.Tab = 9;
/** /**
* The ENTER key. * The ENTER key.
*/ */
@ -446,6 +450,19 @@ System.TerminateIfSenderIs = function(sender, compareTo)
} }
return false; return false;
}; };
System.CheckIfSenderIsInside = function(sender, compareTo)
{
while (sender != null)
{
if (sender === compareTo)
{
return true;
}
sender = sender.parentNode;
if (sender == null) break;
}
return false;
};
/** /**
* Enters full screen mode on the specified element. If no element is specified, the entire page becomes full screen. * Enters full screen mode on the specified element. If no element is specified, the entire page becomes full screen.
* @param element DOMElement The element with which to fill the screen. If not specified, document.body will be used. * @param element DOMElement The element with which to fill the screen. If not specified, document.body will be used.
@ -810,3 +827,8 @@ if (!String.format)
}); });
}; };
} }
System.AddEventListener(window, "load", function()
{
System.ClassList.Remove(document.body, "uwt-javascript-disabled");
});

View File

@ -24,14 +24,23 @@ function AdditionalDetailWidget(parent)
}; };
this.TextLink = parent.childNodes[0]; if (parent.children[0].tagName === "IMG")
this.ButtonLink = parent.childNodes[1]; {
this.IconElement = parent.children[0];
this.TextLink = parent.children[1];
this.ButtonLink = parent.children[2];
}
else
{
this.IconElement = null;
this.TextLink = parent.children[0];
this.ButtonLink = parent.children[1];
}
// aria // aria
this.TextLink.NativeObject = this; this.TextLink.NativeObject = this;
this.TextLink.addEventListener("keydown", function(e) this.TextLink.addEventListener("keydown", function(e)
{ {
console.log(e);
if (e.keyCode == 9) if (e.keyCode == 9)
{ {
if (!e.shiftKey) if (!e.shiftKey)

View File

@ -1,16 +1,18 @@
function Alert(parentElement) function Alert(parentElement)
{ {
this.ParentElement = parentElement; if (parentElement)
this.IconElement = this.ParentElement.children[0];
this.IconElement.NativeObject = this;
this.IconElement.addEventListener("click", function()
{ {
if (System.ClassList.Contains(this.NativeObject.ParentElement, "uwt-collapsible")) this.ParentElement = parentElement;
this.IconElement = this.ParentElement.children[0];
this.IconElement.NativeObject = this;
this.IconElement.addEventListener("click", function()
{ {
System.ClassList.Toggle(this.NativeObject.ParentElement, "uwt-collapsed"); if (System.ClassList.Contains(this.NativeObject.ParentElement, "uwt-collapsible"))
} {
}); System.ClassList.Toggle(this.NativeObject.ParentElement, "uwt-collapsed");
}
});
}
this.mvarTitle = ""; this.mvarTitle = "";
this.setTitle = function(value) this.setTitle = function(value)

View File

@ -120,6 +120,12 @@
System::$SystemPath = $value; System::$SystemPath = $value;
} }
public static function ExpandPhysicalPath($path)
{
//! FIXME: THIS DOES NOT SUPPORT APPLICATION IN SUBDIRECTORY YET
return "https://" . $_SERVER["SERVER_NAME"] . $path;
}
/** /**
* Array of global application configuration name/value pairs. * Array of global application configuration name/value pairs.
* @var array * @var array
@ -535,6 +541,12 @@
} }
return $ret; return $ret;
} }
public static function GetLoginPageUrl()
{
return System::ReplaceVariables(System::GetConfigurationValue("LoginPageRedirectURL", "~/account/login"));
}
public static function RedirectToLoginPage($forceNonTenanted = false) public static function RedirectToLoginPage($forceNonTenanted = false)
{ {
if (System::$EnableTenantedHosting) if (System::$EnableTenantedHosting)
@ -545,7 +557,7 @@
{ {
$_SESSION["System.LastRedirectURL"] = $_SERVER["REQUEST_URI"]; $_SESSION["System.LastRedirectURL"] = $_SERVER["REQUEST_URI"];
} }
System::Redirect(System::ReplaceVariables(System::GetConfigurationValue("LoginPageRedirectURL", "~/account/login")), $forceNonTenanted); System::Redirect(System::GetLoginPageUrl(), $forceNonTenanted);
return; return;
} }
public static function RedirectFromLoginPage() public static function RedirectFromLoginPage()

View File

@ -18,12 +18,16 @@
class AdditionalDetailWidget extends WebControl class AdditionalDetailWidget extends WebControl
{ {
public string $RelatedActionButtonUrl;
public $DisplayStyle; /* AdditionalDetailWidgetDisplayStyle */ public $DisplayStyle; /* AdditionalDetailWidgetDisplayStyle */
public $Text; public $Text;
public $ShowText; /* bool */ public $ShowText; /* bool */
public $ShowURL; /* bool */ public $ShowURL; /* bool */
public $ImageUrl;
public $TargetFrame; public $TargetFrame;
public $TargetURL; public $TargetURL;
public $TargetScript; public $TargetScript;
@ -37,12 +41,15 @@
public function __construct($id) public function __construct($id)
{ {
parent::__construct($id); parent::__construct();
$this->RelatedActionButtonUrl = "";
$this->ClassTitle = ""; $this->ClassTitle = "";
$this->DisplayStyle = AdditionalDetailWidgetDisplayStyle::Ellipsis; $this->DisplayStyle = AdditionalDetailWidgetDisplayStyle::Ellipsis;
$this->MenuItemHeaderText = "Available Actions"; $this->MenuItemHeaderText = "Available Actions";
$this->MenuItems = array(); $this->MenuItems = array();
$this->ShowText = true; $this->ShowText = true;
$this->ImageUrl = null;
$this->ShowURL = true; $this->ShowURL = true;
} }
@ -104,6 +111,10 @@
private function renderMainLink() private function renderMainLink()
{ {
if ($this->ImageUrl !== null)
{
echo("<img class=\"apb-icon\" src=\"" . System::ExpandRelativePath($this->ImageUrl) . "\" />");
}
if ($this->ShowURL) if ($this->ShowURL)
{ {
echo("<a class=\"apb-text\" href=\""); echo("<a class=\"apb-text\" href=\"");
@ -136,7 +147,12 @@
{ {
$this->renderMainLink(); $this->renderMainLink();
echo("<a class=\"apb-button\" href=\"#\" tabindex=\"-1\">&nbsp;</a>"); $apbButtonUrl = "#";
if ($this->RelatedActionButtonUrl !== "")
{
$apbButtonUrl = System::ExpandRelativePath($this->RelatedActionButtonUrl);
}
echo("<a class=\"apb-button\" href=\"" . $apbButtonUrl . "\" tabindex=\"-1\">&nbsp;</a>");
echo("<div class=\"apb-preview uwt-popup\">"); echo("<div class=\"apb-preview uwt-popup\">");

View File

@ -32,6 +32,10 @@ use Phast\Phast;
class Menu extends WebControl class Menu extends WebControl
{ {
/**
* @var bool
*/
public $MultiSelect;
/** /**
* Determines whether the menu displays horizontally or vertically. * Determines whether the menu displays horizontally or vertically.
* @var MenuOrientation * @var MenuOrientation
@ -47,6 +51,7 @@ use Phast\Phast;
{ {
parent::__construct(); parent::__construct();
$this->MultiSelect = false;
$this->Items = array(); $this->Items = array();
$this->ParseChildElements = true; $this->ParseChildElements = true;
@ -81,6 +86,11 @@ use Phast\Phast;
$this->ClassList[] = "Vertical"; $this->ClassList[] = "Vertical";
} }
if ($this->MultiSelect)
{
$this->ClassList[] = "uwt-multiselect";
}
$this->Controls = array(); $this->Controls = array();
foreach ($this->Items as $menuItem) foreach ($this->Items as $menuItem)
{ {
@ -112,46 +122,87 @@ use Phast\Phast;
$li->ClassList[] = "uwt-has-children"; $li->ClassList[] = "uwt-has-children";
} }
$a = new Anchor(); if ($menuItem->TargetURL !== null)
$a->TargetURL = $menuItem->TargetURL;
if ($menuItem->OnClientClick != null)
{ {
$a->Attributes[] = new WebControlAttribute("onclick", $menuItem->OnClientClick); $a = new Anchor();
} $a->TargetURL = $menuItem->TargetURL;
if ($menuItem->OnClientClick != null)
{
$a->Attributes[] = new WebControlAttribute("onclick", $menuItem->OnClientClick);
}
if ($menuItem->IconName != "") if ($menuItem->IconName != "")
{ {
$iIcon = new HTMLControl(); $iIcon = new HTMLControl();
$iIcon->TagName = "i"; $iIcon->TagName = "i";
$iIcon->ClassList[] = "fa"; $iIcon->ClassList[] = "fa";
$iIcon->ClassList[] = "fa-" . $menuItem->IconName; $iIcon->ClassList[] = "fa-" . $menuItem->IconName;
$a->Controls[] = $iIcon; $a->Controls[] = $iIcon;
} }
if ($menuItem->Description != null) if ($menuItem->Title != null)
{ {
$spanTitle = new HTMLControl(); $spanTitle = new HTMLControl();
$spanTitle->TagName = "span"; $spanTitle->TagName = "span";
$spanTitle->ClassList[] = "uwt-title"; $spanTitle->ClassList[] = "uwt-title";
$spanTitle->InnerHTML = $menuItem->Title; if ($menuItem->Description === null)
$a->Controls[] = $spanTitle; {
$spanTitle->ClassList[] = "uwt-description-empty";
}
$spanTitle->InnerHTML = $menuItem->Title;
$a->Controls[] = $spanTitle;
}
if ($menuItem->Description != null)
{
$spanDescription = new HTMLControl();
$spanDescription->TagName = "span";
$spanDescription->ClassList[] = "uwt-description";
$spanDescription->InnerHTML = $menuItem->Description;
$a->Controls[] = $spanDescription;
}
$spanDescription = new HTMLControl(); $li->Controls[] = $a;
$spanDescription->TagName = "span";
$spanDescription->ClassList[] = "uwt-description";
$spanDescription->InnerHTML = $menuItem->Description;
$a->Controls[] = $spanDescription;
} }
else else
{ {
$spanTitle = new HTMLControl();
$spanTitle->TagName = "span";
$spanTitle->ClassList[] = "uwt-title uwt-description-empty";
$spanTitle->InnerHTML = $menuItem->Title;
$a->Controls[] = $spanTitle;
}
$li->Controls[] = $a; if ($menuItem->IconName != "")
{
$iIcon = new HTMLControl();
$iIcon->TagName = "i";
$iIcon->ClassList[] = "fa";
$iIcon->ClassList[] = "fa-" . $menuItem->IconName;
$li->Controls[] = $iIcon;
}
if ($menuItem->Title != null)
{
$spanTitle = new HTMLControl();
$spanTitle->TagName = "span";
$spanTitle->ClassList[] = "uwt-title";
if ($menuItem->Description === null)
{
$spanTitle->ClassList[] = "uwt-description-empty";
}
$spanTitle->InnerHTML = $menuItem->Title;
$li->Controls[] = $spanTitle;
}
if ($menuItem->Description != null)
{
$spanDescription = new HTMLControl();
$spanDescription->TagName = "span";
$spanDescription->ClassList[] = "uwt-description";
$spanDescription->InnerHTML = $menuItem->Description;
$li->Controls[] = $spanDescription;
}
if ($menuItem->Controls != null)
{
foreach ($menuItem->Controls as $ctl)
{
$li->Controls[] = $ctl;
}
}
}
if (count($menuItem->Items) > 0) if (count($menuItem->Items) > 0)
{ {
@ -231,6 +282,7 @@ use Phast\Phast;
public $Items; public $Items;
public $IconName; public $IconName;
public $Title; public $Title;
public $Controls;
public $TargetURL; public $TargetURL;
public $OnClientClick; public $OnClientClick;
public $Selected; public $Selected;
@ -250,6 +302,8 @@ use Phast\Phast;
{ {
parent::__construct(); parent::__construct();
$this->Title = $title; $this->Title = $title;
$this->Controls = null;
$this->IconName = null;
$this->TargetURL = $targetURL; $this->TargetURL = $targetURL;
$this->OnClientClick = $onClientClick; $this->OnClientClick = $onClientClick;
$this->Description = $description; $this->Description = $description;

View File

@ -64,7 +64,7 @@
$this->Items = array(); $this->Items = array();
$this->TagName = "div"; $this->TagName = "div";
$this->ClassList[] = "TextBox"; $this->ClassList[] = "uwt-textbox";
$this->OpenWhenFocused = true; $this->OpenWhenFocused = true;
$this->MultiSelect = false; $this->MultiSelect = false;
@ -82,7 +82,7 @@
if ($this->RequireSelectionFromChoices) if ($this->RequireSelectionFromChoices)
{ {
$this->ClassList[] = "RequireSelection"; $this->ClassList[] = "uwt-selection-required";
} }
if ($this->ClearOnFocus) if ($this->ClearOnFocus)
{ {
@ -90,7 +90,7 @@
} }
if ($this->MultiSelect) if ($this->MultiSelect)
{ {
$this->ClassList[] = "MultiSelect"; $this->ClassList[] = "uwt-multiselect";
} }
if ($this->SuggestionURL != null) if ($this->SuggestionURL != null)
{ {
@ -102,10 +102,10 @@
} }
$divTextboxContent = new HTMLControl("div"); $divTextboxContent = new HTMLControl("div");
$divTextboxContent->ClassList[] = "TextboxContent"; $divTextboxContent->ClassList[] = "uwt-textbox-content";
$spanTextboxSelectedItems = new HTMLControl("span"); $spanTextboxSelectedItems = new HTMLControl("span");
$spanTextboxSelectedItems->ClassList[] = "TextboxSelectedItems"; $spanTextboxSelectedItems->ClassList[] = "uwt-textbox-selected-items";
$i = 0; $i = 0;
foreach ($this->Items as $item) foreach ($this->Items as $item)
@ -113,15 +113,15 @@
if (!$item->Selected) continue; if (!$item->Selected) continue;
$spanSelectedItem = new HTMLControl("span"); $spanSelectedItem = new HTMLControl("span");
$spanSelectedItem->ClassList[] = "SelectedItem"; $spanSelectedItem->ClassList[] = "uwt-textbox-selected-item";
$spanText = new HTMLControl("span"); $spanText = new HTMLControl("span");
$spanText->ClassList[] = "Text"; $spanText->ClassList[] = "uwt-text";
$spanText->InnerHTML = $item->Title; $spanText->InnerHTML = $item->Title;
$spanSelectedItem->Controls[] = $spanText; $spanSelectedItem->Controls[] = $spanText;
$aCloseButton = new Anchor(); $aCloseButton = new Anchor();
$aCloseButton->ClassList[] = "CloseButton"; $aCloseButton->ClassList[] = "uwt-delete-button";
$spanSelectedItem->Controls[] = $aCloseButton; $spanSelectedItem->Controls[] = $aCloseButton;
$spanTextboxSelectedItems->Controls[] = $spanSelectedItem; $spanTextboxSelectedItems->Controls[] = $spanSelectedItem;