Index: t3lib/config_default.php =================================================================== --- t3lib/config_default.php (revision 2956) +++ t3lib/config_default.php (working copy) @@ -181,7 +181,8 @@ 'ShortcutMenu::render' => 'typo3/classes/class.shortcutmenu.php:ShortcutMenu->renderAjax', 'ShortcutMenu::delete' => 'typo3/classes/class.shortcutmenu.php:ShortcutMenu->deleteAjaxShortcut', 'ShortcutMenu::create' => 'typo3/classes/class.shortcutmenu.php:ShortcutMenu->createAjaxShortcut', - 'ModuleMenu::saveMenuState' => 'typo3/classes/class.modulemenu.php:ModuleMenu->saveMenuState' + 'ModuleMenu::saveMenuState' => 'typo3/classes/class.modulemenu.php:ModuleMenu->saveMenuState', + 'ModuleMenu::render' => 'typo3/classes/class.modulemenu.php:ModuleMenu->renderAjax' ), ), 'FE' => Array( // Configuration for the TypoScript frontend (FE). Nothing here relates to the administration backend! Index: typo3/backend.php =================================================================== --- typo3/backend.php (revision 2958) +++ typo3/backend.php (working copy) @@ -493,14 +493,11 @@ } } - '.$goToModuleSwitch.' - /** - * reloads the menu frame + * Function used to switch modules */ - function refreshMenu() { - top.'.$menuFrameName.'.location.href = top.'.$menuFrameName.'.document.URL - } + var currentModuleLoaded = ""; + var goToModule = '.$goToModuleSwitch.' /** * Frameset Module object Index: typo3/classes/class.modulemenu.php =================================================================== --- typo3/classes/class.modulemenu.php (revision 2957) +++ typo3/classes/class.modulemenu.php (working copy) @@ -26,6 +26,14 @@ ***************************************************************/ +if(TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_AJAX) { + require_once(PATH_typo3.'sysext/lang/lang.php'); + + $GLOBALS['LANG'] = t3lib_div::makeInstance('language'); + $GLOBALS['LANG']->init($GLOBALS['BE_USER']->uc['lang']); + $GLOBALS['LANG']->includeLLFile('EXT:lang/locallang_misc.xml'); +} + /** * class to render the TYPO3 backend menu for the modules * @@ -122,9 +130,10 @@ /** * renders the backend menu as unordered list * + * @param boolean optional parameter used to switch wrapping the menu in ul tags off for AJAX calls * @return string menu html code to use in the backend */ - public function render() { + public function render($wrapInUl = true) { $menu = ''; $onBlur = $GLOBALS['CLIENT']['FORMSTYLE'] ? 'this.blur();' : ''; @@ -149,7 +158,29 @@ $menu .= ''."\n"; } - return ''."\n"; + return $wrapInUl ? ''."\n" : $menu; + } + + /** + * renders the backend menu as unordered list as an AJAX response without + * the wrapping ul tags + * + * @param array array of parameters from the AJAX interface, currently unused + * @param TYPO3AJAX object of type TYPO3AJAX + * @return void + */ + public function renderAjax($params = array(), TYPO3AJAX &$ajaxObj = null) { + $menu = $this->render(false); + $menuSwitch = $this->getGotoModuleJavascript(); + + // JS rocks: we can just overwrite a function with a new definition. + // and yes, we actually do that =) + $menuSwitchUpdate = ' + '; + + $ajaxObj->addContent('typo3-menu', $menu.$menuSwitchUpdate); } /** @@ -222,14 +253,14 @@ } $modules[$moduleKey] = array( - 'name' => $moduleName, - 'title' => $GLOBALS['LANG']->moduleLabels['tabs'][$moduleKey], - 'onclick' => 'top.goToModule(\''.$moduleName.'\');', - 'cssId' => $moduleCssId, - 'icon' => $moduleIcon, - 'link' => $moduleLink, - 'prefix' => $moduleNavigationFramePrefix, - 'description' => $GLOBALS['LANG']->moduleLabels['labels'][$moduleKey.'label'] + 'name' => $moduleName, + 'title' => $GLOBALS['LANG']->moduleLabels['tabs'][$moduleKey], + 'onclick' => 'top.goToModule(\''.$moduleName.'\');', + 'cssId' => $moduleCssId, + 'icon' => $moduleIcon, + 'link' => $moduleLink, + 'prefix' => $moduleNavigationFramePrefix, + 'description' => $GLOBALS['LANG']->moduleLabels['labels'][$moduleKey.'label'] ); if(is_array($moduleData['sub'])) { @@ -411,22 +442,22 @@ $submoduleNavigationFrameScript = $this->appendQuestionmarkToLink($submoduleNavigationFrameScript).$subModuleData['navigationFrameScript']; $javascriptCommand = ' - if (top.content.list_frame && top.fsMod.currentMainLoaded=="'.$parentModuleName.'") { - top.currentSubScript="'.$subModuleData['originalLink'].'"; - top.content.list_frame.location=top.getModuleUrl(top.TS.PATH_typo3+"'.$this->appendQuestionmarkToLink($subModuleData['originalLink']).'"'.$additionalJavascript.'+additionalGetVariables); - if(top.currentSubNavScript!="'.$submoduleNavigationFrameScript.'") { - top.currentSubNavScript="'.$submoduleNavigationFrameScript.'"; - top.content.nav_frame.location=top.getModuleUrl(top.TS.PATH_typo3+"'.$submoduleNavigationFrameScript.'"); - } - } else { - top.content.location=top.TS.PATH_typo3+( - top.nextLoadModuleUrl? - "'.($subModuleData['prefix'] ? $this->appendQuestionmarkToLink($subModuleData['link']).'&exScript=' : '').'listframe_loader.php": - "'.$this->appendQuestionmarkToLink($subModuleData['link']).'"'.$additionalJavascript.'+additionalGetVariables - ); - top.fsMod.currentMainLoaded="'.$parentModuleName.'"; - top.currentSubScript="'.$subModuleData['originalLink'].'"; - } + if (top.content.list_frame && top.fsMod.currentMainLoaded=="'.$parentModuleName.'") { + top.currentSubScript="'.$subModuleData['originalLink'].'"; + top.content.list_frame.location=top.getModuleUrl(top.TS.PATH_typo3+"'.$this->appendQuestionmarkToLink($subModuleData['originalLink']).'"'.$additionalJavascript.'+additionalGetVariables); + if(top.currentSubNavScript!="'.$submoduleNavigationFrameScript.'") { + top.currentSubNavScript="'.$submoduleNavigationFrameScript.'"; + top.content.nav_frame.location=top.getModuleUrl(top.TS.PATH_typo3+"'.$submoduleNavigationFrameScript.'"); + } + } else { + top.content.location=top.TS.PATH_typo3+( + top.nextLoadModuleUrl? + "'.($subModuleData['prefix'] ? $this->appendQuestionmarkToLink($subModuleData['link']).'&exScript=' : '').'listframe_loader.php": + "'.$this->appendQuestionmarkToLink($subModuleData['link']).'"'.$additionalJavascript.'+additionalGetVariables + ); + top.fsMod.currentMainLoaded="'.$parentModuleName.'"; + top.currentSubScript="'.$subModuleData['originalLink'].'"; + } '; } @@ -431,13 +462,13 @@ } $javascriptCommand .= ' - top.highlightModuleMenuItem("'.$subModuleData['cssId'].'"); + top.highlightModuleMenuItem("'.$subModuleData['cssId'].'"); '; - $moduleJavascriptCommands[] = "case '".$subModuleData['name']."': \n ".$javascriptCommand." \n break;"; + $moduleJavascriptCommands[] = " case '".$subModuleData['name']."': \n ".$javascriptCommand." \n break;"; } } } elseif(!$mainModuleData['subitems'] && !empty($mainModuleData['link'])) { - // main module has no sub modules but instead is linked itself (doc module) + // main module has no sub modules but instead is linked itself (doc module f.e.) $javascriptCommand = ' top.content.location=top.getModuleUrl(top.TS.PATH_typo3+"'.$this->appendQuestionmarkToLink($mainModuleData['link']).'"+additionalGetVariables); top.highlightModuleMenuItem("'.$mainModuleData['cssId'].'", 1); @@ -442,16 +473,11 @@ top.content.location=top.getModuleUrl(top.TS.PATH_typo3+"'.$this->appendQuestionmarkToLink($mainModuleData['link']).'"+additionalGetVariables); top.highlightModuleMenuItem("'.$mainModuleData['cssId'].'", 1); '; - $moduleJavascriptCommands[] = "case '".$mainModuleData['name']."': \n ".$javascriptCommand." \n break;"; + $moduleJavascriptCommands[] = " case '".$mainModuleData['name']."': \n ".$javascriptCommand." \n break;"; } } - $javascriptCode = ' - /** - * Function used to switch switch module. - */ - var currentModuleLoaded = ""; - function goToModule(modName,cMR_flag,addGetVars) { // + $javascriptCode = 'function(modName, cMR_flag, addGetVars) { var additionalGetVariables = ""; if (addGetVars) additionalGetVariables = addGetVars; Index: typo3/js/modulemenu.js =================================================================== --- typo3/js/modulemenu.js (revision 2958) +++ typo3/js/modulemenu.js (working copy) @@ -31,8 +31,27 @@ * @author Steffen Kamper * @author Ingo Renner */ -var ModuleMenu = { +var ModuleMenu = Class.create({ + + /** + * initially register event listeners + */ + initialize: function() { + Event.observe(document, 'dom:loaded', function(){ + this.registerEventListeners(); + }.bind(this)); + }, + /** + * registers the event listeners, can be used to re-register them after refreshing the menu + */ + registerEventListeners: function() { + $$('#typo3-menu li.menuSection div').invoke('observe', 'click', this.toggleMenu); + }, + + /** + * toggles the associated submodule menu when clicking a main module header + */ toggleMenu: function(event) { var mainModuleHeader = Event.element(event); @@ -46,15 +65,24 @@ }); subModulesMenu.toggle(); + }, + + /** + * refreshes the complete module menu + */ + refreshMenu: function() { + new Ajax.Updater('typo3-menu', TS.PATH_typo3 + 'ajax.php', { + parameters : 'ajaxID=ModuleMenu::render', + asynchronous : false, + evalScripts : true + }); + + this.registerEventListeners(); } -} - // initialize event listening -Event.observe(document, 'dom:loaded', function() { - $$('#typo3-menu li.menuSection div').each(function(mainModuleHeader) { - mainModuleHeader.observe('click', ModuleMenu.toggleMenu) - }); }); +var TYPO3ModuleMenu = new ModuleMenu(); + Index: typo3/mod/tools/em/class.em_index.php =================================================================== --- typo3/mod/tools/em/class.em_index.php (revision 2956) +++ typo3/mod/tools/em/class.em_index.php (working copy) @@ -416,7 +416,13 @@ // Reload left frame menu if ($this->CMD['refreshMenu']) { - $this->doc->JScode .= $this->doc->wrapScriptTags('top.refreshMenu();'); + $this->doc->JScode .= $this->doc->wrapScriptTags(' + if(top.refreshMenu) { + top.refreshMenu(); + } else { + top.TYPO3ModuleMenu.refreshMenu(); + } + '); } $this->doc->form = '
';