]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Evergreen/staff_client/chrome/content/evergreen/util/xuledit.js
misc
[working/Evergreen.git] / Evergreen / staff_client / chrome / content / evergreen / util / xuledit.js
1 // From Ted's Mozilla page: http://ted.mielczarek.org/code/mozilla/index.html 
2 // Modified by Jason for Evergreen to push in the main (auth) window reference
3 var old = '';
4 var timeout = -1;
5 var xwin = null;
6 var newwin = false;
7
8 function init()
9 {
10   if(xwin)  // for some reason onload gets called when the browser refreshes???
11     return;
12
13   update();
14   document.getElementById('ta').select();
15 }
16
17 function openwin()
18 {
19   toggleBrowser(false);
20   xwin = window.open('about:blank', 'xulwin', 'chrome,all,resizable=yes,width=400,height=400');
21   newwin = true;
22   update();
23 }
24
25 function toggleBrowser(show)
26 {
27   document.getElementById("split").collapsed = !show;
28   document.getElementById("content").collapsed = !show;
29   document.getElementById("open").collapsed = !show;
30 }
31
32 function update()
33 {
34   var textarea = document.getElementById("ta");
35
36   // either this is the first time, or
37   // they closed the window
38   if(xwin == null || (xwin instanceof Window && xwin.document == null)) {
39     toggleBrowser(true);
40     xwin = document.getElementById("content");
41     newwin = true;
42   }
43
44   if (old != textarea.value || newwin) {
45     old = textarea.value;
46     newwin = false;
47     var dataURI = "data:application/vnd.mozilla.xul+xml," + encodeURIComponent(old);
48     if(xwin instanceof Window)
49       xwin.document.location = dataURI;
50     else
51       xwin.setAttribute("src",dataURI);
52   }
53   try { xwin.contentWindow.mw = mw; } catch(E) {}
54   try { xwin.mw = mw; } catch(E) {}
55
56   timeout = window.setTimeout(update, 500);
57 }
58
59 function resetTimeout()
60 {
61   if(timeout != -1)
62     window.clearTimeout(timeout);
63
64   timeout = window.setTimeout(update, 500);
65 }