From 6789290e53a872004a19c26e04667ac10f2f43dd Mon Sep 17 00:00:00 2001 From: phasefx Date: Wed, 29 Jun 2005 13:31:48 +0000 Subject: [PATCH] xuledit in a tab. From http://ted.mielczarek.org/code/mozilla/index.html. Need a explicit license? git-svn-id: svn://svn.open-ils.org/ILS/trunk@966 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../evergreen/main/app_shell_menus_overlay.xul | 1 + .../content/evergreen/main/app_shell_overlay.xul | 3 ++ .../chrome/content/evergreen/util/spawn_win.js | 5 ++ .../chrome/content/evergreen/util/xuledit.js | 62 ++++++++++++++++++++++ .../chrome/content/evergreen/util/xuledit.xul | 14 +++++ .../locale/en-US/evergreen/OpenILS.properties | 1 + 6 files changed, 86 insertions(+) create mode 100644 Evergreen/staff_client/chrome/content/evergreen/util/xuledit.js create mode 100644 Evergreen/staff_client/chrome/content/evergreen/util/xuledit.xul diff --git a/Evergreen/staff_client/chrome/content/evergreen/main/app_shell_menus_overlay.xul b/Evergreen/staff_client/chrome/content/evergreen/main/app_shell_menus_overlay.xul index e4995d5a39..7721b03188 100644 --- a/Evergreen/staff_client/chrome/content/evergreen/main/app_shell_menus_overlay.xul +++ b/Evergreen/staff_client/chrome/content/evergreen/main/app_shell_menus_overlay.xul @@ -128,6 +128,7 @@ + diff --git a/Evergreen/staff_client/chrome/content/evergreen/main/app_shell_overlay.xul b/Evergreen/staff_client/chrome/content/evergreen/main/app_shell_overlay.xul index 61aeeb74f1..7e470e8e15 100644 --- a/Evergreen/staff_client/chrome/content/evergreen/main/app_shell_overlay.xul +++ b/Evergreen/staff_client/chrome/content/evergreen/main/app_shell_overlay.xul @@ -55,6 +55,9 @@ + + diff --git a/Evergreen/staff_client/chrome/content/evergreen/util/spawn_win.js b/Evergreen/staff_client/chrome/content/evergreen/util/spawn_win.js index 445a26fd95..f128e56131 100644 --- a/Evergreen/staff_client/chrome/content/evergreen/util/spawn_win.js +++ b/Evergreen/staff_client/chrome/content/evergreen/util/spawn_win.js @@ -142,3 +142,8 @@ function spawn_javascript_console(d,tab_flag,passthru_params) { var chrome = 'chrome://global/cotnent/console.xul'; spawn_interface(d,tab_flag,'main_tabbox',chrome,getString('javascript_console_label'),passthru_params); } + +function spawn_xuleditor(d,tab_flag,passthru_params) { + var chrome = 'chrome://evergreen/content/util/xuledit.xul'; + spawn_interface(d,tab_flag,'main_tabbox',chrome,getString('xuleditor_label'),passthru_params); +} diff --git a/Evergreen/staff_client/chrome/content/evergreen/util/xuledit.js b/Evergreen/staff_client/chrome/content/evergreen/util/xuledit.js new file mode 100644 index 0000000000..9366c8828a --- /dev/null +++ b/Evergreen/staff_client/chrome/content/evergreen/util/xuledit.js @@ -0,0 +1,62 @@ +// From Ted's Mozilla page: http://ted.mielczarek.org/code/mozilla/index.html +var old = ''; +var timeout = -1; +var xwin = null; +var newwin = false; + +function init() +{ + if(xwin) // for some reason onload gets called when the browser refreshes??? + return; + + update(); + document.getElementById('ta').select(); +} + +function openwin() +{ + toggleBrowser(false); + xwin = window.open('about:blank', 'xulwin', 'chrome,all,resizable=yes,width=400,height=400'); + newwin = true; + update(); +} + +function toggleBrowser(show) +{ + document.getElementById("split").collapsed = !show; + document.getElementById("content").collapsed = !show; + document.getElementById("open").collapsed = !show; +} + +function update() +{ + var textarea = document.getElementById("ta"); + + // either this is the first time, or + // they closed the window + if(xwin == null || (xwin instanceof Window && xwin.document == null)) { + toggleBrowser(true); + xwin = document.getElementById("content"); + newwin = true; + } + + if (old != textarea.value || newwin) { + old = textarea.value; + newwin = false; + var dataURI = "data:application/vnd.mozilla.xul+xml," + encodeURIComponent(old); + if(xwin instanceof Window) + xwin.document.location = dataURI; + else + xwin.setAttribute("src",dataURI); + } + + timeout = window.setTimeout(update, 500); +} + +function resetTimeout() +{ + if(timeout != -1) + window.clearTimeout(timeout); + + timeout = window.setTimeout(update, 500); +} diff --git a/Evergreen/staff_client/chrome/content/evergreen/util/xuledit.xul b/Evergreen/staff_client/chrome/content/evergreen/util/xuledit.xul new file mode 100644 index 0000000000..90df2352e2 --- /dev/null +++ b/Evergreen/staff_client/chrome/content/evergreen/util/xuledit.xul @@ -0,0 +1,14 @@ + + + + +