Index: trunk/core/admin_templates/js/toolbar.js =================================================================== diff -u -N -r6784 -r7391 --- trunk/core/admin_templates/js/toolbar.js (.../toolbar.js) (revision 6784) +++ trunk/core/admin_templates/js/toolbar.js (.../toolbar.js) (revision 7391) @@ -4,6 +4,14 @@ this.CheckTitleModule(); this.Alt = RemoveTranslationLink(alt || ''); + if (this.Alt.match(/(.*)::(.*)/)) { + this.Alt = RegExp.$1; + this.Label = RegExp.$2 + } + else { + this.Label = this.Alt; + } + if (typeof(onclick) == 'function') { this.onClick = onclick; } @@ -47,43 +55,65 @@ } ToolBarButton.prototype.GetHTML = function() { - return ''; + var add_style = this.ToolBar.ButtonStyle ? 'style="'+this.ToolBar.ButtonStyle+'"' : ''; + var o = '
' + o += ''; + if (this.ToolBar.UseLabels) o += '
'+this.Label; + o += '
' + return o; } -ToolBarButton.prototype.GetToolID = function() { - return this.Prefix == '' ? 'tool_' + this.Title : 'tool_['+this.Prefix+'][' + this.Title+']' +ToolBarButton.prototype.GetToolID = function(item) { + if (!item) item = 'tool' + return this.Prefix == '' ? item+'_' + this.Title : item+'_['+this.Prefix+'][' + this.Title+']' } ToolBarButton.prototype.Init = function() { img = document.getElementById(this.GetToolID()); this.imgObject = img; + this.Container = document.getElementById(this.GetToolID('div')) ? document.getElementById(this.GetToolID('div')) : false; + this.Container.btn = this; img.btn = this; this.SetOnMouseOver(); this.SetOnMouseOut(); this.SetOnClick(); 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'; + real_path = real_path.replace('http://kostja.prod.intechnic.lv/in-portal.RC', '.'); + old_path = old_path.replace('http://kostja.prod.intechnic.lv/in-portal.RC', '.'); + var source = old_path.replace('/core/', '/kernel/').replace('.gif', '*.gif'); + var path = 'cp '+source+' '+real_path; +// prompt('exec: ', path) +// img.src = 'img/bad_button.GIF'; + } +// preg_print_pre(img, /natural|compl/i) } ToolBarButton.prototype.SetOnMouseOver = function() { - this.imgObject.onmouseover = function() { - this.src = this.btn.IconsPath() + this.btn.ToolBar.IconPrefix + this.btn.Title + '_f2.gif'; + this.Container.onmouseover = function() { + this.btn.imgObject.src = this.btn.IconsPath() + this.btn.ToolBar.IconPrefix + this.btn.Title + '_f2.gif'; + this.className = 'toolbar-button-over'; }; } ToolBarButton.prototype.SetOnMouseOut = function() { - this.imgObject.onmouseout = function() { - this.src = this.btn.IconsPath() + this.btn.ToolBar.IconPrefix + this.btn.Title + '.gif'; + this.Container.onmouseout = function() { + this.btn.imgObject.src = this.btn.IconsPath() + this.btn.ToolBar.IconPrefix + this.btn.Title + '.gif'; + this.className = 'toolbar-button'; }; } ToolBarButton.prototype.SetOnClick = function() { - this.imgObject.onmouseout = function() { - this.src = this.btn.IconsPath() + this.btn.ToolBar.IconPrefix + this.btn.Title + '.gif'; - }; - this.imgObject.inClick = false; + // we have SetOnMouseOut for this ??? + /*this.Container.onmouseout = function() { + this.btn.imgObject.src = this.btn.IconsPath() + this.btn.ToolBar.IconPrefix + this.btn.Title + '.gif'; + };*/ + this.Container.inClick = false; if (typeof(this.onClick) != 'function') { - this.imgObject.onclick = function() { + this.Container.onclick = function() { if (this.inClick) return; this.inClick = true; if (eval('typeof('+this.btn.Title+')') == 'function') @@ -92,7 +122,7 @@ } } else { - this.imgObject.onclick = function() { + this.Container.onclick = function() { if (this.inClick) return; this.inClick = true; this.btn.onClick(); @@ -103,7 +133,7 @@ // the following lines are correct, as long as mozilla understands 'pointer', but IE 'hand', // do not change the order of these lines! if (is.ie6up || is.gecko) { - this.imgObject.style.cursor = 'pointer'; + this.Container.style.cursor = 'pointer'; } else { // somehow set cursor hand for IE 5/ 5.5 @@ -114,11 +144,12 @@ ToolBarButton.prototype.Disable = function() { if ( !this.Enabled ) return; this.imgObject.src = this.IconsPath() + this.ToolBar.IconPrefix + this.Title + '_f3.gif'; - this.imgObject.onmouseover = null; - this.imgObject.onmouseout = null; - this.imgObject.onclick = null; - this.imgObject.style.cursor = 'default'; + this.Container.onmouseover = null; + this.Container.onmouseout = null; + this.Container.onclick = null; + this.Container.style.cursor = 'default'; this.Enabled = false; + this.Container.className = 'toolbar-button-disabled' } ToolBarButton.prototype.Enable = function() { @@ -128,15 +159,16 @@ this.SetOnMouseOut(); this.SetOnClick(); this.Enabled = true; + this.Container.className = 'toolbar-button' } ToolBarButton.prototype.Hide = function() { - this.imgObject.style.display = 'none'; + this.Container.style.display = 'none'; this.Hidden = true; } ToolBarButton.prototype.Show = function() { - this.imgObject.style.display = ''; + this.Container.style.display = ''; this.Hidden = false; } @@ -149,11 +181,17 @@ ToolBarSeparator.prototype = new ToolBarButton; ToolBarSeparator.prototype.GetHTML = function() { - return ''; + var add_style = this.ToolBar.ButtonStyle ? 'style="'+this.ToolBar.ButtonStyle+'"' : ''; + var padding = this.ToolBar.UseLabels ? '12px' : '2px' + return '
'; + + var add_style = this.ToolBar.ButtonStyle ? 'style="'+this.ToolBar.ButtonStyle+'"' : ''; + return '
'; } ToolBarSeparator.prototype.Init = function() { img = document.getElementById(this.ToolBar.IconPrefix + this.Title); + this.Container = document.getElementById(this.GetToolID('div')) ? document.getElementById(this.GetToolID('div')) : false; this.imgObject = img; img.btn = this; } @@ -163,12 +201,30 @@ /* ----------- */ +function ToolBarMarkup(title, html) //extends ToolBarButton +{ + this.Title = title; + this.HTML = html; +} +ToolBarMarkup.prototype = new ToolBarButton; + +ToolBarMarkup.prototype.GetHTML = function() { + return this.HTML; +} + +ToolBarMarkup.prototype.Init = function() { } +ToolBarMarkup.prototype.Enable = function() { } +ToolBarMarkup.prototype.Disable = function() { } + +/* ----------- */ + function ToolBar(icon_prefix, $module) { this.Module = $module ? $module : 'core'; this.IconPrefix = icon_prefix ? icon_prefix : 'tool_'; this.Buttons = new Array(); + this.UseLabels = $use_toolbarlabels ? $use_toolbarlabels : false; } ToolBar.prototype.AddButton = function(a_button) @@ -180,11 +236,12 @@ ToolBar.prototype.Render = function($container) { if ($container) { - $container.innerHTML = ''; // container will contain only buttons + var tmp = ''; for (var i in this.Buttons) { btn = this.Buttons[i]; - $container.innerHTML += btn.GetHTML(); + tmp += btn.GetHTML(); } + $container.innerHTML = tmp; // container will contain only buttons // init all buttons after because objects are not yet created directly after assigning to innerHTML for (var i in this.Buttons) {