[BUGFIX] Make reloadFrames() non-static 02/56202/3
authorAndreas Fernandez <a.fernandez@scripting-base.de>
Fri, 16 Mar 2018 07:23:22 +0000 (08:23 +0100)
committerFrank Naegler <frank.naegler@typo3.org>
Fri, 16 Mar 2018 09:24:02 +0000 (10:24 +0100)
This patch makes the reloadFrames() method non-static, as the method is
required in an instance context.

Resolves: #84323
Related: #82597
Releases: master
Change-Id: I3bdcfdc91721bb2c145fd42ae4448b09a72e636e
Reviewed-on: https://review.typo3.org/56202
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Tymoteusz Motylewski <t.motylewski@gmail.com>
Tested-by: Tymoteusz Motylewski <t.motylewski@gmail.com>
Reviewed-by: Frank Naegler <frank.naegler@typo3.org>
Tested-by: Frank Naegler <frank.naegler@typo3.org>
typo3/sysext/backend/Resources/Private/TypeScript/ModuleMenu.ts
typo3/sysext/backend/Resources/Public/JavaScript/ModuleMenu.js

index b69b999..d5ff2f4 100644 (file)
@@ -35,11 +35,6 @@ class ModuleMenu {
   private loadedModule: string = null;
   private loadedNavigationComponentId: string = '';
 
-  public static reloadFrames(): void {
-    Viewport.NavigationContainer.refresh();
-    Viewport.ContentContainer.refresh();
-  }
-
   /**
    * Fetches all module menu elements in the local storage that should be collapsed
    *
@@ -172,7 +167,15 @@ class ModuleMenu {
     });
   }
 
-
+  /**
+   * Reloads the frames
+   *
+   * Hint: This method can't be static (yet), as this must be bound to the ModuleMenu instance.
+   */
+  public reloadFrames(): void {
+    Viewport.NavigationContainer.refresh();
+    Viewport.ContentContainer.refresh();
+  }
 
   /**
    * Event handler called after clicking on the module menu item
@@ -432,14 +435,11 @@ class ModuleMenu {
   }
 }
 
-let moduleMenuApp;
-
 if (!top.TYPO3.ModuleMenu) {
-  moduleMenuApp = top.TYPO3.ModuleMenu = {
+  top.TYPO3.ModuleMenu = {
     App: new ModuleMenu()
   };
-} else {
-  moduleMenuApp = top.TYPO3.ModuleMenu;
 }
+const moduleMenuApp = top.TYPO3.ModuleMenu;
 
 export = moduleMenuApp;
index 2cf61a4..96d0b78 100644 (file)
@@ -10,4 +10,4 @@
  *
  * The TYPO3 project - inspiring people to share!
  */
-define(["require","exports","./Enum/Viewport/ScaffoldIdentifier","jquery","./Storage/Persistent","./Viewport","./Event/ClientRequest","./Event/TriggerRequest"],function(e,n,t,o,a,i,r,d){"use strict";var l=function(){function n(){this.loadedModule=null,this.loadedNavigationComponentId="",this.initialize()}return n.reloadFrames=function(){i.NavigationContainer.refresh(),i.ContentContainer.refresh()},n.getCollapsedMainMenuItems=function(){return a.isset("modulemenu")?JSON.parse(a.get("modulemenu")):{}},n.addCollapsedMainMenuItem=function(e){var t=n.getCollapsedMainMenuItems();t[e]=!0,a.set("modulemenu",JSON.stringify(t))},n.removeCollapseMainMenuItem=function(e){var n=this.getCollapsedMainMenuItems();delete n[e],a.set("modulemenu",JSON.stringify(n))},n.includeId=function(e,n){if(!e.navigationComponentId&&!e.navigationFrameScript)return n;var t="";return t="TYPO3/CMS/Backend/PageTree/PageTreeElement"===e.navigationComponentId?"web":e.name.split("_")[0],top.fsMod.recentIds[t]&&(n="id="+top.fsMod.recentIds[t]+"&"+n),n},n.toggleMenu=function(e){i.NavigationContainer.cleanup();var n=o(t.ScaffoldIdentifierEnum.scaffold),r="scaffold-modulemenu-expanded";void 0===e&&(e=n.hasClass(r)),n.toggleClass(r,!e),e||o(".scaffold").removeClass("scaffold-search-expanded").removeClass("scaffold-toolbar-expanded"),a.set("BackendComponents.States.typo3-module-menu",{collapsed:e}),i.doLayout()},n.getRecordFromName=function(e){var n=o("#"+e);return{name:e,navigationComponentId:n.data("navigationcomponentid"),navigationFrameScript:n.data("navigationframescript"),navigationFrameScriptParam:n.data("navigationframescriptparameters"),link:n.find("a").data("link")}},n.highlightModuleMenuItem=function(e){o(".modulemenu-item.active").removeClass("active"),o("#"+e).addClass("active")},n.prototype.refreshMenu=function(){o.ajax(TYPO3.settings.ajaxUrls.modulemenu).done(function(e){o("#menu").replaceWith(e.menu),top.currentModuleLoaded&&n.highlightModuleMenuItem(top.currentModuleLoaded),i.doLayout()})},n.prototype.showModule=function(e,t,o){t=t||"";var a=n.getRecordFromName(e);return this.loadModuleComponents(a,t,new r("typo3.showModule",o))},n.prototype.initialize=function(){var e=this,t=o.Deferred();if(t.resolve(),top.startInModule&&top.startInModule[0]&&o("#"+top.startInModule[0]).length>0)t=this.showModule(top.startInModule[0],top.startInModule[1]);else{var r=o(".t3js-mainmodule:first");r.attr("id")&&(t=this.showModule(r.attr("id")))}t.then(function(){var t=a.get("BackendComponents.States.typo3-module-menu");t&&t.collapsed&&n.toggleMenu("true"===t.collapsed);var r=n.getCollapsedMainMenuItems();o.each(r,function(e,n){if(!0===n){var t=o("#"+e);if(t.length>0){var a=t.find(".modulemenu-group-container");t.addClass("collapsed").removeClass("expanded"),i.NavigationContainer.cleanup(),a.hide().promise().done(function(){i.doLayout()})}}}),e.initializeEvents()})},n.prototype.initializeEvents=function(){var e=this;o(document).on("click",".modulemenu-group .modulemenu-group-header",function(e){var t=o(e.currentTarget).parent(".modulemenu-group"),a=t.find(".modulemenu-group-container");i.NavigationContainer.cleanup(),t.hasClass("expanded")?(n.addCollapsedMainMenuItem(t.attr("id")),t.addClass("collapsed").removeClass("expanded"),a.stop().slideUp().promise().done(function(){i.doLayout()})):(n.removeCollapseMainMenuItem(t.attr("id")),t.addClass("expanded").removeClass("collapsed"),a.stop().slideDown().promise().done(function(){i.doLayout()}))}),o(document).on("click",".modulemenu-item,.t3-menuitem-submodule",function(n){n.preventDefault(),e.showModule(o(n.currentTarget).attr("id"),"",n)}),o(document).on("click",".t3js-topbar-button-modulemenu",function(e){e.preventDefault(),n.toggleMenu()}),o(document).on("click",".t3js-scaffold-content-overlay",function(e){e.preventDefault(),n.toggleMenu(!0)}),o(document).on("click",".t3js-topbar-button-navigationcomponent",function(e){e.preventDefault(),i.NavigationContainer.toggle()})},n.prototype.loadModuleComponents=function(e,t,a){var r=this,l=e.name,u=i.ContentContainer.beforeSetUrl(a);return u.then(o.proxy(function(){e.navigationComponentId?r.loadNavigationComponent(e.navigationComponentId):e.navigationFrameScript?(i.NavigationContainer.show("typo3-navigationIframe"),r.openInNavFrame(e.navigationFrameScript,e.navigationFrameScriptParam,new d("typo3.loadModuleComponents",a))):i.NavigationContainer.hide(),n.highlightModuleMenuItem(l),r.loadedModule=l,t=n.includeId(e,t),r.openInContentFrame(e.link,t,new d("typo3.loadModuleComponents",a)),top.currentSubScript=e.link,top.currentModuleLoaded=l,i.doLayout()},this)),u},n.prototype.loadNavigationComponent=function(n){var t=this;if(i.NavigationContainer.show(n),n!==this.loadedNavigationComponentId){var a=n.replace(/[/]/g,"_");""!==this.loadedNavigationComponentId&&o("#navigationComponent-"+this.loadedNavigationComponentId.replace(/[/]/g,"_")).hide(),o('.t3js-scaffold-content-navigation [data-component="'+n+'"]').length<1&&o(".t3js-scaffold-content-navigation").append(o("<div />",{class:"scaffold-content-navigation-component","data-component":n,id:"navigationComponent-"+a})),e([n],function(e){e.initialize("#navigationComponent-"+a),i.NavigationContainer.show(n),t.loadedNavigationComponentId=n})}},n.prototype.openInNavFrame=function(e,n,t){var o=e+(n?(-1!==e.indexOf("?")?"&":"?")+n:""),a=i.NavigationContainer.getUrl(),r=i.NavigationContainer.setUrl(e,new d("typo3.openInNavFrame",t));return a!==o&&("resolved"===r.state()?i.NavigationContainer.refresh():r.then(i.NavigationContainer.refresh)),r},n.prototype.openInContentFrame=function(e,n,t){var o;if(top.nextLoadModuleUrl)o=i.ContentContainer.setUrl(top.nextLoadModuleUrl,new d("typo3.openInContentFrame",t)),top.nextLoadModuleUrl="";else{var a=e+(n?(-1!==e.indexOf("?")?"&":"?")+n:"");o=i.ContentContainer.setUrl(a,new d("typo3.openInContentFrame",t))}return o},n}();return top.TYPO3.ModuleMenu?top.TYPO3.ModuleMenu:top.TYPO3.ModuleMenu={App:new l}});
\ No newline at end of file
+define(["require","exports","./Enum/Viewport/ScaffoldIdentifier","jquery","./Storage/Persistent","./Viewport","./Event/ClientRequest","./Event/TriggerRequest"],function(e,n,t,o,a,i,r,d){"use strict";var l=function(){function n(){this.loadedModule=null,this.loadedNavigationComponentId="",this.initialize()}return n.getCollapsedMainMenuItems=function(){return a.isset("modulemenu")?JSON.parse(a.get("modulemenu")):{}},n.addCollapsedMainMenuItem=function(e){var t=n.getCollapsedMainMenuItems();t[e]=!0,a.set("modulemenu",JSON.stringify(t))},n.removeCollapseMainMenuItem=function(e){var n=this.getCollapsedMainMenuItems();delete n[e],a.set("modulemenu",JSON.stringify(n))},n.includeId=function(e,n){if(!e.navigationComponentId&&!e.navigationFrameScript)return n;var t="";return t="TYPO3/CMS/Backend/PageTree/PageTreeElement"===e.navigationComponentId?"web":e.name.split("_")[0],top.fsMod.recentIds[t]&&(n="id="+top.fsMod.recentIds[t]+"&"+n),n},n.toggleMenu=function(e){i.NavigationContainer.cleanup();var n=o(t.ScaffoldIdentifierEnum.scaffold),r="scaffold-modulemenu-expanded";void 0===e&&(e=n.hasClass(r)),n.toggleClass(r,!e),e||o(".scaffold").removeClass("scaffold-search-expanded").removeClass("scaffold-toolbar-expanded"),a.set("BackendComponents.States.typo3-module-menu",{collapsed:e}),i.doLayout()},n.getRecordFromName=function(e){var n=o("#"+e);return{name:e,navigationComponentId:n.data("navigationcomponentid"),navigationFrameScript:n.data("navigationframescript"),navigationFrameScriptParam:n.data("navigationframescriptparameters"),link:n.find("a").data("link")}},n.highlightModuleMenuItem=function(e){o(".modulemenu-item.active").removeClass("active"),o("#"+e).addClass("active")},n.prototype.refreshMenu=function(){o.ajax(TYPO3.settings.ajaxUrls.modulemenu).done(function(e){o("#menu").replaceWith(e.menu),top.currentModuleLoaded&&n.highlightModuleMenuItem(top.currentModuleLoaded),i.doLayout()})},n.prototype.reloadFrames=function(){i.NavigationContainer.refresh(),i.ContentContainer.refresh()},n.prototype.showModule=function(e,t,o){t=t||"";var a=n.getRecordFromName(e);return this.loadModuleComponents(a,t,new r("typo3.showModule",o))},n.prototype.initialize=function(){var e=this,t=o.Deferred();if(t.resolve(),top.startInModule&&top.startInModule[0]&&o("#"+top.startInModule[0]).length>0)t=this.showModule(top.startInModule[0],top.startInModule[1]);else{var r=o(".t3js-mainmodule:first");r.attr("id")&&(t=this.showModule(r.attr("id")))}t.then(function(){var t=a.get("BackendComponents.States.typo3-module-menu");t&&t.collapsed&&n.toggleMenu("true"===t.collapsed);var r=n.getCollapsedMainMenuItems();o.each(r,function(e,n){if(!0===n){var t=o("#"+e);if(t.length>0){var a=t.find(".modulemenu-group-container");t.addClass("collapsed").removeClass("expanded"),i.NavigationContainer.cleanup(),a.hide().promise().done(function(){i.doLayout()})}}}),e.initializeEvents()})},n.prototype.initializeEvents=function(){var e=this;o(document).on("click",".modulemenu-group .modulemenu-group-header",function(e){var t=o(e.currentTarget).parent(".modulemenu-group"),a=t.find(".modulemenu-group-container");i.NavigationContainer.cleanup(),t.hasClass("expanded")?(n.addCollapsedMainMenuItem(t.attr("id")),t.addClass("collapsed").removeClass("expanded"),a.stop().slideUp().promise().done(function(){i.doLayout()})):(n.removeCollapseMainMenuItem(t.attr("id")),t.addClass("expanded").removeClass("collapsed"),a.stop().slideDown().promise().done(function(){i.doLayout()}))}),o(document).on("click",".modulemenu-item,.t3-menuitem-submodule",function(n){n.preventDefault(),e.showModule(o(n.currentTarget).attr("id"),"",n)}),o(document).on("click",".t3js-topbar-button-modulemenu",function(e){e.preventDefault(),n.toggleMenu()}),o(document).on("click",".t3js-scaffold-content-overlay",function(e){e.preventDefault(),n.toggleMenu(!0)}),o(document).on("click",".t3js-topbar-button-navigationcomponent",function(e){e.preventDefault(),i.NavigationContainer.toggle()})},n.prototype.loadModuleComponents=function(e,t,a){var r=this,l=e.name,u=i.ContentContainer.beforeSetUrl(a);return u.then(o.proxy(function(){e.navigationComponentId?r.loadNavigationComponent(e.navigationComponentId):e.navigationFrameScript?(i.NavigationContainer.show("typo3-navigationIframe"),r.openInNavFrame(e.navigationFrameScript,e.navigationFrameScriptParam,new d("typo3.loadModuleComponents",a))):i.NavigationContainer.hide(),n.highlightModuleMenuItem(l),r.loadedModule=l,t=n.includeId(e,t),r.openInContentFrame(e.link,t,new d("typo3.loadModuleComponents",a)),top.currentSubScript=e.link,top.currentModuleLoaded=l,i.doLayout()},this)),u},n.prototype.loadNavigationComponent=function(n){var t=this;if(i.NavigationContainer.show(n),n!==this.loadedNavigationComponentId){var a=n.replace(/[/]/g,"_");""!==this.loadedNavigationComponentId&&o("#navigationComponent-"+this.loadedNavigationComponentId.replace(/[/]/g,"_")).hide(),o('.t3js-scaffold-content-navigation [data-component="'+n+'"]').length<1&&o(".t3js-scaffold-content-navigation").append(o("<div />",{class:"scaffold-content-navigation-component","data-component":n,id:"navigationComponent-"+a})),e([n],function(e){e.initialize("#navigationComponent-"+a),i.NavigationContainer.show(n),t.loadedNavigationComponentId=n})}},n.prototype.openInNavFrame=function(e,n,t){var o=e+(n?(-1!==e.indexOf("?")?"&":"?")+n:""),a=i.NavigationContainer.getUrl(),r=i.NavigationContainer.setUrl(e,new d("typo3.openInNavFrame",t));return a!==o&&("resolved"===r.state()?i.NavigationContainer.refresh():r.then(i.NavigationContainer.refresh)),r},n.prototype.openInContentFrame=function(e,n,t){var o;if(top.nextLoadModuleUrl)o=i.ContentContainer.setUrl(top.nextLoadModuleUrl,new d("typo3.openInContentFrame",t)),top.nextLoadModuleUrl="";else{var a=e+(n?(-1!==e.indexOf("?")?"&":"?")+n:"");o=i.ContentContainer.setUrl(a,new d("typo3.openInContentFrame",t))}return o},n}();return top.TYPO3.ModuleMenu||(top.TYPO3.ModuleMenu={App:new l}),top.TYPO3.ModuleMenu});
\ No newline at end of file