Index: grid.js =================================================================== --- grid.js (revision 13169) +++ grid.js (working copy) @@ -481,34 +481,31 @@ this.CheckDependencies('Grid.SetDependantToolbarButtons'); } -Grid.prototype.CheckDependencies = function($called_from) -{ -// alert('prefix: ' + this.prefix + '; ' + $called_from + ' -> Grid.CheckDependencies'); +Grid.prototype.CheckDependencies = function($called_from, $run_now) { + if (!$run_now || $run_now === undefined) { + // schedule run via document.ready, so we manage to disable + // toolbar buttons after ToolBar class mass-enables them + var $me = this; + + $(document).ready( + function () { + $me.CheckDependencies($called_from, true); + } + ); + + return ; + } + var enabling = (this.CountSelected() > 0); + for (var i = 0; i < this.DependantButtons.length; i++) { - if (this.DependantButtons[i][0].match("portal:(.*)")) { - button_name = RegExp.$1; - if (toolbar) { - if (enabling == this.DependantButtons[i][1]) { - toolbar.enableButton(button_name, true); - } - else - { - toolbar.disableButton(button_name, true); - } - } + if (this.DependantButtons[i][2] == 1) { + this.ToolBar.SetEnabled(this.DependantButtons[i][0], enabling == this.DependantButtons[i][1]); } else { - if (this.DependantButtons[i][2] == 1) { - this.ToolBar.SetEnabled(this.DependantButtons[i][0], enabling == this.DependantButtons[i][1]); - } - else { - this.ToolBar.SetVisible(this.DependantButtons[i][0], enabling == this.DependantButtons[i][1]); - } + this.ToolBar.SetVisible(this.DependantButtons[i][0], enabling == this.DependantButtons[i][1]); } } - //if (enabling) this.ClearAlternativeGridsSelection('Grid.CheckDependencies'); - } Grid.prototype.ClearAlternativeGridsSelection = function (called_from) Index: toolbar.js =================================================================== --- toolbar.js (revision 13169) +++ toolbar.js (working copy) @@ -94,6 +94,9 @@ this.SetOnRightClick() if (this.Hidden) this.Hide(); + // all buttons are disabled until page is fully loaded! + this.Disable(); + 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'; @@ -343,6 +346,16 @@ btn.Init(); } } + + var $me = this; + + $(document).ready( + function () { + for (var $button_name in $me.Buttons) { + $me.Buttons[$button_name].Enable(); + } + } + ); } ToolBar.prototype.EnableButton = function(button_id) {