Index: branches/5.2.x/core/admin_templates/js/toolbar.js =================================================================== diff -u -N -r14244 -r14856 --- branches/5.2.x/core/admin_templates/js/toolbar.js (.../toolbar.js) (revision 14244) +++ branches/5.2.x/core/admin_templates/js/toolbar.js (.../toolbar.js) (revision 14856) @@ -18,15 +18,13 @@ } - if (typeof(onclick) == 'function') { + if ( $.isFunction(onclick) ) { this.onClick = onclick; } else { this.onClick = function() { - if (eval('typeof('+this.Title+')') == 'function') - eval(this.Title + '()'); + this.runFunction(this.Title); } - } this.imgObject = null; @@ -59,17 +57,13 @@ ToolBarButton.prototype.IconsPath = function() { - if (typeof(img_path) == 'undefined') { - //alert('error: toolbar image path not set'); - } - var $module_path = this.Module; if (this.Module != 'core') { $module_path = 'modules/' + $module_path; } - return img_path.replace('#MODULE#', $module_path) + 'toolbar/'; + return this.ToolBar.IconPath.replace('#MODULE#', $module_path) + 'toolbar/'; } ToolBarButton.prototype.GetHTML = function() { @@ -150,6 +144,12 @@ }; } +ToolBarButton.prototype.runFunction = function($name) { + if ( window[$name] !== undefined && $.isFunction( window[$name] ) ) { + window[$name](); + } +} + ToolBarButton.prototype.SetOnClick = function() { // we have SetOnMouseOut for this ??? /*this.Container.onmouseout = function() { @@ -162,9 +162,7 @@ if (this.inClick || this.btn.ReadOnly) return; this.inClick = true; - if (eval('typeof('+this.btn.Title+')') == 'function') { - eval(this.btn.Title + '()'); - } + this.runFunction(this.btn.Title); this.inClick = false; } @@ -285,13 +283,24 @@ /* ----------- */ -function ToolBar(icon_prefix, $module) +function ToolBar(icon_prefix, $module, $image_path) { this.Module = $module ? $module : 'core'; this.IconPrefix = icon_prefix ? icon_prefix : 'tool_'; this.IconSize = {w:32,h:32}; this.Buttons = {}; this.UseLabels = typeof($use_toolbarlabels) != 'undefined' ? $use_toolbarlabels : false; + + if ( $image_path !== undefined ) { + this.IconPath = $image_path; + } + else if ( typeof(img_path) != 'undefined' ) { + this.IconPath = img_path; + } + else { + this.IconPath = ''; +// alert('error: toolbar image path not set'); + } } ToolBar.prototype.AddButton = function(a_button)