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