diff --git a/Build/types/TYPO3/index.d.ts b/Build/types/TYPO3/index.d.ts index 65b084e2cd14..8c237bb9e8d8 100644 --- a/Build/types/TYPO3/index.d.ts +++ b/Build/types/TYPO3/index.d.ts @@ -24,6 +24,7 @@ declare namespace TYPO3 { export class FormEngineValidation { public readonly errorClass: string; } + export class FormEngine { public readonly Validation: FormEngineValidation; } @@ -51,12 +52,17 @@ declare module 'TYPO3/CMS/Backend/FormEngine' { interface Window { TYPO3: any; $: any; + startInModule: Array; inline: { delayedImportElement: (objectId: number, table: string, uid: number, type: string) => void }; rawurlencode: Function; list_frame: Window; jump: Function; + currentSubScript: string; + currentModuleLoaded: string; + fsMod: { [key: string]: any }; + nextLoadModuleUrl: string; } /** diff --git a/typo3/sysext/backend/Resources/Private/TypeScript/ContextMenuActions.ts b/typo3/sysext/backend/Resources/Private/TypeScript/ContextMenuActions.ts index caeffc1158c6..de2513c1a455 100644 --- a/typo3/sysext/backend/Resources/Private/TypeScript/ContextMenuActions.ts +++ b/typo3/sysext/backend/Resources/Private/TypeScript/ContextMenuActions.ts @@ -14,6 +14,7 @@ import * as $ from 'jquery'; import InfoWindow = require('./InfoWindow'); import Modal = require('./Modal'); +import ModuleMenu = require('./ModuleMenu'); import Severity = require('./Severity'); import Viewport = require('./Viewport'); @@ -116,7 +117,7 @@ class ContextMenuActions { */ public static openListModule(table: string, uid: number): void { const pageId = table === 'pages' ? uid : $(this).data('page-uid'); - top.TYPO3.ModuleMenu.App.showModule('web_list', 'id=' + pageId); + ModuleMenu.App.showModule('web_list', 'id=' + pageId); } /** diff --git a/typo3/sysext/backend/Resources/Private/TypeScript/ModuleMenu.ts b/typo3/sysext/backend/Resources/Private/TypeScript/ModuleMenu.ts new file mode 100644 index 000000000000..b69b999a9269 --- /dev/null +++ b/typo3/sysext/backend/Resources/Private/TypeScript/ModuleMenu.ts @@ -0,0 +1,445 @@ +/* + * This file is part of the TYPO3 CMS project. + * + * It is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License, either version 2 + * of the License, or any later version. + * + * For the full copyright and license information, please read the + * LICENSE.txt file that was distributed with this source code. + * + * The TYPO3 project - inspiring people to share! + */ + +import {NavigationComponentInterface} from './Viewport/NavigationComponentInterface'; +import {ScaffoldIdentifierEnum} from './Enum/Viewport/ScaffoldIdentifier'; +import * as $ from 'jquery'; +import PersistentStorage = require('./Storage/Persistent'); +import Viewport = require('./Viewport'); +import ClientRequest = require('./Event/ClientRequest'); +import TriggerRequest = require('./Event/TriggerRequest'); +import InteractionRequest = require('./Event/InteractionRequest'); + +interface Module { + name: string; + navigationComponentId: string; + navigationFrameScript: string; + navigationFrameScriptParam: string; + link: string; +} + +/** + * Class to render the module menu and handle the BE navigation + */ +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 + * + * @returns {Object} + */ + private static getCollapsedMainMenuItems(): { [key: string]: boolean } { + if (PersistentStorage.isset('modulemenu')) { + return JSON.parse(PersistentStorage.get('modulemenu')); + } else { + return {}; + } + } + + /** + * Adds a module menu item to the local storage + * + * @param {string} item + */ + private static addCollapsedMainMenuItem(item: string): void { + const existingItems = ModuleMenu.getCollapsedMainMenuItems(); + existingItems[item] = true; + PersistentStorage.set('modulemenu', JSON.stringify(existingItems)); + } + + /** + * Removes a module menu item from the local storage + * + * @param {string} item + */ + private static removeCollapseMainMenuItem(item: string): void { + const existingItems = this.getCollapsedMainMenuItems(); + delete existingItems[item]; + PersistentStorage.set('modulemenu', JSON.stringify(existingItems)); + } + + /** + * Prepends previously saved record id to the url params + * + * @param {Object} moduleData + * @param {string} params query string parameters for module url + * @return {string} + */ + private static includeId(moduleData: Module, params: string): string { + if (!moduleData.navigationComponentId && !moduleData.navigationFrameScript) { + return params; + } + // get id + let section = ''; + if (moduleData.navigationComponentId === 'TYPO3/CMS/Backend/PageTree/PageTreeElement') { + section = 'web'; + } else { + section = moduleData.name.split('_')[0]; + } + if (top.fsMod.recentIds[section]) { + params = 'id=' + top.fsMod.recentIds[section] + '&' + params; + } + + return params; + } + + /** + * @param {boolean} collapse + */ + private static toggleMenu(collapse?: boolean): void { + Viewport.NavigationContainer.cleanup(); + + const $mainContainer = $(ScaffoldIdentifierEnum.scaffold); + const expandedClass = 'scaffold-modulemenu-expanded'; + + if (typeof collapse === 'undefined') { + collapse = $mainContainer.hasClass(expandedClass); + } + $mainContainer.toggleClass(expandedClass, !collapse); + if (!collapse) { + $('.scaffold') + .removeClass('scaffold-search-expanded') + .removeClass('scaffold-toolbar-expanded'); + } + + // Persist collapsed state in the UC of the current user + PersistentStorage.set( + 'BackendComponents.States.typo3-module-menu', + { + collapsed: collapse + } + ); + + Viewport.doLayout(); + } + + /** + * Gets the module properties from module menu markup (data attributes) + * + * @param {string} name + * @returns {Module} + */ + private static getRecordFromName(name: string): Module { + const $subModuleElement = $('#' + name); + return { + name: name, + navigationComponentId: $subModuleElement.data('navigationcomponentid'), + navigationFrameScript: $subModuleElement.data('navigationframescript'), + navigationFrameScriptParam: $subModuleElement.data('navigationframescriptparameters'), + link: $subModuleElement.find('a').data('link') + }; + } + + /** + * @param {string} module + */ + private static highlightModuleMenuItem(module: string): void { + $('.modulemenu-item.active').removeClass('active'); + $('#' + module).addClass('active'); + } + + constructor() { + this.initialize(); + } + + /** + * Refresh the HTML by fetching the menu again + */ + public refreshMenu(): void { + $.ajax(TYPO3.settings.ajaxUrls.modulemenu).done((result: { [key: string]: string }): void => { + $('#menu').replaceWith(result.menu); + if (top.currentModuleLoaded) { + ModuleMenu.highlightModuleMenuItem(top.currentModuleLoaded); + } + Viewport.doLayout(); + }); + } + + + + /** + * Event handler called after clicking on the module menu item + * + * @param {string} name + * @param {string} params + * @param {JQueryEventObject} event + * @returns {JQueryDeferred} + */ + public showModule(name: string, params?: string, event?: JQueryEventObject): JQueryDeferred { + params = params || ''; + const moduleData = ModuleMenu.getRecordFromName(name); + return this.loadModuleComponents( + moduleData, + params, + new ClientRequest('typo3.showModule', event) + ); + } + + private initialize(): void { + const me = this; + let deferred = $.Deferred(); + deferred.resolve(); + + // load the start module + if (top.startInModule && top.startInModule[0] && $('#' + top.startInModule[0]).length > 0) { + deferred = this.showModule( + top.startInModule[0], + top.startInModule[1] + ); + } else { + // fetch first module + const $firstModule = $('.t3js-mainmodule:first'); + if ($firstModule.attr('id')) { + deferred = this.showModule( + $firstModule.attr('id') + ); + } + // else case: the main module has no entries, this is probably a backend + // user with very little access rights, maybe only the logout button and + // a user settings module in topbar. + } + + deferred.then((): void => { + // check if module menu should be collapsed or not + const state = PersistentStorage.get('BackendComponents.States.typo3-module-menu'); + if (state && state.collapsed) { + ModuleMenu.toggleMenu(state.collapsed === 'true'); + } + + // check if there are collapsed items in the users' configuration + const collapsedMainMenuItems = ModuleMenu.getCollapsedMainMenuItems(); + $.each(collapsedMainMenuItems, (key: string, itm: boolean): void => { + if (itm !== true) { + return; + } + + const $group = $('#' + key); + if ($group.length > 0) { + const $groupContainer = $group.find('.modulemenu-group-container'); + $group.addClass('collapsed').removeClass('expanded'); + Viewport.NavigationContainer.cleanup(); + $groupContainer.hide().promise().done((): void => { + Viewport.doLayout(); + }); + } + }); + me.initializeEvents(); + }); + } + + private initializeEvents(): void { + $(document).on('click', '.modulemenu-group .modulemenu-group-header', (e: JQueryEventObject): void => { + const $group = $(e.currentTarget).parent('.modulemenu-group'); + const $groupContainer = $group.find('.modulemenu-group-container'); + + Viewport.NavigationContainer.cleanup(); + if ($group.hasClass('expanded')) { + ModuleMenu.addCollapsedMainMenuItem($group.attr('id')); + $group.addClass('collapsed').removeClass('expanded'); + $groupContainer.stop().slideUp().promise().done((): void => { + Viewport.doLayout(); + }); + } else { + ModuleMenu.removeCollapseMainMenuItem($group.attr('id')); + $group.addClass('expanded').removeClass('collapsed'); + $groupContainer.stop().slideDown().promise().done((): void => { + Viewport.doLayout(); + }); + } + }); + + // register clicking on sub modules + $(document).on('click', '.modulemenu-item,.t3-menuitem-submodule', (evt: JQueryEventObject): void => { + evt.preventDefault(); + this.showModule($(evt.currentTarget).attr('id'), '', evt); + }); + $(document).on('click', '.t3js-topbar-button-modulemenu', (evt: JQueryEventObject): void => { + evt.preventDefault(); + ModuleMenu.toggleMenu(); + } + ); + $(document).on('click', '.t3js-scaffold-content-overlay', (evt: JQueryEventObject): void => { + evt.preventDefault(); + ModuleMenu.toggleMenu(true); + } + ); + $(document).on('click', '.t3js-topbar-button-navigationcomponent', (evt: JQueryEventObject): void => { + evt.preventDefault(); + Viewport.NavigationContainer.toggle(); + }); + } + + /** + * Shows requested module (e.g. list/page) + * + * @param {Object} moduleData + * @param {string} params + * @param {InteractionRequest} [interactionRequest] + * @return {jQuery.Deferred} + */ + private loadModuleComponents( + moduleData: Module, + params: string, + interactionRequest: InteractionRequest + ): JQueryDeferred { + const moduleName = moduleData.name; + + // Allow other components e.g. Formengine to cancel switching between modules + // (e.g. you have unsaved changes in the form) + const deferred = Viewport.ContentContainer.beforeSetUrl(interactionRequest); + deferred.then( + $.proxy( + (): void => { + if (moduleData.navigationComponentId) { + this.loadNavigationComponent(moduleData.navigationComponentId); + } else if (moduleData.navigationFrameScript) { + Viewport.NavigationContainer.show('typo3-navigationIframe'); + this.openInNavFrame( + moduleData.navigationFrameScript, + moduleData.navigationFrameScriptParam, + new TriggerRequest( + 'typo3.loadModuleComponents', + interactionRequest + ) + ); + } else { + Viewport.NavigationContainer.hide(); + } + + ModuleMenu.highlightModuleMenuItem(moduleName); + this.loadedModule = moduleName; + params = ModuleMenu.includeId(moduleData, params); + this.openInContentFrame( + moduleData.link, + params, + new TriggerRequest( + 'typo3.loadModuleComponents', + interactionRequest + ) + ); + + // compatibility + top.currentSubScript = moduleData.link; + top.currentModuleLoaded = moduleName; + + Viewport.doLayout(); + }, + this + ) + ); + + return deferred; + } + + /** + * Renders registered (non-iframe) navigation component e.g. a page tree + * + * @param {string} navigationComponentId + */ + private loadNavigationComponent(navigationComponentId: string): void { + const me = this; + + Viewport.NavigationContainer.show(navigationComponentId); + if (navigationComponentId === this.loadedNavigationComponentId) { + return; + } + const componentCssName = navigationComponentId.replace(/[/]/g, '_'); + if (this.loadedNavigationComponentId !== '') { + $('#navigationComponent-' + this.loadedNavigationComponentId.replace(/[/]/g, '_')).hide(); + } + if ($('.t3js-scaffold-content-navigation [data-component="' + navigationComponentId + '"]').length < 1) { + $('.t3js-scaffold-content-navigation') + .append($('
', { + 'class': 'scaffold-content-navigation-component', + 'data-component': navigationComponentId, + id: 'navigationComponent-' + componentCssName + })); + } + + require([navigationComponentId], (NavigationComponent: NavigationComponentInterface): void => { + NavigationComponent.initialize('#navigationComponent-' + componentCssName); + Viewport.NavigationContainer.show(navigationComponentId); + me.loadedNavigationComponentId = navigationComponentId; + }); + } + + /** + * @param {string} url + * @param {string} params + * @param {InteractionRequest} interactionRequest + * @returns {JQueryDeferred} + */ + private openInNavFrame(url: string, params: string, interactionRequest: InteractionRequest): JQueryDeferred { + const navUrl = url + (params ? (url.indexOf('?') !== -1 ? '&' : '?') + params : ''); + const currentUrl = Viewport.NavigationContainer.getUrl(); + const deferred = Viewport.NavigationContainer.setUrl( + url, + new TriggerRequest('typo3.openInNavFrame', interactionRequest) + ); + if (currentUrl !== navUrl) { + // if deferred is already resolved, execute directly + if (deferred.state() === 'resolved') { + Viewport.NavigationContainer.refresh(); + // otherwise hand in future callback + } else { + deferred.then(Viewport.NavigationContainer.refresh); + } + } + return deferred; + } + + /** + * @param {string} url + * @param {string} params + * @param {InteractionRequest} interactionRequest + * @returns {JQueryDeferred} + */ + private openInContentFrame(url: string, params: string, interactionRequest: InteractionRequest): JQueryDeferred { + let deferred; + + if (top.nextLoadModuleUrl) { + deferred = Viewport.ContentContainer.setUrl( + top.nextLoadModuleUrl, + new TriggerRequest('typo3.openInContentFrame', interactionRequest) + ); + top.nextLoadModuleUrl = ''; + } else { + const urlToLoad = url + (params ? (url.indexOf('?') !== -1 ? '&' : '?') + params : ''); + deferred = Viewport.ContentContainer.setUrl( + urlToLoad, + new TriggerRequest('typo3.openInContentFrame', interactionRequest) + ); + } + + return deferred; + } +} + +let moduleMenuApp; + +if (!top.TYPO3.ModuleMenu) { + moduleMenuApp = top.TYPO3.ModuleMenu = { + App: new ModuleMenu() + }; +} else { + moduleMenuApp = top.TYPO3.ModuleMenu; +} + +export = moduleMenuApp; diff --git a/typo3/sysext/backend/Resources/Private/TypeScript/Storage/Persistent.ts b/typo3/sysext/backend/Resources/Private/TypeScript/Storage/Persistent.ts index d66a9a3b1ecf..f783e08e5022 100644 --- a/typo3/sysext/backend/Resources/Private/TypeScript/Storage/Persistent.ts +++ b/typo3/sysext/backend/Resources/Private/TypeScript/Storage/Persistent.ts @@ -49,7 +49,7 @@ class Persistent { * @param {String} value * @returns {$} */ - public set = (key: string, value: string): any => { + public set = (key: string, value: string|object): any => { if (this.data !== false) { this.data = this.setRecursiveDataByDeepKey(this.data, key.split('.'), value); } @@ -164,7 +164,7 @@ class Persistent { * @param {string} value * @returns {*} */ - private storeOnServer = (key: string, value: string): any => { + private storeOnServer = (key: string, value: string|object): any => { const me = this; return $.ajax(TYPO3.settings.ajaxUrls.usersettings_process, { data: { @@ -205,7 +205,7 @@ class Persistent { * @param {string} value * @returns {any[]} */ - private setRecursiveDataByDeepKey = (data: any, keyParts: any[], value: string): any[] => { + private setRecursiveDataByDeepKey = (data: any, keyParts: any[], value: string|object): any[] => { if (keyParts.length === 1) { data = data || {}; data[keyParts[0]] = value; diff --git a/typo3/sysext/backend/Resources/Private/TypeScript/Toolbar.ts b/typo3/sysext/backend/Resources/Private/TypeScript/Toolbar.ts index ddcaa6af828b..7d30180fbcfe 100644 --- a/typo3/sysext/backend/Resources/Private/TypeScript/Toolbar.ts +++ b/typo3/sysext/backend/Resources/Private/TypeScript/Toolbar.ts @@ -12,6 +12,7 @@ */ import * as $ from 'jquery'; +import ModuleMenu = require('./ModuleMenu'); /** * Module: TYPO3/CMS/Backend/Toolbar @@ -31,10 +32,8 @@ class Toolbar { }); $(document).on('click', '.toolbar-item [data-modulename]', (evt: JQueryEventObject): void => { evt.preventDefault(); - require(['TYPO3/CMS/Backend/ModuleMenu'], (): void => { - const moduleName = $(evt.target).closest('[data-modulename]').data('modulename'); - TYPO3.ModuleMenu.App.showModule(moduleName); - }); + const moduleName = $(evt.target).closest('[data-modulename]').data('modulename'); + ModuleMenu.App.showModule(moduleName); }); $(document).on('click', '.t3js-topbar-button-toolbar', (): void => { $('.scaffold') diff --git a/typo3/sysext/backend/Resources/Private/TypeScript/Viewport/NavigationComponentInterface.ts b/typo3/sysext/backend/Resources/Private/TypeScript/Viewport/NavigationComponentInterface.ts index 278214135fe5..6114911a3f05 100644 --- a/typo3/sysext/backend/Resources/Private/TypeScript/Viewport/NavigationComponentInterface.ts +++ b/typo3/sysext/backend/Resources/Private/TypeScript/Viewport/NavigationComponentInterface.ts @@ -17,6 +17,7 @@ interface SetTemporaryMountPoint { } export interface NavigationComponentInterface { + initialize: Function; refreshTree: Function; setTemporaryMountPoint: SetTemporaryMountPoint; unsetTemporaryMountPoint: Function; diff --git a/typo3/sysext/backend/Resources/Public/JavaScript/ContextMenuActions.js b/typo3/sysext/backend/Resources/Public/JavaScript/ContextMenuActions.js index 4767995e0413..309a96ab46ab 100644 --- a/typo3/sysext/backend/Resources/Public/JavaScript/ContextMenuActions.js +++ b/typo3/sysext/backend/Resources/Public/JavaScript/ContextMenuActions.js @@ -10,4 +10,4 @@ * * The TYPO3 project - inspiring people to share! */ -define(["require","exports","jquery","./InfoWindow","./Modal","./Severity","./Viewport"],function(t,e,n,o,r,a,i){"use strict";return function(){function t(){}return t.getReturnUrl=function(){return top.rawurlencode(top.list_frame.document.location.pathname+top.list_frame.document.location.search)},t.editRecord=function(e,n){i.ContentContainer.setUrl(top.TYPO3.settings.FormEngine.moduleUrl+"&edit["+e+"]["+n+"]=edit&returnUrl="+t.getReturnUrl())},t.viewRecord=function(t,e){var o=n(this).data("preview-url");o&&window.open(o,"newTYPO3frontendWindow").focus()},t.openInfoPopUp=function(t,e){o.showItem(t,e)},t.mountAsTreeRoot=function(t,e){"pages"===t&&i.NavigationContainer.PageTree.setTemporaryMountPoint(e)},t.newPageWizard=function(e,n){i.ContentContainer.setUrl(top.TYPO3.settings.NewRecord.moduleUrl+"&id="+n+"&pagesOnly=1&returnUrl="+t.getReturnUrl())},t.newContentWizard=function(e,o){var r=n(this).data("new-wizard-url");r&&(r+="&returnUrl="+t.getReturnUrl(),i.ContentContainer.setUrl(r))},t.newRecord=function(e,n){i.ContentContainer.setUrl(top.TYPO3.settings.FormEngine.moduleUrl+"&edit["+e+"][-"+n+"]=new&returnUrl="+t.getReturnUrl())},t.openHistoryPopUp=function(e,n){i.ContentContainer.setUrl(top.TYPO3.settings.RecordHistory.moduleUrl+"&element="+e+":"+n+"&returnUrl="+t.getReturnUrl())},t.openListModule=function(t,e){var o="pages"===t?e:n(this).data("page-uid");top.TYPO3.ModuleMenu.App.showModule("web_list","id="+o)},t.pagesSort=function(t,e){var o=n(this).data("pages-sort-url");o&&i.ContentContainer.setUrl(o)},t.pagesNewMultiple=function(t,e){var o=n(this).data("pages-new-multiple-url");o&&i.ContentContainer.setUrl(o)},t.disableRecord=function(e,n){i.ContentContainer.setUrl(top.TYPO3.settings.RecordCommit.moduleUrl+"&data["+e+"]["+n+"][hidden]=1&redirect="+t.getReturnUrl()).done(function(){i.NavigationContainer.PageTree.refreshTree()})},t.enableRecord=function(e,n){i.ContentContainer.setUrl(top.TYPO3.settings.RecordCommit.moduleUrl+"&data["+e+"]["+n+"][hidden]=0&redirect="+t.getReturnUrl()).done(function(){i.NavigationContainer.PageTree.refreshTree()})},t.deleteRecord=function(e,o){var l=n(this);r.confirm(l.data("title"),l.data("message"),a.warning,[{text:n(this).data("button-close-text")||TYPO3.lang["button.cancel"]||"Cancel",active:!0,btnClass:"btn-default",name:"cancel"},{text:n(this).data("button-ok-text")||TYPO3.lang["button.delete"]||"Delete",btnClass:"btn-warning",name:"delete"}]).on("button.clicked",function(n){"delete"===n.target.getAttribute("name")&&i.ContentContainer.setUrl(top.TYPO3.settings.RecordCommit.moduleUrl+"&redirect="+t.getReturnUrl()+"&cmd["+e+"]["+o+"][delete]=1").done(function(){"pages"===e&&i.NavigationContainer.PageTree&&i.NavigationContainer.PageTree.refreshTree()}),r.dismiss()})},t.copy=function(e,o){var r=TYPO3.settings.ajaxUrls.contextmenu_clipboard+"&CB[el]["+e+"%7C"+o+"]=1&CB[setCopyMode]=1";n.ajax(r).always(function(){t.triggerRefresh(i.ContentContainer.get().location.href)})},t.clipboardRelease=function(e,o){var r=TYPO3.settings.ajaxUrls.contextmenu_clipboard+"&CB[el]["+e+"%7C"+o+"]=0";n.ajax(r).always(function(){t.triggerRefresh(i.ContentContainer.get().location.href)})},t.cut=function(e,o){var r=TYPO3.settings.ajaxUrls.contextmenu_clipboard+"&CB[el]["+e+"%7C"+o+"]=1&CB[setCopyMode]=0";n.ajax(r).always(function(){t.triggerRefresh(i.ContentContainer.get().location.href)})},t.triggerRefresh=function(t){-1===t.indexOf("record%2Fedit")&&i.ContentContainer.refresh(!0)},t.clearCache=function(t,e){var o=top.TYPO3.settings.WebLayout.moduleUrl+"&id="+e+"&clear_cache=1";n.ajax(o)},t.pasteAfter=function(e,o){t.pasteInto.bind(n(this))(e,-o)},t.pasteInto=function(e,o){var l=n(this),s=function(){var n="&CB[paste]="+e+"%7C"+o+"&CB[pad]=normal&redirect="+t.getReturnUrl();i.ContentContainer.setUrl(top.TYPO3.settings.RecordCommit.moduleUrl+n).done(function(){"pages"===e&&i.NavigationContainer.PageTree&&i.NavigationContainer.PageTree.refreshTree()})};l.data("title")?r.confirm(l.data("title"),l.data("message"),a.warning,[{text:n(this).data("button-close-text")||TYPO3.lang["button.cancel"]||"Cancel",active:!0,btnClass:"btn-default",name:"cancel"},{text:n(this).data("button-ok-text")||TYPO3.lang["button.ok"]||"OK",btnClass:"btn-warning",name:"ok"}]).on("button.clicked",function(t){"ok"===t.target.getAttribute("name")&&s(),r.dismiss()}):s()},t}()}); \ No newline at end of file +define(["require","exports","jquery","./InfoWindow","./Modal","./ModuleMenu","./Severity","./Viewport"],function(e,t,n,o,r,a,i,l){"use strict";return function(){function e(){}return e.getReturnUrl=function(){return top.rawurlencode(top.list_frame.document.location.pathname+top.list_frame.document.location.search)},e.editRecord=function(t,n){l.ContentContainer.setUrl(top.TYPO3.settings.FormEngine.moduleUrl+"&edit["+t+"]["+n+"]=edit&returnUrl="+e.getReturnUrl())},e.viewRecord=function(e,t){var o=n(this).data("preview-url");o&&window.open(o,"newTYPO3frontendWindow").focus()},e.openInfoPopUp=function(e,t){o.showItem(e,t)},e.mountAsTreeRoot=function(e,t){"pages"===e&&l.NavigationContainer.PageTree.setTemporaryMountPoint(t)},e.newPageWizard=function(t,n){l.ContentContainer.setUrl(top.TYPO3.settings.NewRecord.moduleUrl+"&id="+n+"&pagesOnly=1&returnUrl="+e.getReturnUrl())},e.newContentWizard=function(t,o){var r=n(this).data("new-wizard-url");r&&(r+="&returnUrl="+e.getReturnUrl(),l.ContentContainer.setUrl(r))},e.newRecord=function(t,n){l.ContentContainer.setUrl(top.TYPO3.settings.FormEngine.moduleUrl+"&edit["+t+"][-"+n+"]=new&returnUrl="+e.getReturnUrl())},e.openHistoryPopUp=function(t,n){l.ContentContainer.setUrl(top.TYPO3.settings.RecordHistory.moduleUrl+"&element="+t+":"+n+"&returnUrl="+e.getReturnUrl())},e.openListModule=function(e,t){var o="pages"===e?t:n(this).data("page-uid");a.App.showModule("web_list","id="+o)},e.pagesSort=function(e,t){var o=n(this).data("pages-sort-url");o&&l.ContentContainer.setUrl(o)},e.pagesNewMultiple=function(e,t){var o=n(this).data("pages-new-multiple-url");o&&l.ContentContainer.setUrl(o)},e.disableRecord=function(t,n){l.ContentContainer.setUrl(top.TYPO3.settings.RecordCommit.moduleUrl+"&data["+t+"]["+n+"][hidden]=1&redirect="+e.getReturnUrl()).done(function(){l.NavigationContainer.PageTree.refreshTree()})},e.enableRecord=function(t,n){l.ContentContainer.setUrl(top.TYPO3.settings.RecordCommit.moduleUrl+"&data["+t+"]["+n+"][hidden]=0&redirect="+e.getReturnUrl()).done(function(){l.NavigationContainer.PageTree.refreshTree()})},e.deleteRecord=function(t,o){var a=n(this);r.confirm(a.data("title"),a.data("message"),i.warning,[{text:n(this).data("button-close-text")||TYPO3.lang["button.cancel"]||"Cancel",active:!0,btnClass:"btn-default",name:"cancel"},{text:n(this).data("button-ok-text")||TYPO3.lang["button.delete"]||"Delete",btnClass:"btn-warning",name:"delete"}]).on("button.clicked",function(n){"delete"===n.target.getAttribute("name")&&l.ContentContainer.setUrl(top.TYPO3.settings.RecordCommit.moduleUrl+"&redirect="+e.getReturnUrl()+"&cmd["+t+"]["+o+"][delete]=1").done(function(){"pages"===t&&l.NavigationContainer.PageTree&&l.NavigationContainer.PageTree.refreshTree()}),r.dismiss()})},e.copy=function(t,o){var r=TYPO3.settings.ajaxUrls.contextmenu_clipboard+"&CB[el]["+t+"%7C"+o+"]=1&CB[setCopyMode]=1";n.ajax(r).always(function(){e.triggerRefresh(l.ContentContainer.get().location.href)})},e.clipboardRelease=function(t,o){var r=TYPO3.settings.ajaxUrls.contextmenu_clipboard+"&CB[el]["+t+"%7C"+o+"]=0";n.ajax(r).always(function(){e.triggerRefresh(l.ContentContainer.get().location.href)})},e.cut=function(t,o){var r=TYPO3.settings.ajaxUrls.contextmenu_clipboard+"&CB[el]["+t+"%7C"+o+"]=1&CB[setCopyMode]=0";n.ajax(r).always(function(){e.triggerRefresh(l.ContentContainer.get().location.href)})},e.triggerRefresh=function(e){-1===e.indexOf("record%2Fedit")&&l.ContentContainer.refresh(!0)},e.clearCache=function(e,t){var o=top.TYPO3.settings.WebLayout.moduleUrl+"&id="+t+"&clear_cache=1";n.ajax(o)},e.pasteAfter=function(t,o){e.pasteInto.bind(n(this))(t,-o)},e.pasteInto=function(t,o){var a=n(this),s=function(){var n="&CB[paste]="+t+"%7C"+o+"&CB[pad]=normal&redirect="+e.getReturnUrl();l.ContentContainer.setUrl(top.TYPO3.settings.RecordCommit.moduleUrl+n).done(function(){"pages"===t&&l.NavigationContainer.PageTree&&l.NavigationContainer.PageTree.refreshTree()})};a.data("title")?r.confirm(a.data("title"),a.data("message"),i.warning,[{text:n(this).data("button-close-text")||TYPO3.lang["button.cancel"]||"Cancel",active:!0,btnClass:"btn-default",name:"cancel"},{text:n(this).data("button-ok-text")||TYPO3.lang["button.ok"]||"OK",btnClass:"btn-warning",name:"ok"}]).on("button.clicked",function(e){"ok"===e.target.getAttribute("name")&&s(),r.dismiss()}):s()},e}()}); \ No newline at end of file diff --git a/typo3/sysext/backend/Resources/Public/JavaScript/ModuleMenu.js b/typo3/sysext/backend/Resources/Public/JavaScript/ModuleMenu.js index 94e94a2f369c..2cf61a499715 100644 --- a/typo3/sysext/backend/Resources/Public/JavaScript/ModuleMenu.js +++ b/typo3/sysext/backend/Resources/Public/JavaScript/ModuleMenu.js @@ -10,419 +10,4 @@ * * The TYPO3 project - inspiring people to share! */ - - -/** - * Class to render the module menu and handle the BE navigation - */ -require( - [ - 'jquery', - 'TYPO3/CMS/Backend/Storage/Persistent', - 'TYPO3/CMS/Backend/Icons', - 'TYPO3/CMS/Backend/Viewport', - 'TYPO3/CMS/Backend/Event/ClientRequest', - 'TYPO3/CMS/Backend/Event/TriggerRequest' - ], - function($, PersistentStorage, Icons, Viewport, ClientRequest, TriggerRequest) { - if (typeof TYPO3.ModuleMenu !== 'undefined') { - return TYPO3.ModuleMenu.App; - } - - TYPO3.ModuleMenu = {}; - TYPO3.ModuleMenu.App = { - loadedModule: null, - loadedNavigationComponentId: '', - - initialize: function() { - var me = this; - - var deferred = $.Deferred(); - deferred.resolve(); - - // load the start module - if (top.startInModule && top.startInModule[0] && $('#' + top.startInModule[0]).length > 0) { - deferred = me.showModule( - top.startInModule[0], - top.startInModule[1] - ); - } else { - // fetch first module - if ($('.t3js-mainmodule:first').attr('id')) { - deferred = me.showModule( - $('.t3js-mainmodule:first').attr('id') - ); - } - // else case: the main module has no entries, this is probably a backend - // user with very little access rights, maybe only the logout button and - // a user settings module in topbar. - } - - deferred.then(function() { - // check if module menu should be collapsed or not - var state = PersistentStorage.get('BackendComponents.States.typo3-module-menu'); - if (state && state.collapsed) { - TYPO3.ModuleMenu.App.toggleMenu(state.collapsed === 'true'); - } - - // check if there are collapsed items in the users' configuration - var collapsedMainMenuItems = me.getCollapsedMainMenuItems(); - $.each(collapsedMainMenuItems, function(key, itm) { - if (itm !== true) { - return; - } - var $group = $('#' + key); - if ($group.length > 0) { - var $groupContainer = $group.find('.modulemenu-group-container'); - $group.addClass('collapsed').removeClass('expanded'); - TYPO3.Backend.NavigationContainer.cleanup(); - $groupContainer.hide().promise().done(function() { - TYPO3.Backend.doLayout(); - }); - } - }); - me.initializeEvents(); - }); - }, - - initializeEvents: function() { - var me = this; - $(document).on('click', '.modulemenu-group .modulemenu-group-header', function() { - var $group = $(this).parent('.modulemenu-group'); - var $groupContainer = $group.find('.modulemenu-group-container'); - - TYPO3.Backend.NavigationContainer.cleanup(); - if ($group.hasClass('expanded')) { - me.addCollapsedMainMenuItem($group.attr('id')); - $group.addClass('collapsed').removeClass('expanded'); - $groupContainer.stop().slideUp().promise().done(function() { - TYPO3.Backend.doLayout(); - }); - } else { - me.removeCollapseMainMenuItem($group.attr('id')); - $group.addClass('expanded').removeClass('collapsed'); - $groupContainer.stop().slideDown().promise().done(function() { - TYPO3.Backend.doLayout(); - }); - } - - }); - // register clicking on sub modules - $(document).on('click', '.modulemenu-item,.t3-menuitem-submodule', function(evt) { - evt.preventDefault(); - me.showModule( - $(this).attr('id'), - '', - evt - ); - }); - $(document).on('click', '.t3js-topbar-button-modulemenu', - function(evt) { - evt.preventDefault(); - TYPO3.ModuleMenu.App.toggleMenu(); - } - ); - $(document).on('click', '.t3js-scaffold-content-overlay', - function(evt) { - evt.preventDefault(); - TYPO3.ModuleMenu.App.toggleMenu(true); - } - ); - $(document).on('click', '.t3js-topbar-button-navigationcomponent', - function(evt) { - evt.preventDefault(); - TYPO3.Backend.NavigationContainer.toggle(); - } - ); - }, - - /** - * @param {Boolean} collapse - */ - toggleMenu: function(collapse) { - TYPO3.Backend.NavigationContainer.cleanup(); - - var $mainContainer = $('.t3js-scaffold'); - var expandedClass = 'scaffold-modulemenu-expanded'; - - if (typeof collapse === 'undefined') { - collapse = $mainContainer.hasClass(expandedClass); - } - $mainContainer.toggleClass(expandedClass, !collapse); - if (!collapse) { - $('.scaffold') - .removeClass('scaffold-search-expanded') - .removeClass('scaffold-toolbar-expanded'); - } - - // Persist collapsed state in the UC of the current user - PersistentStorage.set( - 'BackendComponents.States.typo3-module-menu', - { - collapsed: collapse - } - ); - - TYPO3.Backend.doLayout(); - }, - - /** - * Gets the module properties from module menu markup (data attributes) - * - * @param {string} name module name e.g. web_list - * @return {Object} - */ - getRecordFromName: function(name) { - var $subModuleElement = $('#' + name); - return { - name: name, - navigationComponentId: $subModuleElement.data('navigationcomponentid'), - navigationFrameScript: $subModuleElement.data('navigationframescript'), - navigationFrameScriptParam: $subModuleElement.data('navigationframescriptparameters'), - link: $subModuleElement.find('a').data('link') - }; - }, - - /** - * Event handler called after clicking on the module menu item - * - * @param {string} name module name e.g. web_layout - * @param {string} params - * @param {Event} [event] - * @return {jQuery.Deferred} - */ - showModule: function(name, params, event) { - params = params || ''; - var moduleData = this.getRecordFromName(name); - return this.loadModuleComponents( - moduleData, - params, - new ClientRequest('typo3.showModule', event) - ); - }, - - ensurePageInTreeSelected: function() { - if (this.loadedNavigationComponentId === 'TYPO3/CMS/Backend/PageTree/PageTreeElement' - && this.availableNavigationComponents['TYPO3/CMS/Backend/PageTree/PageTreeElement'].isInitialized() - ) { - this.availableNavigationComponents['TYPO3/CMS/Backend/PageTree/PageTreeElement'].selectRequestedPageId(); - } - }, - - /** - * Shows requested module (e.g. list/page) - * - * @param {Object} moduleData - * @param {string} params - * @param {InteractionRequest} [interactionRequest] - * @return {jQuery.Deferred} - */ - loadModuleComponents: function(moduleData, params, interactionRequest) { - var moduleName = moduleData.name; - - // Allow other components e.g. Formengine to cancel switching between modules - // (e.g. you have unsaved changes in the form) - var deferred = TYPO3.Backend.ContentContainer.beforeSetUrl(interactionRequest); - deferred.then( - $.proxy(function() { - if (moduleData.navigationComponentId) { - this.loadNavigationComponent(moduleData.navigationComponentId); - } else if (moduleData.navigationFrameScript) { - TYPO3.Backend.NavigationContainer.show('typo3-navigationIframe'); - this.openInNavFrame( - moduleData.navigationFrameScript, - moduleData.navigationFrameScriptParam, - new TriggerRequest( - 'typo3.loadModuleComponents', - interactionRequest - ) - ); - } else { - TYPO3.Backend.NavigationContainer.hide(); - } - - this.highlightModuleMenuItem(moduleName); - this.loadedModule = moduleName; - params = this.includeId(moduleData, params); - this.openInContentFrame( - moduleData.link, - params, - new TriggerRequest( - 'typo3.loadModuleComponents', - interactionRequest - ) - ); - - // compatibility - top.currentSubScript = moduleData.link; - top.currentModuleLoaded = moduleName; - - TYPO3.Backend.doLayout(); - this.ensurePageInTreeSelected(); - }, this - )); - - return deferred; - }, - - /** - * Prepends previously saved record id to the url params - * - * @param {Object} moduleData - * @param {string} params query string parameters for module url - * @return {string} - */ - includeId: function(moduleData, params) { - if (!moduleData.navigationComponentId && !moduleData.navigationFrameScript) { - return params; - } - //get id - var section = ''; - if (moduleData.navigationComponentId === 'TYPO3/CMS/Backend/PageTree/PageTreeElement') { - section = 'web'; - } else { - section = moduleData.name.split('_')[0]; - } - if (top.fsMod.recentIds[section]) { - params = 'id=' + top.fsMod.recentIds[section] + '&' + params; - } - - return params; - }, - - /** - * Renders registered (non-iframe) navigation component e.g. a page tree - * - * @param {string} navigationComponentId - */ - loadNavigationComponent: function(navigationComponentId) { - TYPO3.Backend.NavigationContainer.show(navigationComponentId); - if (navigationComponentId === this.loadedNavigationComponentId) { - return; - } - var componentCssName = navigationComponentId.replace(/[/]/g, '_'); - if (this.loadedNavigationComponentId !== '') { - $('#navigationComponent-' + this.loadedNavigationComponentId.replace(/[/]/g, '_')).hide(); - } - if ($('.t3js-scaffold-content-navigation [data-component="' + navigationComponentId + '"]').length < 1) { - $('.t3js-scaffold-content-navigation') - .append(''); - } - - require([navigationComponentId], function(NavigationComponent) { - NavigationComponent.initialize('#navigationComponent-' + componentCssName); - TYPO3.Backend.NavigationContainer.show(navigationComponentId); - self.loadedNavigationComponentId = navigationComponentId; - }); - }, - - /** - * @param {string} url - * @param {string} params - * @param {InteractionRequest} [interactionRequest] - * @return {jQuery.Deferred} - */ - openInNavFrame: function(url, params, interactionRequest) { - var navUrl = url + (params ? (url.indexOf('?') !== -1 ? '&' : '?') + params : ''); - var currentUrl = TYPO3.Backend.NavigationContainer.getUrl(); - var deferred = TYPO3.Backend.NavigationContainer.setUrl( - url, - new TriggerRequest('typo3.openInNavFrame', interactionRequest) - ); - if (currentUrl !== navUrl) { - // if deferred is already resolved, execute directly - if (deferred.state() === 'resolved') { - TYPO3.Backend.NavigationContainer.refresh(); - // otherwise hand in future callback - } else { - deferred.then(TYPO3.Backend.NavigationContainer.refresh); - } - } - return deferred; - }, - - /** - * @param {string} url - * @param {string} params - * @param {InteractionRequest} [interactionRequest] - * @return {jQuery.Deferred} - */ - openInContentFrame: function(url, params, interactionRequest) { - var deferred; - - if (top.nextLoadModuleUrl) { - deferred = TYPO3.Backend.ContentContainer.setUrl( - top.nextLoadModuleUrl, - new TriggerRequest('typo3.openInContentFrame', interactionRequest) - ); - top.nextLoadModuleUrl = ''; - } else { - var urlToLoad = url + (params ? (url.indexOf('?') !== -1 ? '&' : '?') + params : ''); - deferred = TYPO3.Backend.ContentContainer.setUrl( - urlToLoad, - new TriggerRequest('typo3.openInContentFrame', interactionRequest) - ); - } - - return deferred; - }, - - highlightModuleMenuItem: function(module, mainModule) { - $('.modulemenu-item.active').removeClass('active'); - $('#' + module).addClass('active'); - }, - - // refresh the HTML by fetching the menu again - refreshMenu: function() { - $.ajax(TYPO3.settings.ajaxUrls['modulemenu']).done(function(result) { - $('#menu').replaceWith(result.menu); - if (top.currentModuleLoaded) { - TYPO3.ModuleMenu.App.highlightModuleMenuItem(top.currentModuleLoaded); - } - TYPO3.Backend.doLayout(); - }); - }, - - reloadFrames: function() { - TYPO3.Backend.NavigationContainer.refresh(); - TYPO3.Backend.ContentContainer.refresh(); - }, - - /** - * fetches all module menu elements in the local storage that should be collapsed - * @returns {*} - */ - getCollapsedMainMenuItems: function() { - if (PersistentStorage.isset('modulemenu')) { - return JSON.parse(PersistentStorage.get('modulemenu')); - } else { - return {}; - } - }, - - /** - * adds a module menu item to the local storage - * @param item - */ - addCollapsedMainMenuItem: function(item) { - var existingItems = this.getCollapsedMainMenuItems(); - existingItems[item] = true; - PersistentStorage.set('modulemenu', JSON.stringify(existingItems)); - }, - - /** - * removes a module menu item from the local storage - * @param item - */ - removeCollapseMainMenuItem: function(item) { - var existingItems = this.getCollapsedMainMenuItems(); - delete existingItems[item]; - PersistentStorage.set('modulemenu', JSON.stringify(existingItems)); - } - - }; - // start the module menu app - TYPO3.ModuleMenu.App.initialize(); - return TYPO3.ModuleMenu; - } -); +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("
",{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 diff --git a/typo3/sysext/backend/Resources/Public/JavaScript/Toolbar.js b/typo3/sysext/backend/Resources/Public/JavaScript/Toolbar.js index 1ff9c06541e1..f8941f263d9d 100644 --- a/typo3/sysext/backend/Resources/Public/JavaScript/Toolbar.js +++ b/typo3/sysext/backend/Resources/Public/JavaScript/Toolbar.js @@ -10,4 +10,4 @@ * * The TYPO3 project - inspiring people to share! */ -define(["require","exports","jquery"],function(e,o,n){"use strict";Object.defineProperty(o,"__esModule",{value:!0});var a=function(){function o(){}return o.initialize=function(){o.initializeEvents()},o.initializeEvents=function(){n(".t3js-toolbar-item").parent().on("hidden.bs.dropdown",function(){n(".scaffold").removeClass("scaffold-toolbar-expanded").removeClass("scaffold-search-expanded")}),n(document).on("click",".toolbar-item [data-modulename]",function(o){o.preventDefault(),e(["TYPO3/CMS/Backend/ModuleMenu"],function(){var e=n(o.target).closest("[data-modulename]").data("modulename");TYPO3.ModuleMenu.App.showModule(e)})}),n(document).on("click",".t3js-topbar-button-toolbar",function(){n(".scaffold").removeClass("scaffold-modulemenu-expanded").removeClass("scaffold-search-expanded").toggleClass("scaffold-toolbar-expanded")}),n(document).on("click",".t3js-topbar-button-search",function(){n(".scaffold").removeClass("scaffold-modulemenu-expanded").removeClass("scaffold-toolbar-expanded").toggleClass("scaffold-search-expanded")})},o}();n(function(){a.initialize()})}); \ No newline at end of file +define(["require","exports","jquery","./ModuleMenu"],function(e,o,a,n){"use strict";Object.defineProperty(o,"__esModule",{value:!0});var t=function(){function e(){}return e.initialize=function(){e.initializeEvents()},e.initializeEvents=function(){a(".t3js-toolbar-item").parent().on("hidden.bs.dropdown",function(){a(".scaffold").removeClass("scaffold-toolbar-expanded").removeClass("scaffold-search-expanded")}),a(document).on("click",".toolbar-item [data-modulename]",function(e){e.preventDefault();var o=a(e.target).closest("[data-modulename]").data("modulename");n.App.showModule(o)}),a(document).on("click",".t3js-topbar-button-toolbar",function(){a(".scaffold").removeClass("scaffold-modulemenu-expanded").removeClass("scaffold-search-expanded").toggleClass("scaffold-toolbar-expanded")}),a(document).on("click",".t3js-topbar-button-search",function(){a(".scaffold").removeClass("scaffold-modulemenu-expanded").removeClass("scaffold-toolbar-expanded").toggleClass("scaffold-search-expanded")})},e}();a(function(){t.initialize()})}); \ No newline at end of file