diff --git a/scm-webapp/src/main/webapp/resources/css/style.css b/scm-webapp/src/main/webapp/resources/css/style.css index da258928ef..4617358dc1 100644 --- a/scm-webapp/src/main/webapp/resources/css/style.css +++ b/scm-webapp/src/main/webapp/resources/css/style.css @@ -101,4 +101,8 @@ a:visited { .scm-form-textarea-help-button { vertical-align: top; margin-left: 2px; +} + +.scm-nav-item { + cursor: pointer; } \ No newline at end of file diff --git a/scm-webapp/src/main/webapp/resources/js/sonia.navigation.js b/scm-webapp/src/main/webapp/resources/js/sonia.navigation.js index b16fb4b635..64ca17508f 100644 --- a/scm-webapp/src/main/webapp/resources/js/sonia.navigation.js +++ b/scm-webapp/src/main/webapp/resources/js/sonia.navigation.js @@ -33,97 +33,89 @@ Ext.ns('Sonia.navigation'); Sonia.navigation.NavSection = Ext.extend(Ext.Panel, { - data: null, + links: null, + tpl: new Ext.XTemplate( + '' + ), + initComponent: function(){ - if ( this.data == null ){ - this.data = this.items; + if ( this.links == null ){ + this.links = this.items; } - if ( this.data == null ){ - this.data = []; + if ( this.links == null ){ + this.links = []; } + + Ext.each(this.links, function(link){ + Ext.id( link ); + }); + var config = { frame: true, collapsible:true, - style: 'margin: 5px', - listeners: { - afterrender: { - fn: this.renderMenu, - scope: this - } - } + style: 'margin: 5px' } Ext.apply(this, Ext.apply(this.initialConfig, config)); Sonia.navigation.NavSection.superclass.initComponent.apply(this, arguments); - }, - onItemClick: function(e, t){ - var target = Ext.get(t); - var id = target.id; - var prefix = this.id + '-nav-item-'; - if ( id != null && id.indexOf(prefix) == 0 ){ - var i = parseInt( id.substring( prefix.length ) ); - var fn = this.data[i].fn; - if ( Ext.isFunction( fn ) ){ - var scope = this.data[i].scope; + doAction: function(e, t){ + console.debug( t ); + e.stopEvent(); + Ext.each(this.links, function(navItem){ + if ( navItem.id == t.id && Ext.isFunction(navItem.fn) ){ + var scope = navItem.scope; if ( Ext.isObject( scope )){ - fn.call(scope); + navItem.fn.call(scope); } else { - fn(); + navItem.fn(); } - } else if ( debug ){ - console.debug('fn at "' + this.data[i].label + '" is not a function'); } - } + }); + }, + + afterRender: function(){ + Sonia.navigation.NavSection.superclass.afterRender.apply(this, arguments); + + // create list items + this.tpl.overwrite(this.body, { + links: this.links + }); + + this.body.on('mousedown', this.doAction, this, {delegate:'a'}); + this.body.on('click', Ext.emptyFn, null, {delegate:'a', preventDefault:true}); }, - renderMenu: function(){ - if ( Ext.isArray( this.data ) && this.data.length > 0 ){ - var links = []; - for ( var i=0; i 0 ){ for ( var i=0; i