Commit ede23aaa authored by Andreas Fernandez's avatar Andreas Fernandez Committed by Anja Leichsenring
Browse files

[TASK] Improve loops in TypeScript

This patch improves the loops in TypeScript by using `for (... of ...)`
and incorporating ES7 features as `Object.entries()` and
`Object.values()`.

Resolves: #89262
Releases: master
Change-Id: I4f4300a2e241bcd34494ae0b0d400e589ad702da
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/61653


Tested-by: default avatarTYPO3com <noreply@typo3.com>
Tested-by: Frank Nägler's avatarFrank Nägler <frank.naegler@typo3.org>
Tested-by: Anja Leichsenring's avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Frank Nägler's avatarFrank Nägler <frank.naegler@typo3.org>
Reviewed-by: Anja Leichsenring's avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
parent e531ddce
......@@ -53,10 +53,9 @@ class ContextMenu {
private static drawActionItem(item: MenuItem): string {
const attributes: { [key: string]: string } = item.additionalAttributes || {};
let attributesString = '';
for (let attribute in attributes) {
if (attributes.hasOwnProperty(attribute)) {
attributesString += ' ' + attribute + '="' + attributes[attribute] + '"';
}
for (const attribute of Object.entries(attributes)) {
const [k, v] = attribute;
attributesString += ' ' + k + '="' + v + '"';
}
return '<a class="list-group-item"'
......@@ -273,24 +272,21 @@ class ContextMenu {
*/
private drawMenu(items: MenuItems, level: number): string {
let elements: string = '';
for (let key in items) {
if (items.hasOwnProperty(key)) {
const item = items[key];
if (item.type === 'item') {
elements += ContextMenu.drawActionItem(item);
} else if (item.type === 'divider') {
elements += '<a class="list-group-item list-group-item-divider"></a>';
} else if (item.type === 'submenu' || item.childItems) {
elements += '<a class="list-group-item list-group-item-submenu">'
+ '<span class="list-group-item-icon">' + item.icon + '</span> '
+ item.label + '&nbsp;&nbsp;<span class="fa fa-caret-right"></span>'
+ '</a>';
const childElements = this.drawMenu(item.childItems, 1);
elements += '<div class="context-menu contentMenu' + (level + 1) + '" style="display:none;">'
+ '<div class="list-group">' + childElements + '</div>'
+ '</div>';
}
for (let item of Object.values(items)) {
if (item.type === 'item') {
elements += ContextMenu.drawActionItem(item);
} else if (item.type === 'divider') {
elements += '<a class="list-group-item list-group-item-divider"></a>';
} else if (item.type === 'submenu' || item.childItems) {
elements += '<a class="list-group-item list-group-item-submenu">'
+ '<span class="list-group-item-icon">' + item.icon + '</span> '
+ item.label + '&nbsp;&nbsp;<span class="fa fa-caret-right"></span>'
+ '</a>';
const childElements = this.drawMenu(item.childItems, 1);
elements += '<div class="context-menu contentMenu' + (level + 1) + '" style="display:none;">'
+ '<div class="list-group">' + childElements + '</div>'
+ '</div>';
}
}
return elements;
......
......@@ -71,8 +71,8 @@ class DocumentSaveActions {
const $elem = $('<input />').attr('type', 'hidden').attr('name', name).attr('value', value);
// Run any preSubmit callbacks
for (let i = 0; i < this.preSubmitCallbacks.length; ++i) {
this.preSubmitCallbacks[i](e);
for (let callback of this.preSubmitCallbacks) {
callback(e);
if (e.isPropagationStopped()) {
preventExec = false;
......
......@@ -1028,9 +1028,9 @@ class InlineControlContainer {
if (uniqueValueField !== null) {
const selectedValue = uniqueValueField.options[uniqueValueField.selectedIndex].value;
for (let i = 0; i < values.length; i++) {
if (values[i] !== selectedValue) {
InlineControlContainer.removeSelectOptionByValue(uniqueValueField, values[i]);
for (let value of values) {
if (value !== selectedValue) {
InlineControlContainer.removeSelectOptionByValue(uniqueValueField, value);
}
}
}
......@@ -1060,8 +1060,8 @@ class InlineControlContainer {
if (selectorElement !== null) {
// remove all items from the new select-item which are already used in other children
if (uniqueValueField !== null) {
for (let i = 0; i < values.length; i++) {
InlineControlContainer.removeSelectOptionByValue(uniqueValueField, values[i]);
for (let value of values) {
InlineControlContainer.removeSelectOptionByValue(uniqueValueField, value);
}
// set the selected item automatically to the first of the remaining items if no selector is used
if (!unique.selector) {
......@@ -1071,8 +1071,8 @@ class InlineControlContainer {
this.handleChangedField(uniqueValueField, this.container.dataset.objectGroup + '[' + recordUid + ']');
}
}
for (let j = 0; j < values.length; j++) {
InlineControlContainer.removeSelectOptionByValue(uniqueValueField, values[j]);
for (let value of values) {
InlineControlContainer.removeSelectOptionByValue(uniqueValueField, value);
}
if (typeof unique.used.length !== 'undefined') {
unique.used = {};
......@@ -1085,11 +1085,11 @@ class InlineControlContainer {
// remove the newly used item from each select-field of the child records
if (formField !== null && InlineControlContainer.selectOptionValueExists(selectorElement, selectedValue)) {
const records = Utility.trimExplode(',', (<HTMLInputElement>formField).value);
for (let k = 0; k < records.length; k++) {
for (let record of records) {
uniqueValueField = <HTMLSelectElement>document.querySelector(
'[name="data[' + unique.table + '][' + records[k] + '][' + unique.field + ']"]',
'[name="data[' + unique.table + '][' + record + '][' + unique.field + ']"]',
);
if (uniqueValueField !== null && records[k] !== recordUid) {
if (uniqueValueField !== null && record !== recordUid) {
InlineControlContainer.removeSelectOptionByValue(uniqueValueField, selectedValue);
}
}
......@@ -1145,9 +1145,9 @@ class InlineControlContainer {
const records = Utility.trimExplode(',', formField.value);
let uniqueValueField;
for (let i = 0; i < records.length; i++) {
for (let record of records) {
uniqueValueField = <HTMLSelectElement>document.querySelector(
'[name="data[' + unique.table + '][' + records[i] + '][' + unique.field + ']"]',
'[name="data[' + unique.table + '][' + record + '][' + unique.field + ']"]',
);
if (uniqueValueField !== null && uniqueValueField !== srcElement) {
InlineControlContainer.removeSelectOptionByValue(uniqueValueField, srcElement.value);
......
......@@ -104,16 +104,14 @@ class Utility {
public static convertFormToObject(form: HTMLFormElement): { [key: string]: any } {
const obj: { [key: string]: any } = {};
const elements = form.querySelectorAll('input, select, textarea');
for (let i = 0; i < elements.length; ++i ) {
const element = <HTMLInputElement|HTMLSelectElement|HTMLTextAreaElement>(elements[i]);
form.querySelectorAll('input, select, textarea').forEach((element: HTMLInputElement|HTMLSelectElement|HTMLTextAreaElement): void => {
const name = element.name;
const value = element.value;
if (name) {
obj[name] = value;
}
}
});
return obj;
}
......
......@@ -273,8 +273,7 @@ class Wizard {
let slides = '<div class="carousel slide" data-ride="carousel" data-interval="false">'
+ '<div class="carousel-inner" role="listbox">';
for (let i = 0; i < this.setup.slides.length; ++i) {
let currentSlide: Slide = this.setup.slides[i];
for (let currentSlide of Object.values(this.setup.slides)) {
let slideContent = currentSlide.content;
if (typeof slideContent === 'object') {
......
......@@ -45,12 +45,11 @@ class ExtensionManager {
private static getUrlVars(): any {
let vars: any = [];
let hash: Array<string>;
let hashes: Array<string> = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for (let i = 0; i < hashes.length; i++) {
hash = hashes[i].split('=');
vars.push(hash[0]);
vars[hash[0]] = hash[1];
for (let hash of hashes) {
const [k, v] = hash.split('=');
vars.push(k);
vars[k] = v;
}
return vars;
}
......
......@@ -510,8 +510,8 @@ class LanguagePacks extends AbstractInteractableModule {
private renderNotifications(): void {
const $notificationBox: JQuery = this.getNotificationBox();
for (let i = 0; i < this.notifications.length; ++i) {
$notificationBox.append(this.notifications[i]);
for (let notification of this.notifications) {
$notificationBox.append(notification);
}
this.notifications = [];
}
......
......@@ -220,8 +220,8 @@ class UpgradeDocs extends AbstractInteractableModule {
const andString = andTags.join('');
const tags = [];
if (orTags.length) {
for (let i = 0; i < orTags.length; i++) {
tags.push(andString + orTags[i]);
for (let orTag of orTags) {
tags.push(andString + orTag);
}
} else {
tags.push(andString);
......
......@@ -116,8 +116,8 @@ class Selector {
}
});
if (selectedItems.length > 0) {
for (let i = 0; i < selectedItems.length; i++) {
BrowseFiles.File.insertElement(selectedItems[i]);
for (let selectedItem of selectedItems) {
BrowseFiles.File.insertElement(selectedItem);
}
}
ElementBrowser.focusOpenerAndClose();
......
......@@ -89,8 +89,8 @@ class ElementBrowser {
public executeFunctionByName(functionName: string, context: any, ...args: Array<any>): any {
const namespaces = functionName.split('.');
const func = namespaces.pop();
for (let i = 0; i < namespaces.length; i++) {
context = context[namespaces[i]];
for (let namespace of namespaces) {
context = context[namespace];
}
return context[func].apply(context, args);
}
......
......@@ -70,17 +70,15 @@ class LinkBrowser {
*/
public encodeGetParameters(obj: LinkAttributes, prefix: string, url: string): string {
const str = [];
for (let p in obj) {
if (obj.hasOwnProperty(p)) {
const k: string = prefix ? prefix + '[' + p + ']' : p;
const v: any = obj[p];
if (!url.includes(k + '=')) {
str.push(
typeof v === 'object'
? this.encodeGetParameters(v, k, url)
: encodeURIComponent(k) + '=' + encodeURIComponent(v),
);
}
for (const entry of Object.entries(obj)) {
const [p, v] = entry;
const k: string = prefix ? prefix + '[' + p + ']' : p;
if (!url.includes(k + '=')) {
str.push(
typeof v === 'object'
? this.encodeGetParameters(v, k, url)
: encodeURIComponent(k) + '=' + encodeURIComponent(v),
);
}
}
return '&' + str.join('&');
......
......@@ -81,11 +81,11 @@ class Backend extends Workspaces {
private static generateDiffView(diff: Array<any>): JQuery {
const $diff = $('<div />', {class: 'diff'});
for (let i = 0; i < diff.length; ++i) {
for (let currentDiff of diff) {
$diff.append(
$('<div />', {class: 'diff-item'}).append(
$('<div />', {class: 'diff-item-title'}).text(diff[i].label),
$('<div />', {class: 'diff-item-result diff-item-result-inline'}).html(diff[i].content),
$('<div />', {class: 'diff-item-title'}).text(currentDiff.label),
$('<div />', {class: 'diff-item-result diff-item-result-inline'}).html(currentDiff.content),
),
);
}
......@@ -101,26 +101,26 @@ class Backend extends Workspaces {
private static generateCommentView(comments: Array<any>): JQuery {
const $comments = $('<div />');
for (let i = 0; i < comments.length; ++i) {
for (let comment of comments) {
const $panel = $('<div />', {class: 'panel panel-default'});
if (comments[i].user_comment.length > 0) {
if (comment.user_comment.length > 0) {
$panel.append(
$('<div />', {class: 'panel-body'}).html(comments[i].user_comment),
$('<div />', {class: 'panel-body'}).html(comment.user_comment),
);
}
$panel.append(
$('<div />', {class: 'panel-footer'}).append(
$('<span />', {class: 'label label-success'}).text(comments[i].stage_title),
$('<span />', {class: 'label label-info'}).text(comments[i].tstamp),
$('<span />', {class: 'label label-success'}).text(comment.stage_title),
$('<span />', {class: 'label label-info'}).text(comment.tstamp),
),
);
$comments.append(
$('<div />', {class: 'media'}).append(
$('<div />', {class: 'media-left text-center'}).text(comments[i].user_username).prepend(
$('<div />').html(comments[i].user_avatar),
$('<div />', {class: 'media-left text-center'}).text(comment.user_username).prepend(
$('<div />').html(comment.user_avatar),
),
$('<div />', {class: 'media-body'}).append($panel),
),
......@@ -139,22 +139,22 @@ class Backend extends Workspaces {
private static generateHistoryView(data: Array<any>): JQuery {
const $history = $('<div />');
for (let i = 0; i < data.length; ++i) {
for (let currentData of data) {
const $panel = $('<div />', {class: 'panel panel-default'});
let $diff;
if (typeof data[i].differences === 'object') {
if (data[i].differences.length === 0) {
if (typeof currentData.differences === 'object') {
if (currentData.differences.length === 0) {
// Somehow here are no differences. What a pity, skip that record
continue;
}
$diff = $('<div />', {class: 'diff'});
for (let j = 0; j < data[i].differences.length; ++j) {
for (let j = 0; j < currentData.differences.length; ++j) {
$diff.append(
$('<div />', {class: 'diff-item'}).append(
$('<div />', {class: 'diff-item-title'}).text(data[i].differences[j].label),
$('<div />', {class: 'diff-item-result diff-item-result-inline'}).html(data[i].differences[j].html),
$('<div />', {class: 'diff-item-title'}).text(currentData.differences[j].label),
$('<div />', {class: 'diff-item-result diff-item-result-inline'}).html(currentData.differences[j].html),
),
);
}
......@@ -164,19 +164,19 @@ class Backend extends Workspaces {
);
} else {
$panel.append(
$('<div />', {class: 'panel-body'}).text(data[i].differences),
$('<div />', {class: 'panel-body'}).text(currentData.differences),
);
}
$panel.append(
$('<div />', {class: 'panel-footer'}).append(
$('<span />', {class: 'label label-info'}).text(data[i].datetime),
$('<span />', {class: 'label label-info'}).text(currentData.datetime),
),
);
$history.append(
$('<div />', {class: 'media'}).append(
$('<div />', {class: 'media-left text-center'}).text(data[i].user).prepend(
$('<div />').html(data[i].user_avatar),
$('<div />', {class: 'media-left text-center'}).text(currentData.user).prepend(
$('<div />').html(currentData.user_avatar),
),
$('<div />', {class: 'media-body'}).append($panel),
),
......
......@@ -41,9 +41,7 @@ export default class Workspaces {
),
);
for (let i = 0; i < result.sendMailTo.length; ++i) {
const recipient = result.sendMailTo[i];
for (const recipient of result.sendMailTo) {
$form.append(
$('<div />', {class: 'checkbox'}).append(
$('<label />').text(recipient.label).prepend(
......
......@@ -10,4 +10,4 @@
*
* The TYPO3 project - inspiring people to share!
*/
define(["require","exports","jquery","./ContextMenuActions"],function(t,e,i,n){"use strict";class s{constructor(){this.mousePos={X:null,Y:null},this.delayContextMenuHide=!1,this.record={uid:null,table:null},this.storeMousePositionEvent=(t=>{this.mousePos={X:t.pageX,Y:t.pageY},this.mouseOutFromMenu("#contentMenu0"),this.mouseOutFromMenu("#contentMenu1")}),this.initializeEvents()}static drawActionItem(t){const e=t.additionalAttributes||{};let i="";for(let t in e)e.hasOwnProperty(t)&&(i+=" "+t+'="'+e[t]+'"');return'<a class="list-group-item" data-callback-action="'+t.callbackAction+'"'+i+'><span class="list-group-item-icon">'+t.icon+"</span> "+t.label+"</a>"}static within(t,e,i){const n=t.offset();return i>=n.top&&i<n.top+t.height()&&e>=n.left&&e<n.left+t.width()}static initializeContextMenuContainer(){if(0===i("#contentMenu0").length){const t='<div id="contentMenu0" class="context-menu"></div><div id="contentMenu1" class="context-menu" style="display: block;"></div>';i("body").append(t)}}initializeEvents(){i(document).on("click contextmenu",".t3js-contextmenutrigger",t=>{const e=i(t.currentTarget);e.prop("onclick")&&"click"===t.type||(t.preventDefault(),this.show(e.data("table"),e.data("uid"),e.data("context"),e.data("iteminfo"),e.data("parameters")))}),i(document).on("mousemove",this.storeMousePositionEvent)}show(t,e,i,n,s){this.record={table:t,uid:e};let o="";void 0!==t&&(o+="table="+encodeURIComponent(t)),void 0!==e&&(o+=(o.length>0?"&":"")+"uid="+e),void 0!==i&&(o+=(o.length>0?"&":"")+"context="+i),void 0!==n&&(o+=(o.length>0?"&":"")+"enDisItems="+n),void 0!==s&&(o+=(o.length>0?"&":"")+"addParams="+s),this.fetch(o)}fetch(t){let e=TYPO3.settings.ajaxUrls.contextmenu;t&&(e+=(e.includes("?")?"&":"?")+t),i.ajax(e).done(t=>{void 0!==t&&Object.keys(t).length>0&&this.populateData(t,0)})}populateData(e,o){s.initializeContextMenuContainer();const l=i("#contentMenu"+o);if(l.length&&(0===o||i("#contentMenu"+(o-1)).is(":visible"))){const s=this.drawMenu(e,o);l.html('<div class="list-group">'+s+"</div>"),i("a.list-group-item",l).click(e=>{e.preventDefault();const s=i(e.currentTarget);if(s.hasClass("list-group-item-submenu"))return void this.openSubmenu(o,s);const l=s.data("callback-action"),a=s.data("callback-module");s.data("callback-module")?t([a],t=>{t[l].bind(s)(this.record.table,this.record.uid)}):n&&"function"==typeof n[l]?n[l].bind(s)(this.record.table,this.record.uid):console.log("action: "+l+" not found"),this.hideAll()}),l.css(this.getPosition(l)).show()}}openSubmenu(t,e){const n=i("#contentMenu"+(t+1)).html("");e.next().find(".list-group").clone(!0).appendTo(n),n.css(this.getPosition(n)).show()}getPosition(t){let e=this.mousePos.X,n=this.mousePos.Y;const s=i(window).width()-20,o=i(window).height(),l=t.width(),a=t.height(),c=this.mousePos.X-i(document).scrollLeft(),u=this.mousePos.Y-i(document).scrollTop();return o-a<u&&(u>a?n-=a-10:n+=o-a-u),s-l<c&&(c>l?e-=l-10:s-l-c<i(document).scrollLeft()?e=i(document).scrollLeft():e+=s-l-c),{left:e+"px",top:n+"px"}}drawMenu(t,e){let i="";for(let n in t)if(t.hasOwnProperty(n)){const o=t[n];if("item"===o.type)i+=s.drawActionItem(o);else if("divider"===o.type)i+='<a class="list-group-item list-group-item-divider"></a>';else if("submenu"===o.type||o.childItems){i+='<a class="list-group-item list-group-item-submenu"><span class="list-group-item-icon">'+o.icon+"</span> "+o.label+'&nbsp;&nbsp;<span class="fa fa-caret-right"></span></a>',i+='<div class="context-menu contentMenu'+(e+1)+'" style="display:none;"><div class="list-group">'+this.drawMenu(o.childItems,1)+"</div></div>"}}return i}mouseOutFromMenu(t){const e=i(t);e.length>0&&e.is(":visible")&&!s.within(e,this.mousePos.X,this.mousePos.Y)?this.hide(t):e.length>0&&e.is(":visible")&&(this.delayContextMenuHide=!0)}hide(t){this.delayContextMenuHide=!1,window.setTimeout(()=>{this.delayContextMenuHide||i(t).hide()},500)}hideAll(){this.hide("#contentMenu0"),this.hide("#contentMenu1")}}return new s});
\ No newline at end of file
define(["require","exports","jquery","./ContextMenuActions"],function(t,e,i,n){"use strict";class s{constructor(){this.mousePos={X:null,Y:null},this.delayContextMenuHide=!1,this.record={uid:null,table:null},this.storeMousePositionEvent=(t=>{this.mousePos={X:t.pageX,Y:t.pageY},this.mouseOutFromMenu("#contentMenu0"),this.mouseOutFromMenu("#contentMenu1")}),this.initializeEvents()}static drawActionItem(t){const e=t.additionalAttributes||{};let i="";for(const t of Object.entries(e)){const[e,n]=t;i+=" "+e+'="'+n+'"'}return'<a class="list-group-item" data-callback-action="'+t.callbackAction+'"'+i+'><span class="list-group-item-icon">'+t.icon+"</span> "+t.label+"</a>"}static within(t,e,i){const n=t.offset();return i>=n.top&&i<n.top+t.height()&&e>=n.left&&e<n.left+t.width()}static initializeContextMenuContainer(){if(0===i("#contentMenu0").length){const t='<div id="contentMenu0" class="context-menu"></div><div id="contentMenu1" class="context-menu" style="display: block;"></div>';i("body").append(t)}}initializeEvents(){i(document).on("click contextmenu",".t3js-contextmenutrigger",t=>{const e=i(t.currentTarget);e.prop("onclick")&&"click"===t.type||(t.preventDefault(),this.show(e.data("table"),e.data("uid"),e.data("context"),e.data("iteminfo"),e.data("parameters")))}),i(document).on("mousemove",this.storeMousePositionEvent)}show(t,e,i,n,s){this.record={table:t,uid:e};let o="";void 0!==t&&(o+="table="+encodeURIComponent(t)),void 0!==e&&(o+=(o.length>0?"&":"")+"uid="+e),void 0!==i&&(o+=(o.length>0?"&":"")+"context="+i),void 0!==n&&(o+=(o.length>0?"&":"")+"enDisItems="+n),void 0!==s&&(o+=(o.length>0?"&":"")+"addParams="+s),this.fetch(o)}fetch(t){let e=TYPO3.settings.ajaxUrls.contextmenu;t&&(e+=(e.includes("?")?"&":"?")+t),i.ajax(e).done(t=>{void 0!==t&&Object.keys(t).length>0&&this.populateData(t,0)})}populateData(e,o){s.initializeContextMenuContainer();const l=i("#contentMenu"+o);if(l.length&&(0===o||i("#contentMenu"+(o-1)).is(":visible"))){const s=this.drawMenu(e,o);l.html('<div class="list-group">'+s+"</div>"),i("a.list-group-item",l).click(e=>{e.preventDefault();const s=i(e.currentTarget);if(s.hasClass("list-group-item-submenu"))return void this.openSubmenu(o,s);const l=s.data("callback-action"),a=s.data("callback-module");s.data("callback-module")?t([a],t=>{t[l].bind(s)(this.record.table,this.record.uid)}):n&&"function"==typeof n[l]?n[l].bind(s)(this.record.table,this.record.uid):console.log("action: "+l+" not found"),this.hideAll()}),l.css(this.getPosition(l)).show()}}openSubmenu(t,e){const n=i("#contentMenu"+(t+1)).html("");e.next().find(".list-group").clone(!0).appendTo(n),n.css(this.getPosition(n)).show()}getPosition(t){let e=this.mousePos.X,n=this.mousePos.Y;const s=i(window).width()-20,o=i(window).height(),l=t.width(),a=t.height(),c=this.mousePos.X-i(document).scrollLeft(),u=this.mousePos.Y-i(document).scrollTop();return o-a<u&&(u>a?n-=a-10:n+=o-a-u),s-l<c&&(c>l?e-=l-10:s-l-c<i(document).scrollLeft()?e=i(document).scrollLeft():e+=s-l-c),{left:e+"px",top:n+"px"}}drawMenu(t,e){let i="";for(let n of Object.values(t))if("item"===n.type)i+=s.drawActionItem(n);else if("divider"===n.type)i+='<a class="list-group-item list-group-item-divider"></a>';else if("submenu"===n.type||n.childItems){i+='<a class="list-group-item list-group-item-submenu"><span class="list-group-item-icon">'+n.icon+"</span> "+n.label+'&nbsp;&nbsp;<span class="fa fa-caret-right"></span></a>',i+='<div class="context-menu contentMenu'+(e+1)+'" style="display:none;"><div class="list-group">'+this.drawMenu(n.childItems,1)+"</div></div>"}return i}mouseOutFromMenu(t){const e=i(t);e.length>0&&e.is(":visible")&&!s.within(e,this.mousePos.X,this.mousePos.Y)?this.hide(t):e.length>0&&e.is(":visible")&&(this.delayContextMenuHide=!0)}hide(t){this.delayContextMenuHide=!1,window.setTimeout(()=>{this.delayContextMenuHide||i(t).hide()},500)}hideAll(){this.hide("#contentMenu0"),this.hide("#contentMenu1")}}return new s});
\ No newline at end of file
......@@ -10,4 +10,4 @@
*
* The TYPO3 project - inspiring people to share!
*/
define(["require","exports","jquery","./Icons"],function(t,e,a,n){"use strict";class r{constructor(){this.preSubmitCallbacks=[],a(()=>{this.initializeSaveHandling()})}static getInstance(){return null===r.instance&&(r.instance=new r),r.instance}addPreSubmitCallback(t){if("function"!=typeof t)throw"callback must be a function.";this.preSubmitCallbacks.push(t)}initializeSaveHandling(){let t=!1;const e=["button[form]",'button[name^="_save"]','a[data-name^="_save"]','button[name="CMD"][value^="save"]','a[data-name="CMD"][data-value^="save"]'].join(",");a(".t3js-module-docheader").on("click",e,e=>{if(!t){t=!0;const r=a(e.currentTarget),i=r.attr("form")||r.attr("data-form")||null,s=i?a("#"+i):r.closest("form"),l=r.data("name")||e.currentTarget.getAttribute("name"),u=r.data("value")||e.currentTarget.getAttribute("value"),o=a("<input />").attr("type","hidden").attr("name",l).attr("value",u);for(let a=0;a<this.preSubmitCallbacks.length;++a)if(this.preSubmitCallbacks[a](e),e.isPropagationStopped())return t=!1,!1;s.append(o),s.on("submit",()=>{if(s.find(".has-error").length>0)return t=!1,!1;let e;const a=r.closest(".t3js-splitbutton");return a.length>0?(a.find("button").prop("disabled",!0),e=a.children().first()):(r.prop("disabled",!0),e=r),n.getIcon("spinner-circle-dark",n.sizes.small).done(t=>{e.find(".t3js-icon").replaceWith(t)}),!0}),"A"!==e.currentTarget.tagName&&!r.attr("form")||e.isDefaultPrevented()||(s.find('[name="doSave"]').val("1"),s.submit(),e.preventDefault())}return!0})}}return r.instance=null,r});
\ No newline at end of file
define(["require","exports","jquery","./Icons"],function(t,e,a,n){"use strict";class r{constructor(){this.preSubmitCallbacks=[],a(()=>{this.initializeSaveHandling()})}static getInstance(){return null===r.instance&&(r.instance=new r),r.instance}addPreSubmitCallback(t){if("function"!=typeof t)throw"callback must be a function.";this.preSubmitCallbacks.push(t)}initializeSaveHandling(){let t=!1;const e=["button[form]",'button[name^="_save"]','a[data-name^="_save"]','button[name="CMD"][value^="save"]','a[data-name="CMD"][data-value^="save"]'].join(",");a(".t3js-module-docheader").on("click",e,e=>{if(!t){t=!0;const r=a(e.currentTarget),i=r.attr("form")||r.attr("data-form")||null,s=i?a("#"+i):r.closest("form"),l=r.data("name")||e.currentTarget.getAttribute("name"),u=r.data("value")||e.currentTarget.getAttribute("value"),o=a("<input />").attr("type","hidden").attr("name",l).attr("value",u);for(let a of this.preSubmitCallbacks)if(a(e),e.isPropagationStopped())return t=!1,!1;s.append(o),s.on("submit",()=>{if(s.find(".has-error").length>0)return t=!1,!1;let e;const a=r.closest(".t3js-splitbutton");return a.length>0?(a.find("button").prop("disabled",!0),e=a.children().first()):(r.prop("disabled",!0),e=r),n.getIcon("spinner-circle-dark",n.sizes.small).done(t=>{e.find(".t3js-icon").replaceWith(t)}),!0}),"A"!==e.currentTarget.tagName&&!r.attr("form")||e.isDefaultPrevented()||(s.find('[name="doSave"]').val("1"),s.submit(),e.preventDefault())}return!0})}}return r.instance=null,r});
\ No newline at end of file
......@@ -10,4 +10,4 @@
*
* The TYPO3 project - inspiring people to share!
*/
define(["require","exports"],function(t,e){"use strict";return class{static trimExplode(t,e){return e.split(t).map(t=>t.trim()).filter(t=>""!==t)}static intExplode(t,e,r=!1){return e.split(t).map(t=>parseInt(t,10)).filter(t=>!isNaN(t)||r&&0===t)}static isNumber(t){return!isNaN(parseFloat(t.toString()))&&isFinite(t)}static getParameterFromUrl(t,e){if("function"!=typeof t.split)return"";const r=t.split("?");let i="";if(r.length>=2){const t=r.join("?"),n=encodeURIComponent(e)+"=",s=t.split(/[&;]/g);for(let t=s.length;t-- >0;)if(-1!==s[t].lastIndexOf(n,0)){i=s[t].split("=")[1];break}}return i}static updateQueryStringParameter(t,e,r){const i=new RegExp("([?&])"+e+"=.*?(&|$)","i"),n=t.includes("?")?"&":"?";return t.match(i)?t.replace(i,"$1"+e+"="+r+"$2"):t+n+e+"="+r}static convertFormToObject(t){const e={},r=t.querySelectorAll("input, select, textarea");for(let t=0;t<r.length;++t){const i=r[t],n=i.name,s=i.value;n&&(e[n]=s)}return e}}});
\ No newline at end of file
define(["require","exports"],function(t,e){"use strict";return class{static trimExplode(t,e){return e.split(t).map(t=>t.trim()).filter(t=>""!==t)}static intExplode(t,e,r=!1){return e.split(t).map(t=>parseInt(t,10)).filter(t=>!isNaN(t)||r&&0===t)}static isNumber(t){return!isNaN(parseFloat(t.toString()))&&isFinite(t)}static getParameterFromUrl(t,e){if("function"!=typeof t.split)return"";const r=t.split("?");let i="";if(r.length>=2){const t=r.join("?"),n=encodeURIComponent(e)+"=",s=t.split(/[&;]/g);for(let t=s.length;t-- >0;)if(-1!==s[t].lastIndexOf(n,0)){i=s[t].split("=")[1];break}}return i}static updateQueryStringParameter(t,e,r){const i=new RegExp("([?&])"+e+"=.*?(&|$)","i"),n=t.includes("?")?"&":"?";return t.match(i)?t.replace(i,"$1"+e+"="+r+"$2"):t+n+e+"="+r}static convertFormToObject(t){const e={};return t.querySelectorAll("input, select, textarea").forEach(t=>{const r=t.name,i=t.value;r&&(e[r]=i)}),e}}});
\ No newline at end of file
......@@ -10,4 +10,4 @@
*
* The TYPO3 project - inspiring people to share!
*/
define(["require","exports","./Enum/Severity","jquery","./Modal","./Severity","./Icons"],function(e,t,s,i,a,r,l){"use strict";class n{constructor(){this.setup={slides:[],settings:{},forceSelection:!0,$carousel:null},this.originalSetup=i.extend(!0,{},this.setup)}set(e,t){return this.setup.settings[e]=t,this}addSlide(e,t,i="",a=s.SeverityEnum.info,r){const l={identifier:e,title:t,content:i,severity:a,callback:r};return this.setup.slides.push(l),this}addFinalProcessingSlide(e){return e||(e=(()=>{this.dismiss()})),l.getIcon("spinner-circle-dark",l.sizes.large,null,null).done(t=>{let s=i("<div />",{class:"text-center"}).append(t);this.addSlide("final-processing-slide",top.TYPO3.lang["wizard.processing.title"],s[0].outerHTML,r.info,e)})}show(){let e=this.generateSlides(),t=this.setup.slides[0];a.confirm(t.title,e,t.severity,[{text:top.TYPO3.lang["wizard.button.cancel"],active:!0,btnClass:"btn-default",name:"cancel",trigger:()=>{this.getComponent().trigger("wizard-dismiss")}},{text:top.TYPO3.lang["wizard.button.next"],btnClass:"btn-"+r.getCssClass(t.severity),name:"next"}]),this.setup.forceSelection&&this.lockNextStep(),this.addProgressBar(),this.initializeEvents(),this.getComponent().on("wizard-visible",()=>{this.runSlideCallback(t,this.setup.$carousel.find(".item").first())}).on("wizard-dismissed",()=>{this.setup=i.extend(!0,{},this.originalSetup)})}getComponent(){return null===this.setup.$carousel&&this.generateSlides(),this.setup.$carousel}dismiss(){a.dismiss()}lockNextStep(){let e=this.setup.$carousel.closest(".modal").find('button[name="next"]');return e.prop("disabled",!0),e}unlockNextStep(){let e=this.setup.$carousel.closest(".modal").find('button[name="next"]');return e.prop("disabled",!1),e}setForceSelection(e){this.setup.forceSelection=e}initializeEvents(){let e=this.setup.$carousel.closest(".modal"),t=e.find(".modal-title"),s=e.find(".modal-footer"),l=s.find('button[name="next"]');l.on("click",()=>{this.setup.$carousel.carousel("next")}),this.setup.$carousel.on("slide.bs.carousel",()=>{let i=this.setup.$carousel.data("currentSlide")+1,a=this.setup.$carousel.data("currentIndex")+1;t.text(this.setup.slides[a].title),this.setup.$carousel.data("currentSlide",i),this.setup.$carousel.data("currentIndex",a),i>=this.setup.$carousel.data("realSlideCount")?(e.find(".modal-header .close").remove(),s.slideUp()):s.find(".progress-bar").width(this.setup.$carousel.data("initialStep")*i+"%").text(top.TYPO3.lang["wizard.progress"].replace("{0}",i).replace("{1}",this.setup.$carousel.data("slideCount"))),l.removeClass("btn-"+r.getCssClass(this.setup.slides[a-1].severity)).addClass("btn-"+r.getCssClass(this.setup.slides[a].severity)),e.removeClass("modal-severity-"+r.getCssClass(this.setup.slides[a-1].severity)).addClass("modal-severity-"+r.getCssClass(this.setup.slides[a].severity))}).on("slid.bs.carousel",e=>{let t=this.setup.$carousel.data("currentIndex"),s=this.setup.slides[t];this.runSlideCallback(s,i(e.relatedTarget)),this.setup.forceSelection&&this.lockNextStep()});let n=this.getComponent();n.on("wizard-dismiss",this.dismiss),a.currentModal.on("hidden.bs.modal",()=>{n.trigger("wizard-dismissed")}).on("shown.bs.modal",()=>{n.trigger("wizard-visible")})}runSlideCallback(e,t){"function"==typeof e.callback&&e.callback(t,this.setup.settings,e.identifier)}addProgressBar(){let e,t=this.setup.$carousel.find(".item").length,s=Math.max(1,t),a=this.setup.$carousel.closest(".modal").find(".modal-footer");e=Math.round(100/s),this.setup.$carousel.data("initialStep",e).data("slideCount",s).data("realSlideCount",t).data("currentIndex",0).data("currentSlide",1),s>1&&a.prepend(i("<div />",{class:"progress"}).append(i("<div />",{role:"progressbar",class:"progress-bar","aria-valuemin":0,"aria-valuenow":e,"aria-valuemax":100}).width(e+"%").text(top.TYPO3.lang["wizard.progress"].replace("{0}","1").replace("{1}",s))))}generateSlides(){if(null!==this.setup.$carousel)return this.setup.$carousel;let e='<div class="carousel slide" data-ride="carousel" data-interval="false"><div class="carousel-inner" role="listbox">';for(let t=0;t<this.setup.slides.length;++t){let s=this.setup.slides[t],i=s.content;"object"==typeof i&&(i=i.html()),e+='<div class="item" data-slide="'+s.identifier+'">'+i+"</div>"}return e+="</div></div>",this.setup.$carousel=i(e),this.setup.$carousel.find(".item").first().addClass("active"),this.setup.$carousel}}let d;try{window.opener&&window.opener.TYPO3&&window.opener.TYPO3.Wizard&&(d=window.opener.TYPO3.Wizard),parent&&parent.window.TYPO3&&parent.window.TYPO3.Wizard&&(d=parent.window.TYPO3.Wizard),top&&top.TYPO3&&top.TYPO3.Wizard&&(d=top.TYPO3.Wizard)}catch(e){}return d||(d=new n,"undefined"!=typeof TYPO3&&(TYPO3.Wizard=d)),d});
\ No newline at end of file
define(["require","exports","./Enum/Severity","jquery","./Modal","./Severity","./Icons"],function(e,t,s,i,a,r,l){"use strict";class n{constructor(){this.setup={slides:[],settings:{},forceSelection:!0,$carousel:null},this.originalSetup=i.extend(!0,{},this.setup)}set(e,t){return this.setup.settings[e]=t,this}addSlide(e,t,i="",a=s.SeverityEnum.info,r){const l={identifier:e,title:t,content:i,severity:a,callback:r};return this.setup.slides.push(l),this}addFinalProcessingSlide(e){return e||(e=(()=>{this.dismiss()})),l.getIcon("spinner-circle-dark",l.sizes.large,null,null).done(t=>{let s=i("<div />",{class:"text-center"}).append(t);this.addSlide("final-processing-slide",top.TYPO3.lang["wizard.processing.title"],s[0].outerHTML,r.info,e)})}show(){let e=this.generateSlides(),t=this.setup.slides[0];a.confirm(t.title,e,t.severity,[{text:top.TYPO3.lang["wizard.button.cancel"],active:!0,btnClass:"btn-default",name:"cancel",trigger:()=>{this.getComponent().trigger("wizard-dismiss")}},{text:top.TYPO3.lang["wizard.button.next"],btnClass:"btn-"+r.getCssClass(t.severity),name:"next"}]),this.setup.forceSelection&&this.lockNextStep(),this.addProgressBar(),this.initializeEvents(),this.getComponent().on("wizard-visible",()=>{this.runSlideCallback(t,this.setup.$carousel.find(".item").first())}).on("wizard-dismissed",()=>{this.setup=i.extend(!0,{},this.originalSetup)})}getComponent(){return null===this.setup.$carousel&&this.generateSlides(),this.setup.$carousel}dismiss(){a.dismiss()}lockNextStep(){let e=this.setup.$carousel.closest(".modal").find('button[name="next"]');return e.prop("disabled",!0),e}unlockNextStep(){let e=this.setup.$carousel.closest(".modal").find('button[name="next"]');return e.prop("disabled",!1),e}setForceSelection(e){this.setup.forceSelection=e}initializeEvents(){let e=this.setup.$carousel.closest(".modal"),t=e.find(".modal-title"),s=e.find(".modal-footer"),l=s.find('button[name="next"]');l.on("click",()=>{this.setup.$carousel.carousel("next")}),this.setup.$carousel.on("slide.bs.carousel",()=>{let i=this.setup.$carousel.data("currentSlide")+1,a=this.setup.$carousel.data("currentIndex")+1;t.text(this.setup.slides[a].title),this.setup.$carousel.data("currentSlide",i),this.setup.$carousel.data("currentIndex",a),i>=this.setup.$carousel.data("realSlideCount")?(e.find(".modal-header .close").remove(),s.slideUp()):s.find(".progress-bar").width(this.setup.$carousel.data("initialStep")*i+"%").text(top.TYPO3.lang["wizard.progress"].replace("{0}",i).replace("{1}",this.setup.$carousel.data("slideCount"))),l.removeClass("btn-"+r.getCssClass(this.setup.slides[a-1].severity)).addClass("btn-"+r.getCssClass(this.setup.slides[a].severity)),e.removeClass("modal-severity-"+r.getCssClass(this.setup.slides[a-1].severity)).addClass("modal-severity-"+r.getCssClass(this.setup.slides[a].severity))}).on("slid.bs.carousel",e=>{let t=this.setup.$carousel.data("currentIndex"),s=this.setup.slides[t];this.runSlideCallback(s,i(e.relatedTarget)),this.setup.forceSelection&&this.lockNextStep()});let n=this.getComponent();n.on("wizard-dismiss",this.dismiss),a.currentModal.on("hidden.bs.modal",()=>{n.trigger("wizard-dismissed")}).on("shown.bs.modal",()=>{n.trigger("wizard-visible")})}runSlideCallback(e,t){"function"==typeof e.callback&&e.callback(t,this.setup.settings,e.identifier)}addProgressBar(){let e,t=this.setup.$carousel.find(".item").length,s=Math.max(1,t),a=this.setup.$carousel.closest(".modal").find(".modal-footer");e=Math.round(100/s),this.setup.$carousel.data("initialStep",e).data("slideCount",s).data("realSlideCount",t).data("currentIndex",0).data("currentSlide",1),s>1&&a.prepend(i("<div />",{class:"progress"}).append(i("<div />",{role:"progressbar",class:"progress-bar","aria-valuemin":0,"aria-valuenow":e,"aria-valuemax":100}).width(e+"%").text(top.TYPO3.lang["wizard.progress"].replace("{0}","1").replace("{1}",s))))}generateSlides(){if(null!==this.setup.$carousel)return this.setup.$carousel;let e='<div class="carousel slide" data-ride="carousel" data-interval="false"><div class="carousel-inner" role="listbox">';for(let t of Object.values(this.setup.slides)){let s=t.content;"object"==typeof s&&(s=s.html()),e+='<div class="item" data-slide="'+t.identifier+'">'+s+"</div>"}return e+="</div></div>",this.setup.$carousel=i(e),this.setup.$carousel.find(".item").first().addClass("active"),this.setup.$carousel}}let d;try{window.opener&&window.opener.TYPO3&&window.opener.TYPO3.Wizard&&(d=window.opener.TYPO3.Wizard),parent&&parent.window.TYPO3&&parent.window.TYPO3.Wizard&&(d=parent.window.TYPO3.Wizard),top&&top.TYPO3&&top.TYPO3.Wizard&&(d=top.TYPO3.Wizard)}catch(e){}return d||(d=new n,"undefined"!=typeof TYPO3&&(TYPO3.Wizard=d)),d});
\ No newline at end of file
......@@ -10,4 +10,4 @@
*
* The TYPO3 project - inspiring people to share!
*/
define(["require","exports","jquery","nprogress","TYPO3/CMS/Backend/Modal","TYPO3/CMS/Backend/Tooltip","TYPO3/CMS/Backend/Severity","TYPO3/CMS/Core/SecurityUtility","./Repository","./Update","./UploadForm","datatables","TYPO3/CMS/Backend/Input/Clearable"],function(e,t,n,a,i,o,r,s,l,c,d){"use strict";const p=new s;var u;!function(e){e.extensionlist="#typo3-extension-list",e.searchField="#Tx_Extensionmanager_extensionkey"}(u||(u={}));class m{constructor(){this.bindExtensionListActions=(()=>{n(".removeExtension").not(".transformed").each((e,t)=>{const a=n(t);a.data("href",a.attr("href")),a.attr("href","#"),a.addClass("transformed"),a.click(()=>{i.confirm(TYPO3.lang["extensionList.removalConfirmation.title"],TYPO3.lang["extensionList.removalConfirmation.question"],r.error,[{text:TYPO3.lang["button.cancel"],active:!0,btnClass:"btn-default",trigger:()=>{i.dismiss()}},{text:TYPO3.lang["button.remove"],btnClass:"btn-danger",trigger:()=>{this.removeExtensionFromDisk(a),i.dismiss()}}])})})}),n(()=>{n.fn.dataTableExt.oSort["extension-asc"]=((e,t)=>m.extensionCompare(e,t)),n.fn.dataTableExt.oSort["extension-desc"]=((e,t)=>{return-1*m.extensionCompare(e,t)}),n.fn.dataTableExt.oSort["version-asc"]=((e,t)=>{return-1*m.versionCompare(e,t)}),n.fn.dataTableExt.oSort["version-desc"]=((e,t)=>m.versionCompare(e,t)),this.Update=new c,this.UploadForm=new d,this.Repository=new l;const e=this.manageExtensionListing();let t;n(document).on("click",".onClickMaskExtensionManager",()=>{a.start()}).on("click","a[data-action=update-extension]",e=>{e.preventDefault(),n.ajax({url:n(this).attr("href"),dataType:"json",beforeSend:()=>{a.start()},success:this.updateExtension})}).on("change","input[name=unlockDependencyIgnoreButton]",e=>{n(".t3js-dependencies").toggleClass("disabled",!n(e.currentTarget).prop("checked"))}),null!==(t=document.querySelector(u.searchField))&&t.clearable({onClear:()=>{e.search("").draw()}}),n(document).on("click",".t3-button-action-installdistribution",()=>{a.start()}),this.Repository.initDom(),this.Update.initializeEvents(),this.UploadForm.initializeEvents(),o.initialize("#typo3-extension-list [title]",{delay:{show:500,hide:100},trigger:"hover",container:"body"})})}static getUrlVars(){let e,t=[],n=window.location.href.slice(window.location.href.indexOf("?")+1).split("&");for(let a=0;a<n.length;a++)e=n[a].split("="),t.push(e[0]),t[e[0]]=e[1];return t}static versionCompare(e,t){if(e===t)return 0;