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 if (typeof(tabbox)!='object')
14 tabbox = d.getElementById(tabbox);
15 if (typeof(tabbox)!='object')
16 throw('Could not find tabbox. d = ' + d + ' tabbox = ' + tabbox + '\n');
18 var idx = tabbox.selectedIndex;
19 var tabs = tabbox.firstChild;
20 var panels = tabbox.lastChild;
23 tabs.advanceSelectedTab(+1);
25 tabs.advanceSelectedTab(-1);
27 if (tabs.childNodes.length > 1 ) {
28 tabs.removeItemAt( idx );
29 panels.removeChild( panels.childNodes[ idx ] );
31 replace_tab(d,tabbox,'Tab','chrome://evergreen/content/main/about.xul');
38 sdump('D_TAB',' : tabs.childNodes.length = ' + tabs.childNodes.length + ' panels.childNodes.length = ' + panels.childNodes.length + '\n');
41 function delete_tab_contents( tab, panel ) {
42 sdump('D_TAB','calling delete_tab_contents( ' + tab + ',' + panel + ');\n');
44 while (tab.lastChild) { tab.removeChild(tab.lastChild); }
45 while (panel.lastChild) { panel.removeChild(panel.lastChild); }
47 dump(js2JSON(E)+'\n');
51 function first_free_tab_count() {
52 for (var i = 0; i<10; i++) {
61 function new_tab( d, tabbox ) {
62 sdump('D_TAB','calling new_tab( ' + d + ',' + tabbox + ');\n');
63 if (typeof(tabbox)!='object')
64 tabbox = d.getElementById(tabbox);
65 if (typeof(tabbox)!='object')
66 throw('Could not find tabbox. d = ' + d + ' tabbox = ' + tabbox + '\n');
67 var tabs = tabbox.firstChild;
68 var panels = tabbox.lastChild;
69 var tc = first_free_tab_count();
70 if (tc == -1) { return; } // let's only have up to 10 tabs
71 var panel = d.createElement('tabpanel');
72 var pl = d.createElement('label');
73 pl.setAttribute('value','Panel ' + tc);
74 panel.setAttribute('flex','1');
75 //panel.setAttribute('style','overflow: auto; min-width: 500px; min-height: 500px;');
76 panel.setAttribute('id','panel'+tc);
77 panel.appendChild(pl);
78 panels.appendChild(panel);
80 var tab = d.createElement('tab');
81 tab.setAttribute('label','Tab ' + tc );
82 tab.setAttribute('count',tc);
83 tab.setAttribute('accesskey',tc);
84 tab.setAttribute('linkedpanel','panel'+tc);
85 tabs.appendChild(tab);
87 tabbox.selectedIndex = tc;
88 tabs.selectedIndex = tc;
89 //tabbox.selectedIndex = tabs.childNodes.length - 1;
90 //tabs.selectedIndex = tabs.childNodes.length - 1;
91 replace_tab(d,tabbox,'Tab','chrome://evergreen/content/main/about.xul');
93 dump(js2JSON(E)+'\n');
95 sdump('D_TAB',' : tabs.childNodes.length = ' + tabs.childNodes.length + ' panels.childNodes.length = ' + panels.childNodes.length + '\n');
98 function replace_tab( d, tabbox, label, chrome, params ) {
99 sdump('D_TAB','calling replace_tab( ' + d + ',' + tabbox + ');\n');
100 if (typeof(tabbox)!='object')
101 tabbox = d.getElementById(tabbox);
102 if (typeof(tabbox)!='object')
103 throw('Could not find tabbox. d = ' + d + ' tabbox = ' + tabbox + '\n');
104 var tabs = tabbox.firstChild;
105 var panels = tabbox.lastChild;
106 if (tabs.childNodes.length == 0) { new_tab(d,tabbox); }
108 var tab = tabs.selectedItem;
109 var panel = tabbox.selectedPanel;
110 delete_tab_contents(tab,panel);
112 tab.setAttribute('label',label + ' ' + tab.getAttribute('count') );
114 var frame = d.createElement('iframe');
115 frame.setAttribute('flex','1');
116 //frame.setAttribute('style','overflow: scroll; min-height: 500px; min-width: 500px;');
117 frame.setAttribute('src',chrome);
118 panel.appendChild(frame);
119 //frame.contentWindow.parentWindow = parentWindow;
120 //frame.contentWindow.tabWindow = this;
121 //dump('replace_tab.tabWindow = ' + this + '\n');
122 frame.contentWindow.mw = mw;
123 //frame.contentWindow.am_i_a_top_level_tab = true;
125 frame.contentWindow.params = params;
127 return frame.contentWindow;
129 dump(js2JSON(E)+'\n');
131 sdump('D_TAB',' : tabs.childNodes.length = ' + tabs.childNodes.length + ' panels.childNodes.length = ' + panels.childNodes.length + '\n');