1
// Licensed under the MIT license
2
// http://opensource.org/licenses/mit-license.php
4
// Copyright 2007, Frank Scholz <coherence@beebits.net>
10
if(typeof(Coherence) == "undefined") {
14
Coherence.Base = Nevow.Athena.Widget.subclass('Coherence.Base');
15
Coherence.Base.activeTab = 0;
16
Coherence.Base.build_done = 'no';
18
Coherence.Base.methods(
20
function setTab(self, tab, active) {
21
Divmod.debug("base", "setTab " + tab.id + " " + active);
22
log('tab_item ' + tab.id.split('-')[0]+'-'+tab.id.split('-')[1]+'-container');
23
tab_item = $(tab.id.split('-')[0]+'-'+tab.id.split('-')[1]+'-container')
24
log('tab_item ' + tab_item);
26
if( Coherence.Base.activeTab != 0) {
27
Coherence.Base.activeTab.style.color ='#FFFFFF'
28
Coherence.Base.activeTab.style.backgroundColor ='#404040'
29
c = $(Coherence.Base.activeTab.id.split('-')[0]+'-'+Coherence.Base.activeTab.id.split('-')[1]+'-container')
30
c.style.visibility = 'hidden'
32
tab.style.color ='#000000'
33
tab.style.backgroundColor ='#C0C0C0'
34
log("set " + tab.id.split('-')[0]+'-'+tab.id.split('-')[1]+'-container' + " " + 'visible');
35
tab_item.style.visibility = 'visible'
36
Coherence.Base.activeTab = tab
40
tab.style.color ='#FFFFFF'
41
tab.style.backgroundColor ='#404040'
42
tab_item.style.visibility = 'hidden'
43
Coherence.Base.activeTab = 0
47
function clickTab(self, Event) {
48
Divmod.debug("base", "clickTab " + Event.target.id);
49
if( Event.target.className != 'coherence_menu_item')
51
if( Coherence.Base.activeTab == Event.target)
53
Coherence.Base.prototype.setTab(Event.target, 'on');
56
function addTab(self, tab) {
57
Divmod.debug("base", 'addTab '+tab['title']+' '+tab['athenaid']);
58
if( Coherence.Base.build_done == 'no') {
59
Divmod.debug("base", 'Base.build_done == no');
62
appendChildNodes(self.nodeById('coherence_menu_box'),
63
DIV({'id':tab['athenaid']+'-'+tab['title']+'-tab','class':'coherence_menu_item'}, tab['title']
66
$(tab['athenaid']+'-'+tab['title']+'-tab').addEventListener("click", Coherence.Base.prototype.clickTab, false);
67
//self.nodeById(tab['title']+'-tab').addEventListener("click", Coherence.Base.prototype.clickTab, false);
68
if(tab['active'] == 'yes') {
69
Divmod.debug("base", 'addTab set active '+tab['title']);
70
self.setTab($(tab['athenaid']+'-'+tab['title']+'-tab'), 'on');
72
// MochiKit.Visual.roundElement( $(channel+'-box'));
75
function buildMenu(self, result) {
76
Divmod.debug("base", 'buildMenu ' + result.length);
77
Coherence.Base.build_done = 'yes'
78
for(var i=0; i<result.length;++i) {
79
Divmod.debug("base", 'buildMenu ' + i + ' ' + result[i]);
80
self.addTab(result[i]);
85
function __init__(self, node) {
86
Divmod.debug("base",'Coherence.Base __init__');
87
Coherence.Base.upcall(self, '__init__', node);
88
var d = self.callRemote('going_live');
89
d.addCallback(function (result) { self.buildMenu(result); });
90
Divmod.debug("base",'Coherence.Base __init__ done');