[BUGFIX] jQuery is loaded twice in backend.php 55/34455/3
authorBenjamin Mack <benni@typo3.org>
Fri, 21 Nov 2014 17:25:34 +0000 (18:25 +0100)
committerWouter Wolters <typo3@wouterwolters.nl>
Fri, 21 Nov 2014 19:02:05 +0000 (20:02 +0100)
Due to several patches, jQuery is currently
loaded twice in the backend.php script.
Once via window.jQuery (default noConflict)
and via TYPO3.jQuery. The core only uses
window.jQuery in the module menu JS
which is now changed to use TYPO3.jQuery.

As for the current state, as long as jQuery
is not globally available with window.$ due
to the conflict with Prototype, the TYPO3.jQuery
is used throughout the core, and also
in the module menu.

Releases: master
Resolves: #63133
Change-Id: Iadc019ec4b84f2aee833009c1c47449e9c1d2fe7
Reviewed-on: http://review.typo3.org/34455
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Michael Oehlhof <typo3@oehlhof.de>
Tested-by: Michael Oehlhof <typo3@oehlhof.de>
typo3/sysext/backend/Classes/Controller/BackendController.php
typo3/sysext/backend/Resources/Public/JavaScript/modulemenu.js

index 07c7662..31644dd 100644 (file)
@@ -105,7 +105,8 @@ class BackendController {
                $this->moduleLoader->load($GLOBALS['TBE_MODULES']);
                $this->pageRenderer = $GLOBALS['TBE_TEMPLATE']->getPageRenderer();
                $this->pageRenderer->loadExtJS();
-               $this->pageRenderer->loadJquery(NULL, NULL, \TYPO3\CMS\Core\Page\PageRenderer::JQUERY_NAMESPACE_DEFAULT_NOCONFLICT);
+               // included for the module menu JavaScript, please note that this is subject to change
+               $this->pageRenderer->loadJquery();
                $this->pageRenderer->enableExtJSQuickTips();
                $this->pageRenderer->addJsInlineCode('consoleOverrideWithDebugPanel', '//already done', FALSE);
                $this->pageRenderer->addExtDirectCode();
index 103d293..5a13ab8 100644 (file)
@@ -32,17 +32,17 @@ TYPO3.ModuleMenu.App = {
                var me = this;
 
                // load the start module
-               if (top.startInModule && top.startInModule[0] && jQuery('#' + top.startInModule[0]).length > 0) {
+               if (top.startInModule && top.startInModule[0] && TYPO3.jQuery('#' + top.startInModule[0]).length > 0) {
                        me.showModule(top.startInModule[0]);
                } else {
                        // fetch first module
-                       me.showModule(jQuery('.typo3-module-menu-item:first').attr('id'));
+                       me.showModule(TYPO3.jQuery('.typo3-module-menu-item:first').attr('id'));
                }
 
                // check if there are collapsed items in the local storage
                var collapsedMainMenuItems = this.getCollapsedMainMenuItems();
-               jQuery.each(collapsedMainMenuItems, function(key, itm) {
-                       var $group = jQuery('#' + key);
+               TYPO3.jQuery.each(collapsedMainMenuItems, function(key, itm) {
+                       var $group = TYPO3.jQuery('#' + key);
                        if ($group.length > 0) {
                                var $groupContainer = $group.find('.typo3-module-menu-group-container');
                                $group.addClass('collapsed').removeClass('expanded');
@@ -54,8 +54,8 @@ TYPO3.ModuleMenu.App = {
 
        initializeEvents: function() {
                var me = this;
-               jQuery(document).on('click', '.typo3-module-menu-group .typo3-module-menu-group-header', function() {
-                       var $group = jQuery(this).parent('.typo3-module-menu-group');
+               TYPO3.jQuery(document).on('click', '.typo3-module-menu-group .typo3-module-menu-group-header', function() {
+                       var $group = TYPO3.jQuery(this).parent('.typo3-module-menu-group');
                        var $groupContainer = $group.find('.typo3-module-menu-group-container');
                        if ($group.hasClass('expanded')) {
                                me.addCollapsedMainMenuItem($group.attr('id'));
@@ -68,15 +68,15 @@ TYPO3.ModuleMenu.App = {
                        }
                });
                // register clicking on sub modules
-               jQuery(document).on('click', '.typo3-module-menu-item,.t3-menuitem-submodule', function(evt) {
+               TYPO3.jQuery(document).on('click', '.typo3-module-menu-item,.t3-menuitem-submodule', function(evt) {
                        evt.preventDefault();
-                       me.showModule(jQuery(this).attr('id'));
+                       me.showModule(TYPO3.jQuery(this).attr('id'));
                });
        },
 
        /* fetch the data for a submodule */
        getRecordFromName: function(name) {
-               var $subModuleElement = jQuery('#' + name);
+               var $subModuleElement = TYPO3.jQuery('#' + name);
                return {
                        name: name,
                        navigationComponentId: $subModuleElement.data('navigationcomponentid'),
@@ -186,8 +186,8 @@ TYPO3.ModuleMenu.App = {
        },
 
        highlightModuleMenuItem: function(module, mainModule) {
-               jQuery('.typo3-module-menu-item.active').removeClass('active');
-               jQuery('#' + module).addClass('active');
+               TYPO3.jQuery('.typo3-module-menu-item.active').removeClass('active');
+               TYPO3.jQuery('#' + module).addClass('active');
        },
 
        relativeUrl: function(url) {
@@ -196,8 +196,8 @@ TYPO3.ModuleMenu.App = {
 
                // refresh the HTML by fetching the menu again
        refreshMenu: function() {
-               jQuery.ajax(TYPO3.settings.ajaxUrls['ModuleMenu::reload']).done(function(result) {
-                       jQuery('#typo3-menu').replaceWith(result.menu);
+               TYPO3.jQuery.ajax(TYPO3.settings.ajaxUrls['ModuleMenu::reload']).done(function(result) {
+                       TYPO3.jQuery('#typo3-menu').replaceWith(result.menu);
                        if (top.currentModuleLoaded) {
                                TYPO3.ModuleMenu.App.highlightModuleMenuItem(top.currentModuleLoaded);
                        }
@@ -238,7 +238,7 @@ TYPO3.ModuleMenu.App = {
        removeCollapseMainMenuItem: function(item) {
                var existingItems = this.getCollapsedMainMenuItems();
                existingItems[item] = null;
-               localStorage.setItem('t3-modulemenu', JSON.stringify(jQuery.existingItems));
+               localStorage.setItem('t3-modulemenu', JSON.stringify(TYPO3.jQuery.existingItems));
        }
 
 };