From 9c1342dc36ba271e3620002a4394fce1315df312 Mon Sep 17 00:00:00 2001 From: Andreas Fernandez <a.fernandez@scripting-base.de> Date: Sat, 29 Feb 2020 11:22:49 +0100 Subject: [PATCH] [TASK] Replace $.ajax() in most of EXT:backend This patch replaces $.ajax() in EXT:backend either with our AJAX API or with native XMLHttpRequest. The latter is required in the DragUploader as we need to listen to the progress event which isn't supported by fetch(). This patch skips Storage/Persistent, as this one needs some refactoring due to the usage of synchronous(!) AJAX requests. Resolves: #90597 Releases: master Change-Id: Ifdf41c133929740f3e766ae992848ab99ca1f283 Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/63502 Tested-by: TYPO3com <noreply@typo3.com> Tested-by: Daniel Goerz <daniel.goerz@posteo.de> Tested-by: Susanne Moog <look@susi.dev> Reviewed-by: Daniel Goerz <daniel.goerz@posteo.de> Reviewed-by: Susanne Moog <look@susi.dev> --- .../Public/TypeScript/DragUploader.ts | 109 ++++++++---------- .../Public/TypeScript/Localization.ts | 67 +++++------ .../Public/TypeScript/LoginRefresh.ts | 46 +++----- .../Resources/Public/TypeScript/ModuleMenu.ts | 7 +- .../Public/TypeScript/Viewport/Topbar.ts | 13 ++- .../Public/JavaScript/DragUploader.js | 2 +- .../Public/JavaScript/Localization.js | 2 +- .../Public/JavaScript/LoginRefresh.js | 2 +- .../Resources/Public/JavaScript/ModuleMenu.js | 2 +- .../Public/JavaScript/Viewport/Topbar.js | 2 +- 10 files changed, 116 insertions(+), 136 deletions(-) diff --git a/Build/Sources/TypeScript/backend/Resources/Public/TypeScript/DragUploader.ts b/Build/Sources/TypeScript/backend/Resources/Public/TypeScript/DragUploader.ts index 6e861029255d..e799a3cb55d8 100644 --- a/Build/Sources/TypeScript/backend/Resources/Public/TypeScript/DragUploader.ts +++ b/Build/Sources/TypeScript/backend/Resources/Public/TypeScript/DragUploader.ts @@ -11,16 +11,15 @@ * The TYPO3 project - inspiring people to share! */ -/** - * Module: TYPO3/CMS/Backend/DragUploader - */ -import {SeverityEnum} from './Enum/Severity'; import * as $ from 'jquery'; +import {AjaxResponse} from 'TYPO3/CMS/Core/Ajax/AjaxResponse'; +import {SeverityEnum} from './Enum/Severity'; +import {MessageUtility} from './Utility/MessageUtility'; import moment = require('moment'); import NProgress = require('nprogress'); +import AjaxRequest = require('TYPO3/CMS/Core/Ajax/AjaxRequest'); import Modal = require('./Modal'); import Notification = require('./Notification'); -import {MessageUtility} from './Utility/MessageUtility'; /** * Possible actions for conflicts w/ existing files @@ -261,32 +260,29 @@ class DragUploaderPlugin { this.percentagePerFile = 1 / files.length; // Check for each file if is already exist before adding it to the queue - const ajaxCalls: JQueryXHR[] = []; - $.each(files, (i: string, file: InternalFile) => { - ajaxCalls[parseInt(i, 10)] = $.ajax({ - url: TYPO3.settings.ajaxUrls.file_exists, - data: { - fileName: file.name, - fileTarget: this.target, - }, - cache: false, - success: (response: any) => { - const fileExists = typeof response.uid !== 'undefined'; - if (fileExists) { - this.askForOverride.push({ - original: response, - uploaded: file, - action: this.irreObjectUid ? Action.USE_EXISTING : Action.SKIP, - }); - NProgress.inc(this.percentagePerFile); - } else { - new FileQueueItem(this, file, Action.SKIP); - } - }, + const ajaxCalls: Promise<void>[] = []; + Array.from(files).forEach((file: InternalFile) => { + const request = new AjaxRequest(TYPO3.settings.ajaxUrls.file_exists).withQueryArguments({ + fileName: file.name, + fileTarget: this.target, + }).get({cache: 'no-cache'}).then(async (response: AjaxResponse): Promise<void> => { + const data = await response.resolve(); + const fileExists = typeof data.uid !== 'undefined'; + if (fileExists) { + this.askForOverride.push({ + original: data, + uploaded: file, + action: this.irreObjectUid ? Action.USE_EXISTING : Action.SKIP, + }); + NProgress.inc(this.percentagePerFile); + } else { + new FileQueueItem(this, file, Action.SKIP); + } }); + ajaxCalls.push(request); }); - $.when.apply($, ajaxCalls).done(() => { + Promise.all(ajaxCalls).then((): void => { this.drawOverrideModal(); NProgress.done(); }); @@ -322,14 +318,11 @@ class DragUploaderPlugin { if (this.queueLength > 0) { this.queueLength--; if (this.queueLength === 0) { - $.ajax({ - url: TYPO3.settings.ajaxUrls.flashmessages_render, - cache: false, - success: (data: any) => { - $.each(data, (index: number, flashMessage: { title: string, message: string, severity: number }) => { - Notification.showMessage(flashMessage.title, flashMessage.message, flashMessage.severity); - }); - }, + new AjaxRequest(TYPO3.settings.ajaxUrls.flashmessages_render).get({cache: 'no-cache'}).then(async (response: AjaxResponse): Promise<void> => { + const data = await response.resolve(); + for (let flashMessage of data) { + Notification.showMessage(flashMessage.title, flashMessage.message, flashMessage.severity); + } }); } } @@ -384,7 +377,7 @@ class DragUploaderPlugin { .val(Action.SKIP).text(TYPO3.lang['file_upload.actions.skip']), $('<option />', {'selected': this.defaultAction === Action.RENAME}) .val(Action.RENAME).text(TYPO3.lang['file_upload.actions.rename']), - $('<option />', {'selected': this.defaultAction === Action.OVERRIDE}) + $('<option />', {'selected': this.defaultAction === Action.OVERRIDE}) .val(Action.OVERRIDE).text(TYPO3.lang['file_upload.actions.override']), ), ), @@ -472,18 +465,17 @@ class DragUploaderPlugin { } class FileQueueItem { - private $row: JQuery; + private readonly $row: JQuery; + private readonly $progress: JQuery; + private readonly $progressContainer: JQuery; + private readonly file: InternalFile; + private readonly override: Action; private $iconCol: JQuery; private $fileName: JQuery; - private $progress: JQuery; - private $progressContainer: JQuery; private $progressBar: JQuery; private $progressPercentage: JQuery; private $progressMessage: JQuery; private dragUploader: DragUploaderPlugin; - private file: InternalFile; - private override: Action; - private upload: XMLHttpRequest; constructor(dragUploader: DragUploaderPlugin, file: InternalFile, override: Action) { this.dragUploader = dragUploader; @@ -538,25 +530,20 @@ class FileQueueItem { formData.append('redirect', ''); formData.append('upload_1', this.file); - const s = $.extend(true, {}, $.ajaxSettings, { - url: TYPO3.settings.ajaxUrls.file_process, - contentType: false, - processData: false, - data: formData, - cache: false, - type: 'POST', - success: (data: { upload?: UploadedFile[] }) => this.uploadSuccess(data), - error: (response: XMLHttpRequest) => this.uploadError(response), - }); - - s.xhr = () => { - const xhr = $.ajaxSettings.xhr(); - xhr.upload.addEventListener('progress', (e: ProgressEvent) => this.updateProgress(e)); - return xhr; + // We use XMLHttpRequest as we need the `progress` event which isn't supported by fetch() + const xhr = new XMLHttpRequest(); + xhr.onreadystatechange = (): void => { + if (xhr.readyState === XMLHttpRequest.DONE) { + if (xhr.status === 200) { + this.uploadSuccess(JSON.parse(xhr.responseText)); + } else { + this.uploadError(xhr); + } + } }; - - // start upload - this.upload = $.ajax(s); + xhr.upload.addEventListener('progress', (e: ProgressEvent) => this.updateProgress(e)); + xhr.open('POST', TYPO3.settings.ajaxUrls.file_process); + xhr.send(formData); } } diff --git a/Build/Sources/TypeScript/backend/Resources/Public/TypeScript/Localization.ts b/Build/Sources/TypeScript/backend/Resources/Public/TypeScript/Localization.ts index 50cd8f6ea63e..30f56cd4646c 100644 --- a/Build/Sources/TypeScript/backend/Resources/Public/TypeScript/Localization.ts +++ b/Build/Sources/TypeScript/backend/Resources/Public/TypeScript/Localization.ts @@ -11,8 +11,10 @@ * The TYPO3 project - inspiring people to share! */ -import {SeverityEnum} from './Enum/Severity'; import * as $ from 'jquery'; +import {AjaxResponse} from 'TYPO3/CMS/Core/Ajax/AjaxResponse'; +import {SeverityEnum} from './Enum/Severity'; +import AjaxRequest = require('TYPO3/CMS/Core/Ajax/AjaxRequest'); import Icons = require('./Icons'); import Wizard = require('./Wizard'); @@ -135,7 +137,8 @@ class Localization { this.loadAvailableLanguages( parseInt($triggerButton.data('pageId'), 10), parseInt($triggerButton.data('languageId'), 10), - ).done((result: Array<LanguageRecord>): void => { + ).then(async (response: AjaxResponse): Promise<void> => { + const result: Array<LanguageRecord> = await response.resolve(); if (result.length === 1) { // We only have one result, auto select the record and continue this.sourceLanguage = result[0].uid; @@ -189,7 +192,8 @@ class Localization { this.getSummary( parseInt($triggerButton.data('pageId'), 10), parseInt($triggerButton.data('languageId'), 10), - ).done((result: SummaryRecord): void => { + ).then(async (response: AjaxResponse): Promise<void> => { + const result: SummaryRecord = await response.resolve(); $slide.empty(); this.records = []; @@ -290,11 +294,11 @@ class Localization { parseInt($triggerButton.data('pageId'), 10), parseInt($triggerButton.data('languageId'), 10), this.records, - ).done((): void => { + ).then((): void => { Wizard.dismiss(); document.location.reload(); }); - }).done((): void => { + }).then((): void => { Wizard.show(); Wizard.getComponent().on('click', '.t3js-localization-option', (optionEvt: JQueryEventObject): void => { @@ -320,16 +324,13 @@ class Localization { * * @param {number} pageId * @param {number} languageId - * @returns {JQueryXHR} + * @returns {Promise<AjaxResponse>} */ - private loadAvailableLanguages(pageId: number, languageId: number): JQueryXHR { - return $.ajax({ - url: TYPO3.settings.ajaxUrls.page_languages, - data: { - pageId: pageId, - languageId: languageId, - }, - }); + private loadAvailableLanguages(pageId: number, languageId: number): Promise<AjaxResponse> { + return new AjaxRequest(TYPO3.settings.ajaxUrls.page_languages).withQueryArguments({ + pageId: pageId, + languageId: languageId, + }).get(); } /** @@ -337,17 +338,14 @@ class Localization { * * @param {number} pageId * @param {number} languageId - * @returns {JQueryXHR} + * @returns {Promise<AjaxResponse>} */ - private getSummary(pageId: number, languageId: number): JQueryXHR { - return $.ajax({ - url: TYPO3.settings.ajaxUrls.records_localize_summary, - data: { - pageId: pageId, - destLanguageId: languageId, - languageId: this.sourceLanguage, - }, - }); + private getSummary(pageId: number, languageId: number): Promise<AjaxResponse> { + return new AjaxRequest(TYPO3.settings.ajaxUrls.records_localize_summary).withQueryArguments({ + pageId: pageId, + destLanguageId: languageId, + languageId: this.sourceLanguage, + }).get(); } /** @@ -356,19 +354,16 @@ class Localization { * @param {number} pageId * @param {number} languageId * @param {Array<number>} uidList - * @returns {JQueryXHR} + * @returns {Promise<AjaxResponse>} */ - private localizeRecords(pageId: number, languageId: number, uidList: Array<number>): JQueryXHR { - return $.ajax({ - url: TYPO3.settings.ajaxUrls.records_localize, - data: { - pageId: pageId, - srcLanguageId: this.sourceLanguage, - destLanguageId: languageId, - action: this.localizationMode, - uidList: uidList, - }, - }); + private localizeRecords(pageId: number, languageId: number, uidList: Array<number>): Promise<AjaxResponse> { + return new AjaxRequest(TYPO3.settings.ajaxUrls.records_localize).withQueryArguments({ + pageId: pageId, + srcLanguageId: this.sourceLanguage, + destLanguageId: languageId, + action: this.localizationMode, + uidList: uidList, + }).get(); } } diff --git a/Build/Sources/TypeScript/backend/Resources/Public/TypeScript/LoginRefresh.ts b/Build/Sources/TypeScript/backend/Resources/Public/TypeScript/LoginRefresh.ts index aad40b0d15dc..c198f62f20b1 100644 --- a/Build/Sources/TypeScript/backend/Resources/Public/TypeScript/LoginRefresh.ts +++ b/Build/Sources/TypeScript/backend/Resources/Public/TypeScript/LoginRefresh.ts @@ -12,7 +12,9 @@ */ import * as $ from 'jquery'; +import {AjaxResponse} from 'TYPO3/CMS/Core/Ajax/AjaxResponse'; import Typo3Notification = require('TYPO3/CMS/Backend/Notification'); +import AjaxRequest = require('TYPO3/CMS/Core/Ajax/AjaxRequest'); enum MarkupIdentifiers { loginrefresh = 't3js-modal-loginrefresh', @@ -157,14 +159,10 @@ class LoginRefresh { */ public showLoginForm(): void { // log off for sure - $.ajax({ - url: TYPO3.settings.ajaxUrls.logout, - method: 'GET', - success: () => { - TYPO3.configuration.showRefreshLoginPopup - ? this.showLoginPopup() - : this.$loginForm.modal(this.options.modalConfig); - }, + new AjaxRequest(TYPO3.settings.ajaxUrls.logout).get().then((): void => { + TYPO3.configuration.showRefreshLoginPopup + ? this.showLoginPopup() + : this.$loginForm.modal(this.options.modalConfig); }); } @@ -234,12 +232,8 @@ class LoginRefresh { class: 'btn btn-primary t3js-active', 'data-action': 'refreshSession', }).text(TYPO3.lang['mess.refresh_login_refresh_button']).on('click', () => { - $.ajax({ - url: TYPO3.settings.ajaxUrls.login_timedout, - method: 'GET', - success: () => { - this.hideTimeoutModal(); - }, + new AjaxRequest(TYPO3.settings.ajaxUrls.login_timedout).get().then((): void => { + this.hideTimeoutModal(); }); }), ); @@ -389,22 +383,18 @@ class LoginRefresh { const postData: any = { login_status: 'login', }; - $.each($form.serializeArray(), function(i: number, field: any): void { + $.each($form.serializeArray(), function (i: number, field: any): void { postData[field.name] = field.value; }); - $.ajax({ - url: $form.attr('action'), - method: 'POST', - data: postData, - success: (response: { [key: string ]: any }) => { - if (response.login.success) { - // User is logged in - this.hideLoginForm(); - } else { - Typo3Notification.error(TYPO3.lang['mess.refresh_login_failed'], TYPO3.lang['mess.refresh_login_failed_message']); - $passwordField.focus(); - } - }, + new AjaxRequest($form.attr('action')).post(postData).then(async (response: AjaxResponse): Promise<void> => { + const data = await response.resolve(); + if (data.login.success) { + // User is logged in + this.hideLoginForm(); + } else { + Typo3Notification.error(TYPO3.lang['mess.refresh_login_failed'], TYPO3.lang['mess.refresh_login_failed_message']); + $passwordField.focus(); + } }); } diff --git a/Build/Sources/TypeScript/backend/Resources/Public/TypeScript/ModuleMenu.ts b/Build/Sources/TypeScript/backend/Resources/Public/TypeScript/ModuleMenu.ts index b4efcf7169a2..c6d622aadb63 100644 --- a/Build/Sources/TypeScript/backend/Resources/Public/TypeScript/ModuleMenu.ts +++ b/Build/Sources/TypeScript/backend/Resources/Public/TypeScript/ModuleMenu.ts @@ -11,6 +11,7 @@ * The TYPO3 project - inspiring people to share! */ +import {AjaxResponse} from 'TYPO3/CMS/Core/Ajax/AjaxResponse'; import {NavigationComponentInterface} from './Viewport/NavigationComponentInterface'; import {ScaffoldIdentifierEnum} from './Enum/Viewport/ScaffoldIdentifier'; import * as $ from 'jquery'; @@ -19,6 +20,7 @@ import Viewport = require('./Viewport'); import ClientRequest = require('./Event/ClientRequest'); import TriggerRequest = require('./Event/TriggerRequest'); import InteractionRequest = require('./Event/InteractionRequest'); +import AjaxRequest = require('TYPO3/CMS/Core/Ajax/AjaxRequest'); interface Module { name: string; @@ -158,8 +160,9 @@ class ModuleMenu { * 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); + new AjaxRequest(TYPO3.settings.ajaxUrls.modulemenu).get().then(async (response: AjaxResponse): Promise<void> => { + const result = await response.resolve(); + document.getElementById('menu').outerHTML = result.menu; if (top.currentModuleLoaded) { ModuleMenu.highlightModuleMenuItem(top.currentModuleLoaded); } diff --git a/Build/Sources/TypeScript/backend/Resources/Public/TypeScript/Viewport/Topbar.ts b/Build/Sources/TypeScript/backend/Resources/Public/TypeScript/Viewport/Topbar.ts index b82b395c9808..e9fd298b8480 100644 --- a/Build/Sources/TypeScript/backend/Resources/Public/TypeScript/Viewport/Topbar.ts +++ b/Build/Sources/TypeScript/backend/Resources/Public/TypeScript/Viewport/Topbar.ts @@ -11,9 +11,10 @@ * The TYPO3 project - inspiring people to share! */ +import {AjaxResponse} from 'TYPO3/CMS/Core/Ajax/AjaxResponse'; import {ScaffoldIdentifierEnum} from '../Enum/Viewport/ScaffoldIdentifier'; -import * as $ from 'jquery'; import Toolbar = require('./Toolbar'); +import AjaxRequest = require('TYPO3/CMS/Core/Ajax/AjaxRequest'); class Topbar { public static readonly topbarSelector: string = ScaffoldIdentifierEnum.header; @@ -24,9 +25,13 @@ class Topbar { } 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'); + new AjaxRequest(TYPO3.settings.ajaxUrls.topbar).get().then(async (response: AjaxResponse): Promise<void> => { + const data = await response.resolve(); + const topbar = document.querySelector(Topbar.topbarSelector); + if (topbar !== null) { + topbar.innerHTML = data.topbar; + topbar.dispatchEvent(new Event('t3-topbar-update')); + } }); } } diff --git a/typo3/sysext/backend/Resources/Public/JavaScript/DragUploader.js b/typo3/sysext/backend/Resources/Public/JavaScript/DragUploader.js index 06d868e84a98..30a3216ac568 100644 --- a/typo3/sysext/backend/Resources/Public/JavaScript/DragUploader.js +++ b/typo3/sysext/backend/Resources/Public/JavaScript/DragUploader.js @@ -10,4 +10,4 @@ * * The TYPO3 project - inspiring people to share! */ -define(["require","exports","./Enum/Severity","jquery","moment","nprogress","./Modal","./Notification","./Utility/MessageUtility"],(function(e,t,i,s,a,r,o,n,l){"use strict";var d;Object.defineProperty(t,"__esModule",{value:!0}),function(e){e.OVERRIDE="replace",e.RENAME="rename",e.SKIP="cancel",e.USE_EXISTING="useExisting"}(d||(d={}));class p{constructor(e){this.askForOverride=[],this.percentagePerFile=1,this.dragFileIntoDocument=e=>(e.stopPropagation(),e.preventDefault(),s(e.currentTarget).addClass("drop-in-progress"),this.showDropzone(),!1),this.dragAborted=e=>(e.stopPropagation(),e.preventDefault(),s(e.currentTarget).removeClass("drop-in-progress"),!1),this.ignoreDrop=e=>(e.stopPropagation(),e.preventDefault(),this.dragAborted(e),!1),this.handleDrop=e=>{this.ignoreDrop(e),this.processFiles(e.originalEvent.dataTransfer.files),this.$dropzone.removeClass("drop-status-ok")},this.fileInDropzone=()=>{this.$dropzone.addClass("drop-status-ok")},this.fileOutOfDropzone=()=>{this.$dropzone.removeClass("drop-status-ok")},this.$body=s("body"),this.$element=s(e);const t=void 0!==this.$element.data("dropzoneTrigger");this.$trigger=s(this.$element.data("dropzoneTrigger")),this.defaultAction=this.$element.data("defaultAction")||d.SKIP,this.$dropzone=s("<div />").addClass("dropzone").hide(),this.irreObjectUid=this.$element.data("fileIrreObject");const i=this.$element.data("dropzoneTarget");this.irreObjectUid&&0!==this.$element.nextAll(i).length?(this.dropZoneInsertBefore=!0,this.$dropzone.insertBefore(i)):(this.dropZoneInsertBefore=!1,this.$dropzone.insertAfter(i)),this.$dropzoneMask=s("<div />").addClass("dropzone-mask").appendTo(this.$dropzone),this.fileInput=document.createElement("input"),this.fileInput.setAttribute("type","file"),this.fileInput.setAttribute("multiple","multiple"),this.fileInput.setAttribute("name","files[]"),this.fileInput.classList.add("upload-file-picker"),this.$body.append(this.fileInput),this.$fileList=s(this.$element.data("progress-container")),this.fileListColumnCount=s("thead tr:first th",this.$fileList).length,this.filesExtensionsAllowed=this.$element.data("file-allowed"),this.fileDenyPattern=this.$element.data("file-deny-pattern")?new RegExp(this.$element.data("file-deny-pattern"),"i"):null,this.maxFileSize=parseInt(this.$element.data("max-file-size"),10),this.target=this.$element.data("target-folder"),this.browserCapabilities={fileReader:"undefined"!=typeof FileReader,DnD:"draggable"in document.createElement("span"),Progress:"upload"in new XMLHttpRequest},this.browserCapabilities.DnD?(this.$body.on("dragover",this.dragFileIntoDocument),this.$body.on("dragend",this.dragAborted),this.$body.on("drop",this.ignoreDrop),this.$dropzone.on("dragenter",this.fileInDropzone),this.$dropzoneMask.on("dragenter",this.fileInDropzone),this.$dropzoneMask.on("dragleave",this.fileOutOfDropzone),this.$dropzoneMask.on("drop",e=>this.handleDrop(e)),this.$dropzone.prepend('<div class="dropzone-hint"><div class="dropzone-hint-media"><div class="dropzone-hint-icon"></div></div><div class="dropzone-hint-body"><h3 class="dropzone-hint-title">'+TYPO3.lang["file_upload.dropzonehint.title"]+'</h3><p class="dropzone-hint-message">'+TYPO3.lang["file_upload.dropzonehint.message"]+"</p></div></div>").click(()=>{this.fileInput.click()}),s("<span />").addClass("dropzone-close").click(this.hideDropzone).appendTo(this.$dropzone),0===this.$fileList.length&&(this.$fileList=s("<table />").attr("id","typo3-filelist").addClass("table table-striped table-hover upload-queue").html("<tbody></tbody>").hide(),this.dropZoneInsertBefore?this.$fileList.insertAfter(this.$dropzone):this.$fileList.insertBefore(this.$dropzone),this.fileListColumnCount=7),this.fileInput.addEventListener("change",()=>{this.processFiles(Array.apply(null,this.fileInput.files))}),this.bindUploadButton(!0===t?this.$trigger:this.$element)):console.warn("Browser has no Drag and drop capabilities; cannot initialize DragUploader")}showDropzone(){this.$dropzone.show()}hideDropzone(e){e.stopPropagation(),e.preventDefault(),this.$dropzone.hide()}processFiles(e){this.queueLength=e.length,this.$fileList.is(":visible")||this.$fileList.show(),r.start(),this.percentagePerFile=1/e.length;const t=[];s.each(e,(e,i)=>{t[parseInt(e,10)]=s.ajax({url:TYPO3.settings.ajaxUrls.file_exists,data:{fileName:i.name,fileTarget:this.target},cache:!1,success:e=>{void 0!==e.uid?(this.askForOverride.push({original:e,uploaded:i,action:this.irreObjectUid?d.USE_EXISTING:d.SKIP}),r.inc(this.percentagePerFile)):new h(this,i,d.SKIP)}})}),s.when.apply(s,t).done(()=>{this.drawOverrideModal(),r.done()}),this.fileInput.value=""}bindUploadButton(e){e.click(e=>{e.preventDefault(),this.fileInput.click(),this.showDropzone()})}decrementQueueLength(){this.queueLength>0&&(this.queueLength--,0===this.queueLength&&s.ajax({url:TYPO3.settings.ajaxUrls.flashmessages_render,cache:!1,success:e=>{s.each(e,(e,t)=>{n.showMessage(t.title,t.message,t.severity)})}}))}drawOverrideModal(){const e=Object.keys(this.askForOverride).length;if(0===e)return;const t=s("<div/>").append(s("<p/>").text(TYPO3.lang["file_upload.existingfiles.description"]),s("<table/>",{class:"table"}).append(s("<thead/>").append(s("<tr />").append(s("<th/>"),s("<th/>").text(TYPO3.lang["file_upload.header.originalFile"]),s("<th/>").text(TYPO3.lang["file_upload.header.uploadedFile"]),s("<th/>").text(TYPO3.lang["file_upload.header.action"])))));for(let i=0;i<e;++i){const e=s("<tr />").append(s("<td />").append(""!==this.askForOverride[i].original.thumbUrl?s("<img />",{src:this.askForOverride[i].original.thumbUrl,height:40}):s(this.askForOverride[i].original.icon)),s("<td />").html(this.askForOverride[i].original.name+" ("+g.fileSizeAsString(this.askForOverride[i].original.size)+")<br>"+a.unix(this.askForOverride[i].original.mtime).format("YYYY-MM-DD HH:mm")),s("<td />").html(this.askForOverride[i].uploaded.name+" ("+g.fileSizeAsString(this.askForOverride[i].uploaded.size)+")<br>"+a(this.askForOverride[i].uploaded.lastModified?this.askForOverride[i].uploaded.lastModified:this.askForOverride[i].uploaded.lastModifiedDate).format("YYYY-MM-DD HH:mm")),s("<td />").append(s("<select />",{class:"form-control t3js-actions","data-override":i}).append(this.irreObjectUid?s("<option/>").val(d.USE_EXISTING).text(TYPO3.lang["file_upload.actions.use_existing"]):"",s("<option />",{selected:this.defaultAction===d.SKIP}).val(d.SKIP).text(TYPO3.lang["file_upload.actions.skip"]),s("<option />",{selected:this.defaultAction===d.RENAME}).val(d.RENAME).text(TYPO3.lang["file_upload.actions.rename"]),s("<option />",{selected:this.defaultAction===d.OVERRIDE}).val(d.OVERRIDE).text(TYPO3.lang["file_upload.actions.override"]))));t.find("table").append("<tbody />").append(e)}const r=o.confirm(TYPO3.lang["file_upload.existingfiles.title"],t,i.SeverityEnum.warning,[{text:s(this).data("button-close-text")||TYPO3.lang["file_upload.button.cancel"]||"Cancel",active:!0,btnClass:"btn-default",name:"cancel"},{text:s(this).data("button-ok-text")||TYPO3.lang["file_upload.button.continue"]||"Continue with selected actions",btnClass:"btn-warning",name:"continue"}],["modal-inner-scroll"]);r.find(".modal-dialog").addClass("modal-lg"),r.find(".modal-footer").prepend(s("<span/>").addClass("form-inline").append(s("<label/>").text(TYPO3.lang["file_upload.actions.all.label"]),s("<select/>",{class:"form-control t3js-actions-all"}).append(s("<option/>").val("").text(TYPO3.lang["file_upload.actions.all.empty"]),this.irreObjectUid?s("<option/>").val(d.USE_EXISTING).text(TYPO3.lang["file_upload.actions.all.use_existing"]):"",s("<option/>",{selected:this.defaultAction===d.SKIP}).val(d.SKIP).text(TYPO3.lang["file_upload.actions.all.skip"]),s("<option/>",{selected:this.defaultAction===d.RENAME}).val(d.RENAME).text(TYPO3.lang["file_upload.actions.all.rename"]),s("<option/>",{selected:this.defaultAction===d.OVERRIDE}).val(d.OVERRIDE).text(TYPO3.lang["file_upload.actions.all.override"]))));const n=this;r.on("change",".t3js-actions-all",(function(){const e=s(this).val();""!==e?r.find(".t3js-actions").each((t,i)=>{const a=s(i),r=parseInt(a.data("override"),10);a.val(e).prop("disabled","disabled"),n.askForOverride[r].action=a.val()}):r.find(".t3js-actions").removeProp("disabled")})).on("change",".t3js-actions",(function(){const e=s(this),t=parseInt(e.data("override"),10);n.askForOverride[t].action=e.val()})).on("button.clicked",(function(e){"cancel"===e.target.name?(n.askForOverride=[],o.dismiss()):"continue"===e.target.name&&(s.each(n.askForOverride,(e,t)=>{t.action===d.USE_EXISTING?g.addFileToIrre(n.irreObjectUid,t.original):t.action!==d.SKIP&&new h(n,t.uploaded,t.action)}),n.askForOverride=[],o.dismiss())})).on("hidden.bs.modal",()=>{this.askForOverride=[]})}}class h{constructor(e,t,i){if(this.dragUploader=e,this.file=t,this.override=i,this.$row=s("<tr />").addClass("upload-queue-item uploading"),this.$iconCol=s("<td />").addClass("col-icon").appendTo(this.$row),this.$fileName=s("<td />").text(t.name).appendTo(this.$row),this.$progress=s("<td />").attr("colspan",this.dragUploader.fileListColumnCount-2).appendTo(this.$row),this.$progressContainer=s("<div />").addClass("upload-queue-progress").appendTo(this.$progress),this.$progressBar=s("<div />").addClass("upload-queue-progress-bar").appendTo(this.$progressContainer),this.$progressPercentage=s("<span />").addClass("upload-queue-progress-percentage").appendTo(this.$progressContainer),this.$progressMessage=s("<span />").addClass("upload-queue-progress-message").appendTo(this.$progressContainer),0===s("tbody tr.upload-queue-item",this.dragUploader.$fileList).length?(this.$row.prependTo(s("tbody",this.dragUploader.$fileList)),this.$row.addClass("last")):this.$row.insertBefore(s("tbody tr.upload-queue-item:first",this.dragUploader.$fileList)),this.$iconCol.html('<span class="t3-icon t3-icon-mimetypes t3-icon-other-other"> </span>'),this.dragUploader.maxFileSize>0&&this.file.size>this.dragUploader.maxFileSize)this.updateMessage(TYPO3.lang["file_upload.maxFileSizeExceeded"].replace(/\{0\}/g,this.file.name).replace(/\{1\}/g,g.fileSizeAsString(this.dragUploader.maxFileSize))),this.$row.addClass("error");else if(this.dragUploader.fileDenyPattern&&this.file.name.match(this.dragUploader.fileDenyPattern))this.updateMessage(TYPO3.lang["file_upload.fileNotAllowed"].replace(/\{0\}/g,this.file.name)),this.$row.addClass("error");else if(this.checkAllowedExtensions()){this.updateMessage("- "+g.fileSizeAsString(this.file.size));const e=new FormData;e.append("data[upload][1][target]",this.dragUploader.target),e.append("data[upload][1][data]","1"),e.append("overwriteExistingFiles",this.override),e.append("redirect",""),e.append("upload_1",this.file);const t=s.extend(!0,{},s.ajaxSettings,{url:TYPO3.settings.ajaxUrls.file_process,contentType:!1,processData:!1,data:e,cache:!1,type:"POST",success:e=>this.uploadSuccess(e),error:e=>this.uploadError(e)});t.xhr=()=>{const e=s.ajaxSettings.xhr();return e.upload.addEventListener("progress",e=>this.updateProgress(e)),e},this.upload=s.ajax(t)}else this.updateMessage(TYPO3.lang["file_upload.fileExtensionExpected"].replace(/\{0\}/g,this.dragUploader.filesExtensionsAllowed)),this.$row.addClass("error")}updateMessage(e){this.$progressMessage.text(e)}removeProgress(){this.$progress&&this.$progress.remove()}uploadStart(){this.$progressPercentage.text("(0%)"),this.$progressBar.width("1%"),this.dragUploader.$trigger.trigger("uploadStart",[this])}uploadError(e){this.updateMessage(TYPO3.lang["file_upload.uploadFailed"].replace(/\{0\}/g,this.file.name));const t=s(e.responseText);t.is("t3err")?this.$progressPercentage.text(t.text()):this.$progressPercentage.text("("+e.statusText+")"),this.$row.addClass("error"),this.dragUploader.decrementQueueLength(),this.dragUploader.$trigger.trigger("uploadError",[this,e])}updateProgress(e){const t=Math.round(e.loaded/e.total*100)+"%";this.$progressBar.outerWidth(t),this.$progressPercentage.text(t),this.dragUploader.$trigger.trigger("updateProgress",[this,t,e])}uploadSuccess(e){e.upload&&(this.dragUploader.decrementQueueLength(),this.$row.removeClass("uploading"),this.$fileName.text(e.upload[0].name),this.$progressPercentage.text(""),this.$progressMessage.text("100%"),this.$progressBar.outerWidth("100%"),e.upload[0].icon&&this.$iconCol.html('<a href="#" class="t3js-contextmenutrigger" data-uid="'+e.upload[0].id+'" data-table="sys_file">'+e.upload[0].icon+" </span></a>"),this.dragUploader.irreObjectUid?(g.addFileToIrre(this.dragUploader.irreObjectUid,e.upload[0]),setTimeout(()=>{this.$row.remove(),0===s("tr",this.dragUploader.$fileList).length&&(this.dragUploader.$fileList.hide(),this.dragUploader.$trigger.trigger("uploadSuccess",[this,e]))},3e3)):setTimeout(()=>{this.showFileInfo(e.upload[0]),this.dragUploader.$trigger.trigger("uploadSuccess",[this,e])},3e3))}showFileInfo(e){this.removeProgress();for(let e=7;e<this.dragUploader.fileListColumnCount;e++)s("<td />").text("").appendTo(this.$row);s("<td />").text(e.extension.toUpperCase()).appendTo(this.$row),s("<td />").text(e.date).appendTo(this.$row),s("<td />").text(g.fileSizeAsString(e.size)).appendTo(this.$row);let t="";e.permissions.read&&(t+='<strong class="text-danger">'+TYPO3.lang["permissions.read"]+"</strong>"),e.permissions.write&&(t+='<strong class="text-danger">'+TYPO3.lang["permissions.write"]+"</strong>"),s("<td />").html(t).appendTo(this.$row),s("<td />").text("-").appendTo(this.$row)}checkAllowedExtensions(){if(!this.dragUploader.filesExtensionsAllowed)return!0;const e=this.file.name.split(".").pop(),t=this.dragUploader.filesExtensionsAllowed.split(",");return-1!==s.inArray(e.toLowerCase(),t)}}class g{static fileSizeAsString(e){const t=e/1024;let i="";return i=t>1024?(t/1024).toFixed(1)+" MB":t.toFixed(1)+" KB",i}static addFileToIrre(e,t){const i={actionName:"typo3:foreignRelation:inserted",objectGroup:e,table:"sys_file",uid:t.uid};l.MessageUtility.send(i)}static init(){const e=this.options;s.fn.extend({dragUploader:function(e){return this.each((t,i)=>{const a=s(i);let r=a.data("DragUploaderPlugin");r||a.data("DragUploaderPlugin",r=new p(i)),"string"==typeof e&&r[e]()})}}),s(()=>{s(".t3js-drag-uploader").dragUploader(e)})}}t.initialize=function(){g.init(),void 0!==TYPO3.settings&&void 0!==TYPO3.settings.RequireJS&&void 0!==TYPO3.settings.RequireJS.PostInitializationModules&&void 0!==TYPO3.settings.RequireJS.PostInitializationModules["TYPO3/CMS/Backend/DragUploader"]&&s.each(TYPO3.settings.RequireJS.PostInitializationModules["TYPO3/CMS/Backend/DragUploader"],(t,i)=>{e([i])})},t.initialize()})); \ No newline at end of file +define(["require","exports","jquery","./Enum/Severity","./Utility/MessageUtility","moment","nprogress","TYPO3/CMS/Core/Ajax/AjaxRequest","./Modal","./Notification"],(function(e,t,i,s,a,o,r,n,l,d){"use strict";var p;Object.defineProperty(t,"__esModule",{value:!0}),function(e){e.OVERRIDE="replace",e.RENAME="rename",e.SKIP="cancel",e.USE_EXISTING="useExisting"}(p||(p={}));class h{constructor(e){this.askForOverride=[],this.percentagePerFile=1,this.dragFileIntoDocument=e=>(e.stopPropagation(),e.preventDefault(),i(e.currentTarget).addClass("drop-in-progress"),this.showDropzone(),!1),this.dragAborted=e=>(e.stopPropagation(),e.preventDefault(),i(e.currentTarget).removeClass("drop-in-progress"),!1),this.ignoreDrop=e=>(e.stopPropagation(),e.preventDefault(),this.dragAborted(e),!1),this.handleDrop=e=>{this.ignoreDrop(e),this.processFiles(e.originalEvent.dataTransfer.files),this.$dropzone.removeClass("drop-status-ok")},this.fileInDropzone=()=>{this.$dropzone.addClass("drop-status-ok")},this.fileOutOfDropzone=()=>{this.$dropzone.removeClass("drop-status-ok")},this.$body=i("body"),this.$element=i(e);const t=void 0!==this.$element.data("dropzoneTrigger");this.$trigger=i(this.$element.data("dropzoneTrigger")),this.defaultAction=this.$element.data("defaultAction")||p.SKIP,this.$dropzone=i("<div />").addClass("dropzone").hide(),this.irreObjectUid=this.$element.data("fileIrreObject");const s=this.$element.data("dropzoneTarget");this.irreObjectUid&&0!==this.$element.nextAll(s).length?(this.dropZoneInsertBefore=!0,this.$dropzone.insertBefore(s)):(this.dropZoneInsertBefore=!1,this.$dropzone.insertAfter(s)),this.$dropzoneMask=i("<div />").addClass("dropzone-mask").appendTo(this.$dropzone),this.fileInput=document.createElement("input"),this.fileInput.setAttribute("type","file"),this.fileInput.setAttribute("multiple","multiple"),this.fileInput.setAttribute("name","files[]"),this.fileInput.classList.add("upload-file-picker"),this.$body.append(this.fileInput),this.$fileList=i(this.$element.data("progress-container")),this.fileListColumnCount=i("thead tr:first th",this.$fileList).length,this.filesExtensionsAllowed=this.$element.data("file-allowed"),this.fileDenyPattern=this.$element.data("file-deny-pattern")?new RegExp(this.$element.data("file-deny-pattern"),"i"):null,this.maxFileSize=parseInt(this.$element.data("max-file-size"),10),this.target=this.$element.data("target-folder"),this.browserCapabilities={fileReader:"undefined"!=typeof FileReader,DnD:"draggable"in document.createElement("span"),Progress:"upload"in new XMLHttpRequest},this.browserCapabilities.DnD?(this.$body.on("dragover",this.dragFileIntoDocument),this.$body.on("dragend",this.dragAborted),this.$body.on("drop",this.ignoreDrop),this.$dropzone.on("dragenter",this.fileInDropzone),this.$dropzoneMask.on("dragenter",this.fileInDropzone),this.$dropzoneMask.on("dragleave",this.fileOutOfDropzone),this.$dropzoneMask.on("drop",e=>this.handleDrop(e)),this.$dropzone.prepend('<div class="dropzone-hint"><div class="dropzone-hint-media"><div class="dropzone-hint-icon"></div></div><div class="dropzone-hint-body"><h3 class="dropzone-hint-title">'+TYPO3.lang["file_upload.dropzonehint.title"]+'</h3><p class="dropzone-hint-message">'+TYPO3.lang["file_upload.dropzonehint.message"]+"</p></div></div>").click(()=>{this.fileInput.click()}),i("<span />").addClass("dropzone-close").click(this.hideDropzone).appendTo(this.$dropzone),0===this.$fileList.length&&(this.$fileList=i("<table />").attr("id","typo3-filelist").addClass("table table-striped table-hover upload-queue").html("<tbody></tbody>").hide(),this.dropZoneInsertBefore?this.$fileList.insertAfter(this.$dropzone):this.$fileList.insertBefore(this.$dropzone),this.fileListColumnCount=7),this.fileInput.addEventListener("change",()=>{this.processFiles(Array.apply(null,this.fileInput.files))}),this.bindUploadButton(!0===t?this.$trigger:this.$element)):console.warn("Browser has no Drag and drop capabilities; cannot initialize DragUploader")}showDropzone(){this.$dropzone.show()}hideDropzone(e){e.stopPropagation(),e.preventDefault(),this.$dropzone.hide()}processFiles(e){this.queueLength=e.length,this.$fileList.is(":visible")||this.$fileList.show(),r.start(),this.percentagePerFile=1/e.length;const t=[];Array.from(e).forEach(e=>{const i=new n(TYPO3.settings.ajaxUrls.file_exists).withQueryArguments({fileName:e.name,fileTarget:this.target}).get({cache:"no-cache"}).then(async t=>{const i=await t.resolve();void 0!==i.uid?(this.askForOverride.push({original:i,uploaded:e,action:this.irreObjectUid?p.USE_EXISTING:p.SKIP}),r.inc(this.percentagePerFile)):new g(this,e,p.SKIP)});t.push(i)}),Promise.all(t).then(()=>{this.drawOverrideModal(),r.done()}),this.fileInput.value=""}bindUploadButton(e){e.click(e=>{e.preventDefault(),this.fileInput.click(),this.showDropzone()})}decrementQueueLength(){this.queueLength>0&&(this.queueLength--,0===this.queueLength&&new n(TYPO3.settings.ajaxUrls.flashmessages_render).get({cache:"no-cache"}).then(async e=>{const t=await e.resolve();for(let e of t)d.showMessage(e.title,e.message,e.severity)}))}drawOverrideModal(){const e=Object.keys(this.askForOverride).length;if(0===e)return;const t=i("<div/>").append(i("<p/>").text(TYPO3.lang["file_upload.existingfiles.description"]),i("<table/>",{class:"table"}).append(i("<thead/>").append(i("<tr />").append(i("<th/>"),i("<th/>").text(TYPO3.lang["file_upload.header.originalFile"]),i("<th/>").text(TYPO3.lang["file_upload.header.uploadedFile"]),i("<th/>").text(TYPO3.lang["file_upload.header.action"])))));for(let s=0;s<e;++s){const e=i("<tr />").append(i("<td />").append(""!==this.askForOverride[s].original.thumbUrl?i("<img />",{src:this.askForOverride[s].original.thumbUrl,height:40}):i(this.askForOverride[s].original.icon)),i("<td />").html(this.askForOverride[s].original.name+" ("+c.fileSizeAsString(this.askForOverride[s].original.size)+")<br>"+o.unix(this.askForOverride[s].original.mtime).format("YYYY-MM-DD HH:mm")),i("<td />").html(this.askForOverride[s].uploaded.name+" ("+c.fileSizeAsString(this.askForOverride[s].uploaded.size)+")<br>"+o(this.askForOverride[s].uploaded.lastModified?this.askForOverride[s].uploaded.lastModified:this.askForOverride[s].uploaded.lastModifiedDate).format("YYYY-MM-DD HH:mm")),i("<td />").append(i("<select />",{class:"form-control t3js-actions","data-override":s}).append(this.irreObjectUid?i("<option/>").val(p.USE_EXISTING).text(TYPO3.lang["file_upload.actions.use_existing"]):"",i("<option />",{selected:this.defaultAction===p.SKIP}).val(p.SKIP).text(TYPO3.lang["file_upload.actions.skip"]),i("<option />",{selected:this.defaultAction===p.RENAME}).val(p.RENAME).text(TYPO3.lang["file_upload.actions.rename"]),i("<option />",{selected:this.defaultAction===p.OVERRIDE}).val(p.OVERRIDE).text(TYPO3.lang["file_upload.actions.override"]))));t.find("table").append("<tbody />").append(e)}const a=l.confirm(TYPO3.lang["file_upload.existingfiles.title"],t,s.SeverityEnum.warning,[{text:i(this).data("button-close-text")||TYPO3.lang["file_upload.button.cancel"]||"Cancel",active:!0,btnClass:"btn-default",name:"cancel"},{text:i(this).data("button-ok-text")||TYPO3.lang["file_upload.button.continue"]||"Continue with selected actions",btnClass:"btn-warning",name:"continue"}],["modal-inner-scroll"]);a.find(".modal-dialog").addClass("modal-lg"),a.find(".modal-footer").prepend(i("<span/>").addClass("form-inline").append(i("<label/>").text(TYPO3.lang["file_upload.actions.all.label"]),i("<select/>",{class:"form-control t3js-actions-all"}).append(i("<option/>").val("").text(TYPO3.lang["file_upload.actions.all.empty"]),this.irreObjectUid?i("<option/>").val(p.USE_EXISTING).text(TYPO3.lang["file_upload.actions.all.use_existing"]):"",i("<option/>",{selected:this.defaultAction===p.SKIP}).val(p.SKIP).text(TYPO3.lang["file_upload.actions.all.skip"]),i("<option/>",{selected:this.defaultAction===p.RENAME}).val(p.RENAME).text(TYPO3.lang["file_upload.actions.all.rename"]),i("<option/>",{selected:this.defaultAction===p.OVERRIDE}).val(p.OVERRIDE).text(TYPO3.lang["file_upload.actions.all.override"]))));const r=this;a.on("change",".t3js-actions-all",(function(){const e=i(this).val();""!==e?a.find(".t3js-actions").each((t,s)=>{const a=i(s),o=parseInt(a.data("override"),10);a.val(e).prop("disabled","disabled"),r.askForOverride[o].action=a.val()}):a.find(".t3js-actions").removeProp("disabled")})).on("change",".t3js-actions",(function(){const e=i(this),t=parseInt(e.data("override"),10);r.askForOverride[t].action=e.val()})).on("button.clicked",(function(e){"cancel"===e.target.name?(r.askForOverride=[],l.dismiss()):"continue"===e.target.name&&(i.each(r.askForOverride,(e,t)=>{t.action===p.USE_EXISTING?c.addFileToIrre(r.irreObjectUid,t.original):t.action!==p.SKIP&&new g(r,t.uploaded,t.action)}),r.askForOverride=[],l.dismiss())})).on("hidden.bs.modal",()=>{this.askForOverride=[]})}}class g{constructor(e,t,s){if(this.dragUploader=e,this.file=t,this.override=s,this.$row=i("<tr />").addClass("upload-queue-item uploading"),this.$iconCol=i("<td />").addClass("col-icon").appendTo(this.$row),this.$fileName=i("<td />").text(t.name).appendTo(this.$row),this.$progress=i("<td />").attr("colspan",this.dragUploader.fileListColumnCount-2).appendTo(this.$row),this.$progressContainer=i("<div />").addClass("upload-queue-progress").appendTo(this.$progress),this.$progressBar=i("<div />").addClass("upload-queue-progress-bar").appendTo(this.$progressContainer),this.$progressPercentage=i("<span />").addClass("upload-queue-progress-percentage").appendTo(this.$progressContainer),this.$progressMessage=i("<span />").addClass("upload-queue-progress-message").appendTo(this.$progressContainer),0===i("tbody tr.upload-queue-item",this.dragUploader.$fileList).length?(this.$row.prependTo(i("tbody",this.dragUploader.$fileList)),this.$row.addClass("last")):this.$row.insertBefore(i("tbody tr.upload-queue-item:first",this.dragUploader.$fileList)),this.$iconCol.html('<span class="t3-icon t3-icon-mimetypes t3-icon-other-other"> </span>'),this.dragUploader.maxFileSize>0&&this.file.size>this.dragUploader.maxFileSize)this.updateMessage(TYPO3.lang["file_upload.maxFileSizeExceeded"].replace(/\{0\}/g,this.file.name).replace(/\{1\}/g,c.fileSizeAsString(this.dragUploader.maxFileSize))),this.$row.addClass("error");else if(this.dragUploader.fileDenyPattern&&this.file.name.match(this.dragUploader.fileDenyPattern))this.updateMessage(TYPO3.lang["file_upload.fileNotAllowed"].replace(/\{0\}/g,this.file.name)),this.$row.addClass("error");else if(this.checkAllowedExtensions()){this.updateMessage("- "+c.fileSizeAsString(this.file.size));const e=new FormData;e.append("data[upload][1][target]",this.dragUploader.target),e.append("data[upload][1][data]","1"),e.append("overwriteExistingFiles",this.override),e.append("redirect",""),e.append("upload_1",this.file);const t=new XMLHttpRequest;t.onreadystatechange=()=>{t.readyState===XMLHttpRequest.DONE&&(200===t.status?this.uploadSuccess(JSON.parse(t.responseText)):this.uploadError(t))},t.upload.addEventListener("progress",e=>this.updateProgress(e)),t.open("POST",TYPO3.settings.ajaxUrls.file_process),t.send(e)}else this.updateMessage(TYPO3.lang["file_upload.fileExtensionExpected"].replace(/\{0\}/g,this.dragUploader.filesExtensionsAllowed)),this.$row.addClass("error")}updateMessage(e){this.$progressMessage.text(e)}removeProgress(){this.$progress&&this.$progress.remove()}uploadStart(){this.$progressPercentage.text("(0%)"),this.$progressBar.width("1%"),this.dragUploader.$trigger.trigger("uploadStart",[this])}uploadError(e){this.updateMessage(TYPO3.lang["file_upload.uploadFailed"].replace(/\{0\}/g,this.file.name));const t=i(e.responseText);t.is("t3err")?this.$progressPercentage.text(t.text()):this.$progressPercentage.text("("+e.statusText+")"),this.$row.addClass("error"),this.dragUploader.decrementQueueLength(),this.dragUploader.$trigger.trigger("uploadError",[this,e])}updateProgress(e){const t=Math.round(e.loaded/e.total*100)+"%";this.$progressBar.outerWidth(t),this.$progressPercentage.text(t),this.dragUploader.$trigger.trigger("updateProgress",[this,t,e])}uploadSuccess(e){e.upload&&(this.dragUploader.decrementQueueLength(),this.$row.removeClass("uploading"),this.$fileName.text(e.upload[0].name),this.$progressPercentage.text(""),this.$progressMessage.text("100%"),this.$progressBar.outerWidth("100%"),e.upload[0].icon&&this.$iconCol.html('<a href="#" class="t3js-contextmenutrigger" data-uid="'+e.upload[0].id+'" data-table="sys_file">'+e.upload[0].icon+" </span></a>"),this.dragUploader.irreObjectUid?(c.addFileToIrre(this.dragUploader.irreObjectUid,e.upload[0]),setTimeout(()=>{this.$row.remove(),0===i("tr",this.dragUploader.$fileList).length&&(this.dragUploader.$fileList.hide(),this.dragUploader.$trigger.trigger("uploadSuccess",[this,e]))},3e3)):setTimeout(()=>{this.showFileInfo(e.upload[0]),this.dragUploader.$trigger.trigger("uploadSuccess",[this,e])},3e3))}showFileInfo(e){this.removeProgress();for(let e=7;e<this.dragUploader.fileListColumnCount;e++)i("<td />").text("").appendTo(this.$row);i("<td />").text(e.extension.toUpperCase()).appendTo(this.$row),i("<td />").text(e.date).appendTo(this.$row),i("<td />").text(c.fileSizeAsString(e.size)).appendTo(this.$row);let t="";e.permissions.read&&(t+='<strong class="text-danger">'+TYPO3.lang["permissions.read"]+"</strong>"),e.permissions.write&&(t+='<strong class="text-danger">'+TYPO3.lang["permissions.write"]+"</strong>"),i("<td />").html(t).appendTo(this.$row),i("<td />").text("-").appendTo(this.$row)}checkAllowedExtensions(){if(!this.dragUploader.filesExtensionsAllowed)return!0;const e=this.file.name.split(".").pop(),t=this.dragUploader.filesExtensionsAllowed.split(",");return-1!==i.inArray(e.toLowerCase(),t)}}class c{static fileSizeAsString(e){const t=e/1024;let i="";return i=t>1024?(t/1024).toFixed(1)+" MB":t.toFixed(1)+" KB",i}static addFileToIrre(e,t){const i={actionName:"typo3:foreignRelation:inserted",objectGroup:e,table:"sys_file",uid:t.uid};a.MessageUtility.send(i)}static init(){const e=this.options;i.fn.extend({dragUploader:function(e){return this.each((t,s)=>{const a=i(s);let o=a.data("DragUploaderPlugin");o||a.data("DragUploaderPlugin",o=new h(s)),"string"==typeof e&&o[e]()})}}),i(()=>{i(".t3js-drag-uploader").dragUploader(e)})}}t.initialize=function(){c.init(),void 0!==TYPO3.settings&&void 0!==TYPO3.settings.RequireJS&&void 0!==TYPO3.settings.RequireJS.PostInitializationModules&&void 0!==TYPO3.settings.RequireJS.PostInitializationModules["TYPO3/CMS/Backend/DragUploader"]&&i.each(TYPO3.settings.RequireJS.PostInitializationModules["TYPO3/CMS/Backend/DragUploader"],(t,i)=>{e([i])})},t.initialize()})); \ No newline at end of file diff --git a/typo3/sysext/backend/Resources/Public/JavaScript/Localization.js b/typo3/sysext/backend/Resources/Public/JavaScript/Localization.js index d8a9a2857db8..325aa5ca4fd9 100644 --- a/typo3/sysext/backend/Resources/Public/JavaScript/Localization.js +++ b/typo3/sysext/backend/Resources/Public/JavaScript/Localization.js @@ -10,4 +10,4 @@ * * The TYPO3 project - inspiring people to share! */ -define(["require","exports","./Enum/Severity","jquery","./Icons","./Wizard"],(function(e,a,t,l,s,o){"use strict";return new class{constructor(){this.triggerButton=".t3js-localize",this.localizationMode=null,this.sourceLanguage=null,this.records=[],l(()=>{this.initialize()})}initialize(){const e=this;s.getIcon("actions-localize",s.sizes.large).then(a=>{s.getIcon("actions-edit-copy",s.sizes.large).then(i=>{l(e.triggerButton).removeClass("disabled"),l(document).on("click",e.triggerButton,e=>{e.preventDefault();const n=l(e.currentTarget),c=[];let d="";n.data("allowTranslate")&&c.push('<div class="row"><div class="btn-group col-sm-3"><label class="btn btn-block btn-default t3js-localization-option" data-helptext=".t3js-helptext-translate">'+a+'<input type="radio" name="mode" id="mode_translate" value="localize" style="display: none"><br>Translate</label></div><div class="col-sm-9"><p class="t3js-helptext t3js-helptext-translate text-muted">'+TYPO3.lang["localize.educate.translate"]+"</p></div></div>"),n.data("allowCopy")&&c.push('<div class="row"><div class="col-sm-3 btn-group"><label class="btn btn-block btn-default t3js-localization-option" data-helptext=".t3js-helptext-copy">'+i+'<input type="radio" name="mode" id="mode_copy" value="copyFromLanguage" style="display: none"><br>Copy</label></div><div class="col-sm-9"><p class="t3js-helptext t3js-helptext-copy text-muted">'+TYPO3.lang["localize.educate.copy"]+"</p></div></div>"),0===n.data("allowTranslate")&&0===n.data("allowCopy")&&c.push('<div class="row"><div class="col-sm-12"><div class="alert alert-warning"><div class="media"><div class="media-left"><span class="fa-stack fa-lg"><i class="fa fa-circle fa-stack-2x"></i><i class="fa fa-exclamation fa-stack-1x"></i></span></div><div class="media-body"><p class="alert-message">'+TYPO3.lang["localize.educate.mixedmode"]+"</p></div></div></div></div></div>"),d+='<div data-toggle="buttons">'+c.join("<hr>")+"</div>",o.addSlide("localize-choose-action",TYPO3.lang["localize.wizard.header_page"].replace("{0}",n.data("page")).replace("{1}",n.data("languageName")),d,t.SeverityEnum.info),o.addSlide("localize-choose-language",TYPO3.lang["localize.view.chooseLanguage"],"",t.SeverityEnum.info,e=>{s.getIcon("spinner-circle-dark",s.sizes.large).then(a=>{e.html('<div class="text-center">'+a+"</div>"),this.loadAvailableLanguages(parseInt(n.data("pageId"),10),parseInt(n.data("languageId"),10)).done(a=>{if(1===a.length)return this.sourceLanguage=a[0].uid,void o.unlockNextStep().trigger("click");o.getComponent().on("click",".t3js-language-option",e=>{const a=l(e.currentTarget).find('input[type="radio"]');this.sourceLanguage=a.val(),console.log("Localization.ts@132",this.sourceLanguage),o.unlockNextStep()});const t=l("<div />",{class:"row","data-toggle":"buttons"});for(const e of a)t.append(l("<div />",{class:"col-sm-4"}).append(l("<label />",{class:"btn btn-default btn-block t3js-language-option option"}).text(" "+e.title).prepend(e.flagIcon).prepend(l("<input />",{type:"radio",name:"language",id:"language"+e.uid,value:e.uid,style:"display: none;"}))));e.empty().append(t)})})}),o.addSlide("localize-summary",TYPO3.lang["localize.view.summary"],"",t.SeverityEnum.info,e=>{s.getIcon("spinner-circle-dark",s.sizes.large).then(a=>{e.html('<div class="text-center">'+a+"</div>")}),this.getSummary(parseInt(n.data("pageId"),10),parseInt(n.data("languageId"),10)).done(a=>{e.empty(),this.records=[];const t=a.columns.columns;a.columns.columnList.forEach(s=>{if(void 0===a.records[s])return;const o=t[s],i=l("<div />",{class:"row"});a.records[s].forEach(e=>{const a=" ("+e.uid+") "+e.title;this.records.push(e.uid),i.append(l("<div />",{class:"col-sm-6"}).append(l("<div />",{class:"input-group"}).append(l("<span />",{class:"input-group-addon"}).append(l("<input />",{type:"checkbox",class:"t3js-localization-toggle-record",id:"record-uid-"+e.uid,checked:"checked","data-uid":e.uid,"aria-label":a})),l("<label />",{class:"form-control",for:"record-uid-"+e.uid}).text(a).prepend(e.icon))))}),e.append(l("<fieldset />",{class:"localization-fieldset"}).append(l("<label />").text(o).prepend(l("<input />",{class:"t3js-localization-toggle-column",type:"checkbox",checked:"checked"})),i))}),o.unlockNextStep(),o.getComponent().on("change",".t3js-localization-toggle-record",e=>{const a=l(e.currentTarget),t=a.data("uid"),s=a.closest("fieldset"),i=s.find(".t3js-localization-toggle-column");if(a.is(":checked"))this.records.push(t);else{const e=this.records.indexOf(t);e>-1&&this.records.splice(e,1)}const n=s.find(".t3js-localization-toggle-record"),c=s.find(".t3js-localization-toggle-record:checked");i.prop("checked",c.length>0),i.prop("indeterminate",c.length>0&&c.length<n.length),this.records.length>0?o.unlockNextStep():o.lockNextStep()}).on("change",".t3js-localization-toggle-column",e=>{const a=l(e.currentTarget),t=a.closest("fieldset").find(".t3js-localization-toggle-record");t.prop("checked",a.is(":checked")),t.trigger("change")})})}),o.addFinalProcessingSlide(()=>{this.localizeRecords(parseInt(n.data("pageId"),10),parseInt(n.data("languageId"),10),this.records).done(()=>{o.dismiss(),document.location.reload()})}).done(()=>{o.show(),o.getComponent().on("click",".t3js-localization-option",e=>{const a=l(e.currentTarget),t=a.find('input[type="radio"]');if(a.data("helptext")){const t=l(e.delegateTarget);t.find(".t3js-helptext").addClass("text-muted"),t.find(a.data("helptext")).removeClass("text-muted")}this.localizationMode=t.val(),o.unlockNextStep()})})})})})}loadAvailableLanguages(e,a){return l.ajax({url:TYPO3.settings.ajaxUrls.page_languages,data:{pageId:e,languageId:a}})}getSummary(e,a){return l.ajax({url:TYPO3.settings.ajaxUrls.records_localize_summary,data:{pageId:e,destLanguageId:a,languageId:this.sourceLanguage}})}localizeRecords(e,a,t){return l.ajax({url:TYPO3.settings.ajaxUrls.records_localize,data:{pageId:e,srcLanguageId:this.sourceLanguage,destLanguageId:a,action:this.localizationMode,uidList:t}})}}})); \ No newline at end of file +define(["require","exports","jquery","./Enum/Severity","TYPO3/CMS/Core/Ajax/AjaxRequest","./Icons","./Wizard"],(function(e,t,a,l,s,i,o){"use strict";return new class{constructor(){this.triggerButton=".t3js-localize",this.localizationMode=null,this.sourceLanguage=null,this.records=[],a(()=>{this.initialize()})}initialize(){const e=this;i.getIcon("actions-localize",i.sizes.large).then(t=>{i.getIcon("actions-edit-copy",i.sizes.large).then(s=>{a(e.triggerButton).removeClass("disabled"),a(document).on("click",e.triggerButton,e=>{e.preventDefault();const n=a(e.currentTarget),c=[];let d="";n.data("allowTranslate")&&c.push('<div class="row"><div class="btn-group col-sm-3"><label class="btn btn-block btn-default t3js-localization-option" data-helptext=".t3js-helptext-translate">'+t+'<input type="radio" name="mode" id="mode_translate" value="localize" style="display: none"><br>Translate</label></div><div class="col-sm-9"><p class="t3js-helptext t3js-helptext-translate text-muted">'+TYPO3.lang["localize.educate.translate"]+"</p></div></div>"),n.data("allowCopy")&&c.push('<div class="row"><div class="col-sm-3 btn-group"><label class="btn btn-block btn-default t3js-localization-option" data-helptext=".t3js-helptext-copy">'+s+'<input type="radio" name="mode" id="mode_copy" value="copyFromLanguage" style="display: none"><br>Copy</label></div><div class="col-sm-9"><p class="t3js-helptext t3js-helptext-copy text-muted">'+TYPO3.lang["localize.educate.copy"]+"</p></div></div>"),0===n.data("allowTranslate")&&0===n.data("allowCopy")&&c.push('<div class="row"><div class="col-sm-12"><div class="alert alert-warning"><div class="media"><div class="media-left"><span class="fa-stack fa-lg"><i class="fa fa-circle fa-stack-2x"></i><i class="fa fa-exclamation fa-stack-1x"></i></span></div><div class="media-body"><p class="alert-message">'+TYPO3.lang["localize.educate.mixedmode"]+"</p></div></div></div></div></div>"),d+='<div data-toggle="buttons">'+c.join("<hr>")+"</div>",o.addSlide("localize-choose-action",TYPO3.lang["localize.wizard.header_page"].replace("{0}",n.data("page")).replace("{1}",n.data("languageName")),d,l.SeverityEnum.info),o.addSlide("localize-choose-language",TYPO3.lang["localize.view.chooseLanguage"],"",l.SeverityEnum.info,e=>{i.getIcon("spinner-circle-dark",i.sizes.large).then(t=>{e.html('<div class="text-center">'+t+"</div>"),this.loadAvailableLanguages(parseInt(n.data("pageId"),10),parseInt(n.data("languageId"),10)).then(async t=>{const l=await t.resolve();if(1===l.length)return this.sourceLanguage=l[0].uid,void o.unlockNextStep().trigger("click");o.getComponent().on("click",".t3js-language-option",e=>{const t=a(e.currentTarget).find('input[type="radio"]');this.sourceLanguage=t.val(),console.log("Localization.ts@132",this.sourceLanguage),o.unlockNextStep()});const s=a("<div />",{class:"row","data-toggle":"buttons"});for(const e of l)s.append(a("<div />",{class:"col-sm-4"}).append(a("<label />",{class:"btn btn-default btn-block t3js-language-option option"}).text(" "+e.title).prepend(e.flagIcon).prepend(a("<input />",{type:"radio",name:"language",id:"language"+e.uid,value:e.uid,style:"display: none;"}))));e.empty().append(s)})})}),o.addSlide("localize-summary",TYPO3.lang["localize.view.summary"],"",l.SeverityEnum.info,e=>{i.getIcon("spinner-circle-dark",i.sizes.large).then(t=>{e.html('<div class="text-center">'+t+"</div>")}),this.getSummary(parseInt(n.data("pageId"),10),parseInt(n.data("languageId"),10)).then(async t=>{const l=await t.resolve();e.empty(),this.records=[];const s=l.columns.columns;l.columns.columnList.forEach(t=>{if(void 0===l.records[t])return;const i=s[t],o=a("<div />",{class:"row"});l.records[t].forEach(e=>{const t=" ("+e.uid+") "+e.title;this.records.push(e.uid),o.append(a("<div />",{class:"col-sm-6"}).append(a("<div />",{class:"input-group"}).append(a("<span />",{class:"input-group-addon"}).append(a("<input />",{type:"checkbox",class:"t3js-localization-toggle-record",id:"record-uid-"+e.uid,checked:"checked","data-uid":e.uid,"aria-label":t})),a("<label />",{class:"form-control",for:"record-uid-"+e.uid}).text(t).prepend(e.icon))))}),e.append(a("<fieldset />",{class:"localization-fieldset"}).append(a("<label />").text(i).prepend(a("<input />",{class:"t3js-localization-toggle-column",type:"checkbox",checked:"checked"})),o))}),o.unlockNextStep(),o.getComponent().on("change",".t3js-localization-toggle-record",e=>{const t=a(e.currentTarget),l=t.data("uid"),s=t.closest("fieldset"),i=s.find(".t3js-localization-toggle-column");if(t.is(":checked"))this.records.push(l);else{const e=this.records.indexOf(l);e>-1&&this.records.splice(e,1)}const n=s.find(".t3js-localization-toggle-record"),c=s.find(".t3js-localization-toggle-record:checked");i.prop("checked",c.length>0),i.prop("indeterminate",c.length>0&&c.length<n.length),this.records.length>0?o.unlockNextStep():o.lockNextStep()}).on("change",".t3js-localization-toggle-column",e=>{const t=a(e.currentTarget),l=t.closest("fieldset").find(".t3js-localization-toggle-record");l.prop("checked",t.is(":checked")),l.trigger("change")})})}),o.addFinalProcessingSlide(()=>{this.localizeRecords(parseInt(n.data("pageId"),10),parseInt(n.data("languageId"),10),this.records).then(()=>{o.dismiss(),document.location.reload()})}).then(()=>{o.show(),o.getComponent().on("click",".t3js-localization-option",e=>{const t=a(e.currentTarget),l=t.find('input[type="radio"]');if(t.data("helptext")){const l=a(e.delegateTarget);l.find(".t3js-helptext").addClass("text-muted"),l.find(t.data("helptext")).removeClass("text-muted")}this.localizationMode=l.val(),o.unlockNextStep()})})})})})}loadAvailableLanguages(e,t){return new s(TYPO3.settings.ajaxUrls.page_languages).withQueryArguments({pageId:e,languageId:t}).get()}getSummary(e,t){return new s(TYPO3.settings.ajaxUrls.records_localize_summary).withQueryArguments({pageId:e,destLanguageId:t,languageId:this.sourceLanguage}).get()}localizeRecords(e,t,a){return new s(TYPO3.settings.ajaxUrls.records_localize).withQueryArguments({pageId:e,srcLanguageId:this.sourceLanguage,destLanguageId:t,action:this.localizationMode,uidList:a}).get()}}})); \ No newline at end of file diff --git a/typo3/sysext/backend/Resources/Public/JavaScript/LoginRefresh.js b/typo3/sysext/backend/Resources/Public/JavaScript/LoginRefresh.js index 2daed6455647..40337d232a9b 100644 --- a/typo3/sysext/backend/Resources/Public/JavaScript/LoginRefresh.js +++ b/typo3/sysext/backend/Resources/Public/JavaScript/LoginRefresh.js @@ -10,4 +10,4 @@ * * The TYPO3 project - inspiring people to share! */ -define(["require","exports","jquery","TYPO3/CMS/Backend/Notification"],(function(o,e,i,t){"use strict";var s;!function(o){o.loginrefresh="t3js-modal-loginrefresh",o.lockedModal="t3js-modal-backendlocked",o.loginFormModal="t3js-modal-backendloginform"}(s||(s={}));class n{constructor(){this.options={modalConfig:{backdrop:"static"}},this.webNotification=null,this.intervalTime=60,this.intervalId=null,this.backendIsLocked=!1,this.isTimingOut=!1,this.$timeoutModal=null,this.$backendLockedModal=null,this.$loginForm=null,this.loginFramesetUrl="",this.logoutUrl="",this.submitForm=o=>{o.preventDefault();const e=this.$loginForm.find("form"),s=e.find("input[name=p_field]"),n=e.find("input[name=userident]"),a=s.val();if(""===a&&""===n.val())return t.error(TYPO3.lang["mess.refresh_login_failed"],TYPO3.lang["mess.refresh_login_emptyPassword"]),void s.focus();a&&(n.val(a),s.val(""));const l={login_status:"login"};i.each(e.serializeArray(),(function(o,e){l[e.name]=e.value})),i.ajax({url:e.attr("action"),method:"POST",data:l,success:o=>{o.login.success?this.hideLoginForm():(t.error(TYPO3.lang["mess.refresh_login_failed"],TYPO3.lang["mess.refresh_login_failed_message"]),s.focus())}})},this.checkActiveSession=()=>{i.getJSON(TYPO3.settings.ajaxUrls.login_timedout,[],o=>{o.login.locked?this.backendIsLocked||(this.backendIsLocked=!0,this.showBackendLockedModal()):this.backendIsLocked&&(this.backendIsLocked=!1,this.hideBackendLockedModal()),this.backendIsLocked||(o.login.timed_out||o.login.will_time_out)&&(o.login.timed_out?this.showLoginForm():this.showTimeoutModal())})}}initialize(){this.initializeTimeoutModal(),this.initializeBackendLockedModal(),this.initializeLoginForm(),this.startTask(),"https:"===document.location.protocol&&"undefined"!=typeof Notification&&"granted"!==Notification.permission&&Notification.requestPermission()}startTask(){if(null!==this.intervalId)return;let o=1e3*this.intervalTime;this.intervalId=setInterval(this.checkActiveSession,o)}stopTask(){clearInterval(this.intervalId),this.intervalId=null}setIntervalTime(o){this.intervalTime=Math.min(o,86400)}setLogoutUrl(o){this.logoutUrl=o}setLoginFramesetUrl(o){this.loginFramesetUrl=o}showTimeoutModal(){this.isTimingOut=!0,this.$timeoutModal.modal(this.options.modalConfig),this.fillProgressbar(this.$timeoutModal),"https:"===document.location.protocol&&"undefined"!=typeof Notification&&"granted"===Notification.permission&&document.hidden&&(this.webNotification=new Notification(TYPO3.lang["mess.login_about_to_expire_title"],{body:TYPO3.lang["mess.login_about_to_expire"],icon:"/typo3/sysext/backend/Resources/Public/Images/Logo.png"}),this.webNotification.onclick=()=>{window.focus()})}hideTimeoutModal(){this.isTimingOut=!1,this.$timeoutModal.modal("hide"),"undefined"!=typeof Notification&&null!==this.webNotification&&this.webNotification.close()}showBackendLockedModal(){this.$backendLockedModal.modal(this.options.modalConfig)}hideBackendLockedModal(){this.$backendLockedModal.modal("hide")}showLoginForm(){i.ajax({url:TYPO3.settings.ajaxUrls.logout,method:"GET",success:()=>{TYPO3.configuration.showRefreshLoginPopup?this.showLoginPopup():this.$loginForm.modal(this.options.modalConfig)}})}showLoginPopup(){const o=window.open(this.loginFramesetUrl,"relogin_"+Math.random().toString(16).slice(2),"height=450,width=700,status=0,menubar=0,location=1");o&&o.focus()}hideLoginForm(){this.$loginForm.modal("hide")}initializeBackendLockedModal(){this.$backendLockedModal=this.generateModal(s.lockedModal),this.$backendLockedModal.find(".modal-header h4").text(TYPO3.lang["mess.please_wait"]),this.$backendLockedModal.find(".modal-body").append(i("<p />").text(TYPO3.lang["mess.be_locked"])),this.$backendLockedModal.find(".modal-footer").remove(),i("body").append(this.$backendLockedModal)}initializeTimeoutModal(){this.$timeoutModal=this.generateModal(s.loginrefresh),this.$timeoutModal.addClass("modal-severity-notice"),this.$timeoutModal.find(".modal-header h4").text(TYPO3.lang["mess.login_about_to_expire_title"]),this.$timeoutModal.find(".modal-body").append(i("<p />").text(TYPO3.lang["mess.login_about_to_expire"]),i("<div />",{class:"progress"}).append(i("<div />",{class:"progress-bar progress-bar-warning progress-bar-striped active",role:"progressbar","aria-valuemin":"0","aria-valuemax":"100"}).append(i("<span />",{class:"sr-only"})))),this.$timeoutModal.find(".modal-footer").append(i("<button />",{class:"btn btn-default","data-action":"logout"}).text(TYPO3.lang["mess.refresh_login_logout_button"]).on("click",()=>{top.location.href=this.logoutUrl}),i("<button />",{class:"btn btn-primary t3js-active","data-action":"refreshSession"}).text(TYPO3.lang["mess.refresh_login_refresh_button"]).on("click",()=>{i.ajax({url:TYPO3.settings.ajaxUrls.login_timedout,method:"GET",success:()=>{this.hideTimeoutModal()}})})),this.registerDefaultModalEvents(this.$timeoutModal),i("body").append(this.$timeoutModal)}initializeLoginForm(){if(TYPO3.configuration.showRefreshLoginPopup)return;this.$loginForm=this.generateModal(s.loginFormModal),this.$loginForm.addClass("modal-notice");let e=String(TYPO3.lang["mess.refresh_login_title"]).replace("%s",TYPO3.configuration.username);this.$loginForm.find(".modal-header h4").text(e),this.$loginForm.find(".modal-body").append(i("<p />").text(TYPO3.lang["mess.login_expired"]),i("<form />",{id:"beLoginRefresh",method:"POST",action:TYPO3.settings.ajaxUrls.login}).append(i("<div />",{class:"form-group"}).append(i("<input />",{type:"password",name:"p_field",autofocus:"autofocus",class:"form-control",placeholder:TYPO3.lang["mess.refresh_login_password"],"data-rsa-encryption":"t3-loginrefres-userident"})),i("<input />",{type:"hidden",name:"username",value:TYPO3.configuration.username}),i("<input />",{type:"hidden",name:"userident",id:"t3-loginrefres-userident"}))),this.$loginForm.find(".modal-footer").append(i("<a />",{href:this.logoutUrl,class:"btn btn-default"}).text(TYPO3.lang["mess.refresh_exit_button"]),i("<button />",{type:"button",class:"btn btn-primary","data-action":"refreshSession"}).text(TYPO3.lang["mess.refresh_login_button"]).on("click",()=>{this.$loginForm.find("form").submit()})),this.registerDefaultModalEvents(this.$loginForm).on("submit",this.submitForm),i("body").append(this.$loginForm),o.specified("TYPO3/CMS/Rsaauth/RsaEncryptionModule")&&o(["TYPO3/CMS/Rsaauth/RsaEncryptionModule"],(function(o){o.registerForm(i("#beLoginRefresh").get(0))}))}generateModal(o){return i("<div />",{id:o,class:"t3js-modal "+o+" modal modal-type-default modal-severity-notice modal-style-light modal-size-small fade"}).append(i("<div />",{class:"modal-dialog"}).append(i("<div />",{class:"modal-content"}).append(i("<div />",{class:"modal-header"}).append(i("<h4 />",{class:"modal-title"})),i("<div />",{class:"modal-body"}),i("<div />",{class:"modal-footer"}))))}fillProgressbar(o){if(!this.isTimingOut)return;let e=0;const i=o.find(".progress-bar"),t=i.children(".sr-only"),s=setInterval(()=>{const o=e>=100;!this.isTimingOut||o?(clearInterval(s),o&&(this.hideTimeoutModal(),this.showLoginForm()),e=0):e+=1;const n=e+"%";i.css("width",n),t.text(n)},300)}registerDefaultModalEvents(o){return o.on("hidden.bs.modal",()=>{this.startTask()}).on("shown.bs.modal",()=>{this.stopTask(),this.$timeoutModal.find(".modal-footer .t3js-active").first().focus()}),o}}let a;try{window.opener&&window.opener.TYPO3&&window.opener.TYPO3.LoginRefresh&&(a=window.opener.TYPO3.LoginRefresh),parent&&parent.window.TYPO3&&parent.window.TYPO3.LoginRefresh&&(a=parent.window.TYPO3.LoginRefresh),top&&top.TYPO3&&top.TYPO3.LoginRefresh&&(a=top.TYPO3.LoginRefresh)}catch(o){}return a||(a=new n,"undefined"!=typeof TYPO3&&(TYPO3.LoginRefresh=a)),a})); \ No newline at end of file +define(["require","exports","jquery","TYPO3/CMS/Backend/Notification","TYPO3/CMS/Core/Ajax/AjaxRequest"],(function(e,o,i,t,s){"use strict";var n;!function(e){e.loginrefresh="t3js-modal-loginrefresh",e.lockedModal="t3js-modal-backendlocked",e.loginFormModal="t3js-modal-backendloginform"}(n||(n={}));class a{constructor(){this.options={modalConfig:{backdrop:"static"}},this.webNotification=null,this.intervalTime=60,this.intervalId=null,this.backendIsLocked=!1,this.isTimingOut=!1,this.$timeoutModal=null,this.$backendLockedModal=null,this.$loginForm=null,this.loginFramesetUrl="",this.logoutUrl="",this.submitForm=e=>{e.preventDefault();const o=this.$loginForm.find("form"),n=o.find("input[name=p_field]"),a=o.find("input[name=userident]"),l=n.val();if(""===l&&""===a.val())return t.error(TYPO3.lang["mess.refresh_login_failed"],TYPO3.lang["mess.refresh_login_emptyPassword"]),void n.focus();l&&(a.val(l),n.val(""));const d={login_status:"login"};i.each(o.serializeArray(),(function(e,o){d[o.name]=o.value})),new s(o.attr("action")).post(d).then(async e=>{(await e.resolve()).login.success?this.hideLoginForm():(t.error(TYPO3.lang["mess.refresh_login_failed"],TYPO3.lang["mess.refresh_login_failed_message"]),n.focus())})},this.checkActiveSession=()=>{i.getJSON(TYPO3.settings.ajaxUrls.login_timedout,[],e=>{e.login.locked?this.backendIsLocked||(this.backendIsLocked=!0,this.showBackendLockedModal()):this.backendIsLocked&&(this.backendIsLocked=!1,this.hideBackendLockedModal()),this.backendIsLocked||(e.login.timed_out||e.login.will_time_out)&&(e.login.timed_out?this.showLoginForm():this.showTimeoutModal())})}}initialize(){this.initializeTimeoutModal(),this.initializeBackendLockedModal(),this.initializeLoginForm(),this.startTask(),"https:"===document.location.protocol&&"undefined"!=typeof Notification&&"granted"!==Notification.permission&&Notification.requestPermission()}startTask(){if(null!==this.intervalId)return;let e=1e3*this.intervalTime;this.intervalId=setInterval(this.checkActiveSession,e)}stopTask(){clearInterval(this.intervalId),this.intervalId=null}setIntervalTime(e){this.intervalTime=Math.min(e,86400)}setLogoutUrl(e){this.logoutUrl=e}setLoginFramesetUrl(e){this.loginFramesetUrl=e}showTimeoutModal(){this.isTimingOut=!0,this.$timeoutModal.modal(this.options.modalConfig),this.fillProgressbar(this.$timeoutModal),"https:"===document.location.protocol&&"undefined"!=typeof Notification&&"granted"===Notification.permission&&document.hidden&&(this.webNotification=new Notification(TYPO3.lang["mess.login_about_to_expire_title"],{body:TYPO3.lang["mess.login_about_to_expire"],icon:"/typo3/sysext/backend/Resources/Public/Images/Logo.png"}),this.webNotification.onclick=()=>{window.focus()})}hideTimeoutModal(){this.isTimingOut=!1,this.$timeoutModal.modal("hide"),"undefined"!=typeof Notification&&null!==this.webNotification&&this.webNotification.close()}showBackendLockedModal(){this.$backendLockedModal.modal(this.options.modalConfig)}hideBackendLockedModal(){this.$backendLockedModal.modal("hide")}showLoginForm(){new s(TYPO3.settings.ajaxUrls.logout).get().then(()=>{TYPO3.configuration.showRefreshLoginPopup?this.showLoginPopup():this.$loginForm.modal(this.options.modalConfig)})}showLoginPopup(){const e=window.open(this.loginFramesetUrl,"relogin_"+Math.random().toString(16).slice(2),"height=450,width=700,status=0,menubar=0,location=1");e&&e.focus()}hideLoginForm(){this.$loginForm.modal("hide")}initializeBackendLockedModal(){this.$backendLockedModal=this.generateModal(n.lockedModal),this.$backendLockedModal.find(".modal-header h4").text(TYPO3.lang["mess.please_wait"]),this.$backendLockedModal.find(".modal-body").append(i("<p />").text(TYPO3.lang["mess.be_locked"])),this.$backendLockedModal.find(".modal-footer").remove(),i("body").append(this.$backendLockedModal)}initializeTimeoutModal(){this.$timeoutModal=this.generateModal(n.loginrefresh),this.$timeoutModal.addClass("modal-severity-notice"),this.$timeoutModal.find(".modal-header h4").text(TYPO3.lang["mess.login_about_to_expire_title"]),this.$timeoutModal.find(".modal-body").append(i("<p />").text(TYPO3.lang["mess.login_about_to_expire"]),i("<div />",{class:"progress"}).append(i("<div />",{class:"progress-bar progress-bar-warning progress-bar-striped active",role:"progressbar","aria-valuemin":"0","aria-valuemax":"100"}).append(i("<span />",{class:"sr-only"})))),this.$timeoutModal.find(".modal-footer").append(i("<button />",{class:"btn btn-default","data-action":"logout"}).text(TYPO3.lang["mess.refresh_login_logout_button"]).on("click",()=>{top.location.href=this.logoutUrl}),i("<button />",{class:"btn btn-primary t3js-active","data-action":"refreshSession"}).text(TYPO3.lang["mess.refresh_login_refresh_button"]).on("click",()=>{new s(TYPO3.settings.ajaxUrls.login_timedout).get().then(()=>{this.hideTimeoutModal()})})),this.registerDefaultModalEvents(this.$timeoutModal),i("body").append(this.$timeoutModal)}initializeLoginForm(){if(TYPO3.configuration.showRefreshLoginPopup)return;this.$loginForm=this.generateModal(n.loginFormModal),this.$loginForm.addClass("modal-notice");let o=String(TYPO3.lang["mess.refresh_login_title"]).replace("%s",TYPO3.configuration.username);this.$loginForm.find(".modal-header h4").text(o),this.$loginForm.find(".modal-body").append(i("<p />").text(TYPO3.lang["mess.login_expired"]),i("<form />",{id:"beLoginRefresh",method:"POST",action:TYPO3.settings.ajaxUrls.login}).append(i("<div />",{class:"form-group"}).append(i("<input />",{type:"password",name:"p_field",autofocus:"autofocus",class:"form-control",placeholder:TYPO3.lang["mess.refresh_login_password"],"data-rsa-encryption":"t3-loginrefres-userident"})),i("<input />",{type:"hidden",name:"username",value:TYPO3.configuration.username}),i("<input />",{type:"hidden",name:"userident",id:"t3-loginrefres-userident"}))),this.$loginForm.find(".modal-footer").append(i("<a />",{href:this.logoutUrl,class:"btn btn-default"}).text(TYPO3.lang["mess.refresh_exit_button"]),i("<button />",{type:"button",class:"btn btn-primary","data-action":"refreshSession"}).text(TYPO3.lang["mess.refresh_login_button"]).on("click",()=>{this.$loginForm.find("form").submit()})),this.registerDefaultModalEvents(this.$loginForm).on("submit",this.submitForm),i("body").append(this.$loginForm),e.specified("TYPO3/CMS/Rsaauth/RsaEncryptionModule")&&e(["TYPO3/CMS/Rsaauth/RsaEncryptionModule"],(function(e){e.registerForm(i("#beLoginRefresh").get(0))}))}generateModal(e){return i("<div />",{id:e,class:"t3js-modal "+e+" modal modal-type-default modal-severity-notice modal-style-light modal-size-small fade"}).append(i("<div />",{class:"modal-dialog"}).append(i("<div />",{class:"modal-content"}).append(i("<div />",{class:"modal-header"}).append(i("<h4 />",{class:"modal-title"})),i("<div />",{class:"modal-body"}),i("<div />",{class:"modal-footer"}))))}fillProgressbar(e){if(!this.isTimingOut)return;let o=0;const i=e.find(".progress-bar"),t=i.children(".sr-only"),s=setInterval(()=>{const e=o>=100;!this.isTimingOut||e?(clearInterval(s),e&&(this.hideTimeoutModal(),this.showLoginForm()),o=0):o+=1;const n=o+"%";i.css("width",n),t.text(n)},300)}registerDefaultModalEvents(e){return e.on("hidden.bs.modal",()=>{this.startTask()}).on("shown.bs.modal",()=>{this.stopTask(),this.$timeoutModal.find(".modal-footer .t3js-active").first().focus()}),e}}let l;try{window.opener&&window.opener.TYPO3&&window.opener.TYPO3.LoginRefresh&&(l=window.opener.TYPO3.LoginRefresh),parent&&parent.window.TYPO3&&parent.window.TYPO3.LoginRefresh&&(l=parent.window.TYPO3.LoginRefresh),top&&top.TYPO3&&top.TYPO3.LoginRefresh&&(l=top.TYPO3.LoginRefresh)}catch(e){}return l||(l=new a,"undefined"!=typeof TYPO3&&(TYPO3.LoginRefresh=l)),l})); \ 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 014095779a69..4e5f1c56bb65 100644 --- a/typo3/sysext/backend/Resources/Public/JavaScript/ModuleMenu.js +++ b/typo3/sysext/backend/Resources/Public/JavaScript/ModuleMenu.js @@ -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 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?(e.includes("?")?"&":"?")+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?(e.includes("?")?"&":"?")+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 +define(["require","exports","./Enum/Viewport/ScaffoldIdentifier","jquery","./Storage/Persistent","./Viewport","./Event/ClientRequest","./Event/TriggerRequest","TYPO3/CMS/Core/Ajax/AjaxRequest"],(function(e,t,n,o,a,i,d,r,s){"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(){new s(TYPO3.settings.ajaxUrls.modulemenu).get().then(async e=>{const t=await e.resolve();document.getElementById("menu").outerHTML=t.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?(e.includes("?")?"&":"?")+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?(e.includes("?")?"&":"?")+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 diff --git a/typo3/sysext/backend/Resources/Public/JavaScript/Viewport/Topbar.js b/typo3/sysext/backend/Resources/Public/JavaScript/Viewport/Topbar.js index abb92161d4c3..f654aac3dc7d 100644 --- a/typo3/sysext/backend/Resources/Public/JavaScript/Viewport/Topbar.js +++ b/typo3/sysext/backend/Resources/Public/JavaScript/Viewport/Topbar.js @@ -10,4 +10,4 @@ * * The TYPO3 project - inspiring people to share! */ -define(["require","exports","../Enum/Viewport/ScaffoldIdentifier","jquery","./Toolbar"],(function(r,e,t,o,a){"use strict";class i{constructor(){this.Toolbar=new a}refresh(){o.ajax(TYPO3.settings.ajaxUrls.topbar).done(r=>{o(i.topbarSelector).html(r.topbar),o(i.topbarSelector).trigger("t3-topbar-update")})}}return i.topbarSelector=t.ScaffoldIdentifierEnum.header,i})); \ No newline at end of file +define(["require","exports","../Enum/Viewport/ScaffoldIdentifier","./Toolbar","TYPO3/CMS/Core/Ajax/AjaxRequest"],(function(e,t,r,o,n){"use strict";class a{constructor(){this.Toolbar=new o}refresh(){new n(TYPO3.settings.ajaxUrls.topbar).get().then(async e=>{const t=await e.resolve(),r=document.querySelector(a.topbarSelector);null!==r&&(r.innerHTML=t.topbar,r.dispatchEvent(new Event("t3-topbar-update")))})}}return a.topbarSelector=r.ScaffoldIdentifierEnum.header,a})); \ No newline at end of file -- GitLab