diff --git a/Build/package.json b/Build/package.json index cc419ce9be1dc426fcf613c0a9bed8cad7647681..0ee0e9ff252ab7a6c060b106054eeb7c27526476 100644 --- a/Build/package.json +++ b/Build/package.json @@ -15,7 +15,7 @@ "@types/jasmine": "^2.5.53", "@types/jquery": "2.0.47", "@types/jqueryui": "^1.11.34", - "@types/nprogress": "*", + "@types/nprogress": "^0.0.29", "@types/requirejs": "*", "@typo3/icons": "^1.5.1", "autoprefixer": "^6.3.7", diff --git a/Build/types/TYPO3/index.d.ts b/Build/types/TYPO3/index.d.ts index 31a7f8ccfbe703ea67912198c8cff094433c706e..b0577d9ceb0f7c1f22405936369cd9258f7a7494 100644 --- a/Build/types/TYPO3/index.d.ts +++ b/Build/types/TYPO3/index.d.ts @@ -5,6 +5,7 @@ * Add types as you use them */ declare namespace TYPO3 { + export let Backend: any; export let DebugConsole: any; export let Icons: any; export let InfoWindow: any; diff --git a/Build/yarn.lock b/Build/yarn.lock index 7d0d0af4ca811f3edc81e03fae3be8af1e70e706..a89198b8cc975057a9d30f84caa39ade18629406 100644 --- a/Build/yarn.lock +++ b/Build/yarn.lock @@ -46,7 +46,7 @@ dependencies: "@types/jquery" "*" -"@types/nprogress@*": +"@types/nprogress@^0.0.29": version "0.0.29" resolved "https://registry.yarnpkg.com/@types/nprogress/-/nprogress-0.0.29.tgz#060bd510022a005f1840234030d3132fb9195471" diff --git a/typo3/sysext/backend/Resources/Private/TypeScript/Enum/Viewport/ScaffoldIdentifier.ts b/typo3/sysext/backend/Resources/Private/TypeScript/Enum/Viewport/ScaffoldIdentifier.ts new file mode 100644 index 0000000000000000000000000000000000000000..4581ec9e4edd87fe06136f2001f76a2e46b01320 --- /dev/null +++ b/typo3/sysext/backend/Resources/Private/TypeScript/Enum/Viewport/ScaffoldIdentifier.ts @@ -0,0 +1,24 @@ +/* + * 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! + */ + +export enum ScaffoldIdentifierEnum { + scaffold = '.t3js-scaffold', + header = '.t3js-scaffold-header', + moduleMenu = '.t3js-scaffold-modulemenu', + content = '.t3js-scaffold-content', + contentModule = '.t3js-scaffold-content-module', + contentModuleIframe = '.t3js-scaffold-content-module-iframe', + contentNavigation = '.t3js-scaffold-content-navigation', + contentNavigationDataComponent = '.t3js-scaffold-content-navigation [data-component]', + contentNavigationIframe = '.t3js-scaffold-content-navigation-iframe' +} diff --git a/typo3/sysext/backend/Resources/Private/TypeScript/Enum/Viewport/TopbarIdentifiers.ts b/typo3/sysext/backend/Resources/Private/TypeScript/Enum/Viewport/TopbarIdentifiers.ts new file mode 100644 index 0000000000000000000000000000000000000000..e73b8ca85244f6cc806b334fe09306a26b6db717 --- /dev/null +++ b/typo3/sysext/backend/Resources/Private/TypeScript/Enum/Viewport/TopbarIdentifiers.ts @@ -0,0 +1,16 @@ +/* + * 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! + */ + +export enum TopbarIdentifiersEnum { + buttonNavigationComponent = '.t3js-topbar-button-navigationcomponent' +} diff --git a/typo3/sysext/backend/Resources/Private/TypeScript/Viewport.ts b/typo3/sysext/backend/Resources/Private/TypeScript/Viewport.ts new file mode 100644 index 0000000000000000000000000000000000000000..867337b2bff19042a2d0f980437eb2fd09b3b9ec --- /dev/null +++ b/typo3/sysext/backend/Resources/Private/TypeScript/Viewport.ts @@ -0,0 +1,60 @@ +/* + * 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 * as $ from 'jquery'; +import ContentContainer = require('./Viewport/ContentContainer'); +import ConsumerScope = require('./Event/ConsumerScope'); +import Loader = require('./Viewport/Loader'); +import NavigationContainer = require('./Viewport/NavigationContainer'); +import Topbar = require('./Viewport/Topbar'); + +class Viewport { + // The attributes are uppercase for compatibility reasons + public readonly Loader: Loader = Loader; + public readonly Topbar: Topbar = Topbar; + public readonly NavigationContainer: NavigationContainer = null; + public readonly ContentContainer: ContentContainer = null; + public readonly consumerScope: any = ConsumerScope; + + constructor() { + $((): void => { + this.initialize(); + }); + this.NavigationContainer = new NavigationContainer(this.consumerScope); + this.ContentContainer = new ContentContainer(this.consumerScope); + } + + private initialize(): void { + this.doLayout(); + $(window).on('resize', () => { + this.doLayout(); + }); + } + + private doLayout(): void { + this.NavigationContainer.cleanup(); + this.NavigationContainer.calculateScrollbar(); + $('.t3js-topbar-header').css('padding-right', $('.t3js-scaffold-toolbar').outerWidth()); + } +} + +let viewportObject; + +if (!TYPO3.Backend) { + viewportObject = new Viewport(); + TYPO3.Backend = viewportObject; +} else { + viewportObject = TYPO3.Backend; +} + +export = viewportObject; diff --git a/typo3/sysext/backend/Resources/Private/TypeScript/Viewport/AbstractContainer.ts b/typo3/sysext/backend/Resources/Private/TypeScript/Viewport/AbstractContainer.ts new file mode 100644 index 0000000000000000000000000000000000000000..49afd4a8229075a287884b645aa15fd89651fcfa --- /dev/null +++ b/typo3/sysext/backend/Resources/Private/TypeScript/Viewport/AbstractContainer.ts @@ -0,0 +1,22 @@ +/* + * 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 ConsumerScope = require('../Event/ConsumerScope'); + +export abstract class AbstractContainer { + protected readonly consumerScope: any = ConsumerScope; + + constructor(consumerScope: any) { + this.consumerScope = consumerScope; + } +} diff --git a/typo3/sysext/backend/Resources/Private/TypeScript/Viewport/ContentContainer.ts b/typo3/sysext/backend/Resources/Private/TypeScript/Viewport/ContentContainer.ts new file mode 100644 index 0000000000000000000000000000000000000000..3c84ce1aaf1a9af7d7ee66a4d7820c881be08353 --- /dev/null +++ b/typo3/sysext/backend/Resources/Private/TypeScript/Viewport/ContentContainer.ts @@ -0,0 +1,111 @@ +/* + * 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 {ScaffoldIdentifierEnum} from '../Enum/Viewport/ScaffoldIdentifier'; +import {AbstractContainer} from './AbstractContainer'; +import * as $ from 'jquery'; +import InteractionRequest = require('../Event/InteractionRequest'); +import Loader = require('./Loader'); +import Utility = require('../Utility'); +import TriggerRequest = require('../Event/TriggerRequest'); + +class ContentContainer extends AbstractContainer { + public get(): Window { + return (<HTMLIFrameElement>$(ScaffoldIdentifierEnum.contentModuleIframe)[0]).contentWindow; + } + + /** + * @param {InteractionRequest} interactionRequest + * @returns {JQueryDeferred<TriggerRequest>} + */ + public beforeSetUrl(interactionRequest: InteractionRequest): JQueryDeferred<TriggerRequest> { + return this.consumerScope.invoke( + new TriggerRequest('typo3.beforeSetUrl', interactionRequest) + ); + } + + /** + * @param {String} urlToLoad + * @param {InteractionRequest} [interactionRequest] + * @returns {JQueryDeferred<TriggerRequest>} + */ + public setUrl(urlToLoad: string, interactionRequest: InteractionRequest): JQueryDeferred<TriggerRequest> { + let deferred: JQueryDeferred<TriggerRequest>; + const iFrame = this.resolveIFrameElement(); + // abort, if no IFRAME can be found + if (iFrame === null) { + deferred = $.Deferred(); + deferred.reject(); + return deferred; + } + deferred = this.consumerScope.invoke( + new TriggerRequest('typo3.setUrl', interactionRequest) + ); + deferred.then((): void => { + Loader.start(); + $(ScaffoldIdentifierEnum.contentModuleIframe) + .attr('src', urlToLoad) + .one('load', (): void => { + Loader.finish(); + }); + }); + return deferred; + } + + /** + * @returns {string} + */ + public getUrl(): string { + return $(ScaffoldIdentifierEnum.contentModuleIframe).attr('src'); + } + + /** + * @param {boolean} forceGet + * @param {InteractionRequest} interactionRequest + * @returns {JQueryDeferred<{}>} + */ + public refresh(forceGet: boolean, interactionRequest: InteractionRequest): JQueryDeferred<{}> { + let deferred; + const iFrame = <HTMLIFrameElement>this.resolveIFrameElement(); + // abort, if no IFRAME can be found + if (iFrame === null) { + deferred = $.Deferred(); + deferred.reject(); + return deferred; + } + deferred = this.consumerScope.invoke( + new TriggerRequest('typo3.refresh', interactionRequest) + ); + deferred.then((): void => { + iFrame.contentWindow.location.reload(forceGet); + }); + return deferred; + } + + public getIdFromUrl(): number { + if (this.getUrl) { + return parseInt(Utility.getParameterFromUrl(this.getUrl(), 'id'), 10); + } + return 0; + } + + private resolveIFrameElement(): HTMLElement { + const $iFrame = $(ScaffoldIdentifierEnum.contentModuleIframe + ':first'); + if ($iFrame.length === 0) { + return null; + } + return $iFrame.get(0); + } +} + +export = ContentContainer; diff --git a/typo3/sysext/backend/Resources/Private/TypeScript/Viewport/Loader.ts b/typo3/sysext/backend/Resources/Private/TypeScript/Viewport/Loader.ts new file mode 100644 index 0000000000000000000000000000000000000000..611ef66b4783a027d9f91e3a197bff1789a39b21 --- /dev/null +++ b/typo3/sysext/backend/Resources/Private/TypeScript/Viewport/Loader.ts @@ -0,0 +1,31 @@ +/* + * 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 {ScaffoldIdentifierEnum} from '../Enum/Viewport/ScaffoldIdentifier'; + +class Loader { + public static start(): void { + require(['nprogress'], (NProgress: NProgressStatic): void => { + NProgress.configure({parent: ScaffoldIdentifierEnum.contentModule, showSpinner: false}); + NProgress.start(); + }); + } + + public static finish(): void { + require(['nprogress'], (NProgress: NProgressStatic): void => { + NProgress.done(); + }); + } +} + +export = Loader; diff --git a/typo3/sysext/backend/Resources/Private/TypeScript/Viewport/NavigationComponentInterface.ts b/typo3/sysext/backend/Resources/Private/TypeScript/Viewport/NavigationComponentInterface.ts new file mode 100644 index 0000000000000000000000000000000000000000..278214135fe51d3bb4b428f28d92bbc8526d1798 --- /dev/null +++ b/typo3/sysext/backend/Resources/Private/TypeScript/Viewport/NavigationComponentInterface.ts @@ -0,0 +1,23 @@ +/* + * 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! + */ + + +interface SetTemporaryMountPoint { + (pid: number): void; +} + +export interface NavigationComponentInterface { + refreshTree: Function; + setTemporaryMountPoint: SetTemporaryMountPoint; + unsetTemporaryMountPoint: Function; +} diff --git a/typo3/sysext/backend/Resources/Private/TypeScript/Viewport/NavigationContainer.ts b/typo3/sysext/backend/Resources/Private/TypeScript/Viewport/NavigationContainer.ts new file mode 100644 index 0000000000000000000000000000000000000000..504c26fae3c901377b755206e8d0c37e4dd14914 --- /dev/null +++ b/typo3/sysext/backend/Resources/Private/TypeScript/Viewport/NavigationContainer.ts @@ -0,0 +1,127 @@ +/* + * 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 './NavigationComponentInterface'; +import {ScaffoldIdentifierEnum} from '../Enum/Viewport/ScaffoldIdentifier'; +import {TopbarIdentifiersEnum} from '../Enum/Viewport/TopbarIdentifiers'; +import {AbstractContainer} from './AbstractContainer'; +import * as $ from 'jquery'; +import PageTree = require('./PageTree'); +import Icons = require('./../Icons'); +import TriggerRequest = require('../Event/TriggerRequest'); +import InteractionRequest = require('../Event/InteractionRequest'); + +class NavigationContainer extends AbstractContainer { + public PageTree: PageTree = null; + private instance: NavigationComponentInterface = null; + + /** + * Public method used by Navigation components to register themselves. + * See TYPO3/CMS/Backend/PageTree/PageTreeElement->initialize + * + * @param {NavigationComponentInterface} component + */ + public setComponentInstance(component: NavigationComponentInterface): void { + this.instance = component; + this.PageTree = new PageTree(component); + } + + public toggle(): void { + $(ScaffoldIdentifierEnum.scaffold).toggleClass('scaffold-content-navigation-expanded'); + } + + public cleanup(): void { + $(ScaffoldIdentifierEnum.moduleMenu).removeAttr('style'); + $(ScaffoldIdentifierEnum.content).removeAttr('style'); + } + + public hide(): void { + $(TopbarIdentifiersEnum.buttonNavigationComponent).prop('disabled', true); + Icons.getIcon( + 'actions-pagetree', + Icons.sizes.small, + 'overlay-readonly', + null, + Icons.markupIdentifiers.inline + ).done((icon: string): void => { + $(TopbarIdentifiersEnum.buttonNavigationComponent).html(icon); + }); + $(ScaffoldIdentifierEnum.scaffold).removeClass('scaffold-content-navigation-expanded'); + $(ScaffoldIdentifierEnum.contentModule).removeAttr('style'); + } + + public show(component: string): void { + $(TopbarIdentifiersEnum.buttonNavigationComponent).prop('disabled', false); + Icons.getIcon('actions-pagetree', Icons.sizes.small, null, null, Icons.markupIdentifiers.inline).done((icon: string): void => { + $(TopbarIdentifiersEnum.buttonNavigationComponent).html(icon); + }); + + $(ScaffoldIdentifierEnum.contentNavigationDataComponent).hide(); + if (typeof component !== undefined) { + $(ScaffoldIdentifierEnum.scaffold).addClass('scaffold-content-navigation-expanded'); + $(ScaffoldIdentifierEnum.contentNavigation + ' [data-component="' + component + '"]').show(); + } + } + + /** + * @param {string} urlToLoad + * @param {InteractionRequest} interactionRequest + * @returns {JQueryDeferred<TriggerRequest>} + */ + public setUrl(urlToLoad: string, interactionRequest: InteractionRequest): JQueryDeferred<TriggerRequest> { + const deferred = this.consumerScope.invoke( + new TriggerRequest('typo3.setUrl', interactionRequest) + ); + deferred.then((): void => { + $(ScaffoldIdentifierEnum.scaffold).addClass('scaffold-content-navigation-expanded'); + $(ScaffoldIdentifierEnum.contentNavigationIframe).attr('src', urlToLoad); + }); + return deferred; + } + + /** + * @returns {string} + */ + public getUrl(): string { + return $(ScaffoldIdentifierEnum.contentNavigationIframe).attr('src'); + } + + /** + * @param {boolean} forceGet + */ + public refresh(forceGet: boolean): any { + return (<HTMLIFrameElement>$(ScaffoldIdentifierEnum.contentNavigationIframe)[0]).contentWindow.location.reload(forceGet); + } + + public calculateScrollbar(): void { + this.cleanup(); + const $scaffold = $(ScaffoldIdentifierEnum.scaffold); + const $moduleMenuContainer = $(ScaffoldIdentifierEnum.moduleMenu); + const $contentContainer = $(ScaffoldIdentifierEnum.content); + const $moduleMenu = $('.t3js-modulemenu'); + $moduleMenuContainer.css('overflow', 'auto'); + const moduleMenuContainerWidth = $moduleMenuContainer.outerWidth(); + const moduleMenuWidth = $moduleMenu.outerWidth(); + $moduleMenuContainer.removeAttr('style').css('overflow', 'hidden'); + if ($scaffold.hasClass('scaffold-modulemenu-expanded') === false) { + $moduleMenuContainer.width(moduleMenuContainerWidth + (moduleMenuContainerWidth - moduleMenuWidth)); + $contentContainer.css('left', moduleMenuContainerWidth + (moduleMenuContainerWidth - moduleMenuWidth)); + } else { + $moduleMenuContainer.removeAttr('style'); + $contentContainer.removeAttr('style'); + } + $moduleMenuContainer.css('overflow', 'auto'); + } +} + +export = NavigationContainer; diff --git a/typo3/sysext/backend/Resources/Private/TypeScript/Viewport/PageTree.ts b/typo3/sysext/backend/Resources/Private/TypeScript/Viewport/PageTree.ts new file mode 100644 index 0000000000000000000000000000000000000000..9e0c3360c94be1174c5352a322e63f26f208577f --- /dev/null +++ b/typo3/sysext/backend/Resources/Private/TypeScript/Viewport/PageTree.ts @@ -0,0 +1,42 @@ +/* + * 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 './NavigationComponentInterface'; + +class PageTree { + private instance: NavigationComponentInterface = null; + + constructor(instance: NavigationComponentInterface) { + this.instance = instance; + } + + public refreshTree(): void { + if (this.instance !== null) { + this.instance.refreshTree(); + } + } + + public setTemporaryMountPoint(pid: number): void { + if (this.instance !== null) { + this.instance.setTemporaryMountPoint(pid); + } + } + + public unsetTemporaryMountPoint(): void { + if (this.instance !== null) { + this.instance.unsetTemporaryMountPoint(); + } + } +} + +export = PageTree; diff --git a/typo3/sysext/backend/Resources/Private/TypeScript/Viewport/Topbar.ts b/typo3/sysext/backend/Resources/Private/TypeScript/Viewport/Topbar.ts new file mode 100644 index 0000000000000000000000000000000000000000..4d1797407e0dba0a89e9894dd12bba7ed83d7af8 --- /dev/null +++ b/typo3/sysext/backend/Resources/Private/TypeScript/Viewport/Topbar.ts @@ -0,0 +1,35 @@ +/* + * 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 {ScaffoldIdentifierEnum} from '../Enum/Viewport/ScaffoldIdentifier'; +import * as $ from 'jquery'; + +class Topbar { + public static readonly topbarSelector: string = ScaffoldIdentifierEnum.header; + + public static Toolbar: { [key: string]: Function } = { + registerEvent: (callback: (eventHandler: JQueryEventObject) => any): void => { + $(callback); + $(Topbar.topbarSelector).on('t3-topbar-update', callback); + } + }; + + public static refresh(): void { + $.ajax(TYPO3.settings.ajaxUrls.topbar).done((data: { [key: string]: string }): void => { + $(Topbar.topbarSelector).html(data.topbar); + $(Topbar.topbarSelector).trigger('t3-topbar-update'); + }); + } +} + +export = Topbar; diff --git a/typo3/sysext/backend/Resources/Public/JavaScript/Enum/Viewport/ScaffoldIdentifier.js b/typo3/sysext/backend/Resources/Public/JavaScript/Enum/Viewport/ScaffoldIdentifier.js new file mode 100644 index 0000000000000000000000000000000000000000..e9018f8581ef892777966ec6dbae132039fa551b --- /dev/null +++ b/typo3/sysext/backend/Resources/Public/JavaScript/Enum/Viewport/ScaffoldIdentifier.js @@ -0,0 +1,13 @@ +/* + * 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! + */ +define(["require","exports"],function(t,e){"use strict";var n;Object.defineProperty(e,"__esModule",{value:!0}),(n=e.ScaffoldIdentifierEnum||(e.ScaffoldIdentifierEnum={})).scaffold=".t3js-scaffold",n.header=".t3js-scaffold-header",n.moduleMenu=".t3js-scaffold-modulemenu",n.content=".t3js-scaffold-content",n.contentModule=".t3js-scaffold-content-module",n.contentModuleIframe=".t3js-scaffold-content-module-iframe",n.contentNavigation=".t3js-scaffold-content-navigation",n.contentNavigationDataComponent=".t3js-scaffold-content-navigation [data-component]",n.contentNavigationIframe=".t3js-scaffold-content-navigation-iframe"}); \ No newline at end of file diff --git a/typo3/sysext/backend/Resources/Public/JavaScript/Enum/Viewport/TopbarIdentifiers.js b/typo3/sysext/backend/Resources/Public/JavaScript/Enum/Viewport/TopbarIdentifiers.js new file mode 100644 index 0000000000000000000000000000000000000000..dd0491436724807b5cef60095d738e1d0980a830 --- /dev/null +++ b/typo3/sysext/backend/Resources/Public/JavaScript/Enum/Viewport/TopbarIdentifiers.js @@ -0,0 +1,13 @@ +/* + * 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! + */ +define(["require","exports"],function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),(t.TopbarIdentifiersEnum||(t.TopbarIdentifiersEnum={})).buttonNavigationComponent=".t3js-topbar-button-navigationcomponent"}); \ No newline at end of file diff --git a/typo3/sysext/backend/Resources/Public/JavaScript/Viewport.js b/typo3/sysext/backend/Resources/Public/JavaScript/Viewport.js index d1338fb4a44df2ae8b1091aae774d4ae01a6520b..a16af34d504ff7ac13aef9953e8b510571240ac1 100644 --- a/typo3/sysext/backend/Resources/Public/JavaScript/Viewport.js +++ b/typo3/sysext/backend/Resources/Public/JavaScript/Viewport.js @@ -10,258 +10,4 @@ * * The TYPO3 project - inspiring people to share! */ - -/** - * Module: TYPO3/CMS/Backend/Viewport - * Handles the main logic of the TYPO3 backend viewport - * @exports TYPO3/CMS/Backend/Viewport - */ -define( - 'TYPO3/CMS/Backend/Viewport', - [ - 'jquery', - 'TYPO3/CMS/Backend/Icons', - 'TYPO3/CMS/Backend/Utility', - 'TYPO3/CMS/Backend/Event/ConsumerScope', - 'TYPO3/CMS/Backend/Event/TriggerRequest' - ], - function($, Icons, Utility, ConsumerScope, TriggerRequest) { - 'use strict'; - - function resolveIFrameElement() { - var $iFrame = $('.t3js-scaffold-content-module-iframe:first'); - if ($iFrame.length === 0) { - return null; - } - return $iFrame.get(0); - } - - TYPO3.Backend = { - /** - * @type {ConsumerScope} - */ - consumerScope: ConsumerScope, - - initialize: function() { - TYPO3.Backend.doLayout(); - $(window).on('resize', TYPO3.Backend.doLayout); - }, - /** - * This function is triggered whenever a re-layouting of component is needed - */ - doLayout: function() { - TYPO3.Backend.NavigationContainer.cleanup(); - TYPO3.Backend.NavigationContainer.calculateScrollbar(); - $('.t3js-topbar-header').css('padding-right', $('.t3js-scaffold-toolbar').outerWidth()); - }, - Loader: { - start: function() { - require(['nprogress'], function(NProgress) { - NProgress.configure({parent: '.t3js-scaffold-content-module', showSpinner: false}); - NProgress.start(); - }); - }, - finish: function() { - require(['nprogress'], function(NProgress) { - NProgress.done(); - }); - } - }, - NavigationContainer: { - instance: null, - - PageTree: { - refreshTree: function() { - if (TYPO3.Backend.NavigationContainer.instance !== null) { - TYPO3.Backend.NavigationContainer.instance.refreshTree(); - } - }, - setTemporaryMountPoint: function(pid) { - if (TYPO3.Backend.NavigationContainer.instance !== null) { - TYPO3.Backend.NavigationContainer.instance.setTemporaryMountPoint(pid); - } - }, - unsetTemporaryMountPoint: function() { - if (TYPO3.Backend.NavigationContainer.instance !== null) { - TYPO3.Backend.NavigationContainer.instance.unsetTemporaryMountPoint(); - } - } - }, - toggle: function() { - $('.t3js-scaffold').toggleClass('scaffold-content-navigation-expanded') - }, - cleanup: function() { - $('.t3js-scaffold-modulemenu').removeAttr('style'); - $('t3js-scaffold-content').removeAttr('style'); - }, - hide: function() { - $('.t3js-topbar-button-navigationcomponent').attr('disabled', true); - Icons.getIcon('actions-pagetree', Icons.sizes.small, 'overlay-readonly', null, Icons.markupIdentifiers.inline).done(function(icon) { - $('.t3js-topbar-button-navigationcomponent').html(icon); - }); - $('.t3js-scaffold').removeClass('scaffold-content-navigation-expanded'); - $('.t3js-scaffold-content-module').removeAttr('style'); - }, - show: function(component) { - $('.t3js-topbar-button-navigationcomponent').attr('disabled', false); - Icons.getIcon('actions-pagetree', Icons.sizes.small, null, null, Icons.markupIdentifiers.inline).done(function(icon) { - $('.t3js-topbar-button-navigationcomponent').html(icon); - }); - if (component !== undefined) { - $('.t3js-scaffold').addClass('scaffold-content-navigation-expanded'); - } - $('.t3js-scaffold-content-navigation [data-component]').hide(); - $('.t3js-scaffold-content-navigation [data-component="' + component + '"]').show(); - }, - /** - * @param {string} urlToLoad - * @param {InteractionRequest} [interactionRequest] - * @return {jQuery.Deferred} - */ - setUrl: function(urlToLoad, interactionRequest) { - var deferred = TYPO3.Backend.consumerScope.invoke( - new TriggerRequest('typo3.setUrl', interactionRequest) - ); - deferred.then(function() { - $('.t3js-scaffold').addClass('scaffold-content-navigation-expanded'); - $('.t3js-scaffold-content-navigation-iframe').attr('src', urlToLoad); - }); - return deferred; - }, - getUrl: function() { - return $('.t3js-scaffold-content-navigation-iframe').attr('src'); - }, - /** - * @param {boolean} forceGet - */ - refresh: function(forceGet) { - $('.t3js-scaffold-content-navigation-iframe')[0].contentWindow.location.reload(forceGet); - }, - calculateScrollbar: function() { - TYPO3.Backend.NavigationContainer.cleanup(); - var $scaffold = $('.t3js-scaffold'); - var $moduleMenuContainer = $('.t3js-scaffold-modulemenu'); - var $contentContainer = $('.t3js-scaffold-content'); - var $moduleMenu = $('.t3js-modulemenu'); - $moduleMenuContainer.css('overflow', 'auto'); - var moduleMenuContainerWidth = $moduleMenuContainer.outerWidth(); - var moduleMenuWidth = $moduleMenu.outerWidth(); - $moduleMenuContainer.removeAttr('style').css('overflow', 'hidden'); - if ($scaffold.hasClass('scaffold-modulemenu-expanded') === false) { - $moduleMenuContainer.width(moduleMenuContainerWidth + (moduleMenuContainerWidth - moduleMenuWidth)); - $contentContainer.css('left', moduleMenuContainerWidth + (moduleMenuContainerWidth - moduleMenuWidth)) - } else { - $moduleMenuContainer.removeAttr('style'); - $contentContainer.removeAttr('style'); - } - $moduleMenuContainer.css('overflow', 'auto'); - }, - - /** - * Public method used by Naviagtion components to register themselves. - * See TYPO3/CMS/Backend/PageTree/PageTreeElement->initialize - * - * @param {Object} component - */ - setComponentInstance: function(component) { - TYPO3.Backend.NavigationContainer.instance = component; - } - }, - /** - * Content container manages the right site of the viewport (showing module specific content) - */ - ContentContainer: { - get: function() { - return $('.t3js-scaffold-content-module-iframe')[0].contentWindow; - }, - /** - * @param {InteractionRequest} [interactionRequest] - * @return {jQuery.Deferred} - */ - beforeSetUrl: function(interactionRequest) { - return TYPO3.Backend.consumerScope.invoke( - new TriggerRequest('typo3.beforeSetUrl', interactionRequest) - ); - }, - /** - * @param {String} urlToLoad - * @param {InteractionRequest} [interactionRequest] - * @return {jQuery.Deferred} - */ - setUrl: function(urlToLoad, interactionRequest) { - var deferred; - var iFrame = resolveIFrameElement(); - // abort, if no IFRAME can be found - if (iFrame === null) { - deferred = $.Deferred(); - deferred.reject(); - return deferred; - } - deferred = TYPO3.Backend.consumerScope.invoke( - new TriggerRequest('typo3.setUrl', interactionRequest) - ); - deferred.then(function() { - TYPO3.Backend.Loader.start(); - $('.t3js-scaffold-content-module-iframe') - .attr('src', urlToLoad) - .one('load', function() { - TYPO3.Backend.Loader.finish(); - }); - }); - return deferred; - }, - getUrl: function() { - return $('.t3js-scaffold-content-module-iframe').attr('src'); - }, - /** - * @param {boolean} forceGet - * @param {InteractionRequest} interactionRequest - * @return {jQuery.Deferred} - */ - refresh: function(forceGet, interactionRequest) { - var deferred; - var iFrame = resolveIFrameElement(); - // abort, if no IFRAME can be found - if (iFrame === null) { - deferred = $.Deferred(); - deferred.reject(); - return deferred; - } - deferred = TYPO3.Backend.consumerScope.invoke( - new TriggerRequest('typo3.refresh', interactionRequest) - ); - deferred.then(function() { - iFrame.contentWindow.location.reload(forceGet); - }); - return deferred; - }, - getIdFromUrl: function() { - if (this.getUrl) { - return Utility.getParameterFromUrl(this.getUrl, 'id'); - } else { - return 0; - } - } - }, - Topbar: { - topbarSelector: '.t3js-scaffold-header', - refresh: function() { - $.ajax(TYPO3.settings.ajaxUrls['topbar']).done(function(data) { - $(TYPO3.Backend.Topbar.topbarSelector).html(data.topbar); - $(TYPO3.Backend.Topbar.topbarSelector).trigger('t3-topbar-update'); - }); - }, - Toolbar: { - registerEvent: function(callback) { - $(callback); - $(TYPO3.Backend.Topbar.topbarSelector).on('t3-topbar-update', callback); - } - } - } - }; - - // start the module menu app - TYPO3.Backend.initialize(); - return TYPO3.Backend; - } -); +define(["require","exports","jquery","./Viewport/ContentContainer","./Event/ConsumerScope","./Viewport/Loader","./Viewport/NavigationContainer","./Viewport/Topbar"],function(t,n,i,o,e,a,r,s){"use strict";var c,u=function(){function t(){var t=this;this.Loader=a,this.Topbar=s,this.NavigationContainer=null,this.ContentContainer=null,this.consumerScope=e,i(function(){t.initialize()}),this.NavigationContainer=new r(this.consumerScope),this.ContentContainer=new o(this.consumerScope)}return t.prototype.initialize=function(){var t=this;this.doLayout(),i(window).on("resize",function(){t.doLayout()})},t.prototype.doLayout=function(){this.NavigationContainer.cleanup(),this.NavigationContainer.calculateScrollbar(),i(".t3js-topbar-header").css("padding-right",i(".t3js-scaffold-toolbar").outerWidth())},t}();return TYPO3.Backend?c=TYPO3.Backend:(c=new u,TYPO3.Backend=c),c}); \ No newline at end of file diff --git a/typo3/sysext/backend/Resources/Public/JavaScript/Viewport/AbstractContainer.js b/typo3/sysext/backend/Resources/Public/JavaScript/Viewport/AbstractContainer.js new file mode 100644 index 0000000000000000000000000000000000000000..7507ad317191ca929d29d053c3c7033113a24811 --- /dev/null +++ b/typo3/sysext/backend/Resources/Public/JavaScript/Viewport/AbstractContainer.js @@ -0,0 +1,13 @@ +/* + * 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! + */ +define(["require","exports","../Event/ConsumerScope"],function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=function(e){this.consumerScope=n,this.consumerScope=e};t.AbstractContainer=o}); \ No newline at end of file diff --git a/typo3/sysext/backend/Resources/Public/JavaScript/Viewport/ContentContainer.js b/typo3/sysext/backend/Resources/Public/JavaScript/Viewport/ContentContainer.js new file mode 100644 index 0000000000000000000000000000000000000000..26e5b5bfcfc46e2163321ab65715580eaee825f1 --- /dev/null +++ b/typo3/sysext/backend/Resources/Public/JavaScript/Viewport/ContentContainer.js @@ -0,0 +1,13 @@ +/* + * 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! + */ +var __extends=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();define(["require","exports","../Enum/Viewport/ScaffoldIdentifier","./AbstractContainer","jquery","./Loader","../Utility","../Event/TriggerRequest"],function(e,t,r,n,o,i,u,c){"use strict";return function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.get=function(){return o(r.ScaffoldIdentifierEnum.contentModuleIframe)[0].contentWindow},t.prototype.beforeSetUrl=function(e){return this.consumerScope.invoke(new c("typo3.beforeSetUrl",e))},t.prototype.setUrl=function(e,t){var n;return null===this.resolveIFrameElement()?((n=o.Deferred()).reject(),n):((n=this.consumerScope.invoke(new c("typo3.setUrl",t))).then(function(){i.start(),o(r.ScaffoldIdentifierEnum.contentModuleIframe).attr("src",e).one("load",function(){i.finish()})}),n)},t.prototype.getUrl=function(){return o(r.ScaffoldIdentifierEnum.contentModuleIframe).attr("src")},t.prototype.refresh=function(e,t){var r,n=this.resolveIFrameElement();return null===n?((r=o.Deferred()).reject(),r):((r=this.consumerScope.invoke(new c("typo3.refresh",t))).then(function(){n.contentWindow.location.reload(e)}),r)},t.prototype.getIdFromUrl=function(){return this.getUrl?parseInt(u.getParameterFromUrl(this.getUrl(),"id"),10):0},t.prototype.resolveIFrameElement=function(){var e=o(r.ScaffoldIdentifierEnum.contentModuleIframe+":first");return 0===e.length?null:e.get(0)},t}(n.AbstractContainer)}); \ No newline at end of file diff --git a/typo3/sysext/backend/Resources/Public/JavaScript/Viewport/Loader.js b/typo3/sysext/backend/Resources/Public/JavaScript/Viewport/Loader.js new file mode 100644 index 0000000000000000000000000000000000000000..d110671a0cecbbe05513633bd564549f4a86139e --- /dev/null +++ b/typo3/sysext/backend/Resources/Public/JavaScript/Viewport/Loader.js @@ -0,0 +1,13 @@ +/* + * 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! + */ +define(["require","exports","../Enum/Viewport/ScaffoldIdentifier"],function(n,t,e){"use strict";return function(){function t(){}return t.start=function(){n(["nprogress"],function(n){n.configure({parent:e.ScaffoldIdentifierEnum.contentModule,showSpinner:!1}),n.start()})},t.finish=function(){n(["nprogress"],function(n){n.done()})},t}()}); \ No newline at end of file diff --git a/typo3/sysext/backend/Resources/Public/JavaScript/Viewport/NavigationComponentInterface.js b/typo3/sysext/backend/Resources/Public/JavaScript/Viewport/NavigationComponentInterface.js new file mode 100644 index 0000000000000000000000000000000000000000..d580a287e270282e806ba0cd2b9e01889db90f99 --- /dev/null +++ b/typo3/sysext/backend/Resources/Public/JavaScript/Viewport/NavigationComponentInterface.js @@ -0,0 +1,13 @@ +/* + * 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! + */ +define(["require","exports"],function(e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0})}); \ No newline at end of file diff --git a/typo3/sysext/backend/Resources/Public/JavaScript/Viewport/NavigationContainer.js b/typo3/sysext/backend/Resources/Public/JavaScript/Viewport/NavigationContainer.js new file mode 100644 index 0000000000000000000000000000000000000000..a64817d6ffea46a207e9fe25a4142a0766925564 --- /dev/null +++ b/typo3/sysext/backend/Resources/Public/JavaScript/Viewport/NavigationContainer.js @@ -0,0 +1,13 @@ +/* + * 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! + */ +var __extends=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])};return function(e,n){function o(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(o.prototype=n.prototype,new o)}}();define(["require","exports","../Enum/Viewport/ScaffoldIdentifier","../Enum/Viewport/TopbarIdentifiers","./AbstractContainer","jquery","./PageTree","./../Icons","../Event/TriggerRequest"],function(t,e,n,o,i,r,a,f,c){"use strict";return function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.PageTree=null,e.instance=null,e}return __extends(e,t),e.prototype.setComponentInstance=function(t){this.instance=t,this.PageTree=new a(t)},e.prototype.toggle=function(){r(n.ScaffoldIdentifierEnum.scaffold).toggleClass("scaffold-content-navigation-expanded")},e.prototype.cleanup=function(){r(n.ScaffoldIdentifierEnum.moduleMenu).removeAttr("style"),r(n.ScaffoldIdentifierEnum.content).removeAttr("style")},e.prototype.hide=function(){r(o.TopbarIdentifiersEnum.buttonNavigationComponent).prop("disabled",!0),f.getIcon("actions-pagetree",f.sizes.small,"overlay-readonly",null,f.markupIdentifiers.inline).done(function(t){r(o.TopbarIdentifiersEnum.buttonNavigationComponent).html(t)}),r(n.ScaffoldIdentifierEnum.scaffold).removeClass("scaffold-content-navigation-expanded"),r(n.ScaffoldIdentifierEnum.contentModule).removeAttr("style")},e.prototype.show=function(t){r(o.TopbarIdentifiersEnum.buttonNavigationComponent).prop("disabled",!1),f.getIcon("actions-pagetree",f.sizes.small,null,null,f.markupIdentifiers.inline).done(function(t){r(o.TopbarIdentifiersEnum.buttonNavigationComponent).html(t)}),r(n.ScaffoldIdentifierEnum.contentNavigationDataComponent).hide(),void 0!==typeof t&&(r(n.ScaffoldIdentifierEnum.scaffold).addClass("scaffold-content-navigation-expanded"),r(n.ScaffoldIdentifierEnum.contentNavigation+' [data-component="'+t+'"]').show())},e.prototype.setUrl=function(t,e){var o=this.consumerScope.invoke(new c("typo3.setUrl",e));return o.then(function(){r(n.ScaffoldIdentifierEnum.scaffold).addClass("scaffold-content-navigation-expanded"),r(n.ScaffoldIdentifierEnum.contentNavigationIframe).attr("src",t)}),o},e.prototype.getUrl=function(){return r(n.ScaffoldIdentifierEnum.contentNavigationIframe).attr("src")},e.prototype.refresh=function(t){return r(n.ScaffoldIdentifierEnum.contentNavigationIframe)[0].contentWindow.location.reload(t)},e.prototype.calculateScrollbar=function(){this.cleanup();var t=r(n.ScaffoldIdentifierEnum.scaffold),e=r(n.ScaffoldIdentifierEnum.moduleMenu),o=r(n.ScaffoldIdentifierEnum.content),i=r(".t3js-modulemenu");e.css("overflow","auto");var a=e.outerWidth(),f=i.outerWidth();e.removeAttr("style").css("overflow","hidden"),!1===t.hasClass("scaffold-modulemenu-expanded")?(e.width(a+(a-f)),o.css("left",a+(a-f))):(e.removeAttr("style"),o.removeAttr("style")),e.css("overflow","auto")},e}(i.AbstractContainer)}); \ No newline at end of file diff --git a/typo3/sysext/backend/Resources/Public/JavaScript/Viewport/PageTree.js b/typo3/sysext/backend/Resources/Public/JavaScript/Viewport/PageTree.js new file mode 100644 index 0000000000000000000000000000000000000000..0ae29c3f0814847c3b9aeaf1c8f6a52d6bea0256 --- /dev/null +++ b/typo3/sysext/backend/Resources/Public/JavaScript/Viewport/PageTree.js @@ -0,0 +1,13 @@ +/* + * 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! + */ +define(["require","exports"],function(n,t){"use strict";return function(){function n(n){this.instance=null,this.instance=n}return n.prototype.refreshTree=function(){null!==this.instance&&this.instance.refreshTree()},n.prototype.setTemporaryMountPoint=function(n){null!==this.instance&&this.instance.setTemporaryMountPoint(n)},n.prototype.unsetTemporaryMountPoint=function(){null!==this.instance&&this.instance.unsetTemporaryMountPoint()},n}()}); \ No newline at end of file diff --git a/typo3/sysext/backend/Resources/Public/JavaScript/Viewport/Topbar.js b/typo3/sysext/backend/Resources/Public/JavaScript/Viewport/Topbar.js new file mode 100644 index 0000000000000000000000000000000000000000..07afb075c955c9b6567caec64d3769a1ccc188e8 --- /dev/null +++ b/typo3/sysext/backend/Resources/Public/JavaScript/Viewport/Topbar.js @@ -0,0 +1,13 @@ +/* + * 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! + */ +define(["require","exports","../Enum/Viewport/ScaffoldIdentifier","jquery"],function(t,e,r,o){"use strict";return function(){function t(){}return t.refresh=function(){o.ajax(TYPO3.settings.ajaxUrls.topbar).done(function(e){o(t.topbarSelector).html(e.topbar),o(t.topbarSelector).trigger("t3-topbar-update")})},t.topbarSelector=r.ScaffoldIdentifierEnum.header,t.Toolbar={registerEvent:function(e){o(e),o(t.topbarSelector).on("t3-topbar-update",e)}},t}()}); \ No newline at end of file