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()
{
};
/**
* The TAB key.
*/
KeyboardKeys.Tab = 9;
/**
* The ENTER key.
*/
@ -446,6 +450,19 @@ System.TerminateIfSenderIs = function(sender, compareTo)
}
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.
* @param element DOMElement The element with which to fill the screen. If not specified, document.body will be used.
@ -809,4 +826,9 @@ 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];
this.ButtonLink = parent.childNodes[1];
if (parent.children[0].tagName === "IMG")
{
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
this.TextLink.NativeObject = this;
this.TextLink.addEventListener("keydown", function(e)
{
console.log(e);
if (e.keyCode == 9)
{
if (!e.shiftKey)

View File

@ -1,16 +1,18 @@
function Alert(parentElement)
{
this.ParentElement = parentElement;
this.IconElement = this.ParentElement.children[0];
this.IconElement.NativeObject = this;
this.IconElement.addEventListener("click", function()
if (parentElement)
{
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.setTitle = function(value)

View File

@ -119,6 +119,12 @@
}
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.
@ -535,6 +541,12 @@
}
return $ret;
}
public static function GetLoginPageUrl()
{
return System::ReplaceVariables(System::GetConfigurationValue("LoginPageRedirectURL", "~/account/login"));
}
public static function RedirectToLoginPage($forceNonTenanted = false)
{
if (System::$EnableTenantedHosting)
@ -545,7 +557,7 @@
{
$_SESSION["System.LastRedirectURL"] = $_SERVER["REQUEST_URI"];
}
System::Redirect(System::ReplaceVariables(System::GetConfigurationValue("LoginPageRedirectURL", "~/account/login")), $forceNonTenanted);
System::Redirect(System::GetLoginPageUrl(), $forceNonTenanted);
return;
}
public static function RedirectFromLoginPage()

View File

@ -18,11 +18,15 @@
class AdditionalDetailWidget extends WebControl
{
public string $RelatedActionButtonUrl;
public $DisplayStyle; /* AdditionalDetailWidgetDisplayStyle */
public $Text;
public $ShowText; /* bool */
public $ShowURL; /* bool */
public $ImageUrl;
public $TargetFrame;
public $TargetURL;
@ -37,12 +41,15 @@
public function __construct($id)
{
parent::__construct($id);
parent::__construct();
$this->RelatedActionButtonUrl = "";
$this->ClassTitle = "";
$this->DisplayStyle = AdditionalDetailWidgetDisplayStyle::Ellipsis;
$this->MenuItemHeaderText = "Available Actions";
$this->MenuItems = array();
$this->ShowText = true;
$this->ImageUrl = null;
$this->ShowURL = true;
}
@ -104,6 +111,10 @@
private function renderMainLink()
{
if ($this->ImageUrl !== null)
{
echo("<img class=\"apb-icon\" src=\"" . System::ExpandRelativePath($this->ImageUrl) . "\" />");
}
if ($this->ShowURL)
{
echo("<a class=\"apb-text\" href=\"");
@ -135,8 +146,13 @@
protected function BeforeContent()
{
$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\">");

View File

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

View File

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