From 8e597efadb7fd584c33c10248c0194c4d4291a5f Mon Sep 17 00:00:00 2001 From: Susanne Moog <typo3@susannemoog.de> Date: Fri, 21 Jan 2011 09:26:38 +0000 Subject: [PATCH] Fixed bug #17179: No possibility to refresh the positioning of the toolbar items with a common function git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@10193 709f56b5-9817-0410-a4d7-c38de5d9e867 --- ChangeLog | 1 + typo3/js/backendsearch.js | 36 +--------------- typo3/js/clearcachemenu.js | 36 +--------------- typo3/js/shortcutmenu.js | 37 ++-------------- typo3/js/toolbarmanager.js | 42 +++++++++++++++++++ typo3/js/workspacemenu.js | 35 +--------------- typo3/sysext/opendocs/opendocs.js | 35 +--------------- .../sys_action/toolbarmenu/tx_sysactions.js | 35 +--------------- 8 files changed, 56 insertions(+), 201 deletions(-) diff --git a/ChangeLog b/ChangeLog index ebdcd31073ad..740e62d75020 100755 --- a/ChangeLog +++ b/ChangeLog @@ -19,6 +19,7 @@ 2011-01-21 Susanne Moog <typo3@susanne-moog.de> * Fixed bug #17169: Bug: Wrong color gradients for filter and new button in new page tree + * Fixed bug #17179: No possibility to refresh the positioning of the toolbar items with a common function 2011-01-21 Tobias Liebig <mail_typo3@etobi.de> diff --git a/typo3/js/backendsearch.js b/typo3/js/backendsearch.js index 7bfb68211bd8..a50559127aa8 100644 --- a/typo3/js/backendsearch.js +++ b/typo3/js/backendsearch.js @@ -35,10 +35,9 @@ var BackendSearch = Class.create({ * registers for resize event listener and executes on DOM ready */ initialize: function() { - Event.observe(window, 'resize', this.positionMenu); - Ext.onReady(function() { - this.positionMenu(); + Event.observe(window, 'resize', TYPO3BackendToolbarManager.positionMenu('backend-search-menu')); + TYPO3BackendToolbarManager.positionMenu('backend-search-menu'); this.toolbarItemIcon = $$('#backend-search-menu .toolbar-item span.t3-icon')[0]; $('search-query').observe('keypress', function(event) { @@ -63,37 +62,6 @@ var BackendSearch = Class.create({ }.bindAsEventListener(this)); }, - /** - * positions the menu below the toolbar icon, let's do some math! - */ - positionMenu: function() { - var calculatedOffset = 0; - var parentWidth = $('backend-search-menu').getWidth(); - var currentToolbarItemLayer = $$('#backend-search-menu div')[0]; - var ownWidth = currentToolbarItemLayer.getWidth(); - - var parentSiblings = $('backend-search-menu').previousSiblings(); - - parentSiblings.each(function(toolbarItem) { - calculatedOffset += toolbarItem.getWidth() - 1; - // -1 to compensate for the margin-right -1px of the list items, - // which itself is necessary for overlaying the separator with the active state background - - if (toolbarItem.down().hasClassName('no-separator')) { - calculatedOffset -= 1; - } - }); - calculatedOffset = calculatedOffset - ownWidth + parentWidth; - - // border correction - if (currentToolbarItemLayer.getStyle('display') !== 'none') { - calculatedOffset += 2; - } - - $$('#backend-search-menu div')[0].setStyle({ - left: calculatedOffset + 'px' - }); - }, /** * toggles the visibility of the menu and places it under the toolbar icon diff --git a/typo3/js/clearcachemenu.js b/typo3/js/clearcachemenu.js index 8a71b0854843..a89085ca5fd2 100644 --- a/typo3/js/clearcachemenu.js +++ b/typo3/js/clearcachemenu.js @@ -35,10 +35,10 @@ var ClearCacheMenu = Class.create({ * registers for resize event listener and executes on DOM ready */ initialize: function() { - Event.observe(window, 'resize', this.positionMenu); Ext.onReady(function() { - this.positionMenu(); + Event.observe(window, 'resize', TYPO3BackendToolbarManager.positionMenu('clear-cache-actions-menu')); + TYPO3BackendToolbarManager.positionMenu('clear-cache-actions-menu'); this.toolbarItemIcon = $$('#clear-cache-actions-menu .toolbar-item span.t3-icon')[0]; Event.observe('clear-cache-actions-menu', 'click', this.toggleMenu) @@ -50,38 +50,6 @@ var ClearCacheMenu = Class.create({ }, this); }, - /** - * positions the menu below the toolbar icon, let's do some math! - */ - positionMenu: function() { - var calculatedOffset = 0; - var parentWidth = $('clear-cache-actions-menu').getWidth(); - var currentToolbarItemLayer = $$('#clear-cache-actions-menu ul')[0]; - var ownWidth = currentToolbarItemLayer.getWidth(); - var parentSiblings = $('clear-cache-actions-menu').previousSiblings(); - - parentSiblings.each(function(toolbarItem) { - calculatedOffset += toolbarItem.getWidth() - 1; - // -1 to compensate for the margin-right -1px of the list items, - // which itself is necessary for overlaying the separator with the active state background - - if (toolbarItem.down().hasClassName('no-separator')) { - calculatedOffset -= 1; - } - }); - calculatedOffset = calculatedOffset - ownWidth + parentWidth; - - // border correction - if (currentToolbarItemLayer.getStyle('display') !== 'none') { - calculatedOffset += 2; - } - - - $$('#clear-cache-actions-menu ul')[0].setStyle({ - left: calculatedOffset + 'px' - }); - }, - /** * toggles the visibility of the menu and places it under the toolbar icon */ diff --git a/typo3/js/shortcutmenu.js b/typo3/js/shortcutmenu.js index 668cb17deb35..d065ec2c8e3a 100644 --- a/typo3/js/shortcutmenu.js +++ b/typo3/js/shortcutmenu.js @@ -36,10 +36,10 @@ var ShortcutMenu = Class.create({ * registers for resize event listener and executes on DOM ready */ initialize: function() { - Event.observe(window, 'resize', this.positionMenu); - Ext.onReady(function() { - this.positionMenu(); + Event.observe(window, 'resize', TYPO3BackendToolbarManager.positionMenu('shortcut-menu')); + TYPO3BackendToolbarManager.positionMenu('shortcut-menu'); + this.toolbarItemIcon = $$('#shortcut-menu .toolbar-item span.t3-icon')[0]; Event.observe($$('#shortcut-menu .toolbar-item')[0], 'click', this.toggleMenu); @@ -100,37 +100,6 @@ var ShortcutMenu = Class.create({ }, - /** - * positions the menu below the toolbar icon, let's do some math! - */ - positionMenu: function() { - var calculatedOffset = 0; - var parentWidth = $('shortcut-menu').getWidth(); - var currentToolbarItemLayer = $$('#shortcut-menu .toolbar-item-menu')[0]; - var ownWidth = currentToolbarItemLayer.getWidth(); - var parentSiblings = $('shortcut-menu').previousSiblings(); - - parentSiblings.each(function(toolbarItem) { - calculatedOffset += toolbarItem.getWidth() - 1; - // -1 to compensate for the margin-right -1px of the list items, - // which itself is necessary for overlaying the separator with the active state background - - if (toolbarItem.down().hasClassName('no-separator')) { - calculatedOffset -= 1; - } - }); - calculatedOffset = calculatedOffset - ownWidth + parentWidth; - - // border correction - if (currentToolbarItemLayer.getStyle('display') !== 'none') { - calculatedOffset += 2; - } - - $$('#shortcut-menu .toolbar-item-menu')[0].setStyle({ - left: calculatedOffset + 'px' - }); - }, - /** * toggles the visibility of the menu and places it under the toolbar icon */ diff --git a/typo3/js/toolbarmanager.js b/typo3/js/toolbarmanager.js index 87903c2532e5..a1b345c1119f 100644 --- a/typo3/js/toolbarmanager.js +++ b/typo3/js/toolbarmanager.js @@ -44,6 +44,48 @@ var ToolbarManager = Class.create({ // show toolbarItem toolbarItem.addClassName('toolbar-item-active'); } + }, + + /** + * refreshs positioning of all submenus + */ + refreshAll: function() { + $$('.toolbar-item-menu').each(function(element) { + menuParent = Ext.get(element); + TYPO3BackendToolbarManager.positionMenu(menuParent.findParentNode('[id$="-menu"]').id); + }); + }, + + /** + * positions a toolbar item (has to have .toolbar-item-menu) + * @param elementId The parent element ofthe menu to be positioned + */ + positionMenu: function(elementId) { + var calculatedOffset = 0; + var parentWidth = $(elementId).getWidth(); + var currentToolbarItemLayer = $$('#' + elementId + ' .toolbar-item-menu')[0]; + var ownWidth = currentToolbarItemLayer.getWidth(); + var parentSiblings = $(elementId).previousSiblings(); + + parentSiblings.each(function(toolbarItem) { + calculatedOffset += toolbarItem.getWidth() - 1; + // -1 to compensate for the margin-right -1px of the list items, + // which itself is necessary for overlaying the separator with the active state background + + if (toolbarItem.down().hasClassName('no-separator')) { + calculatedOffset -= 1; + } + }); + calculatedOffset = calculatedOffset - ownWidth + parentWidth; + + // border correction + if (currentToolbarItemLayer.getStyle('display') !== 'none') { + calculatedOffset += 2; + } + + $$('#' + elementId + ' .toolbar-item-menu')[0].setStyle({ + left: calculatedOffset + 'px' + }); } }); diff --git a/typo3/js/workspacemenu.js b/typo3/js/workspacemenu.js index e4c4d60b421a..908757e76833 100644 --- a/typo3/js/workspacemenu.js +++ b/typo3/js/workspacemenu.js @@ -36,10 +36,10 @@ var WorkspaceMenu = Class.create({ * registers for resize event listener and executes on DOM ready */ initialize: function() { - Event.observe(window, 'resize', this.positionMenu); Ext.onReady(function() { - this.positionMenu(); + Event.observe(window, 'resize', TYPO3BackendToolbarManager.positionMenu('workspace-selector-menu')); + TYPO3BackendToolbarManager.positionMenu('workspace-selector-menu'); Event.observe('workspace-selector-menu', 'click', this.toggleMenu); Event.observe('frontendPreviewToggle', 'click', this.toggleFrontendPreview.bind(this)); @@ -53,37 +53,6 @@ var WorkspaceMenu = Class.create({ }, this); }, - /** - * positions the menu below the toolbar icon, let's do some math! - */ - positionMenu: function() { - var calculatedOffset = 0; - var parentWidth = $('workspace-selector-menu').getWidth(); - var currentToolbarItemLayer = $$('#workspace-selector-menu ul')[0]; - var ownWidth = currentToolbarItemLayer.getWidth(); - var parentSiblings = $('workspace-selector-menu').previousSiblings(); - - parentSiblings.each(function(toolbarItem) { - calculatedOffset += toolbarItem.getWidth() - 1; - // -1 to compensate for the margin-right -1px of the list items, - // which itself is necessary for overlaying the separator with the active state background - - if (toolbarItem.down().hasClassName('no-separator')) { - calculatedOffset -= 1; - } - }); - calculatedOffset = calculatedOffset - ownWidth + parentWidth; - - // border correction - if (currentToolbarItemLayer.getStyle('display') !== 'none') { - calculatedOffset += 2; - } - - $$('#workspace-selector-menu ul')[0].setStyle({ - left: calculatedOffset + 'px' - }); - }, - /** * toggles the visibility of the menu and places it under the toolbar icon */ diff --git a/typo3/sysext/opendocs/opendocs.js b/typo3/sysext/opendocs/opendocs.js index 056f5b0db44e..514a0fa6cc1a 100644 --- a/typo3/sysext/opendocs/opendocs.js +++ b/typo3/sysext/opendocs/opendocs.js @@ -37,10 +37,10 @@ var OpenDocs = Class.create({ * registers for resize event listener and executes on DOM ready */ initialize: function() { - Event.observe(window, 'resize', this.positionMenu); Ext.onReady(function() { - this.positionMenu(); + Event.observe(window, 'resize', TYPO3BackendToolbarManager.positionMenu('tx-opendocs-menu')); + TYPO3BackendToolbarManager.positionMenu('tx-opendocs-menu'); this.toolbarItemIcon = $$('#tx-opendocs-menu .toolbar-item span.t3-icon')[0]; this.ajaxScript = top.TS.PATH_typo3 + this.ajaxScript; // can't be initialized earlier @@ -49,37 +49,6 @@ var OpenDocs = Class.create({ }, this); }, - /** - * positions the menu below the toolbar icon, let's do some math! - */ - positionMenu: function() { - var calculatedOffset = 0; - var parentWidth = $('tx-opendocs-menu').getWidth(); - var currentToolbarItemLayer = $$('#tx-opendocs-menu .toolbar-item-menu')[0]; - var ownWidth = currentToolbarItemLayer.getWidth(); - var parentSiblings = $('tx-opendocs-menu').previousSiblings(); - - parentSiblings.each(function(toolbarItem) { - calculatedOffset += toolbarItem.getWidth() - 1; - // -1 to compensate for the margin-right -1px of the list items, - // which itself is necessary for overlaying the separator with the active state background - - if(toolbarItem.down().hasClassName('no-separator')) { - calculatedOffset -= 1; - } - }); - calculatedOffset = calculatedOffset - ownWidth + parentWidth; - - // border correction - if (currentToolbarItemLayer.getStyle('display') !== 'none') { - calculatedOffset += 2; - } - - $$('#tx-opendocs-menu .toolbar-item-menu')[0].setStyle({ - left: calculatedOffset + 'px' - }); - }, - /** * toggles the visibility of the menu and places it under the toolbar icon */ diff --git a/typo3/sysext/sys_action/toolbarmenu/tx_sysactions.js b/typo3/sysext/sys_action/toolbarmenu/tx_sysactions.js index 4dd6b4a2f0eb..edceca257b6c 100644 --- a/typo3/sysext/sys_action/toolbarmenu/tx_sysactions.js +++ b/typo3/sysext/sys_action/toolbarmenu/tx_sysactions.js @@ -35,10 +35,10 @@ var SysActionMenu = Class.create({ * registers for resize event listener and executes on DOM ready */ initialize: function() { - Event.observe(window, 'resize', this.positionMenu); Ext.onReady(function() { - this.positionMenu(); + Event.observe(window, 'resize', TYPO3BackendToolbarManager.positionMenu('tx-sys-action-menu')); + TYPO3BackendToolbarManager.positionMenu('tx-sys-action-menu'); this.toolbarItemIcon = $$('#tx-sys-action-menu .toolbar-item span')[0].src; Event.observe('tx-sys-action-menu', 'click', this.toggleMenu); @@ -46,37 +46,6 @@ var SysActionMenu = Class.create({ }, this); }, - /** - * positions the menu below the toolbar icon, let's do some math! - */ - positionMenu: function() { - var calculatedOffset = 0; - var parentWidth = $('tx-sys-action-menu').getWidth(); - var currentToolbarItemLayer = $$('#tx-sys-action-menu ul')[0]; - var ownWidth = currentToolbarItemLayer.getWidth(); - var parentSiblings = $('tx-sys-action-menu').previousSiblings(); - - parentSiblings.each(function(toolbarItem) { - calculatedOffset += toolbarItem.getWidth() - 1; - // -1 to compensate for the margin-right -1px of the list items, - // which itself is necessary for overlaying the separator with the active state background - - if(toolbarItem.down().hasClassName('no-separator')) { - calculatedOffset -= 1; - } - }); - calculatedOffset = calculatedOffset - ownWidth + parentWidth; - - // border correction - if (currentToolbarItemLayer.getStyle('display') !== 'none') { - calculatedOffset += 2; - } - - $$('#tx-sys-action-menu ul')[0].setStyle({ - left: calculatedOffset + 'px' - }); - }, - /** * toggles the visibility of the menu and places it under the toolbar icon */ -- GitLab