Index: trunk/core/admin_templates/js/toolbar.js =================================================================== diff -u -N -r7391 -r7635 --- trunk/core/admin_templates/js/toolbar.js (.../toolbar.js) (revision 7391) +++ trunk/core/admin_templates/js/toolbar.js (.../toolbar.js) (revision 7635) @@ -1,8 +1,13 @@ function ToolBarButton(title, alt, onclick, $hidden, prefix) { this.Title = title || ''; + this.TranslateLink = false; this.CheckTitleModule(); this.Alt = RemoveTranslationLink(alt || ''); + if (this.Alt != alt) { + this.TranslateLink = alt || ''; + this.TranslateLink = this.TranslateLink.replace(/<a href="(.*?)">(.*?)<\/a>/g, '$1'); + } if (this.Alt.match(/(.*)::(.*)/)) { this.Alt = RegExp.$1; @@ -12,6 +17,7 @@ this.Label = this.Alt; } + if (typeof(onclick) == 'function') { this.onClick = onclick; } @@ -78,7 +84,9 @@ this.SetOnMouseOver(); this.SetOnMouseOut(); this.SetOnClick(); + this.SetOnRightClick() if (this.Hidden) this.Hide(); + if (!img.complete) { var real_path = img_path.replace('#MODULE#', this.Module) + 'toolbar/'; var old_path = img_path.replace('#MODULE#', 'kernel') + 'toolbar/'+this.ToolBar.IconPrefix + this.Title+'.gif'; @@ -92,6 +100,36 @@ // preg_print_pre(img, /natural|compl/i) } +ToolBarButton.prototype.EditTitle = function() { + if (this.TranslateLink !== false) { + var $links = this.TranslateLink; + + $links = $links.split('::'); + var $i = 0; + while ($i < $links.length) { + var $link = $links[$i]; + if ($link.match(/(javascript:|http:\/\/)(.*)/)) { + var $link_type = RegExp.$1; + $link = RegExp.$2.replace(/'/g, '"'); + if ($link_type == 'javascript:') { + eval($link); + } + else { + window.location.href = 'http://' + $link; + } + + // edit one phrase at a time + break; + } + $i++; + } + + return false; + } + + return true; +} + ToolBarButton.prototype.SetOnMouseOver = function() { this.Container.onmouseover = function() { this.btn.imgObject.src = this.btn.IconsPath() + this.btn.ToolBar.IconPrefix + this.btn.Title + '_f2.gif'; @@ -141,6 +179,13 @@ } } +ToolBarButton.prototype.SetOnRightClick = function() { + this.Container.oncontextmenu = function() { + return this.btn.EditTitle(); + } +} + + ToolBarButton.prototype.Disable = function() { if ( !this.Enabled ) return; this.imgObject.src = this.IconsPath() + this.ToolBar.IconPrefix + this.Title + '_f3.gif'; @@ -224,7 +269,7 @@ this.Module = $module ? $module : 'core'; this.IconPrefix = icon_prefix ? icon_prefix : 'tool_'; this.Buttons = new Array(); - this.UseLabels = $use_toolbarlabels ? $use_toolbarlabels : false; + this.UseLabels = typeof($use_toolbarlabels) != 'undefined' ? $use_toolbarlabels : false; } ToolBar.prototype.AddButton = function(a_button)