Commit 82a23c30 authored by Andreas Fernandez's avatar Andreas Fernandez Committed by Daniel Goerz
Browse files

[TASK] Use AJAX API in Icons

Resolves: #90193
Releases: master
Change-Id: I6e263dabffc3172ec48d55e2148e7d5b087b6b29
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/63023


Reviewed-by: Susanne Moog's avatarSusanne Moog <look@susi.dev>
Reviewed-by: Daniel Goerz's avatarDaniel Goerz <daniel.goerz@posteo.de>
Tested-by: default avatarTYPO3com <noreply@typo3.com>
Tested-by: Susanne Moog's avatarSusanne Moog <look@susi.dev>
Tested-by: Daniel Goerz's avatarDaniel Goerz <daniel.goerz@posteo.de>
parent 5acc2999
......@@ -166,14 +166,14 @@ class AjaxDataHandler {
});
const $iconElement = $anchorElement.find(Identifiers.icon);
Icons.getIcon(iconName, Icons.sizes.small).done((icon: string): void => {
Icons.getIcon(iconName, Icons.sizes.small).then((icon: string): void => {
$iconElement.replaceWith(icon);
});
// Set overlay for the record icon
const $recordIcon = $rowElement.find('.col-icon ' + Identifiers.icon);
if (nextState === 'hidden') {
Icons.getIcon('miscellaneous-placeholder', Icons.sizes.small, 'overlay-hidden').done((icon: string): void => {
Icons.getIcon('miscellaneous-placeholder', Icons.sizes.small, 'overlay-hidden').then((icon: string): void => {
$recordIcon.append($(icon).find('.icon-overlay'));
});
} else {
......@@ -204,7 +204,7 @@ class AjaxDataHandler {
// make the AJAX call to toggle the visibility
AjaxDataHandler.call(params).then((result: ResponseInterface): void => {
// revert to the old class
Icons.getIcon('actions-edit-delete', Icons.sizes.small).done((icon: string): void => {
Icons.getIcon('actions-edit-delete', Icons.sizes.small).then((icon: string): void => {
$iconElement = $anchorElement.find(Identifiers.icon);
$iconElement.replaceWith(icon);
});
......@@ -259,7 +259,7 @@ class AjaxDataHandler {
* @private
*/
private _showSpinnerIcon($iconElement: JQuery): void {
Icons.getIcon('spinner-circle-dark', Icons.sizes.small).done((icon: string): void => {
Icons.getIcon('spinner-circle-dark', Icons.sizes.small).then((icon: string): void => {
$iconElement.replaceWith(icon);
});
}
......
......@@ -98,7 +98,7 @@ class DocumentSaveActions {
$affectedButton = $me;
}
Icons.getIcon('spinner-circle-dark', Icons.sizes.small).done((markup: string): void => {
Icons.getIcon('spinner-circle-dark', Icons.sizes.small).then((markup: string): void => {
$affectedButton.find('.t3js-icon').replaceWith(markup);
});
......
......@@ -475,7 +475,7 @@ class InlineControlContainer {
recordContainer.classList.add(hiddenClass);
}
Icons.getIcon(toggleIcon, Icons.sizes.small).done((markup: string): void => {
Icons.getIcon(toggleIcon, Icons.sizes.small).then((markup: string): void => {
target.replaceChild(document.createRange().createContextualFragment(markup), target.querySelector('.t3js-icon'));
});
}
......@@ -918,7 +918,7 @@ class InlineControlContainer {
} else {
sortUp.classList.remove('disabled');
}
Icons.getIcon(iconIdentifier, Icons.sizes.small).done((markup: string): void => {
Icons.getIcon(iconIdentifier, Icons.sizes.small).then((markup: string): void => {
sortUp.replaceChild(document.createRange().createContextualFragment(markup), sortUp.querySelector('.t3js-icon'));
});
}
......@@ -932,7 +932,7 @@ class InlineControlContainer {
} else {
sortDown.classList.remove('disabled');
}
Icons.getIcon(iconIdentifier, Icons.sizes.small).done((markup: string): void => {
Icons.getIcon(iconIdentifier, Icons.sizes.small).then((markup: string): void => {
sortDown.replaceChild(document.createRange().createContextualFragment(markup), sortDown.querySelector('.t3js-icon'));
});
}
......
......@@ -11,7 +11,8 @@
* The TYPO3 project - inspiring people to share!
*/
import * as $ from 'jquery';
import {AjaxResponse} from 'TYPO3/CMS/Core/Ajax/AjaxResponse';
import AjaxRequest = require('TYPO3/CMS/Core/Ajax/AjaxRequest');
import ClientStorage = require('./Storage/Client');
enum Sizes {
......@@ -32,7 +33,7 @@ enum MarkupIdentifiers {
}
interface PromiseCache {
[key: string]: JQueryPromise<any>;
[key: string]: Promise<string>;
}
/**
......@@ -53,7 +54,7 @@ class Icons {
* @param {string} overlayIdentifier
* @param {string} state
* @param {MarkupIdentifiers} markupIdentifier
* @returns {JQueryPromise<any>}
* @returns {Promise<string>}
*/
public getIcon(
identifier: string,
......@@ -61,7 +62,7 @@ class Icons {
overlayIdentifier?: string,
state?: string,
markupIdentifier?: MarkupIdentifiers,
): JQueryPromise<any> {
): Promise<string> {
/**
* Icon keys:
......@@ -79,7 +80,7 @@ class Icons {
const describedIcon = [identifier, size, overlayIdentifier, state, markupIdentifier];
const cacheIdentifier = describedIcon.join('_');
return $.when(this.getIconRegistryCache()).pipe((registryCacheIdentifier: string): any => {
return this.getIconRegistryCache().then((registryCacheIdentifier: string): any => {
if (!ClientStorage.isset('icon_registry_cache_identifier')
|| ClientStorage.get('icon_registry_cache_identifier') !== registryCacheIdentifier
) {
......@@ -93,16 +94,17 @@ class Icons {
});
}
private getIconRegistryCache(): JQueryPromise<any> {
private getIconRegistryCache(): Promise<string> {
const promiseCacheIdentifier = 'icon_registry_cache_identifier';
if (!this.isPromiseCached(promiseCacheIdentifier)) {
this.putInPromiseCache(promiseCacheIdentifier, $.ajax({
url: TYPO3.settings.ajaxUrls.icons_cache,
success: (response: string): string => {
return response;
},
}));
this.putInPromiseCache(
promiseCacheIdentifier,
(new AjaxRequest(TYPO3.settings.ajaxUrls.icons_cache)).get()
.then(async (response: AjaxResponse): Promise<string> => {
return await response.resolve()
})
);
}
return this.getFromPromiseCache(promiseCacheIdentifier);
......@@ -115,21 +117,22 @@ class Icons {
* @param {string} cacheIdentifier
* @returns {JQueryPromise<any>}
*/
private fetchFromRemote(icon: Array<string>, cacheIdentifier: string): JQueryPromise<any> {
private fetchFromRemote(icon: Array<string>, cacheIdentifier: string): Promise<string> {
if (!this.isPromiseCached(cacheIdentifier)) {
this.putInPromiseCache(cacheIdentifier, $.ajax({
url: TYPO3.settings.ajaxUrls.icons,
dataType: 'html',
data: {
icon: JSON.stringify(icon),
},
success: (markup: string) => {
if (markup.includes('t3js-icon') && markup.includes('<span class="icon-markup">')) {
ClientStorage.set('icon_' + cacheIdentifier, markup);
}
return markup;
},
}));
const queryArguments = {
icon: JSON.stringify(icon),
};
this.putInPromiseCache(
cacheIdentifier,
(new AjaxRequest(TYPO3.settings.ajaxUrls.icons)).withQueryArguments(queryArguments).get()
.then(async (response: AjaxResponse): Promise<string> => {
const markup = await response.resolve();
if (markup.includes('t3js-icon') && markup.includes('<span class="icon-markup">')) {
ClientStorage.set('icon_' + cacheIdentifier, markup);
}
return markup;
})
);
}
return this.getFromPromiseCache(cacheIdentifier);
}
......@@ -137,17 +140,14 @@ class Icons {
/**
* Gets the icon from localStorage
* @param {string} cacheIdentifier
* @returns {JQueryPromise<any>}
* @returns {Promise<string>}
*/
private fetchFromLocal(cacheIdentifier: string): JQueryPromise<any> {
const deferred = $.Deferred();
private fetchFromLocal(cacheIdentifier: string): Promise<string> {
if (ClientStorage.isset('icon_' + cacheIdentifier)) {
deferred.resolve(ClientStorage.get('icon_' + cacheIdentifier));
} else {
deferred.reject();
return Promise.resolve(ClientStorage.get('icon_' + cacheIdentifier));
}
return deferred.promise();
return Promise.reject();
}
/**
......@@ -164,9 +164,9 @@ class Icons {
* Get icon from cache
*
* @param {string} cacheIdentifier
* @returns {JQueryPromise<any>}
* @returns {Promise<string>}
*/
private getFromPromiseCache(cacheIdentifier: string): JQueryPromise<any> {
private getFromPromiseCache(cacheIdentifier: string): Promise<string> {
return this.promiseCache[cacheIdentifier];
}
......@@ -174,9 +174,9 @@ class Icons {
* Put icon into cache
*
* @param {string} cacheIdentifier
* @param {JQueryPromise<any>} markup
* @param {Promise<string>} markup
*/
private putInPromiseCache(cacheIdentifier: string, markup: JQueryPromise<any>): void {
private putInPromiseCache(cacheIdentifier: string, markup: Promise<string>): void {
this.promiseCache[cacheIdentifier] = markup;
}
}
......
......@@ -229,7 +229,7 @@ class ImageManipulation {
const payload: object = this.trigger.data('payload');
const initCropperModal: () => void = this.initializeCropperModal.bind(this);
Icons.getIcon('spinner-circle', Icons.sizes.default, null, null, Icons.markupIdentifiers.inline).done((icon: string): void => {
Icons.getIcon('spinner-circle', Icons.sizes.default, null, null, Icons.markupIdentifiers.inline).then((icon: string): void => {
/**
* Open modal with image to crop
*/
......
......@@ -130,7 +130,7 @@ class LiveSearch {
'',
Icons.states.default,
Icons.markupIdentifiers.inline,
).done((markup: string): void => {
).then((markup: string): void => {
$toolbarItem.find('.icon-apps-toolbar-menu-search').replaceWith(markup);
});
}
......@@ -150,7 +150,7 @@ class LiveSearch {
'',
Icons.states.default,
Icons.markupIdentifiers.inline,
).done((markup: string): void => {
).then((markup: string): void => {
$toolbarItem.find('.icon-spinner-circle-light').replaceWith(markup);
});
}
......
......@@ -52,8 +52,8 @@ class Localization {
private initialize(): void {
const me = this;
Icons.getIcon('actions-localize', Icons.sizes.large).done((localizeIconMarkup: string): void => {
Icons.getIcon('actions-edit-copy', Icons.sizes.large).done((copyIconMarkup: string): void => {
Icons.getIcon('actions-localize', Icons.sizes.large).then((localizeIconMarkup: string): void => {
Icons.getIcon('actions-edit-copy', Icons.sizes.large).then((copyIconMarkup: string): void => {
$(me.triggerButton).removeClass('disabled');
$(document).on('click', me.triggerButton, (e: JQueryEventObject): void => {
......@@ -129,7 +129,7 @@ class Localization {
'',
SeverityEnum.info,
($slide: JQuery): void => {
Icons.getIcon('spinner-circle-dark', Icons.sizes.large).done((markup: string): void => {
Icons.getIcon('spinner-circle-dark', Icons.sizes.large).then((markup: string): void => {
$slide.html('<div class="text-center">' + markup + '</div>');
this.loadAvailableLanguages(
......@@ -183,7 +183,7 @@ class Localization {
TYPO3.lang['localize.view.summary'],
'',
SeverityEnum.info, ($slide: JQuery): void => {
Icons.getIcon('spinner-circle-dark', Icons.sizes.large).done((markup: string): void => {
Icons.getIcon('spinner-circle-dark', Icons.sizes.large).then((markup: string): void => {
$slide.html('<div class="text-center">' + markup + '</div>');
});
this.getSummary(
......
......@@ -404,7 +404,7 @@ class Modal {
if (configuration.type === 'ajax') {
const contentTarget = configuration.ajaxTarget ? configuration.ajaxTarget : Identifiers.body;
const $loaderTarget = currentModal.find(contentTarget);
Icons.getIcon('spinner-circle', Icons.sizes.default, null, null, Icons.markupIdentifiers.inline).done((icon: string): void => {
Icons.getIcon('spinner-circle', Icons.sizes.default, null, null, Icons.markupIdentifiers.inline).then((icon: string): void => {
$loaderTarget.html('<div class="modal-loading">' + icon + '</div>');
$.get(
<string>configuration.content,
......@@ -448,7 +448,7 @@ class Modal {
$me.find(Identifiers.footer).find('.t3js-active').first().focus();
// Get Icons
$me.find(Identifiers.iconPlaceholder).each((index: number, elem: Element): void => {
Icons.getIcon($(elem).data('icon'), Icons.sizes.small, null, null, Icons.markupIdentifiers.inline).done((icon: string): void => {
Icons.getIcon($(elem).data('icon'), Icons.sizes.small, null, null, Icons.markupIdentifiers.inline).then((icon: string): void => {
this.currentModal.find(Identifiers.iconPlaceholder + '[data-icon=' + $(icon).data('identifier') + ']').replaceWith(icon);
});
});
......
......@@ -102,16 +102,16 @@ class MultiStepWizard {
* Add the final processing slide as the last step
*
* @param {Function} callback
* @returns {JQueryPromise<any>}
* @returns {Promise<string>}
*/
public addFinalProcessingSlide(callback?: Function): JQueryPromise<any> {
public addFinalProcessingSlide(callback?: Function): Promise<void> {
if (!callback) {
callback = (): void => {
this.dismiss();
};
}
return Icons.getIcon('spinner-circle', Icons.sizes.default, null, null).done((markup: string) => {
return Icons.getIcon('spinner-circle', Icons.sizes.default, null, null).then((markup: string) => {
let $processingSlide = $('<div />', {class: 'text-center'}).append(markup);
this.addSlide(
'final-processing-slide', top.TYPO3.lang['wizard.processing.title'],
......
......@@ -61,7 +61,7 @@ class ClearCacheMenu {
const $toolbarItemIcon = $(Identifiers.toolbarIconSelector, Identifiers.containerSelector);
const $existingIcon = $toolbarItemIcon.clone();
Icons.getIcon('spinner-circle-light', Icons.sizes.small).done((spinner: string): void => {
Icons.getIcon('spinner-circle-light', Icons.sizes.small).then((spinner: string): void => {
$toolbarItemIcon.replaceWith(spinner);
});
......
......@@ -69,7 +69,7 @@ class ShortcutMenu {
const $toolbarItemIcon = $(Identifiers.toolbarIconSelector, Identifiers.containerSelector);
const $existingIcon = $toolbarItemIcon.clone();
Icons.getIcon('spinner-circle-light', Icons.sizes.small).done((spinner: string): void => {
Icons.getIcon('spinner-circle-light', Icons.sizes.small).then((spinner: string): void => {
$toolbarItemIcon.replaceWith(spinner);
});
......@@ -82,7 +82,7 @@ class ShortcutMenu {
this.refreshMenu();
$(Identifiers.toolbarIconSelector, Identifiers.containerSelector).replaceWith($existingIcon);
if (typeof shortcutButton === 'object') {
Icons.getIcon('actions-system-shortcut-active', Icons.sizes.small).done((icon: string): void => {
Icons.getIcon('actions-system-shortcut-active', Icons.sizes.small).then((icon: string): void => {
$(shortcutButton).html(icon);
});
$(shortcutButton).addClass('active');
......
......@@ -68,7 +68,7 @@ class SystemInformationMenu {
this.timer = null;
}
Icons.getIcon('spinner-circle-light', Icons.sizes.small).done((spinner: string): void => {
Icons.getIcon('spinner-circle-light', Icons.sizes.small).then((spinner: string): void => {
$toolbarItemIcon.replaceWith(spinner);
});
......
......@@ -53,7 +53,7 @@ class NavigationContainer extends AbstractContainer {
'overlay-readonly',
null,
Icons.markupIdentifiers.inline,
).done((icon: string): void => {
).then((icon: string): void => {
$(TopbarIdentifiersEnum.buttonNavigationComponent).html(icon);
});
$(ScaffoldIdentifierEnum.scaffold).removeClass('scaffold-content-navigation-expanded');
......@@ -62,7 +62,7 @@ class NavigationContainer extends AbstractContainer {
public show(component: string): void {
$(TopbarIdentifiersEnum.buttonNavigationComponent).prop('disabled', false);
Icons.getIcon('actions-pagetree', Icons.sizes.small, null, null, Icons.markupIdentifiers.inline).done((icon: string): void => {
Icons.getIcon('actions-pagetree', Icons.sizes.small, null, null, Icons.markupIdentifiers.inline).then((icon: string): void => {
$(TopbarIdentifiersEnum.buttonNavigationComponent).html(icon);
});
......
......@@ -78,14 +78,14 @@ class Wizard {
return this;
}
public addFinalProcessingSlide(callback?: Function): JQueryPromise<any> {
public addFinalProcessingSlide(callback?: Function): Promise<void> {
if (!callback) {
callback = (): void => {
this.dismiss();
};
}
return Icons.getIcon('spinner-circle-dark', Icons.sizes.large, null, null).done((markup: string) => {
return Icons.getIcon('spinner-circle-dark', Icons.sizes.large, null, null).then((markup: string) => {
let $processingSlide = $('<div />', {class: 'text-center'}).append(markup);
this.addSlide(
'final-processing-slide', top.TYPO3.lang['wizard.processing.title'],
......
......@@ -10,4 +10,4 @@
*
* The TYPO3 project - inspiring people to share!
*/
var __awaiter=this&&this.__awaiter||function(e,t,a,n){return new(a||(a=Promise))((function(i,o){function r(e){try{l(n.next(e))}catch(e){o(e)}}function s(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof a?t:new a((function(e){e(t)}))).then(r,s)}l((n=n.apply(e,t||[])).next())}))};define(["require","exports","TYPO3/CMS/Core/Ajax/AjaxRequest","./Enum/Severity","jquery","./Icons","./Modal","./Notification","./Viewport"],(function(e,t,a,n,i,o,r,s,l){"use strict";var d;!function(e){e.hide=".t3js-record-hide",e.delete=".t3js-record-delete",e.icon=".t3js-icon"}(d||(d={}));class c{static refreshPageTree(){l.NavigationContainer&&l.NavigationContainer.PageTree&&l.NavigationContainer.PageTree.refreshTree()}static call(e){return new a(TYPO3.settings.ajaxUrls.record_process).withQueryArguments(e).get().then(e=>__awaiter(this,void 0,void 0,(function*(){return yield e.resolve()})))}constructor(){i(()=>{this.initialize()})}process(e){return c.call(e).then(e=>(e.hasErrors&&this.handleErrors(e),e))}initialize(){i(document).on("click",d.hide,e=>{e.preventDefault();const t=i(e.currentTarget),a=t.find(d.icon),n=t.closest("tr[data-uid]"),o=t.data("params");this._showSpinnerIcon(a),c.call(o).then(e=>{e.hasErrors?this.handleErrors(e):this.toggleRow(n)})}),i(document).on("click",d.delete,e=>{e.preventDefault();const t=i(e.currentTarget);t.tooltip("hide"),r.confirm(t.data("title"),t.data("message"),n.SeverityEnum.warning,[{text:t.data("button-close-text")||TYPO3.lang["button.cancel"]||"Cancel",active:!0,btnClass:"btn-default",name:"cancel"},{text:t.data("button-ok-text")||TYPO3.lang["button.delete"]||"Delete",btnClass:"btn-warning",name:"delete"}]).on("button.clicked",e=>{"cancel"===e.target.getAttribute("name")?r.dismiss():"delete"===e.target.getAttribute("name")&&(r.dismiss(),this.deleteRecord(t))})})}toggleRow(e){const t=e.find(d.hide),a=t.closest("table[data-table]").data("table"),n=t.data("params");let r,s,l;"hidden"===t.data("state")?(s="visible",r=n.replace("=0","=1"),l="actions-edit-hide"):(s="hidden",r=n.replace("=1","=0"),l="actions-edit-unhide"),t.data("state",s).data("params",r),t.tooltip("hide").one("hidden.bs.tooltip",()=>{const e=t.data("toggleTitle");t.data("toggleTitle",t.attr("data-original-title")).attr("data-original-title",e)});const h=t.find(d.icon);o.getIcon(l,o.sizes.small).done(e=>{h.replaceWith(e)});const u=e.find(".col-icon "+d.icon);"hidden"===s?o.getIcon("miscellaneous-placeholder",o.sizes.small,"overlay-hidden").done(e=>{u.append(i(e).find(".icon-overlay"))}):u.find(".icon-overlay").remove(),e.fadeTo("fast",.4,()=>{e.fadeTo("fast",1)}),"pages"===a&&c.refreshPageTree()}deleteRecord(e){const t=e.data("params");let a=e.find(d.icon);this._showSpinnerIcon(a),c.call(t).then(t=>{if(o.getIcon("actions-edit-delete",o.sizes.small).done(t=>{(a=e.find(d.icon)).replaceWith(t)}),t.hasErrors)this.handleErrors(t);else{const t=e.closest("table[data-table]"),a=e.closest(".panel"),n=a.find(".panel-heading"),i=t.data("table");let o=e.closest("tr[data-uid]");const r=o.data("uid"),s=t.find("[data-l10nparent="+r+"]").closest("tr[data-uid]");if((o=o.add(s)).fadeTo("slow",.4,()=>{o.slideUp("slow",()=>{o.remove(),0===t.find("tbody tr").length&&a.slideUp("slow")})}),"0"===e.data("l10parent")||""===e.data("l10parent")){const e=Number(n.find(".t3js-table-total-items").html());n.find(".t3js-table-total-items").text(e-1)}"pages"===i&&c.refreshPageTree()}})}handleErrors(e){i.each(e.messages,(e,t)=>{s.error(t.title,t.message)})}_showSpinnerIcon(e){o.getIcon("spinner-circle-dark",o.sizes.small).done(t=>{e.replaceWith(t)})}}return new c}));
\ No newline at end of file
var __awaiter=this&&this.__awaiter||function(e,t,a,n){return new(a||(a=Promise))((function(i,r){function s(e){try{l(n.next(e))}catch(e){r(e)}}function o(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof a?t:new a((function(e){e(t)}))).then(s,o)}l((n=n.apply(e,t||[])).next())}))};define(["require","exports","TYPO3/CMS/Core/Ajax/AjaxRequest","./Enum/Severity","jquery","./Icons","./Modal","./Notification","./Viewport"],(function(e,t,a,n,i,r,s,o,l){"use strict";var d;!function(e){e.hide=".t3js-record-hide",e.delete=".t3js-record-delete",e.icon=".t3js-icon"}(d||(d={}));class c{static refreshPageTree(){l.NavigationContainer&&l.NavigationContainer.PageTree&&l.NavigationContainer.PageTree.refreshTree()}static call(e){return new a(TYPO3.settings.ajaxUrls.record_process).withQueryArguments(e).get().then(e=>__awaiter(this,void 0,void 0,(function*(){return yield e.resolve()})))}constructor(){i(()=>{this.initialize()})}process(e){return c.call(e).then(e=>(e.hasErrors&&this.handleErrors(e),e))}initialize(){i(document).on("click",d.hide,e=>{e.preventDefault();const t=i(e.currentTarget),a=t.find(d.icon),n=t.closest("tr[data-uid]"),r=t.data("params");this._showSpinnerIcon(a),c.call(r).then(e=>{e.hasErrors?this.handleErrors(e):this.toggleRow(n)})}),i(document).on("click",d.delete,e=>{e.preventDefault();const t=i(e.currentTarget);t.tooltip("hide"),s.confirm(t.data("title"),t.data("message"),n.SeverityEnum.warning,[{text:t.data("button-close-text")||TYPO3.lang["button.cancel"]||"Cancel",active:!0,btnClass:"btn-default",name:"cancel"},{text:t.data("button-ok-text")||TYPO3.lang["button.delete"]||"Delete",btnClass:"btn-warning",name:"delete"}]).on("button.clicked",e=>{"cancel"===e.target.getAttribute("name")?s.dismiss():"delete"===e.target.getAttribute("name")&&(s.dismiss(),this.deleteRecord(t))})})}toggleRow(e){const t=e.find(d.hide),a=t.closest("table[data-table]").data("table"),n=t.data("params");let s,o,l;"hidden"===t.data("state")?(o="visible",s=n.replace("=0","=1"),l="actions-edit-hide"):(o="hidden",s=n.replace("=1","=0"),l="actions-edit-unhide"),t.data("state",o).data("params",s),t.tooltip("hide").one("hidden.bs.tooltip",()=>{const e=t.data("toggleTitle");t.data("toggleTitle",t.attr("data-original-title")).attr("data-original-title",e)});const h=t.find(d.icon);r.getIcon(l,r.sizes.small).then(e=>{h.replaceWith(e)});const u=e.find(".col-icon "+d.icon);"hidden"===o?r.getIcon("miscellaneous-placeholder",r.sizes.small,"overlay-hidden").then(e=>{u.append(i(e).find(".icon-overlay"))}):u.find(".icon-overlay").remove(),e.fadeTo("fast",.4,()=>{e.fadeTo("fast",1)}),"pages"===a&&c.refreshPageTree()}deleteRecord(e){const t=e.data("params");let a=e.find(d.icon);this._showSpinnerIcon(a),c.call(t).then(t=>{if(r.getIcon("actions-edit-delete",r.sizes.small).then(t=>{(a=e.find(d.icon)).replaceWith(t)}),t.hasErrors)this.handleErrors(t);else{const t=e.closest("table[data-table]"),a=e.closest(".panel"),n=a.find(".panel-heading"),i=t.data("table");let r=e.closest("tr[data-uid]");const s=r.data("uid"),o=t.find("[data-l10nparent="+s+"]").closest("tr[data-uid]");if((r=r.add(o)).fadeTo("slow",.4,()=>{r.slideUp("slow",()=>{r.remove(),0===t.find("tbody tr").length&&a.slideUp("slow")})}),"0"===e.data("l10parent")||""===e.data("l10parent")){const e=Number(n.find(".t3js-table-total-items").html());n.find(".t3js-table-total-items").text(e-1)}"pages"===i&&c.refreshPageTree()}})}handleErrors(e){i.each(e.messages,(e,t)=>{o.error(t.title,t.message)})}_showSpinnerIcon(e){r.getIcon("spinner-circle-dark",r.sizes.small).then(t=>{e.replaceWith(t)})}}return new c}));
\ 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 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
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).then(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
......@@ -108,19 +108,19 @@ define(['jquery',
this.tree = this.$treeWrapper.data('svgtree');
var $toolbar = this.$template.clone().insertBefore(this.$treeWrapper);
Icons.getIcon('actions-filter', Icons.sizes.small).done(function(icon) {
Icons.getIcon('actions-filter', Icons.sizes.small).then(function(icon) {
$toolbar.find('.filter').append(icon);
});
Icons.getIcon('apps-pagetree-category-expand-all', Icons.sizes.small).done(function(icon) {
Icons.getIcon('apps-pagetree-category-expand-all', Icons.sizes.small).then(function(icon) {
$toolbar.find('.expand-all-btn').append(icon);
});
Icons.getIcon('apps-pagetree-category-collapse-all', Icons.sizes.small).done(function(icon) {
Icons.getIcon('apps-pagetree-category-collapse-all', Icons.sizes.small).then(function(icon) {
$toolbar.find('.collapse-all-btn').append(icon);
});
Icons.getIcon('apps-pagetree-category-toggle-hide-checked', Icons.sizes.small).done(function(icon) {
Icons.getIcon('apps-pagetree-category-toggle-hide-checked', Icons.sizes.small).then(function(icon) {
$toolbar.find('.hide-unchecked-btn').append(icon);
});
......
......@@ -10,4 +10,4 @@
*
* The TYPO3 project - inspiring people to share!
*/
define(["require","exports","jquery","./Storage/Client"],(function(e,i,t,s){"use strict";var r,c,n;!function(e){e.small="small",e.default="default",e.large="large",e.overlay="overlay"}(r||(r={})),function(e){e.default="default",e.disabled="disabled"}(c||(c={})),function(e){e.default="default",e.inline="inline"}(n||(n={}));class a{constructor(){this.sizes=r,this.states=c,this.markupIdentifiers=n,this.promiseCache={}}getIcon(e,i,a,o,h){const l=[e,i=i||r.default,a,o=o||c.default,h=h||n.default],u=l.join("_");return t.when(this.getIconRegistryCache()).pipe(e=>(s.isset("icon_registry_cache_identifier")&&s.get("icon_registry_cache_identifier")===e||(s.unsetByPrefix("icon_"),s.set("icon_registry_cache_identifier",e)),this.fetchFromLocal(u).then(null,()=>this.fetchFromRemote(l,u))))}getIconRegistryCache(){return this.isPromiseCached("icon_registry_cache_identifier")||this.putInPromiseCache("icon_registry_cache_identifier",t.ajax({url:TYPO3.settings.ajaxUrls.icons_cache,success:e=>e})),this.getFromPromiseCache("icon_registry_cache_identifier")}fetchFromRemote(e,i){return this.isPromiseCached(i)||this.putInPromiseCache(i,t.ajax({url:TYPO3.settings.ajaxUrls.icons,dataType:"html",data:{icon:JSON.stringify(e)},success:e=>(e.includes("t3js-icon")&&e.includes('<span class="icon-markup">')&&s.set("icon_"+i,e),e)})),this.getFromPromiseCache(i)}fetchFromLocal(e){const i=t.Deferred();return s.isset("icon_"+e)?i.resolve(s.get("icon_"+e)):i.reject(),i.promise()}isPromiseCached(e){return void 0!==this.promiseCache[e]}getFromPromiseCache(e){return this.promiseCache[e]}putInPromiseCache(e,i){this.promiseCache[e]=i}}let o;return o||(o=new a,TYPO3.Icons=o),o}));
\ No newline at end of file
var __awaiter=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(r,s){function c(e){try{a(n.next(e))}catch(e){s(e)}}function o(e){try{a(n.throw(e))}catch(e){s(e)}}function a(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(c,o)}a((n=n.apply(e,t||[])).next())}))};define(["require","exports","TYPO3/CMS/Core/Ajax/AjaxRequest","./Storage/Client"],(function(e,t,i,n){"use strict";var r,s,c;!function(e){e.small="small",e.default="default",e.large="large",e.overlay="overlay"}(r||(r={})),function(e){e.default="default",e.disabled="disabled"}(s||(s={})),function(e){e.default="default",e.inline="inline"}(c||(c={}));class o{constructor(){this.sizes=r,this.states=s,this.markupIdentifiers=c,this.promiseCache={}}getIcon(e,t,i,o,a){const h=[e,t=t||r.default,i,o=o||s.default,a=a||c.default],u=h.join("_");return this.getIconRegistryCache().then(e=>(n.isset("icon_registry_cache_identifier")&&n.get("icon_registry_cache_identifier")===e||(n.unsetByPrefix("icon_"),n.set("icon_registry_cache_identifier",e)),this.fetchFromLocal(u).then(null,()=>this.fetchFromRemote(h,u))))}getIconRegistryCache(){return this.isPromiseCached("icon_registry_cache_identifier")||this.putInPromiseCache("icon_registry_cache_identifier",new i(TYPO3.settings.ajaxUrls.icons_cache).get().then(e=>__awaiter(this,void 0,void 0,(function*(){return yield e.resolve()})))),this.getFromPromiseCache("icon_registry_cache_identifier")}fetchFromRemote(e,t){if(!this.isPromiseCached(t)){const r={icon:JSON.stringify(e)};this.putInPromiseCache(t,new i(TYPO3.settings.ajaxUrls.icons).withQueryArguments(r).get().then(e=>__awaiter(this,void 0,void 0,(function*(){const i=yield e.resolve();return i.includes("t3js-icon")&&i.includes('<span class="icon-markup">')&&n.set("icon_"+t,i),i}))))}return this.getFromPromiseCache(t)}fetchFromLocal(e){return n.isset("icon_"+e)?Promise.resolve(n.get("icon_"+e)):Promise.reject()}isPromiseCached(e){return void 0!==this.promiseCache[e]}getFromPromiseCache(e){return this.promiseCache[e]}putInPromiseCache(e,t){this.promiseCache[e]=t}}let a;return a||(a=new o,TYPO3.Icons=a),a}));
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment