From 870a09d044ccbf030c1f804f33203aa1d8d076e6 Mon Sep 17 00:00:00 2001 From: "oeschger%netscape.com" Date: Tue, 19 Jun 2001 22:35:17 +0000 Subject: [PATCH] context sensitive help, sr=blake, a=asa, r=sfraser, b=46226 --- extensions/help/resources/content/help.js | 118 +++++++++++++++--- .../locale/en-US/cs_nav_dialogs.html | 10 ++ .../locale/en-US/cs_nav_dialogs.xhtml | 10 ++ .../locale/en-US/cs_nav_prefs_advanced.html | 10 ++ .../locale/en-US/cs_nav_prefs_advanced.xhtml | 10 ++ .../locale/en-US/cs_nav_prefs_appearance.html | 10 ++ .../en-US/cs_nav_prefs_appearance.xhtml | 10 ++ .../locale/en-US/cs_nav_prefs_navigator.html | 10 ++ .../locale/en-US/cs_nav_prefs_navigator.xhtml | 10 ++ .../locale/en-US/cs_nav_sidebar.html | 10 ++ 10 files changed, 188 insertions(+), 20 deletions(-) create mode 100644 extensions/help/resources/locale/en-US/cs_nav_dialogs.html create mode 100644 extensions/help/resources/locale/en-US/cs_nav_dialogs.xhtml create mode 100644 extensions/help/resources/locale/en-US/cs_nav_prefs_advanced.html create mode 100644 extensions/help/resources/locale/en-US/cs_nav_prefs_advanced.xhtml create mode 100644 extensions/help/resources/locale/en-US/cs_nav_prefs_appearance.html create mode 100644 extensions/help/resources/locale/en-US/cs_nav_prefs_appearance.xhtml create mode 100644 extensions/help/resources/locale/en-US/cs_nav_prefs_navigator.html create mode 100644 extensions/help/resources/locale/en-US/cs_nav_prefs_navigator.xhtml create mode 100644 extensions/help/resources/locale/en-US/cs_nav_sidebar.html diff --git a/extensions/help/resources/content/help.js b/extensions/help/resources/content/help.js index 4451328d400..c0e3d477296 100644 --- a/extensions/help/resources/content/help.js +++ b/extensions/help/resources/content/help.js @@ -1,6 +1,12 @@ //-------- global variables var gBrowser; + +// The key object is used to define special context strings that, when appended to +// the url for the help window itself, load specific content. For example, the uri: +// chrome://help/content/help.xul?mail +// loads the document at: +// chrome://help/locale/mail_help.html into the window on initialization. var key = { "?mail": "chrome://help/locale/mail_help.html", "?nav": "chrome://help/locale/nav_help.html", @@ -8,6 +14,38 @@ var key = { "?sec": "chrome://help/locale/security_help.html", "?cust": "chrome://help/locale/customize_help.html", "?comp": "chrome://help/locale/composer_help.html", + "?prefs": "chrome://help/locale/prefs_help.html#prefs_first", + + "?mail_prefs_general": "chrome://help/locale/mail_help.html#PREFERENCES_MAILNEWS_MAIN_PANE", + "?mail_prefs_display": "chrome://help/locale/mail_help.html#PREFERENCES_MAILNEWS_DISPLAY", + "?mail_prefs_messages": "chrome://help/locale/mail_help.html#PREFERENCES_MAILNEWS_MESSAGES", + "?mail_prefs_formatting": "chrome://help/locale/mail_help.html#PREFERENCES_MAILNEWS_FORMATTING", + "?mail_prefs_addressing": "chrome://help/locale/mail_help.html#PREFERENCES_MAILNEWS_ADDRESSING", + "?mail_prefs_offline": "chrome://help/locale/mail_help.html#PREFERENCES_MAILNEWS_OFFLINE", + + "?composer_prefs_general": "chrome://help/locale/composer_help.html#PREFERENCES_EDITOR_GENERAL", + "?composer_prefs_newpage": "chrome://help/locale/composer_help.html#PREFERENCES_NEWPAGE", + + "?appearance_pref": "chrome://help/locale/cs_nav_prefs_appearance.html", + "?appearance_pref_appearance": "chrome://help/locale/cs_nav_prefs_appearance.html#appearance", + "?appearance_pref_fonts": "chrome://help/locale/cs_nav_prefs_appearance.html#fonts", + "?appearance_pref_colors": "chrome://help/locale/cs_nav_prefs_appearance.html#colors", + "?appearance_pref_fonts": "chrome://help/locale/cs_nav_prefs_appearance.html#fonts", + "?appearance_pref_themes": "chrome://help/locale/cs_nav_prefs_appearance.html#themes", + + "?navigator_pref": "chrome://help/locale/cs_nav_prefs_navigator.html", + "?navigator_pref_navigator": "chrome://help/locale/cs_nav_prefs_navigator.html#Navigator", + "?navigator_pref_history": "chrome://help/locale/cs_nav_prefs_navigator.html#History", + "?navigator_pref_languages": "chrome://help/locale/cs_nav_prefs_navigator.html#Languages", + "?navigator_pref_helper_applications": "chrome://help/locale/cs_nav_prefs_navigator.html#Helper", + "?navigator_pref_internet_searching": "chrome://help/locale/cs_nav_prefs_navigator.html#Internet", + + "?advanced_pref": "chrome://help/locale/cs_nav_prefs_advanced.html", + "?advanced_pref_advanced": "chrome://help/locale/cs_nav_prefs_advanced.html#Advanced", + "?advanced_pref_cache": "chrome://help/locale/cs_nav_prefs_advanced.html#Cache", + "?advanced_pref_software_installation": "chrome://help/locale/cs_nav_prefs_advanced.html#Software_Installation", + "?advanced_pref_software_mouse_wheel": "chrome://help/locale/cs_nav_prefs_advanced.html#Mouse_Wheel", + "?advanced_pref_software_system": "chrome://help/locale/cs_nav_prefs_advanced.html#system", "?nover_noencrypt": "chrome://help/locale/ssl_page_info_help.html#Not_Verified_Not Encrypted", "?ver_encrypt": "chrome://help/locale/ssl_page_info_help.html#Verified_Encrypted", @@ -41,15 +79,38 @@ var key = { "?sec_gen": "chrome://help/locale/privsec_help.html#privsec_help_first", "?ssl_prefs": "chrome://help/locale/ssl_help.html#ssl_first", - "?validation_prefs": "chrome://help/locale/ssl_help.html#ssl_first", - "?passwords_prefs": "chrome://help/locale/ssl_help.html#ssl_first" + "?validation_prefs": "chrome://help/locale/validation_help.html", + "?passwords_prefs": "chrome://help/locale/passwords_help.html", + "?forms_prefs": "chrome://help/locale/using_priv_help.html#using_forms", + "?cookies_prefs": "chrome://help/locale/using_priv_help.html#using_cookies", + "?images_prefs": "chrome://help/locale/using_priv_help.html#using_images", + "?certs_prefs": "chrome://help/locale/certs_prefs_help.html", + + "?im_prefs_general": "chrome://help/locale/im_help.html#im_gen", + "?im_prefs_privacy": "chrome://help/locale/im_help.html#im_privacy", + "?im_prefs_notification": "chrome://help/locale/im_help.html#im_notif", + "?im_prefs_away": "chrome://help/locale/im_help.html#im_awaypref", + "?im_prefs_connection": "chrome://help/locale/im_help.html#im_connect" } +// This function is called by dialogs that want to display context-sensitive help +function openHelp(uri) +{ + var windowManager = Components.classes['@mozilla.org/rdf/datasource;1?name=window-mediator'].getService(); + var windowManagerInterface = windowManager.QueryInterface( Components.interfaces.nsIWindowMediator); + var topWindow = windowManagerInterface.getMostRecentWindow( "mozilla:help" ); + if ( topWindow ) { + topWindow.focus(); + } else if (window.opener) { + window.opener.open(uri, "_blank", "chrome,menubar,toolbar,dialog=no,resizable,scrollbars"); + } else { + window.open(uri, "_blank", "chrome,menubar,toolbar,dialog=no,resizable,scrollbars"); + } +} function init() { // Initialize the Help window - // "window.arguments[0]" is undefined or context string // move to right end of screen var width = document.documentElement.getAttribute("width"); @@ -61,33 +122,49 @@ function init() .createInstance(Components.interfaces.nsISHistory); getWebNavigation().sessionHistory = sessionHistory; - - //if ("argument" in window && window.arguments.length >= 1) { - // browser.loadURI(window.arguments[0]); - //} else { - // goHome(); // should be able to do browser.goHome(); - //} - - if (window.location.search) { + // if this is context-sensitive, + // then window.location.search contains the "key" (from the top of this file) + // that resolves to a particular html document or target + if (key[window.location.search]) { + dump("loading help content: " + key[window.location.search] + "\n"); loadURI(key[window.location.search]); - // selectTOC(key[window.location.search]); - - } else { + setContext(); + } else { goHome(); } } +// select the item in the tree called "Dialog Help" if the window was loaded from a dialog +function setContext() { + var items = document.getElementsByAttribute("helplink", "chrome://help/locale/context_help.html"); + if (items.length) { + var tree = document.getElementById("help-toc-tree"); + try { tree.selectItem(items[0].parentNode.parentNode); } catch(ex) { dump("can't select in toc: " + ex + "\n"); } + } +} + function selectTOC(link_attr) { var items = document.getElementsByAttribute("helplink", link_attr); - if (items.length >= 1) { - var parentRow = items[0].parentNode; - var selectableNode = parentRow.parentNode; // helplink is an attribute - // on a treecell, which cannot be selected - var tree = document.getElementById("help-toc-tree"); - tree.selectItem(selectableNode); + if (items.length) { + openTwistyTo(items[0]); + var tree = document.getElementById("help-toc-tree"); + try { tree.selectItem(items[0].parentNode.parentNode); } catch(ex) { dump("can't select in toc: " + ex + "\n"); } } } +// open parent nodes for the selected node +// until you get to the top of the tree +function openTwistyTo(selectedURINode) +{ + var parent = selectedURINode.parentNode; + var tree = document.getElementById("help-toc-tree"); + if (parent == tree) + return; + + parent.setAttribute("open", "true"); + openTwistyTo(parent); +} + function getWebNavigation() { @@ -98,6 +175,7 @@ function loadURI(aURI) { const nsIWebNavigation = Components.interfaces.nsIWebNavigation; getWebNavigation().loadURI(aURI, nsIWebNavigation.LOAD_FLAGS_NONE); + dump("help document: " + uRI); } function goBack() diff --git a/extensions/help/resources/locale/en-US/cs_nav_dialogs.html b/extensions/help/resources/locale/en-US/cs_nav_dialogs.html new file mode 100644 index 00000000000..62cb3960a4e --- /dev/null +++ b/extensions/help/resources/locale/en-US/cs_nav_dialogs.html @@ -0,0 +1,10 @@ + + +Mozilla Dialog Help + + + +

Context sensitive help: write me!

+

file: mozilla/extensions/help/resources/locale/en-US/cs_nav_dialogs.html

+ + \ No newline at end of file diff --git a/extensions/help/resources/locale/en-US/cs_nav_dialogs.xhtml b/extensions/help/resources/locale/en-US/cs_nav_dialogs.xhtml new file mode 100644 index 00000000000..62cb3960a4e --- /dev/null +++ b/extensions/help/resources/locale/en-US/cs_nav_dialogs.xhtml @@ -0,0 +1,10 @@ + + +Mozilla Dialog Help + + + +

Context sensitive help: write me!

+

file: mozilla/extensions/help/resources/locale/en-US/cs_nav_dialogs.html

+ + \ No newline at end of file diff --git a/extensions/help/resources/locale/en-US/cs_nav_prefs_advanced.html b/extensions/help/resources/locale/en-US/cs_nav_prefs_advanced.html new file mode 100644 index 00000000000..8de6a2a9bb1 --- /dev/null +++ b/extensions/help/resources/locale/en-US/cs_nav_prefs_advanced.html @@ -0,0 +1,10 @@ + + +Mozilla Advanced Preferences Help + + + +

Context sensitive help: write me!

+

file: mozilla/extensions/help/resources/locale/en-US/cs_nav_prefs_advanced.html

+ + \ No newline at end of file diff --git a/extensions/help/resources/locale/en-US/cs_nav_prefs_advanced.xhtml b/extensions/help/resources/locale/en-US/cs_nav_prefs_advanced.xhtml new file mode 100644 index 00000000000..8de6a2a9bb1 --- /dev/null +++ b/extensions/help/resources/locale/en-US/cs_nav_prefs_advanced.xhtml @@ -0,0 +1,10 @@ + + +Mozilla Advanced Preferences Help + + + +

Context sensitive help: write me!

+

file: mozilla/extensions/help/resources/locale/en-US/cs_nav_prefs_advanced.html

+ + \ No newline at end of file diff --git a/extensions/help/resources/locale/en-US/cs_nav_prefs_appearance.html b/extensions/help/resources/locale/en-US/cs_nav_prefs_appearance.html new file mode 100644 index 00000000000..7d9b954ba33 --- /dev/null +++ b/extensions/help/resources/locale/en-US/cs_nav_prefs_appearance.html @@ -0,0 +1,10 @@ + + +Mozilla Appearance Preferences Help + + + +

Context sensitive help: write me!

+

file: mozilla/extensions/help/resources/locale/en-US/cs_nav_prefs_appearance.html

+ + \ No newline at end of file diff --git a/extensions/help/resources/locale/en-US/cs_nav_prefs_appearance.xhtml b/extensions/help/resources/locale/en-US/cs_nav_prefs_appearance.xhtml new file mode 100644 index 00000000000..7d9b954ba33 --- /dev/null +++ b/extensions/help/resources/locale/en-US/cs_nav_prefs_appearance.xhtml @@ -0,0 +1,10 @@ + + +Mozilla Appearance Preferences Help + + + +

Context sensitive help: write me!

+

file: mozilla/extensions/help/resources/locale/en-US/cs_nav_prefs_appearance.html

+ + \ No newline at end of file diff --git a/extensions/help/resources/locale/en-US/cs_nav_prefs_navigator.html b/extensions/help/resources/locale/en-US/cs_nav_prefs_navigator.html new file mode 100644 index 00000000000..50e69042882 --- /dev/null +++ b/extensions/help/resources/locale/en-US/cs_nav_prefs_navigator.html @@ -0,0 +1,10 @@ + + +Mozilla Navigator Preferences Help + + + +

Context sensitive help: write me!

+

file: mozilla/extensions/help/resources/locale/en-US/cs_nav_prefs_navigator.html

+ + \ No newline at end of file diff --git a/extensions/help/resources/locale/en-US/cs_nav_prefs_navigator.xhtml b/extensions/help/resources/locale/en-US/cs_nav_prefs_navigator.xhtml new file mode 100644 index 00000000000..50e69042882 --- /dev/null +++ b/extensions/help/resources/locale/en-US/cs_nav_prefs_navigator.xhtml @@ -0,0 +1,10 @@ + + +Mozilla Navigator Preferences Help + + + +

Context sensitive help: write me!

+

file: mozilla/extensions/help/resources/locale/en-US/cs_nav_prefs_navigator.html

+ + \ No newline at end of file diff --git a/extensions/help/resources/locale/en-US/cs_nav_sidebar.html b/extensions/help/resources/locale/en-US/cs_nav_sidebar.html new file mode 100644 index 00000000000..9251c06b392 --- /dev/null +++ b/extensions/help/resources/locale/en-US/cs_nav_sidebar.html @@ -0,0 +1,10 @@ + + +Mozilla Sidebar Help + + + +

Context sensitive help: write me!

+

file: mozilla/extensions/help/resources/locale/en-US/cs_nav_sidebar.html

+ + \ No newline at end of file