diff --git a/ChangeLog b/ChangeLog index ebdcd31073ad66bd45b8726d18f89041f031a21e..740e62d75020e9cc1755b42373568873753795be 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 7bfb68211bd8d7cb1a0c144f7c298f3312730f51..a50559127aa828f152b12355f3ca1ec963f81527 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 8a71b08548436272b27650f3f258f7e864628a32..a89085ca5fd249ad206338ae8ba2531970cd9be7 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 668cb17deb35c4a7428a45f881f88342eb4ac4a1..d065ec2c8e3ac2e8052deabf30d917718a93b65a 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 87903c2532e5a9a2526242578db66fc216b9193f..a1b345c1119f0908c140299dc0b8ae19c9bd7644 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 e4c4d60b421a588194b88e35e4a0fe01bcb81f2c..908757e76833323080300d32588e8d3f5870aa4f 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 056f5b0db44e538ddde7fc14aefab7bd323f6093..514a0fa6cc1a761e9773f57f6e93cac84a697347 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 4dd6b4a2f0ebeba8ca0d841556d89cd01da0102b..edceca257b6cb38aaa43c841d7b20a4f500e0a62 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 */