diff --git a/editor/ui/composer/content/EditorContextMenu.js b/editor/ui/composer/content/EditorContextMenu.js index 03f7d90b1899..d7dbba8d322a 100644 --- a/editor/ui/composer/content/EditorContextMenu.js +++ b/editor/ui/composer/content/EditorContextMenu.js @@ -39,7 +39,7 @@ function EditorFillContextMenu(event, contextMenuNode) InitRemoveStylesMenuitems("removeStylesMenuitem_cm", "removeLinksMenuitem_cm", "removeNamedAnchorsMenuitem_cm"); // This item is present only in context menu: - DisableItem("editLink_cm", objectName != "href"); + SetElementEnabledById("editLink_cm", objectName == "href"); var inCell = IsInTableCell(); // Set appropriate text for join cells command diff --git a/editor/ui/composer/content/editor.js b/editor/ui/composer/content/editor.js index f6b8b700ca74..95530f46d008 100644 --- a/editor/ui/composer/content/editor.js +++ b/editor/ui/composer/content/editor.js @@ -1768,7 +1768,7 @@ function BuildRecentMenu(savePrefs) } // Disable menu item if no entries - DisableItem("menu_RecentFiles", disableMenu); + SetElementEnabledById("menu_RecentFiles", !disableMenu); } function AppendRecentMenuitem(menupopup, title, url, menuIndex) @@ -2010,8 +2010,8 @@ function EditorInitToolbars() //Hide the edit mode toolbar gEditModeBar.setAttribute("hidden", "true"); - DisableItem("cmd_viewFormatToolbar", true); - DisableItem("cmd_viewEditModeToolbar", true); + SetElementEnabledById("cmd_viewFormatToolbar", false); + SetElementEnabledById("cmd_viewEditModeToolbar", false); } } @@ -2429,7 +2429,6 @@ function InitRemoveStylesMenuitems(removeStylesId, removeLinksId, removeNamedAnc // Change wording of menuitems depending on selection var stylesItem = document.getElementById(removeStylesId); var linkItem = document.getElementById(removeLinksId); - var namedAnchorsItem = document.getElementById(removeNamedAnchorsId); var isCollapsed = editorShell.editorSelection.isCollapsed; if (stylesItem) @@ -2445,13 +2444,10 @@ function InitRemoveStylesMenuitems(removeStylesId, removeLinksId, removeNamedAnc // Disable if not in a link, but always allow "Remove" // if selection isn't collapsed since we only look at anchor node - DisableItem(removeLinksId, isCollapsed && !window.editorShell.GetElementOrParentByTagName("href", null)); - } - if (namedAnchorsItem) - { - // Disable if selection is collapsed - DisableItem(removeNamedAnchorsId, isCollapsed); + SetElementEnabled(linkItem, !isCollapsed || window.editorShell.GetElementOrParentByTagName("href", null)); } + // Disable if selection is collapsed + SetElementEnabledById(removeNamedAnchorsId, !isCollapsed); } function goUpdateTableMenuItems(commandset) diff --git a/editor/ui/composer/content/editorUtilities.js b/editor/ui/composer/content/editorUtilities.js index 9ca5d0571dfb..db8234d06b67 100644 --- a/editor/ui/composer/content/editorUtilities.js +++ b/editor/ui/composer/content/editorUtilities.js @@ -205,28 +205,6 @@ function SetElementEnabled(element, doEnable) } } -function SetElementHidden(element, hide) -{ - if (element) - { - if (hide) - element.setAttribute("hidden", "true"); - else - element.removeAttribute("hidden"); - } -} - -function DisableItem(id, disable) -{ - var item = document.getElementById(id); - if (item) - { - if (disable != (item.getAttribute("disabled") == "true")) - item.setAttribute("disabled", disable ? "true" : ""); - } -} - - /************* Services / Prefs ***************/ function GetIOService()