1 sdump('D_TRACE','Loading util.js\n');
3 var tab_count = [ false, false, false, false, false, false, false, false, false, false ];
5 function app_shell_init() {
6 dump("TESTING: app_shell.js: " + mw.G['main_test_variable'] + '\n');
7 replace_tab('main_tabbox','Tab','chrome://evergreen/content/main/about.xul');
11 function close_tab( d, tabbox ) {
12 var tbox = d.getElementById(tabbox);
13 var tabs = tbox.firstChild;
14 var panels = tbox.lastChild;
15 if (tabs.childNodes.length == 0) { return 0; }
17 var tab = tabs.selectedItem;
18 var panel = tbox.selectedPanel;
19 tab_count[ tab.getAttribute('count') ] = false;
20 tabs.advanceSelectedTab(-1);
21 tabs.removeChild( tab );
22 panels.removeChild( panel );
26 if (tabs.childNodes.length == 0) {
27 new_tab('main_tabbox');
31 function delete_tab_contents( tab, panel ) {
33 while (tab.lastChild) { tab.removeChild(tab.lastChild); }
34 while (panel.lastChild) { panel.removeChild(panel.lastChild); }
40 function first_free_tab_count() {
41 for (var i = 0; i<10; i++) {
50 function new_tab( d, tabbox ) {
51 var tbox = d.getElementById(tabbox);
52 var tabs = tbox.firstChild;
53 var panels = tbox.lastChild;
54 var tc = first_free_tab_count();
55 if (tc == -1) { return; } // let's only have up to 10 tabs
56 var panel = d.createElement('tabpanel');
57 var pl = d.createElement('label');
58 pl.setAttribute('value','Panel ' + tc);
59 panel.setAttribute('flex','1');
60 //panel.setAttribute('style','overflow: auto; min-width: 500px; min-height: 500px;');
61 panel.setAttribute('id','panel'+tc);
62 panel.appendChild(pl);
63 panels.appendChild(panel);
65 var tab = d.createElement('tab');
66 tab.setAttribute('label','Tab ' + tc );
67 tab.setAttribute('count',tc);
68 tab.setAttribute('accesskey',tc);
69 tab.setAttribute('linkedpanel','panel'+tc);
70 tabs.appendChild(tab);
72 tbox.selectedIndex = tc;
73 tabs.selectedIndex = tc;
74 //tbox.selectedIndex = tabs.childNodes.length - 1;
75 //tabs.selectedIndex = tabs.childNodes.length - 1;
76 replace_tab(tabbox,'Tab','chrome://evergreen/content/about.xul');
82 function replace_tab( d, tabbox, label, chrome, params ) {
83 var tbox = d.getElementById(tabbox);
84 var tabs = tbox.firstChild;
85 var panels = tbox.lastChild;
86 if (tabs.childNodes.length == 0) { new_tab(tabbox); }
88 var tab = tabs.selectedItem;
89 var panel = tbox.selectedPanel;
90 delete_tab_contents(tab,panel);
92 tab.setAttribute('label',label + ' ' + tab.getAttribute('count') );
94 var frame = d.createElement('iframe');
95 frame.setAttribute('flex','1');
96 //frame.setAttribute('style','overflow: scroll; min-height: 500px; min-width: 500px;');
97 frame.setAttribute('src',chrome);
98 panel.appendChild(frame);
99 frame.contentWindow.parentWindow = parentWindow;
100 frame.contentWindow.tabWindow = this;
101 dump('replace_tab.tabWindow = ' + this + '\n');
102 frame.contentWindow.mw = mw;
103 frame.contentWindow.am_i_a_top_level_tab = true;
105 frame.contentWindow.params = params;
107 return frame.contentWindow;