Commit 6f873476 authored by Andreas Fernandez's avatar Andreas Fernandez Committed by Benjamin Franzke
Browse files

[TASK] Fix TypeScript sources in preparation to upgrade

To ease the upgrade to TypeScript 3.6, this patch adjusts the source
code in a TS 2.4 compatible way. This way, the upgrade patch stays as
small as possible.

Resolves: #89106
Releases: master
Change-Id: I7e2d65262395e19f958182f8658aa326dd0aec43
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/61638

Tested-by: default avatarTYPO3com <noreply@typo3.com>
Tested-by: Anja Leichsenring's avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Benjamin Franzke's avatarBenjamin Franzke <bfr@qbus.de>
Reviewed-by: Anja Leichsenring's avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Benjamin Franzke's avatarBenjamin Franzke <bfr@qbus.de>
parent 71fda451
......@@ -222,7 +222,7 @@ class ContextMenuActions {
success: (): void => {
if (table === 'pages' && Viewport.NavigationContainer.PageTree) {
if (uid === top.fsMod.recentIds.web) {
let node = Viewport.NavigationContainer.PageTree.instance.nodes[0];
let node = Viewport.NavigationContainer.PageTree.getFirstNode();
Viewport.NavigationContainer.PageTree.selectNode(node);
}
......@@ -281,7 +281,7 @@ class ContextMenuActions {
*/
public static triggerRefresh(iframeUrl: string): void {
if (iframeUrl.indexOf('record%2Fedit') === -1) {
Viewport.ContentContainer.refresh(true);
Viewport.ContentContainer.refresh();
}
}
......
......@@ -54,6 +54,7 @@ interface UploadedFile {
interface InternalFile extends File {
lastModified: any;
lastModifiedDate: any;
}
interface DragUploaderOptions {
......
......@@ -19,7 +19,7 @@ interface FieldOptions {
tableName: string;
fieldName: string;
config: { [key: string]: any };
listenerFieldNames: string[];
listenerFieldNames: { [key: string]: string };
language: number;
originalValue: string;
signature: string;
......
......@@ -113,7 +113,7 @@ class ImageManipulation {
viewMode: 1,
zoomable: false,
};
private resizeTimeout: Number = 450;
private resizeTimeout: number = 450;
/**
* @method isCropAreaEmpty
......@@ -967,9 +967,12 @@ class ImageManipulation {
let timer: number;
$(window).on('resize', (): void => {
clearTimeout(timer);
timer = setTimeout((): void => {
fn();
}, this.resizeTimeout);
timer = setTimeout(
(): void => {
fn();
},
this.resizeTimeout,
);
});
}
}
......
......@@ -67,7 +67,7 @@ class LoginRefresh {
return;
}
// set interval to 60 seconds
let interval: Number = this.intervalTime * 1000;
let interval: number = this.intervalTime * 1000;
this.intervalId = setInterval(this.checkActiveSession, interval);
}
......
......@@ -191,7 +191,7 @@ class ModuleMenu {
return this.loadModuleComponents(
moduleData,
params,
new ClientRequest('typo3.showModule', event),
new ClientRequest('typo3.showModule', event ? event.originalEvent : null),
);
}
......
......@@ -196,8 +196,10 @@ class Notification {
$me.removeClass('in');
next();
})
.slideUp(() => {
$me.remove();
.slideUp({
complete: (): void => {
$me.remove();
},
});
});
$box.appendTo(this.messageContainer);
......@@ -218,7 +220,7 @@ class Notification {
}
}
let notificationObject;
let notificationObject: any;
try {
// fetch from parent
......
......@@ -55,7 +55,7 @@ class Severity {
}
}
let severityObject;
let severityObject: any;
try {
// fetch from opening window
if (window.opener && window.opener.TYPO3 && window.opener.TYPO3.Severity) {
......
......@@ -21,32 +21,33 @@ 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 Topbar: Topbar;
public readonly NavigationContainer: NavigationContainer = null;
public readonly ContentContainer: ContentContainer = null;
public readonly consumerScope: any = ConsumerScope;
constructor() {
$((): void => this.initialize());
this.Topbar = new Topbar();
this.NavigationContainer = new NavigationContainer(this.consumerScope);
this.ContentContainer = new ContentContainer(this.consumerScope);
}
public doLayout(): void {
this.NavigationContainer.cleanup();
this.NavigationContainer.calculateScrollbar();
$('.t3js-topbar-header').css('padding-right', $('.t3js-scaffold-toolbar').outerWidth());
}
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;
let viewportObject: Viewport;
if (!top.TYPO3.Backend) {
viewportObject = new Viewport();
......
......@@ -14,6 +14,7 @@
import {ScaffoldIdentifierEnum} from '../Enum/Viewport/ScaffoldIdentifier';
import {AbstractContainer} from './AbstractContainer';
import * as $ from 'jquery';
import ClientRequest = require('../Event/ClientRequest');
import InteractionRequest = require('../Event/InteractionRequest');
import Loader = require('./Loader');
import Utility = require('../Utility');
......@@ -39,7 +40,7 @@ class ContentContainer extends AbstractContainer {
* @param {InteractionRequest} [interactionRequest]
* @returns {JQueryDeferred<TriggerRequest>}
*/
public setUrl(urlToLoad: string, interactionRequest: InteractionRequest): 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
......@@ -48,6 +49,9 @@ class ContentContainer extends AbstractContainer {
deferred.reject();
return deferred;
}
if (!(interactionRequest instanceof InteractionRequest)) {
interactionRequest = new ClientRequest('typo3.setUrl', null);
}
deferred = this.consumerScope.invoke(
new TriggerRequest('typo3.setUrl', interactionRequest),
);
......@@ -70,11 +74,10 @@ class ContentContainer extends AbstractContainer {
}
/**
* @param {boolean} forceGet
* @param {InteractionRequest} interactionRequest
* @returns {JQueryDeferred<{}>}
*/
public refresh(forceGet: boolean, interactionRequest?: InteractionRequest): JQueryDeferred<{}> {
public refresh(interactionRequest?: InteractionRequest): JQueryDeferred<{}> {
let deferred;
const iFrame = <HTMLIFrameElement>this.resolveIFrameElement();
// abort, if no IFRAME can be found
......@@ -87,7 +90,7 @@ class ContentContainer extends AbstractContainer {
new TriggerRequest('typo3.refresh', interactionRequest),
);
deferred.then((): void => {
iFrame.contentWindow.location.reload(forceGet);
iFrame.contentWindow.location.reload();
});
return deferred;
}
......
......@@ -22,4 +22,5 @@ export interface NavigationComponentInterface {
setTemporaryMountPoint: SetTemporaryMountPoint;
unsetTemporaryMountPoint: Function;
selectNode: Function;
getFirstNode: Function;
}
......@@ -96,11 +96,8 @@ class NavigationContainer extends AbstractContainer {
return $(ScaffoldIdentifierEnum.contentNavigationIframe).attr('src');
}
/**
* @param {boolean} forceGet
*/
public refresh(forceGet: boolean): any {
return (<HTMLIFrameElement>$(ScaffoldIdentifierEnum.contentNavigationIframe)[0]).contentWindow.location.reload(forceGet);
public refresh(): any {
return (<HTMLIFrameElement>$(ScaffoldIdentifierEnum.contentNavigationIframe)[0]).contentWindow.location.reload();
}
public calculateScrollbar(): void {
......
......@@ -14,7 +14,7 @@
import {NavigationComponentInterface} from './NavigationComponentInterface';
class PageTree {
private instance: NavigationComponentInterface = null;
private readonly instance: NavigationComponentInterface = null;
constructor(instance: NavigationComponentInterface) {
this.instance = instance;
......@@ -43,6 +43,14 @@ class PageTree {
this.instance.selectNode(node);
}
}
public getFirstNode(): object {
if (this.instance !== null) {
return this.instance.getFirstNode();
}
return {};
}
}
export = PageTree;
/*
* 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 Toolbar {
public registerEvent(callback: (eventHandler: JQueryEventObject) => any): void {
$(callback);
$(ScaffoldIdentifierEnum.header).on('t3-topbar-update', callback);
}
}
export = Toolbar;
......@@ -13,18 +13,17 @@
import {ScaffoldIdentifierEnum} from '../Enum/Viewport/ScaffoldIdentifier';
import * as $ from 'jquery';
import Toolbar = require('./Toolbar');
class Topbar {
public static readonly topbarSelector: string = ScaffoldIdentifierEnum.header;
public readonly Toolbar: Toolbar;
public static Toolbar: { [key: string]: Function } = {
registerEvent: (callback: (eventHandler: JQueryEventObject) => any): void => {
$(callback);
$(Topbar.topbarSelector).on('t3-topbar-update', callback);
},
};
public constructor() {
this.Toolbar = new Toolbar();
}
public static refresh(): void {
public refresh(): void {
$.ajax(TYPO3.settings.ajaxUrls.topbar).done((data: { [key: string]: string }): void => {
$(Topbar.topbarSelector).html(data.topbar);
$(Topbar.topbarSelector).trigger('t3-topbar-update');
......
......@@ -156,6 +156,10 @@ class Wizard {
return $button;
}
public setForceSelection(force: boolean): void {
this.setup.forceSelection = force;
}
private initializeEvents(): void {
let $modal = this.setup.$carousel.closest('.modal');
let $modalTitle = $modal.find('.modal-title');
......@@ -288,7 +292,7 @@ class Wizard {
}
}
let wizardObject;
let wizardObject: any;
try {
// fetch from opening window
if (window.opener && window.opener.TYPO3 && window.opener.TYPO3.Wizard) {
......
......@@ -18,6 +18,7 @@ import 'TYPO3/CMS/Backend/jquery.clearable';
import * as $ from 'jquery';
import Modal = require('TYPO3/CMS/Backend/Modal');
import Persistent = require('TYPO3/CMS/Backend/Storage/Persistent');
import SecurityUtility = require('TYPO3/CMS/Core/SecurityUtility');
import Tooltip = require('TYPO3/CMS/Backend/Tooltip');
import Utility = require('TYPO3/CMS/Backend/Utility');
import Viewport = require('TYPO3/CMS/Backend/Viewport');
......@@ -241,7 +242,7 @@ class Backend extends Workspaces {
this.addIntegrityCheckWarningToWizard();
}
Wizard.set('forceSelection', false);
Wizard.setForceSelection(false);
Wizard.addSlide(
'swap-confirm',
'Swap',
......@@ -974,7 +975,7 @@ class Backend extends Workspaces {
}
if (!integrityCheckRequired) {
Wizard.setup.forceSelection = false;
Wizard.setForceSelection(false);
this.renderSelectionActionWizard(selectedAction, affectedRecords);
} else {
this.checkIntegrity(
......@@ -983,7 +984,7 @@ class Backend extends Workspaces {
type: 'selection',
},
).done((response: any): void => {
Wizard.setup.forceSelection = false;
Wizard.setForceSelection(false);
if (response[0].result.result === 'warning') {
this.addIntegrityCheckWarningToWizard();
}
......@@ -1014,7 +1015,9 @@ class Backend extends Workspaces {
Wizard.addSlide(
'mass-action-confirmation',
TYPO3.lang['window.selectionAction.title'],
$('<p />').text(TYPO3.lang['tooltip.' + selectedAction + 'Selected']),
'<p>'
+ new SecurityUtility().encodeHtml(TYPO3.lang['tooltip.' + selectedAction + 'Selected'])
+ '</p>',
SeverityEnum.warning,
);
Wizard.addFinalProcessingSlide((): void => {
......@@ -1050,7 +1053,7 @@ class Backend extends Workspaces {
}
if (!integrityCheckRequired) {
Wizard.setup.forceSelection = false;
Wizard.setForceSelection(false);
this.renderMassActionWizard(selectedAction);
} else {
this.checkIntegrity(
......@@ -1059,7 +1062,7 @@ class Backend extends Workspaces {
type: selectedAction,
},
).done((response: any): void => {
Wizard.setup.forceSelection = false;
Wizard.setForceSelection(false);
if (response[0].result.result === 'warning') {
this.addIntegrityCheckWarningToWizard();
}
......@@ -1092,11 +1095,15 @@ class Backend extends Workspaces {
throw 'Invalid mass action ' + selectedAction + ' called.';
}
Wizard.set('forceSelection', false);
const securityUtility = new SecurityUtility();
Wizard.setForceSelection(false);
Wizard.addSlide(
'mass-action-confirmation',
TYPO3.lang['window.massAction.title'],
$('<p />').html(TYPO3.lang['tooltip.' + selectedAction + 'All'] + '<br><br>' + TYPO3.lang['tooltip.affectWholeWorkspace']),
'<p>'
+ securityUtility.encodeHtml(TYPO3.lang['tooltip.' + selectedAction + 'All']) + '<br><br>'
+ securityUtility.encodeHtml(TYPO3.lang['tooltip.affectWholeWorkspace'])
+ '</p>',
SeverityEnum.warning,
);
......
......@@ -77,15 +77,18 @@ declare namespace TBE_EDITOR {
* Current AMD/RequireJS modules are returning *instances* of ad-hoc *classes*, make that known to TypeScript
*/
declare module 'TYPO3/CMS/Backend/FormEngineValidation' {
export = new TYPO3.CMS.Backend.FormEngineValidation();
const _exported: TYPO3.CMS.Backend.FormEngineValidation;
export = _exported;
}
declare module 'TYPO3/CMS/Backend/FormEngine' {
export = new TYPO3.CMS.Backend.FormEngine();
const _exported: TYPO3.CMS.Backend.FormEngine;
export = _exported;
}
declare module 'TYPO3/CMS/Backend/FormEngine/Element/SelectTree' {
export = TYPO3.CMS.Backend.FormEngine.Element.SelectTree;
const _exported: any;
export = _exported;
}
// type definition for global namespace object
......
......@@ -10,4 +10,4 @@
*
* The TYPO3 project - inspiring people to share!
*/
define(["require","exports","./Enum/Severity","jquery","./InfoWindow","./Modal","./ModuleMenu","./Viewport","TYPO3/CMS/Backend/Notification"],function(e,t,n,a,r,o,i,s,l){"use strict";class c{static getReturnUrl(){return encodeURIComponent(top.list_frame.document.location.pathname+top.list_frame.document.location.search)}static editRecord(e,t){let n="",r=a(this).data("pages-language-uid");r&&(n="&overrideVals[pages][sys_language_uid]="+r),s.ContentContainer.setUrl(top.TYPO3.settings.FormEngine.moduleUrl+"&edit["+e+"]["+t+"]=edit"+n+"&returnUrl="+c.getReturnUrl())}static viewRecord(e,t){const n=a(this).data("preview-url");if(n){window.open(n,"newTYPO3frontendWindow").focus()}}static openInfoPopUp(e,t){r.showItem(e,t)}static mountAsTreeRoot(e,t){"pages"===e&&s.NavigationContainer.PageTree.setTemporaryMountPoint(t)}static newPageWizard(e,t){s.ContentContainer.setUrl(top.TYPO3.settings.NewRecord.moduleUrl+"&id="+t+"&pagesOnly=1&returnUrl="+c.getReturnUrl())}static newContentWizard(e,t){const r=a(this);let i=r.data("new-wizard-url");i&&(i+="&returnUrl="+c.getReturnUrl(),o.advanced({title:r.data("title"),type:o.types.ajax,size:o.sizes.medium,content:i,severity:n.SeverityEnum.notice}))}static newRecord(e,t){s.ContentContainer.setUrl(top.TYPO3.settings.FormEngine.moduleUrl+"&edit["+e+"][-"+t+"]=new&returnUrl="+c.getReturnUrl())}static openHistoryPopUp(e,t){s.ContentContainer.setUrl(top.TYPO3.settings.RecordHistory.moduleUrl+"&element="+e+":"+t+"&returnUrl="+c.getReturnUrl())}static openListModule(e,t){const n="pages"===e?t:a(this).data("page-uid");i.App.showModule("web_list","id="+n)}static pagesSort(e,t){const n=a(this).data("pages-sort-url");n&&s.ContentContainer.setUrl(n)}static pagesNewMultiple(e,t){const n=a(this).data("pages-new-multiple-url");n&&s.ContentContainer.setUrl(n)}static disableRecord(e,t){s.ContentContainer.setUrl(top.TYPO3.settings.RecordCommit.moduleUrl+"&data["+e+"]["+t+"][hidden]=1&redirect="+c.getReturnUrl()).done(()=>{s.NavigationContainer.PageTree.refreshTree()})}static enableRecord(e,t){s.ContentContainer.setUrl(top.TYPO3.settings.RecordCommit.moduleUrl+"&data["+e+"]["+t+"][hidden]=0&redirect="+c.getReturnUrl()).done(()=>{s.NavigationContainer.PageTree.refreshTree()})}static deleteRecord(e,t){const r=a(this);o.confirm(r.data("title"),r.data("message"),n.SeverityEnum.warning,[{text:a(this).data("button-close-text")||TYPO3.lang["button.cancel"]||"Cancel",active:!0,btnClass:"btn-default",name:"cancel"},{text:a(this).data("button-ok-text")||TYPO3.lang["button.delete"]||"Delete",btnClass:"btn-warning",name:"delete"}]).on("button.clicked",n=>{if("delete"===n.target.getAttribute("name")){const n=top.TYPO3.settings.RecordCommit.moduleUrl+"&cmd["+e+"]["+t+"][delete]=1";a.ajax({url:n,success:()=>{if("pages"===e&&s.NavigationContainer.PageTree){if(t===top.fsMod.recentIds.web){let e=s.NavigationContainer.PageTree.instance.nodes[0];s.NavigationContainer.PageTree.selectNode(e)}s.NavigationContainer.PageTree.refreshTree()}}})}o.dismiss()})}static copy(e,t){const n=TYPO3.settings.ajaxUrls.contextmenu_clipboard+"&CB[el]["+e+"%7C"+t+"]=1&CB[setCopyMode]=1";a.ajax(n).always(()=>{c.triggerRefresh(s.ContentContainer.get().location.href)})}static clipboardRelease(e,t){const n=TYPO3.settings.ajaxUrls.contextmenu_clipboard+"&CB[el]["+e+"%7C"+t+"]=0";a.ajax(n).always(()=>{c.triggerRefresh(s.ContentContainer.get().location.href)})}static cut(e,t){const n=TYPO3.settings.ajaxUrls.contextmenu_clipboard+"&CB[el]["+e+"%7C"+t+"]=1&CB[setCopyMode]=0";a.ajax(n).always(()=>{c.triggerRefresh(s.ContentContainer.get().location.href)})}static triggerRefresh(e){-1===e.indexOf("record%2Fedit")&&s.ContentContainer.refresh(!0)}static clearCache(e,t){a.ajax({url:TYPO3.settings.ajaxUrls.web_list_clearpagecache+"&id="+t,cache:!1,dataType:"json",success:e=>{!0===e.success?l.success(e.title,e.message,1):l.error(e.title,e.message,1)},error:()=>{l.error("Clearing page caches went wrong on the server side.")}})}static pasteAfter(e,t){c.pasteInto.bind(a(this))(e,-t)}static pasteInto(e,t){const r=a(this),i=()=>{const n="&CB[paste]="+e+"%7C"+t+"&CB[pad]=normal&redirect="+c.getReturnUrl();s.ContentContainer.setUrl(top.TYPO3.settings.RecordCommit.moduleUrl+n).done(()=>{"pages"===e&&s.NavigationContainer.PageTree&&s.NavigationContainer.PageTree.refreshTree()})};r.data("title")?o.confirm(r.data("title"),r.data("message"),n.SeverityEnum.warning,[{text:a(this).data("button-close-text")||TYPO3.lang["button.cancel"]||"Cancel",active:!0,btnClass:"btn-default",name:"cancel"},{text:a(this).data("button-ok-text")||TYPO3.lang["button.ok"]||"OK",btnClass:"btn-warning",name:"ok"}]).on("button.clicked",e=>{"ok"===e.target.getAttribute("name")&&i(),o.dismiss()}):i()}}return c});
\ No newline at end of file
define(["require","exports","./Enum/Severity","jquery","./InfoWindow","./Modal","./ModuleMenu","./Viewport","TYPO3/CMS/Backend/Notification"],function(e,t,n,a,r,o,i,s,l){"use strict";class c{static getReturnUrl(){return encodeURIComponent(top.list_frame.document.location.pathname+top.list_frame.document.location.search)}static editRecord(e,t){let n="",r=a(this).data("pages-language-uid");r&&(n="&overrideVals[pages][sys_language_uid]="+r),s.ContentContainer.setUrl(top.TYPO3.settings.FormEngine.moduleUrl+"&edit["+e+"]["+t+"]=edit"+n+"&returnUrl="+c.getReturnUrl())}static viewRecord(e,t){const n=a(this).data("preview-url");if(n){window.open(n,"newTYPO3frontendWindow").focus()}}static openInfoPopUp(e,t){r.showItem(e,t)}static mountAsTreeRoot(e,t){"pages"===e&&s.NavigationContainer.PageTree.setTemporaryMountPoint(t)}static newPageWizard(e,t){s.ContentContainer.setUrl(top.TYPO3.settings.NewRecord.moduleUrl+"&id="+t+"&pagesOnly=1&returnUrl="+c.getReturnUrl())}static newContentWizard(e,t){const r=a(this);let i=r.data("new-wizard-url");i&&(i+="&returnUrl="+c.getReturnUrl(),o.advanced({title:r.data("title"),type:o.types.ajax,size:o.sizes.medium,content:i,severity:n.SeverityEnum.notice}))}static newRecord(e,t){s.ContentContainer.setUrl(top.TYPO3.settings.FormEngine.moduleUrl+"&edit["+e+"][-"+t+"]=new&returnUrl="+c.getReturnUrl())}static openHistoryPopUp(e,t){s.ContentContainer.setUrl(top.TYPO3.settings.RecordHistory.moduleUrl+"&element="+e+":"+t+"&returnUrl="+c.getReturnUrl())}static openListModule(e,t){const n="pages"===e?t:a(this).data("page-uid");i.App.showModule("web_list","id="+n)}static pagesSort(e,t){const n=a(this).data("pages-sort-url");n&&s.ContentContainer.setUrl(n)}static pagesNewMultiple(e,t){const n=a(this).data("pages-new-multiple-url");n&&s.ContentContainer.setUrl(n)}static disableRecord(e,t){s.ContentContainer.setUrl(top.TYPO3.settings.RecordCommit.moduleUrl+"&data["+e+"]["+t+"][hidden]=1&redirect="+c.getReturnUrl()).done(()=>{s.NavigationContainer.PageTree.refreshTree()})}static enableRecord(e,t){s.ContentContainer.setUrl(top.TYPO3.settings.RecordCommit.moduleUrl+"&data["+e+"]["+t+"][hidden]=0&redirect="+c.getReturnUrl()).done(()=>{s.NavigationContainer.PageTree.refreshTree()})}static deleteRecord(e,t){const r=a(this);o.confirm(r.data("title"),r.data("message"),n.SeverityEnum.warning,[{text:a(this).data("button-close-text")||TYPO3.lang["button.cancel"]||"Cancel",active:!0,btnClass:"btn-default",name:"cancel"},{text:a(this).data("button-ok-text")||TYPO3.lang["button.delete"]||"Delete",btnClass:"btn-warning",name:"delete"}]).on("button.clicked",n=>{if("delete"===n.target.getAttribute("name")){const n=top.TYPO3.settings.RecordCommit.moduleUrl+"&cmd["+e+"]["+t+"][delete]=1";a.ajax({url:n,success:()=>{if("pages"===e&&s.NavigationContainer.PageTree){if(t===top.fsMod.recentIds.web){let e=s.NavigationContainer.PageTree.getFirstNode();s.NavigationContainer.PageTree.selectNode(e)}s.NavigationContainer.PageTree.refreshTree()}}})}o.dismiss()})}static copy(e,t){const n=TYPO3.settings.ajaxUrls.contextmenu_clipboard+"&CB[el]["+e+"%7C"+t+"]=1&CB[setCopyMode]=1";a.ajax(n).always(()=>{c.triggerRefresh(s.ContentContainer.get().location.href)})}static clipboardRelease(e,t){const n=TYPO3.settings.ajaxUrls.contextmenu_clipboard+"&CB[el]["+e+"%7C"+t+"]=0";a.ajax(n).always(()=>{c.triggerRefresh(s.ContentContainer.get().location.href)})}static cut(e,t){const n=TYPO3.settings.ajaxUrls.contextmenu_clipboard+"&CB[el]["+e+"%7C"+t+"]=1&CB[setCopyMode]=0";a.ajax(n).always(()=>{c.triggerRefresh(s.ContentContainer.get().location.href)})}static triggerRefresh(e){-1===e.indexOf("record%2Fedit")&&s.ContentContainer.refresh()}static clearCache(e,t){a.ajax({url:TYPO3.settings.ajaxUrls.web_list_clearpagecache+"&id="+t,cache:!1,dataType:"json",success:e=>{!0===e.success?l.success(e.title,e.message,1):l.error(e.title,e.message,1)},error:()=>{l.error("Clearing page caches went wrong on the server side.")}})}static pasteAfter(e,t){c.pasteInto.bind(a(this))(e,-t)}static pasteInto(e,t){const r=a(this),i=()=>{const n="&CB[paste]="+e+"%7C"+t+"&CB[pad]=normal&redirect="+c.getReturnUrl();s.ContentContainer.setUrl(top.TYPO3.settings.RecordCommit.moduleUrl+n).done(()=>{"pages"===e&&s.NavigationContainer.PageTree&&s.NavigationContainer.PageTree.refreshTree()})};r.data("title")?o.confirm(r.data("title"),r.data("message"),n.SeverityEnum.warning,[{text:a(this).data("button-close-text")||TYPO3.lang["button.cancel"]||"Cancel",active:!0,btnClass:"btn-default",name:"cancel"},{text:a(this).data("button-ok-text")||TYPO3.lang["button.ok"]||"OK",btnClass:"btn-warning",name:"ok"}]).on("button.clicked",e=>{"ok"===e.target.getAttribute("name")&&i(),o.dismiss()}):i()}}return c});
\ No newline at end of file
......@@ -10,4 +10,4 @@
*
* The TYPO3 project - inspiring people to share!
*/
define(["require","exports","./Enum/Viewport/ScaffoldIdentifier","jquery","./Storage/Persistent","./Viewport","./Event/ClientRequest","./Event/TriggerRequest"],function(e,t,n,o,a,i,d,r){"use strict";class s{constructor(){this.loadedModule=null,this.loadedNavigationComponentId="",o(()=>this.initialize())}static getCollapsedMainMenuItems(){return a.isset("modulemenu")?JSON.parse(a.get("modulemenu")):{}}static addCollapsedMainMenuItem(e){const t=s.getCollapsedMainMenuItems();t[e]=!0,a.set("modulemenu",JSON.stringify(t))}static removeCollapseMainMenuItem(e){const t=this.getCollapsedMainMenuItems();delete t[e],a.set("modulemenu",JSON.stringify(t))}static includeId(e,t){if(!e.navigationComponentId&&!e.navigationFrameScript)return t;let n="";return n="TYPO3/CMS/Backend/PageTree/PageTreeElement"===e.navigationComponentId?"web":e.name.split("_")[0],top.fsMod.recentIds[n]&&(t="id="+top.fsMod.recentIds[n]+"&"+t),t}static toggleMenu(e){i.NavigationContainer.cleanup();const t=o(n.ScaffoldIdentifierEnum.scaffold);void 0===e&&(e=t.hasClass("scaffold-modulemenu-expanded")),t.toggleClass("scaffold-modulemenu-expanded",!e),e||o(".scaffold").removeClass("scaffold-search-expanded").removeClass("scaffold-toolbar-expanded"),a.set("BackendComponents.States.typo3-module-menu",{collapsed:e}),i.doLayout()}static getRecordFromName(e){const t=o("#"+e);return{name:e,navigationComponentId:t.data("navigationcomponentid"),navigationFrameScript:t.data("navigationframescript"),navigationFrameScriptParam:t.data("navigationframescriptparameters"),link:t.find("a").data("link")}}static highlightModuleMenuItem(e){o(".modulemenu-item.active").removeClass("active"),o("#"+e).addClass("active")}refreshMenu(){o.ajax(TYPO3.settings.ajaxUrls.modulemenu).done(e=>{o("#menu").replaceWith(e.menu),top.currentModuleLoaded&&s.highlightModuleMenuItem(top.currentModuleLoaded),i.doLayout()})}reloadFrames(){i.NavigationContainer.refresh(),i.ContentContainer.refresh()}showModule(e,t,n){t=t||"";const o=s.getRecordFromName(e);return this.loadModuleComponents(o,t,new d("typo3.showModule",n))}initialize(){const e=this;let 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{const e=o(".t3js-mainmodule:first");e.attr("id")&&(t=this.showModule(e.attr("id")))}t.then(()=>{e.initializeEvents()})}initializeEvents(){o(document).on("click",".modulemenu-group .modulemenu-group-header",e=>{const t=o(e.currentTarget).parent(".modulemenu-group"),n=t.find(".modulemenu-group-container");i.NavigationContainer.cleanup(),t.hasClass("expanded")?(s.addCollapsedMainMenuItem(t.attr("id")),t.addClass("collapsed").removeClass("expanded"),n.stop().slideUp().promise().done(()=>{i.doLayout()})):(s.removeCollapseMainMenuItem(t.attr("id")),t.addClass("expanded").removeClass("collapsed"),n.stop().slideDown().promise().done(()=>{i.doLayout()}))}),o(document).on("click",".modulemenu-item,.t3-menuitem-submodule",e=>{e.preventDefault(),this.showModule(o(e.currentTarget).attr("id"),"",e)}),o(document).on("click",".t3js-topbar-button-modulemenu",e=>{e.preventDefault(),s.toggleMenu()}),o(document).on("click",".t3js-scaffold-content-overlay",e=>{e.preventDefault(),s.toggleMenu(!0)}),o(document).on("click",".t3js-topbar-button-navigationcomponent",e=>{e.preventDefault(),i.NavigationContainer.toggle()})}loadModuleComponents(e,t,n){const a=e.name,d=i.ContentContainer.beforeSetUrl(n);return d.then(o.proxy(()=>{e.navigationComponentId?this.loadNavigationComponent(e.navigationComponentId):e.navigationFrameScript?(i.NavigationContainer.show("typo3-navigationIframe"),this.openInNavFrame(e.navigationFrameScript,e.navigationFrameScriptParam,new r("typo3.loadModuleComponents",n))):i.NavigationContainer.hide(),s.highlightModuleMenuItem(a),this.loadedModule=a,t=s.includeId(e,t),this.openInContentFrame(e.link,t,new r("typo3.loadModuleComponents",n)),top.currentSubScript=e.link,top.currentModuleLoaded=a,i.doLayout()},this)),d}loadNavigationComponent(t){const n=this;if(i.NavigationContainer.show(t),t===this.loadedNavigationComponentId)return;const a=t.replace(/[\/]/g,"_");""!==this.loadedNavigationComponentId&&o("#navigationComponent-"+this.loadedNavigationComponentId.replace(/[\/]/g,"_")).hide(),o('.t3js-scaffold-content-navigation [data-component="'+t+'"]').length<1&&o(".t3js-scaffold-content-navigation").append(o("<div />",{class:"scaffold-content-navigation-component","data-component":t,id:"navigationComponent-"+a})),e([t],e=>{e.initialize("#navigationComponent-"+a),i.NavigationContainer.show(t),n.loadedNavigationComponentId=t})}openInNavFrame(e,t,n){const o=e+(t?(-1!==e.indexOf("?")?"&":"?")+t:""),a=i.NavigationContainer.getUrl(),d=i.NavigationContainer.setUrl(e,new r("typo3.openInNavFrame",n));return a!==o&&("resolved"===d.state()?i.NavigationContainer.refresh():d.then(i.NavigationContainer.refresh)),d}openInContentFrame(e,t,n){let o;if(top.nextLoadModuleUrl)o=i.ContentContainer.setUrl(top.nextLoadModuleUrl,new r("typo3.openInContentFrame",n)),top.nextLoadModuleUrl="";else{const a=e+(t?(-1!==e.indexOf("?")?"&":"?")+t:"");o=i.ContentContainer.setUrl(a,new r("typo3.openInContentFrame",n))}return o}}return top.TYPO3.ModuleMenu||(top.TYPO3.ModuleMenu={App:new s}),top.TYPO3.ModuleMenu});
\ No newline at end of file
define(["require","exports","./Enum/Viewport/ScaffoldIdentifier","jquery","./Storage/Persistent","./Viewport","./Event/ClientRequest","./Event/TriggerRequest"],function(e,t,n,o,a,i,d,r){"use strict";class l{constructor(){this.loadedModule=null,this.loadedNavigationComponentId="",o(()=>this.initialize())}static getCollapsedMainMenuItems(){return a.isset("modulemenu")?JSON.parse(a.get("modulemenu")):{}}static addCollapsedMainMenuItem(e){const t=l.getCollapsedMainMenuItems();t[e]=!0,a.set("modulemenu",JSON.stringify(t))}static removeCollapseMainMenuItem(e){const t=this.getCollapsedMainMenuItems();delete t[e],a.set("modulemenu",JSON.stringify(t))}static includeId(e,t){if(!e.navigationComponentId&&!e.navigationFrameScript)return t;let n="";return n="TYPO3/CMS/Backend/PageTree/PageTreeElement"===e.navigationComponentId?"web":e.name.split("_")[0],top.fsMod.recentIds[n]&&(t="id="+top.fsMod.recentIds[n]+"&"+t),t}static toggleMenu(e){i.NavigationContainer.cleanup();const t=o(n.ScaffoldIdentifierEnum.scaffold);void 0===e&&(e=t.hasClass("scaffold-modulemenu-expanded")),t.toggleClass("scaffold-modulemenu-expanded",!e),e||o(".scaffold").removeClass("scaffold-search-expanded").removeClass("scaffold-toolbar-expanded"),a.set("BackendComponents.States.typo3-module-menu",{collapsed:e}),i.doLayout()}static getRecordFromName(e){const t=o("#"+e);return{name:e,navigationComponentId:t.data("navigationcomponentid"),navigationFrameScript:t.data("navigationframescript"),navigationFrameScriptParam:t.data("navigationframescriptparameters"),link:t.find("a").data("link")}}static highlightModuleMenuItem(e){o(".modulemenu-item.active").removeClass("active"),o("#"+e).addClass("active")}refreshMenu(){o.ajax(TYPO3.settings.ajaxUrls.modulemenu).done(e=>{o("#menu").replaceWith(e.menu),top.currentModuleLoaded&&l.highlightModuleMenuItem(top.currentModuleLoaded),i.doLayout()})}reloadFrames(){i.NavigationContainer.refresh(),i.ContentContainer.refresh()}showModule(e,t,n){t=t||"";const o=l.getRecordFromName(e);return this.loadModuleComponents(o,t,new d("typo3.showModule",n?n.originalEvent:null))}initialize(){const e=this;let 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{const e=o(".t3js-mainmodule:first");e.attr("id")&&(t=this.showModule(e.attr("id")))}t.then(()=>{e.initializeEvents()})}initializeEvents(){o(document).on("click",".modulemenu-group .modulemenu-group-header",e=>{const t=o(e.currentTarget).parent(".modulemenu-group"),n=t.find(".modulemenu-group-container");i.NavigationContainer.cleanup(),t.hasClass("expanded")?(l.addCollapsedMainMenuItem(t.attr("id")),t.addClass("collapsed").removeClass("expanded"),n.stop().slideUp().promise().done(()=>{i.doLayout()})):(l.removeCollapseMainMenuItem(t.attr("id")),t.addClass("expanded").removeClass("collapsed"),n.stop().slideDown().promise().done(()=>{i.doLayout()}))}),o(document).on("click",".modulemenu-item,.t3-menuitem-submodule",e=>{e.preventDefault(),this.showModule(o(e.currentTarget).attr("id"),"",e)}),o(document).on("click",".t3js-topbar-button-modulemenu",e=>{e.preventDefault(),l.toggleMenu()}),o(document).on("click",".t3js-scaffold-content-overlay",e=>{e.preventDefault(),l.toggleMenu(!0)}),o(document).on("click",".t3js-topbar-button-navigationcomponent",e=>{e.preventDefault(),i.NavigationContainer.toggle()})}loadModuleComponents(e,t,n){const a=e.name,d=i.ContentContainer.beforeSetUrl(n);return d.then(o.proxy(()=>{e.navigationComponentId?this.loadNavigationComponent(e.navigationComponentId):e.navigationFrameScript?(i.NavigationContainer.show("typo3-navigationIframe"),this.openInNavFrame(e.navigationFrameScript,e.navigationFrameScriptParam,new r("typo3.loadModuleComponents",n))):i.NavigationContainer.hide(),l.highlightModuleMenuItem(a),this.loadedModule=a,t=l.includeId(e,t),this.openInContentFrame(e.link,t,new r("typo3.loadModuleComponents",n)),top.currentSubScript=e.link,top.currentModuleLoaded=a,i.doLayout()},this)),d}loadNavigationComponent(t){const n=this;if(i.NavigationContainer.show(t),t===this.loadedNavigationComponentId)return;const a=t.replace(/[\/]/g,"_");""!==this.loadedNavigationComponentId&&o("#navigationComponent-"+this.loadedNavigationComponentId.replace(/[\/]/g,"_")).hide(),o('.t3js-scaffold-content-navigation [data-component="'+t+'"]').length<1&&o(".t3js-scaffold-content-navigation").append(o("<div />",{class:"scaffold-content-navigation-component","data-component":t,id:"navigationComponent-"+a})),e([t],e=>{e.initialize("#navigationComponent-"+a),i.NavigationContainer.show(t),n.loadedNavigationComponentId=t})}openInNavFrame(e,t,n){const o=e+(t?(-1!==e.indexOf("?")?"&":"?")+t:""),a=i.NavigationContainer.getUrl(),d=i.NavigationContainer.setUrl(e,new r("typo3.openInNavFrame",n));return a!==o&&("resolved"===d.state()?i.NavigationContainer.refresh():d.then(i.NavigationContainer.refresh)),d}openInContentFrame(e,t,n){let o;if(top.nextLoadModuleUrl)o=i.ContentContainer.setUrl(top.nextLoadModuleUrl,new r("typo3.openInContentFrame",n)),top.nextLoadModuleUrl="";else{const a=e+(t?(-1!==e.indexOf("?")?"&":"?")+t:"");o=i.ContentContainer.setUrl(a,new r("typo3.openInContentFrame",n))}return o}}return top.TYPO3.ModuleMenu||(top.TYPO3.ModuleMenu={App:new l}),top.TYPO3.ModuleMenu});
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment