1 var tab_count = [ false, false, false, false, false, false, false, false, false, false ];
3 function app_shell_init() {
4 dump("TESTING: app_shell.js: " + mw.G['main_test_variable'] + '\n');
5 replace_tab('main_tabbox','Tab','chrome://evergreen/content/main/about.xul');
9 function close_tab( d, tabbox ) {
10 var tbox = d.getElementById(tabbox);
11 var tabs = tbox.firstChild;
12 var panels = tbox.lastChild;
13 if (tabs.childNodes.length == 0) { return 0; }
15 var tab = tabs.selectedItem;
16 var panel = tbox.selectedPanel;
17 tab_count[ tab.getAttribute('count') ] = false;
18 tabs.advanceSelectedTab(-1);
19 tabs.removeChild( tab );
20 panels.removeChild( panel );
24 if (tabs.childNodes.length == 0) {
25 new_tab('main_tabbox');
29 function delete_tab_contents( tab, panel ) {
31 while (tab.lastChild) { tab.removeChild(tab.lastChild); }
32 while (panel.lastChild) { panel.removeChild(panel.lastChild); }
38 function first_free_tab_count() {
39 for (var i = 0; i<10; i++) {
48 function new_tab( d, tabbox ) {
49 var tbox = d.getElementById(tabbox);
50 var tabs = tbox.firstChild;
51 var panels = tbox.lastChild;
52 var tc = first_free_tab_count();
53 if (tc == -1) { return; } // let's only have up to 10 tabs
54 var panel = d.createElement('tabpanel');
55 var pl = d.createElement('label');
56 pl.setAttribute('value','Panel ' + tc);
57 panel.setAttribute('flex','1');
58 //panel.setAttribute('style','overflow: auto; min-width: 500px; min-height: 500px;');
59 panel.setAttribute('id','panel'+tc);
60 panel.appendChild(pl);
61 panels.appendChild(panel);
63 var tab = d.createElement('tab');
64 tab.setAttribute('label','Tab ' + tc );
65 tab.setAttribute('count',tc);
66 tab.setAttribute('accesskey',tc);
67 tab.setAttribute('linkedpanel','panel'+tc);
68 tabs.appendChild(tab);
70 tbox.selectedIndex = tc;
71 tabs.selectedIndex = tc;
72 //tbox.selectedIndex = tabs.childNodes.length - 1;
73 //tabs.selectedIndex = tabs.childNodes.length - 1;
74 replace_tab(tabbox,'Tab','chrome://evergreen/content/about.xul');
80 function replace_tab( d, tabbox, label, chrome, params ) {
81 var tbox = d.getElementById(tabbox);
82 var tabs = tbox.firstChild;
83 var panels = tbox.lastChild;
84 if (tabs.childNodes.length == 0) { new_tab(tabbox); }
86 var tab = tabs.selectedItem;
87 var panel = tbox.selectedPanel;
88 delete_tab_contents(tab,panel);
90 tab.setAttribute('label',label + ' ' + tab.getAttribute('count') );
92 var frame = d.createElement('iframe');
93 frame.setAttribute('flex','1');
94 //frame.setAttribute('style','overflow: scroll; min-height: 500px; min-width: 500px;');
95 frame.setAttribute('src',chrome);
96 panel.appendChild(frame);
97 frame.contentWindow.parentWindow = parentWindow;
98 frame.contentWindow.tabWindow = this;
99 dump('replace_tab.tabWindow = ' + this + '\n');
100 frame.contentWindow.mw = mw;
101 frame.contentWindow.am_i_a_top_level_tab = true;
103 frame.contentWindow.params = params;
105 return frame.contentWindow;