Index: trunk/kernel/admin_templates/incs/toolbar.js =================================================================== diff -u -r5057 -r5060 --- trunk/kernel/admin_templates/incs/toolbar.js (.../toolbar.js) (revision 5057) +++ trunk/kernel/admin_templates/incs/toolbar.js (.../toolbar.js) (revision 5060) @@ -25,41 +25,35 @@ ToolBarButton.prototype.CheckTitleModule = function() { if (this.Title.match(/([^:]+):(.*)$/)) { + // has module set directly this.Title = RegExp.$2; - this.Module = RegExp.$1 + '/'; + this.Module = RegExp.$1; } - else this.Module = ''; + else { + // use default module + this.Module = 'kernel'; + } } ToolBarButton.prototype.IconsPath = function() { if (!img_path) { alert('error: toolbar image path not set'); } -// alert('base toolbar button: ['+img_path + this.Module + 'toolbar/'+'];'); - return img_path + this.Module + 'toolbar/'; + return img_path.replace('#MODULE#', this.Module) + 'toolbar/'; } ToolBarButton.prototype.GetHTML = function() { - return ''; + return ''; } -ToolBarButton.prototype.GetObject = function() { - var $img = document.createElement('IMG'); - $img.id = this.GetToolId(); - $img.src = this.IconsPath() + this.ToolBar.IconPrefix + this.Title + '.gif'; - $img.title = this.Alt; - return $img; -} - -ToolBarButton.prototype.GetToolId = function() { +ToolBarButton.prototype.GetToolID = function() { return this.Prefix == '' ? 'tool_' + this.Title : 'tool_['+this.Prefix+'][' + this.Title+']' } ToolBarButton.prototype.Init = function() { - - img = document.getElementById(this.GetToolId()); - + + img = document.getElementById(this.GetToolID()); this.imgObject = img; img.btn = this; this.SetOnMouseOver(); @@ -152,17 +146,9 @@ ToolBarSeparator.prototype = new ToolBarButton; ToolBarSeparator.prototype.GetHTML = function() { - return ''; + return ''; } -ToolBarSeparator.prototype.GetObject = function() { - var $img = document.createElement('IMG'); - $img.id = 'tool_' + this.Title; - $img.src = this.IconsPath() + 'tool_divider.gif'; - $img.title = ''; - return $img; -} - ToolBarSeparator.prototype.Init = function() { img = document.getElementById(this.ToolBar.IconPrefix + this.Title); this.imgObject = img; @@ -175,13 +161,10 @@ /* ----------- */ - -function ToolBar(icon_prefix) +function ToolBar(icon_prefix, $module) { - if (typeof(icon_prefix) == 'undefined') - this.IconPrefix = 'tool_'; - else - this.IconPrefix = icon_prefix; + this.Module = $module ? $module : 'kernel'; + this.IconPrefix = icon_prefix ? icon_prefix : 'tool_'; this.Buttons = new Array(); } @@ -194,13 +177,13 @@ ToolBar.prototype.Render = function($container) { if ($container) { - html = ''; + $container.innerHTML = ''; // container will contain only buttons for (var i in this.Buttons) { btn = this.Buttons[i]; - html += btn.GetHTML(); -// appendChild( btn.GetObject() ); + $container.innerHTML += btn.GetHTML(); } - $container.innerHTML = html; + + // init all buttons after because objects are not yet created directly after assigning to innerHTML for (var i in this.Buttons) { btn = this.Buttons[i]; btn.Init();