1 sdump('D_TRACE','Loading app_shell.js\n');
3 var tab_count = [ false, false, false, false, false, false, false, false, false, false ];
5 function app_shell_init(params) {
6 dump("TESTING: app_shell.js: " + mw.G['main_test_variable'] + '\n');
7 replace_tab(params.d,'main_tabbox','Tab','chrome://evergreen/content/main/about.xul');
11 function close_tab( d, tabbox ) {
12 sdump('D_TAB','calling close_tab( ' + d + ',' + tabbox + ');\n');
13 var tbox = d.getElementById(tabbox);
14 var tabs = tbox.firstChild;
15 var panels = tbox.lastChild;
16 if (tabs.childNodes.length == 0) { return 0; }
18 var tab = tabs.selectedItem;
19 var panel = tbox.selectedPanel;
20 tab_count[ tab.getAttribute('count') ] = false;
21 tabs.advanceSelectedTab(-1);
22 tabs.removeChild( tab );
23 panels.removeChild( panel );
25 dump(js2JSON(E)+'\n');
27 if (tabs.childNodes.length == 0) {
28 new_tab(d,'main_tabbox');
32 function delete_tab_contents( tab, panel ) {
33 sdump('D_TAB','calling delete_tab_contents( ' + tab + ',' + panel + ');\n');
35 while (tab.lastChild) { tab.removeChild(tab.lastChild); }
36 while (panel.lastChild) { panel.removeChild(panel.lastChild); }
38 dump(js2JSON(E)+'\n');
42 function first_free_tab_count() {
43 for (var i = 0; i<10; i++) {
52 function new_tab( d, tabbox ) {
53 sdump('D_TAB','calling new_tab( ' + d + ',' + tabbox + ');\n');
54 var tbox = d.getElementById(tabbox);
55 var tabs = tbox.firstChild;
56 var panels = tbox.lastChild;
57 var tc = first_free_tab_count();
58 if (tc == -1) { return; } // let's only have up to 10 tabs
59 var panel = d.createElement('tabpanel');
60 var pl = d.createElement('label');
61 pl.setAttribute('value','Panel ' + tc);
62 panel.setAttribute('flex','1');
63 //panel.setAttribute('style','overflow: auto; min-width: 500px; min-height: 500px;');
64 panel.setAttribute('id','panel'+tc);
65 panel.appendChild(pl);
66 panels.appendChild(panel);
68 var tab = d.createElement('tab');
69 tab.setAttribute('label','Tab ' + tc );
70 tab.setAttribute('count',tc);
71 tab.setAttribute('accesskey',tc);
72 tab.setAttribute('linkedpanel','panel'+tc);
73 tabs.appendChild(tab);
75 tbox.selectedIndex = tc;
76 tabs.selectedIndex = tc;
77 //tbox.selectedIndex = tabs.childNodes.length - 1;
78 //tabs.selectedIndex = tabs.childNodes.length - 1;
79 replace_tab(d,tabbox,'Tab','chrome://evergreen/content/about.xul');
81 dump(js2JSON(E)+'\n');
85 function replace_tab( d, tabbox, label, chrome, params ) {
86 sdump('D_TAB','calling replace_tab( ' + d + ',' + tabbox + ');\n');
87 var tbox = d.getElementById(tabbox);
88 var tabs = tbox.firstChild;
89 var panels = tbox.lastChild;
90 if (tabs.childNodes.length == 0) { new_tab(d,tabbox); }
92 var tab = tabs.selectedItem;
93 var panel = tbox.selectedPanel;
94 delete_tab_contents(tab,panel);
96 tab.setAttribute('label',label + ' ' + tab.getAttribute('count') );
98 var frame = d.createElement('iframe');
99 frame.setAttribute('flex','1');
100 //frame.setAttribute('style','overflow: scroll; min-height: 500px; min-width: 500px;');
101 frame.setAttribute('src',chrome);
102 panel.appendChild(frame);
103 //frame.contentWindow.parentWindow = parentWindow;
104 //frame.contentWindow.tabWindow = this;
105 //dump('replace_tab.tabWindow = ' + this + '\n');
106 frame.contentWindow.mw = mw;
107 //frame.contentWindow.am_i_a_top_level_tab = true;
109 frame.contentWindow.params = params;
111 return frame.contentWindow;
113 dump(js2JSON(E)+'\n');