Commit 5adf2b74 authored by Andreas Fernandez's avatar Andreas Fernandez Committed by Daniel Goerz
Browse files

[TASK] Use getElementById where feasible

It's safe to use getElementById() instead of querySelector() in case an
element is fetched by its ID.

Numbers for nerds:
getElementById() is nearly 1.5x faster than querySelector(). To be fair,
both functions are really fast with executing multiple million operations
per second, thus nobody will notice a performance impact.
See https://www.measurethat.net/Benchmarks/ShowResult/106740

Resolves: #91254
Related: #91183
Releases: master
Change-Id: I2ed590d20c9af66ce818f012ac73ec45c5c9fa55
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/64384

Tested-by: default avatarTYPO3com <noreply@typo3.com>
Tested-by: Benjamin Franzke's avatarBenjamin Franzke <bfr@qbus.de>
Tested-by: Daniel Goerz's avatarDaniel Goerz <daniel.goerz@posteo.de>
Reviewed-by: Benjamin Franzke's avatarBenjamin Franzke <bfr@qbus.de>
Reviewed-by: Daniel Goerz's avatarDaniel Goerz <daniel.goerz@posteo.de>
parent 65597ce9
......@@ -77,7 +77,7 @@ namespace TYPO3 {
}
renderBackdrop(): void {
const adminPanel = document.querySelector('#TSFE_ADMIN_PANEL_FORM');
const adminPanel = document.getElementById('TSFE_ADMIN_PANEL_FORM');
const backdrop = document.createElement('div');
const body = document.querySelector('body');
body.classList.add(AdminPanelClasses.noScroll);
......
......@@ -22,7 +22,7 @@ class GroupElement extends AbstractSortableSelectItems {
super();
$((): void => {
this.element = <HTMLSelectElement>document.querySelector('#' + elementId);
this.element = <HTMLSelectElement>document.getElementById(elementId);
this.registerEventHandler();
this.registerSuggest();
});
......
......@@ -29,7 +29,7 @@ class InputLinkElement {
constructor(elementId: string) {
$((): void => {
this.element = <HTMLSelectElement>document.querySelector('#' + elementId);
this.element = <HTMLSelectElement>document.getElementById(elementId);
this.container = <HTMLElement>this.element.closest('.t3js-form-field-inputlink');
this.toggleSelector = <HTMLButtonElement>this.container.querySelector(Selectors.toggleSelector);
this.explanationField = <HTMLInputElement>this.container.querySelector(Selectors.explanationSelector);
......
......@@ -24,8 +24,8 @@ class SelectMultipleSideBySideElement extends AbstractSortableSelectItems {
super();
$((): void => {
this.selectedOptionsElement = <HTMLSelectElement>document.querySelector('#' + selectedOptionsElementId);
this.availableOptionsElement = <HTMLSelectElement>document.querySelector('#' + availableOptionsElementId);
this.selectedOptionsElement = <HTMLSelectElement>document.getElementById(selectedOptionsElementId);
this.availableOptionsElement = <HTMLSelectElement>document.getElementById(availableOptionsElementId);
this.registerEventHandler();
});
}
......
......@@ -19,8 +19,8 @@ class SelectTreeElement {
private readonly callback: Function = null;
constructor(treeWrapperId: string, treeRecordFieldId: string, callback: Function) {
this.treeWrapper = <HTMLElement>document.querySelector('#' + treeWrapperId);
this.recordField = <HTMLInputElement>document.querySelector('#' + treeRecordFieldId);
this.treeWrapper = <HTMLElement>document.getElementById(treeWrapperId);
this.recordField = <HTMLInputElement>document.getElementById(treeRecordFieldId);
this.callback = callback;
this.initialize();
......
......@@ -20,7 +20,7 @@ class TextElement {
constructor(elementId: string) {
$((): void => {
this.element = <HTMLTextAreaElement>document.querySelector('#' + elementId);
this.element = <HTMLTextAreaElement>document.getElementById(elementId);
Resizable.enable(this.element);
Tabbable.enable(this.element);
......
......@@ -20,7 +20,7 @@ class TextTableElement {
constructor(elementId: string) {
$((): void => {
this.element = <HTMLTextAreaElement>document.querySelector('#' + elementId);
this.element = <HTMLTextAreaElement>document.getElementById(elementId);
Resizable.enable(this.element);
Tabbable.enable(this.element);
......
......@@ -131,7 +131,7 @@ class Notification {
: duration
);
if (this.messageContainer === null || document.querySelector('#alert-container') === null) {
if (this.messageContainer === null || document.getElementById('alert-container') === null) {
this.messageContainer = $('<div>', {'id': 'alert-container'}).appendTo('body');
}
......
......@@ -38,7 +38,7 @@ class ToggleSearchToolbox {
});
let searchField: HTMLInputElement;
if ((searchField = document.querySelector('#search_field')) !== null) {
if ((searchField = document.getElementById('search_field') as HTMLInputElement) !== null) {
const searchResultShown = ('' !== searchField.value);
// make search field clearable
......
......@@ -21,7 +21,7 @@ describe('TYPO3/CMS/Backend/Notification:', () => {
$.fx.off = true;
jasmine.clock().install();
const alertContainer = document.querySelector('#alert-container');
const alertContainer = document.getElementById('alert-container');
while (alertContainer !== null && alertContainer.firstChild) {
alertContainer.removeChild(alertContainer.firstChild);
}
......
......@@ -21,7 +21,7 @@ import 'TYPO3/CMS/Backend/Input/Clearable';
class BackendUserListing {
constructor() {
let searchField: HTMLInputElement;
if ((searchField = document.querySelector('#tx_Beuser_username')) !== null) {
if ((searchField = document.getElementById('tx_Beuser_username') as HTMLInputElement) !== null) {
const searchResultShown = ('' !== searchField.value);
// make search field clearable
......
......@@ -32,7 +32,7 @@ class DashboardModal {
title: this.dataset.modalTitle,
size: Modal.sizes.medium,
severity: SeverityEnum.notice,
content: $(document.querySelector(`#dashboardModal-${this.dataset.modalIdentifier}`).innerHTML),
content: $(document.getElementById(`dashboardModal-${this.dataset.modalIdentifier}`).innerHTML),
additionalCssClasses: ['dashboard-modal'],
callback: (currentModal: any): void => {
currentModal.on('submit', '.dashboardModal-form', (e: JQueryEventObject): void => {
......
......@@ -10,4 +10,4 @@
*
* The TYPO3 project - inspiring people to share!
*/
"use strict";var TYPO3;!function(e){e.AdminPanelSelectors={adminPanelRole:"form[data-typo3-role=typo3-adminPanel]",moduleTriggerRole:"[data-typo3-role=typo3-adminPanel-module-trigger]",moduleParentClass:".typo3-adminPanel-module",contentTabRole:"[data-typo3-role=typo3-adminPanel-content-tab]",saveButtonRole:"[data-typo3-role=typo3-adminPanel-saveButton]",triggerRole:"[data-typo3-role=typo3-adminPanel-trigger]",popupTriggerRole:"[data-typo3-role=typo3-adminPanel-popup-trigger]",panelTriggerRole:"[data-typo3-role=typo3-adminPanel-panel-trigger]",panelParentClass:".typo3-adminPanel-panel",contentSettingsTriggerRole:"[data-typo3-role=typo3-adminPanel-content-settings]",contentSettingsParentClass:".typo3-adminPanel-content-settings",contentParentClass:".typo3-adminPanel-content",zoomTarget:"[data-typo3-zoom-target]",zoomClose:"[data-typo3-zoom-close]",currentContentRole:"[data-typo3-role=typo3-adminPanel-content]",contentPaneRole:"[data-typo3-role=typo3-adminPanel-content-pane]"},e.AdminPanelClasses={active:"active",activeModule:"typo3-adminPanel-module-active",activeContentSetting:"typo3-adminPanel-content-settings-active",backdrop:"typo3-adminPanel-backdrop",activeTab:"typo3-adminPanel-content-header-item-active",activePane:"typo3-adminPanel-content-panes-item-active",noScroll:"typo3-adminPanel-noscroll",zoomShow:"typo3-adminPanel-zoom-show"};e.AdminPanel=class{constructor(){this.adminPanel=document.querySelector(e.AdminPanelSelectors.adminPanelRole),this.modules=this.querySelectorAll(e.AdminPanelSelectors.moduleTriggerRole).map(t=>{const n=t.closest(e.AdminPanelSelectors.moduleParentClass);return new s(this,n,t)}),this.popups=this.querySelectorAll(e.AdminPanelSelectors.popupTriggerRole).map(e=>new t(this,e)),this.panels=this.querySelectorAll(e.AdminPanelSelectors.panelTriggerRole).map(t=>{const a=t.closest(e.AdminPanelSelectors.panelParentClass);return new n(a,t)}),this.contentSettings=this.querySelectorAll(e.AdminPanelSelectors.contentSettingsTriggerRole).map(t=>{const n=t.closest(e.AdminPanelSelectors.contentParentClass).querySelector(e.AdminPanelSelectors.contentSettingsParentClass);return new a(n,t)}),this.trigger=document.querySelector(e.AdminPanelSelectors.triggerRole),this.initializeEvents(),this.addBackdropListener()}disableModules(){this.modules.forEach(e=>e.disable())}disablePopups(){this.popups.forEach(e=>e.disable())}renderBackdrop(){const t=document.querySelector("#TSFE_ADMIN_PANEL_FORM"),n=document.createElement("div");document.querySelector("body").classList.add(e.AdminPanelClasses.noScroll),n.classList.add(e.AdminPanelClasses.backdrop),t.appendChild(n),this.addBackdropListener()}removeBackdrop(){const t=document.querySelector("."+e.AdminPanelClasses.backdrop);document.querySelector("body").classList.remove(e.AdminPanelClasses.noScroll),null!==t&&t.remove()}querySelectorAll(e,t=null){return null===t?Array.from(document.querySelectorAll(e)):Array.from(t.querySelectorAll(e))}initializeEvents(){this.querySelectorAll(e.AdminPanelSelectors.contentTabRole).forEach(e=>e.addEventListener("click",this.switchTab.bind(this))),this.querySelectorAll(e.AdminPanelSelectors.zoomTarget).forEach(e=>e.addEventListener("click",this.openZoom.bind(this))),this.querySelectorAll(e.AdminPanelSelectors.zoomClose).forEach(e=>e.addEventListener("click",this.closeZoom.bind(this))),this.querySelectorAll(e.AdminPanelSelectors.triggerRole).forEach(e=>e.addEventListener("click",this.toggleAdminPanelState.bind(this))),this.querySelectorAll(e.AdminPanelSelectors.saveButtonRole).forEach(e=>e.addEventListener("click",this.sendAdminPanelForm.bind(this))),this.querySelectorAll("[data-typo3-role=typo3-adminPanel-content-close]").forEach(e=>{e.addEventListener("click",()=>{this.disableModules(),this.removeBackdrop()})}),this.querySelectorAll(".typo3-adminPanel-table th, .typo3-adminPanel-table td").forEach(e=>{e.addEventListener("click",()=>{e.focus();try{document.execCommand("copy")}catch(e){}})})}switchTab(t){t.preventDefault();const n=e.AdminPanelClasses.activeTab,a=e.AdminPanelClasses.activePane,s=t.currentTarget,l=s.closest(e.AdminPanelSelectors.currentContentRole),i=this.querySelectorAll(e.AdminPanelSelectors.contentTabRole,l),o=this.querySelectorAll(e.AdminPanelSelectors.contentPaneRole,l);i.forEach(e=>e.classList.remove(n)),s.classList.add(n),o.forEach(e=>e.classList.remove(a)),document.querySelector("[data-typo3-tab-id="+s.dataset.typo3TabTarget+"]").classList.add(a)}openZoom(t){t.preventDefault();const n=t.currentTarget.getAttribute("data-typo3-zoom-target");document.querySelector("[data-typo3-zoom-id="+n+"]").classList.add(e.AdminPanelClasses.zoomShow)}closeZoom(t){t.preventDefault(),t.currentTarget.closest("[data-typo3-zoom-id]").classList.remove(e.AdminPanelClasses.zoomShow)}sendAdminPanelForm(e){e.preventDefault();const t=new FormData(this.adminPanel),n=new XMLHttpRequest;n.open("POST",this.adminPanel.dataset.typo3AjaxUrl),n.send(t),n.onload=()=>location.assign(this.getCleanReloadUrl())}toggleAdminPanelState(){const e=new XMLHttpRequest;e.open("GET",this.trigger.dataset.typo3AjaxUrl),e.send(),e.onload=()=>location.reload()}getCleanReloadUrl(){let e=[];location.search.substr(1).split("&").forEach(t=>{t&&!t.includes("ADMCMD_")&&e.push(t)});const t=e?"?"+e.join("&"):"";return location.origin+location.pathname+t}addBackdropListener(){this.querySelectorAll("."+e.AdminPanelClasses.backdrop).forEach(t=>{t.addEventListener("click",()=>{this.removeBackdrop(),this.querySelectorAll(e.AdminPanelSelectors.moduleTriggerRole).forEach(t=>{t.closest(e.AdminPanelSelectors.moduleParentClass).classList.remove(e.AdminPanelClasses.activeModule)})})})}};class t{constructor(e,t){this.adminPanel=e,this.element=t,this.initializeEvents()}isActive(){return this.element.classList.contains(e.AdminPanelClasses.active)}enable(){this.element.classList.add(e.AdminPanelClasses.active)}disable(){this.element.classList.remove(e.AdminPanelClasses.active)}initializeEvents(){this.element.addEventListener("click",()=>{this.isActive()?this.disable():(this.adminPanel.disablePopups(),this.enable())})}}class n{constructor(e,t){this.element=e,this.trigger=t,this.initializeEvents()}isActive(){return this.element.classList.contains(e.AdminPanelClasses.active)}enable(){this.element.classList.add(e.AdminPanelClasses.active)}disable(){this.element.classList.remove(e.AdminPanelClasses.active)}initializeEvents(){this.trigger.addEventListener("click",()=>{this.isActive()?this.disable():this.enable()})}}class a{constructor(e,t){this.element=e,this.trigger=t,this.initializeEvents()}isActive(){return this.element.classList.contains(e.AdminPanelClasses.activeContentSetting)}enable(){this.element.classList.add(e.AdminPanelClasses.activeContentSetting)}disable(){this.element.classList.remove(e.AdminPanelClasses.activeContentSetting)}initializeEvents(){this.trigger.addEventListener("click",()=>{this.isActive()?this.disable():this.enable()})}}class s{constructor(e,t,n){this.adminPanel=e,this.element=t,this.trigger=n,this.initializeEvents()}isActive(){return this.element.classList.contains(e.AdminPanelClasses.activeModule)}enable(){this.element.classList.add(e.AdminPanelClasses.activeModule)}disable(){this.element.classList.remove(e.AdminPanelClasses.activeModule)}initializeEvents(){this.trigger.addEventListener("click",()=>{this.adminPanel.removeBackdrop(),this.isActive()?this.disable():(this.adminPanel.disableModules(),this.adminPanel.renderBackdrop(),this.enable())})}}}(TYPO3||(TYPO3={})),window.addEventListener("load",()=>new TYPO3.AdminPanel,!1);
\ No newline at end of file
"use strict";var TYPO3;!function(e){e.AdminPanelSelectors={adminPanelRole:"form[data-typo3-role=typo3-adminPanel]",moduleTriggerRole:"[data-typo3-role=typo3-adminPanel-module-trigger]",moduleParentClass:".typo3-adminPanel-module",contentTabRole:"[data-typo3-role=typo3-adminPanel-content-tab]",saveButtonRole:"[data-typo3-role=typo3-adminPanel-saveButton]",triggerRole:"[data-typo3-role=typo3-adminPanel-trigger]",popupTriggerRole:"[data-typo3-role=typo3-adminPanel-popup-trigger]",panelTriggerRole:"[data-typo3-role=typo3-adminPanel-panel-trigger]",panelParentClass:".typo3-adminPanel-panel",contentSettingsTriggerRole:"[data-typo3-role=typo3-adminPanel-content-settings]",contentSettingsParentClass:".typo3-adminPanel-content-settings",contentParentClass:".typo3-adminPanel-content",zoomTarget:"[data-typo3-zoom-target]",zoomClose:"[data-typo3-zoom-close]",currentContentRole:"[data-typo3-role=typo3-adminPanel-content]",contentPaneRole:"[data-typo3-role=typo3-adminPanel-content-pane]"},e.AdminPanelClasses={active:"active",activeModule:"typo3-adminPanel-module-active",activeContentSetting:"typo3-adminPanel-content-settings-active",backdrop:"typo3-adminPanel-backdrop",activeTab:"typo3-adminPanel-content-header-item-active",activePane:"typo3-adminPanel-content-panes-item-active",noScroll:"typo3-adminPanel-noscroll",zoomShow:"typo3-adminPanel-zoom-show"};e.AdminPanel=class{constructor(){this.adminPanel=document.querySelector(e.AdminPanelSelectors.adminPanelRole),this.modules=this.querySelectorAll(e.AdminPanelSelectors.moduleTriggerRole).map(t=>{const n=t.closest(e.AdminPanelSelectors.moduleParentClass);return new s(this,n,t)}),this.popups=this.querySelectorAll(e.AdminPanelSelectors.popupTriggerRole).map(e=>new t(this,e)),this.panels=this.querySelectorAll(e.AdminPanelSelectors.panelTriggerRole).map(t=>{const a=t.closest(e.AdminPanelSelectors.panelParentClass);return new n(a,t)}),this.contentSettings=this.querySelectorAll(e.AdminPanelSelectors.contentSettingsTriggerRole).map(t=>{const n=t.closest(e.AdminPanelSelectors.contentParentClass).querySelector(e.AdminPanelSelectors.contentSettingsParentClass);return new a(n,t)}),this.trigger=document.querySelector(e.AdminPanelSelectors.triggerRole),this.initializeEvents(),this.addBackdropListener()}disableModules(){this.modules.forEach(e=>e.disable())}disablePopups(){this.popups.forEach(e=>e.disable())}renderBackdrop(){const t=document.getElementById("TSFE_ADMIN_PANEL_FORM"),n=document.createElement("div");document.querySelector("body").classList.add(e.AdminPanelClasses.noScroll),n.classList.add(e.AdminPanelClasses.backdrop),t.appendChild(n),this.addBackdropListener()}removeBackdrop(){const t=document.querySelector("."+e.AdminPanelClasses.backdrop);document.querySelector("body").classList.remove(e.AdminPanelClasses.noScroll),null!==t&&t.remove()}querySelectorAll(e,t=null){return null===t?Array.from(document.querySelectorAll(e)):Array.from(t.querySelectorAll(e))}initializeEvents(){this.querySelectorAll(e.AdminPanelSelectors.contentTabRole).forEach(e=>e.addEventListener("click",this.switchTab.bind(this))),this.querySelectorAll(e.AdminPanelSelectors.zoomTarget).forEach(e=>e.addEventListener("click",this.openZoom.bind(this))),this.querySelectorAll(e.AdminPanelSelectors.zoomClose).forEach(e=>e.addEventListener("click",this.closeZoom.bind(this))),this.querySelectorAll(e.AdminPanelSelectors.triggerRole).forEach(e=>e.addEventListener("click",this.toggleAdminPanelState.bind(this))),this.querySelectorAll(e.AdminPanelSelectors.saveButtonRole).forEach(e=>e.addEventListener("click",this.sendAdminPanelForm.bind(this))),this.querySelectorAll("[data-typo3-role=typo3-adminPanel-content-close]").forEach(e=>{e.addEventListener("click",()=>{this.disableModules(),this.removeBackdrop()})}),this.querySelectorAll(".typo3-adminPanel-table th, .typo3-adminPanel-table td").forEach(e=>{e.addEventListener("click",()=>{e.focus();try{document.execCommand("copy")}catch(e){}})})}switchTab(t){t.preventDefault();const n=e.AdminPanelClasses.activeTab,a=e.AdminPanelClasses.activePane,s=t.currentTarget,l=s.closest(e.AdminPanelSelectors.currentContentRole),i=this.querySelectorAll(e.AdminPanelSelectors.contentTabRole,l),o=this.querySelectorAll(e.AdminPanelSelectors.contentPaneRole,l);i.forEach(e=>e.classList.remove(n)),s.classList.add(n),o.forEach(e=>e.classList.remove(a)),document.querySelector("[data-typo3-tab-id="+s.dataset.typo3TabTarget+"]").classList.add(a)}openZoom(t){t.preventDefault();const n=t.currentTarget.getAttribute("data-typo3-zoom-target");document.querySelector("[data-typo3-zoom-id="+n+"]").classList.add(e.AdminPanelClasses.zoomShow)}closeZoom(t){t.preventDefault(),t.currentTarget.closest("[data-typo3-zoom-id]").classList.remove(e.AdminPanelClasses.zoomShow)}sendAdminPanelForm(e){e.preventDefault();const t=new FormData(this.adminPanel),n=new XMLHttpRequest;n.open("POST",this.adminPanel.dataset.typo3AjaxUrl),n.send(t),n.onload=()=>location.assign(this.getCleanReloadUrl())}toggleAdminPanelState(){const e=new XMLHttpRequest;e.open("GET",this.trigger.dataset.typo3AjaxUrl),e.send(),e.onload=()=>location.reload()}getCleanReloadUrl(){let e=[];location.search.substr(1).split("&").forEach(t=>{t&&!t.includes("ADMCMD_")&&e.push(t)});const t=e?"?"+e.join("&"):"";return location.origin+location.pathname+t}addBackdropListener(){this.querySelectorAll("."+e.AdminPanelClasses.backdrop).forEach(t=>{t.addEventListener("click",()=>{this.removeBackdrop(),this.querySelectorAll(e.AdminPanelSelectors.moduleTriggerRole).forEach(t=>{t.closest(e.AdminPanelSelectors.moduleParentClass).classList.remove(e.AdminPanelClasses.activeModule)})})})}};class t{constructor(e,t){this.adminPanel=e,this.element=t,this.initializeEvents()}isActive(){return this.element.classList.contains(e.AdminPanelClasses.active)}enable(){this.element.classList.add(e.AdminPanelClasses.active)}disable(){this.element.classList.remove(e.AdminPanelClasses.active)}initializeEvents(){this.element.addEventListener("click",()=>{this.isActive()?this.disable():(this.adminPanel.disablePopups(),this.enable())})}}class n{constructor(e,t){this.element=e,this.trigger=t,this.initializeEvents()}isActive(){return this.element.classList.contains(e.AdminPanelClasses.active)}enable(){this.element.classList.add(e.AdminPanelClasses.active)}disable(){this.element.classList.remove(e.AdminPanelClasses.active)}initializeEvents(){this.trigger.addEventListener("click",()=>{this.isActive()?this.disable():this.enable()})}}class a{constructor(e,t){this.element=e,this.trigger=t,this.initializeEvents()}isActive(){return this.element.classList.contains(e.AdminPanelClasses.activeContentSetting)}enable(){this.element.classList.add(e.AdminPanelClasses.activeContentSetting)}disable(){this.element.classList.remove(e.AdminPanelClasses.activeContentSetting)}initializeEvents(){this.trigger.addEventListener("click",()=>{this.isActive()?this.disable():this.enable()})}}class s{constructor(e,t,n){this.adminPanel=e,this.element=t,this.trigger=n,this.initializeEvents()}isActive(){return this.element.classList.contains(e.AdminPanelClasses.activeModule)}enable(){this.element.classList.add(e.AdminPanelClasses.activeModule)}disable(){this.element.classList.remove(e.AdminPanelClasses.activeModule)}initializeEvents(){this.trigger.addEventListener("click",()=>{this.adminPanel.removeBackdrop(),this.isActive()?this.disable():(this.adminPanel.disableModules(),this.adminPanel.renderBackdrop(),this.enable())})}}}(TYPO3||(TYPO3={})),window.addEventListener("load",()=>new TYPO3.AdminPanel,!1);
\ No newline at end of file
......@@ -10,4 +10,4 @@
*
* The TYPO3 project - inspiring people to share!
*/
define(["require","exports","./AbstractSortableSelectItems","jquery","../../FormEngineSuggest"],(function(e,t,r,s,n){"use strict";class l extends r.AbstractSortableSelectItems{constructor(e){super(),this.element=null,s(()=>{this.element=document.querySelector("#"+e),this.registerEventHandler(),this.registerSuggest()})}registerEventHandler(){this.registerSortableEventHandler(this.element)}registerSuggest(){let e;null!==(e=this.element.closest(".t3js-formengine-field-item").querySelector(".t3-form-suggest"))&&new n(e)}}return l}));
\ No newline at end of file
define(["require","exports","./AbstractSortableSelectItems","jquery","../../FormEngineSuggest"],(function(e,t,r,s,n){"use strict";class l extends r.AbstractSortableSelectItems{constructor(e){super(),this.element=null,s(()=>{this.element=document.getElementById(e),this.registerEventHandler(),this.registerSuggest()})}registerEventHandler(){this.registerSortableEventHandler(this.element)}registerSuggest(){let e;null!==(e=this.element.closest(".t3js-formengine-field-item").querySelector(".t3-form-suggest"))&&new n(e)}}return l}));
\ No newline at end of file
......@@ -10,4 +10,4 @@
*
* The TYPO3 project - inspiring people to share!
*/
define(["require","exports","jquery"],(function(e,t,i){"use strict";var l;!function(e){e.toggleSelector=".t3js-form-field-inputlink-explanation-toggle",e.inputFieldSelector=".t3js-form-field-inputlink-input",e.explanationSelector=".t3js-form-field-inputlink-explanation",e.iconSelector=".t3js-form-field-inputlink-icon"}(l||(l={}));return class{constructor(e){this.element=null,this.container=null,this.toggleSelector=null,this.explanationField=null,this.icon=null,i(()=>{this.element=document.querySelector("#"+e),this.container=this.element.closest(".t3js-form-field-inputlink"),this.toggleSelector=this.container.querySelector(l.toggleSelector),this.explanationField=this.container.querySelector(l.explanationSelector),this.icon=this.container.querySelector(l.iconSelector),this.toggleVisibility(""===this.explanationField.value),this.registerEventHandler()})}toggleVisibility(e){this.explanationField.classList.toggle("hidden",e),this.element.classList.toggle("hidden",!e);const t=this.container.querySelector(".form-control-clearable button.close");null!==t&&t.classList.toggle("hidden",!e)}registerEventHandler(){this.toggleSelector.addEventListener("click",e=>{e.preventDefault();const t=!this.explanationField.classList.contains("hidden");this.toggleVisibility(t)}),this.container.querySelector(l.inputFieldSelector).addEventListener("change",()=>{const e=!this.explanationField.classList.contains("hidden");e&&this.toggleVisibility(e),this.disableToggle(),this.clearIcon()})}disableToggle(){this.toggleSelector.classList.add("disabled"),this.toggleSelector.setAttribute("disabled","disabled")}clearIcon(){this.icon.innerHTML=""}}}));
\ No newline at end of file
define(["require","exports","jquery"],(function(e,t,i){"use strict";var l;!function(e){e.toggleSelector=".t3js-form-field-inputlink-explanation-toggle",e.inputFieldSelector=".t3js-form-field-inputlink-input",e.explanationSelector=".t3js-form-field-inputlink-explanation",e.iconSelector=".t3js-form-field-inputlink-icon"}(l||(l={}));return class{constructor(e){this.element=null,this.container=null,this.toggleSelector=null,this.explanationField=null,this.icon=null,i(()=>{this.element=document.getElementById(e),this.container=this.element.closest(".t3js-form-field-inputlink"),this.toggleSelector=this.container.querySelector(l.toggleSelector),this.explanationField=this.container.querySelector(l.explanationSelector),this.icon=this.container.querySelector(l.iconSelector),this.toggleVisibility(""===this.explanationField.value),this.registerEventHandler()})}toggleVisibility(e){this.explanationField.classList.toggle("hidden",e),this.element.classList.toggle("hidden",!e);const t=this.container.querySelector(".form-control-clearable button.close");null!==t&&t.classList.toggle("hidden",!e)}registerEventHandler(){this.toggleSelector.addEventListener("click",e=>{e.preventDefault();const t=!this.explanationField.classList.contains("hidden");this.toggleVisibility(t)}),this.container.querySelector(l.inputFieldSelector).addEventListener("change",()=>{const e=!this.explanationField.classList.contains("hidden");e&&this.toggleVisibility(e),this.disableToggle(),this.clearIcon()})}disableToggle(){this.toggleSelector.classList.add("disabled"),this.toggleSelector.setAttribute("disabled","disabled")}clearIcon(){this.icon.innerHTML=""}}}));
\ No newline at end of file
......@@ -10,4 +10,4 @@
*
* The TYPO3 project - inspiring people to share!
*/
define(["require","exports","./AbstractSortableSelectItems","jquery","TYPO3/CMS/Backend/FormEngine","./Extra/SelectBoxFilter"],(function(e,t,l,n,r,s){"use strict";class i extends l.AbstractSortableSelectItems{constructor(e,t){super(),this.selectedOptionsElement=null,this.availableOptionsElement=null,n(()=>{this.selectedOptionsElement=document.querySelector("#"+e),this.availableOptionsElement=document.querySelector("#"+t),this.registerEventHandler()})}registerEventHandler(){this.registerSortableEventHandler(this.selectedOptionsElement),this.availableOptionsElement.addEventListener("click",e=>{const t=e.currentTarget,l=t.dataset.relatedfieldname;if(l){const e=t.dataset.exclusiveValues,s=t.querySelectorAll("option:checked");s.length>0&&s.forEach(t=>{r.setSelectOptionFromExternalSource(l,t.value,t.textContent,t.getAttribute("title"),e,n(t))})}}),new s(this.availableOptionsElement)}}return i}));
\ No newline at end of file
define(["require","exports","./AbstractSortableSelectItems","jquery","TYPO3/CMS/Backend/FormEngine","./Extra/SelectBoxFilter"],(function(e,t,l,n,s,r){"use strict";class i extends l.AbstractSortableSelectItems{constructor(e,t){super(),this.selectedOptionsElement=null,this.availableOptionsElement=null,n(()=>{this.selectedOptionsElement=document.getElementById(e),this.availableOptionsElement=document.getElementById(t),this.registerEventHandler()})}registerEventHandler(){this.registerSortableEventHandler(this.selectedOptionsElement),this.availableOptionsElement.addEventListener("click",e=>{const t=e.currentTarget,l=t.dataset.relatedfieldname;if(l){const e=t.dataset.exclusiveValues,r=t.querySelectorAll("option:checked");r.length>0&&r.forEach(t=>{s.setSelectOptionFromExternalSource(l,t.value,t.textContent,t.getAttribute("title"),e,n(t))})}}),new r(this.availableOptionsElement)}}return i}));
\ No newline at end of file
......@@ -10,4 +10,4 @@
*
* The TYPO3 project - inspiring people to share!
*/
define(["require","exports","TYPO3/CMS/Backend/FormEngine/Element/SelectTree"],(function(e,t,r){"use strict";return class{constructor(e,t,r){this.treeWrapper=null,this.recordField=null,this.callback=null,this.treeWrapper=document.querySelector("#"+e),this.recordField=document.querySelector("#"+t),this.callback=r,this.initialize()}initialize(){const t=this.generateRequestUrl(),i=new r,a={dataUrl:t,showIcons:!0,showCheckboxes:!0,readOnlyMode:1===parseInt(this.recordField.dataset.readOnly,10),input:this.recordField,exclusiveNodesIdentifiers:this.recordField.dataset.treeExclusiveKeys,validation:JSON.parse(this.recordField.dataset.formengineValidationRules)[0],expandUpToLevel:this.recordField.dataset.treeExpandUpToLevel};i.initialize(this.treeWrapper,a)&&(i.dispatch.on("nodeSelectedAfter.requestUpdate",this.callback),this.recordField.dataset.treeShowToolbar&&e(["TYPO3/CMS/Backend/FormEngine/Element/TreeToolbar"],e=>{(new e).initialize(this.treeWrapper)}))}generateRequestUrl(){const e={tableName:this.recordField.dataset.tablename,fieldName:this.recordField.dataset.fieldname,uid:this.recordField.dataset.uid,recordTypeValue:this.recordField.dataset.recordtypevalue,dataStructureIdentifier:""!==this.recordField.dataset.datastructureidentifier?JSON.parse(this.recordField.dataset.datastructureidentifier):"",flexFormSheetName:this.recordField.dataset.flexformsheetname,flexFormFieldName:this.recordField.dataset.flexformfieldname,flexFormContainerName:this.recordField.dataset.flexformcontainername,flexFormContainerIdentifier:this.recordField.dataset.flexformcontaineridentifier,flexFormContainerFieldName:this.recordField.dataset.flexformcontainerfieldname,flexFormSectionContainerIsNew:this.recordField.dataset.flexformsectioncontainerisnew,command:this.recordField.dataset.command};return TYPO3.settings.ajaxUrls.record_tree_data+"&"+$.param(e)}}}));
\ No newline at end of file
define(["require","exports","TYPO3/CMS/Backend/FormEngine/Element/SelectTree"],(function(e,t,r){"use strict";return class{constructor(e,t,r){this.treeWrapper=null,this.recordField=null,this.callback=null,this.treeWrapper=document.getElementById(e),this.recordField=document.getElementById(t),this.callback=r,this.initialize()}initialize(){const t=this.generateRequestUrl(),i=new r,a={dataUrl:t,showIcons:!0,showCheckboxes:!0,readOnlyMode:1===parseInt(this.recordField.dataset.readOnly,10),input:this.recordField,exclusiveNodesIdentifiers:this.recordField.dataset.treeExclusiveKeys,validation:JSON.parse(this.recordField.dataset.formengineValidationRules)[0],expandUpToLevel:this.recordField.dataset.treeExpandUpToLevel};i.initialize(this.treeWrapper,a)&&(i.dispatch.on("nodeSelectedAfter.requestUpdate",this.callback),this.recordField.dataset.treeShowToolbar&&e(["TYPO3/CMS/Backend/FormEngine/Element/TreeToolbar"],e=>{(new e).initialize(this.treeWrapper)}))}generateRequestUrl(){const e={tableName:this.recordField.dataset.tablename,fieldName:this.recordField.dataset.fieldname,uid:this.recordField.dataset.uid,recordTypeValue:this.recordField.dataset.recordtypevalue,dataStructureIdentifier:""!==this.recordField.dataset.datastructureidentifier?JSON.parse(this.recordField.dataset.datastructureidentifier):"",flexFormSheetName:this.recordField.dataset.flexformsheetname,flexFormFieldName:this.recordField.dataset.flexformfieldname,flexFormContainerName:this.recordField.dataset.flexformcontainername,flexFormContainerIdentifier:this.recordField.dataset.flexformcontaineridentifier,flexFormContainerFieldName:this.recordField.dataset.flexformcontainerfieldname,flexFormSectionContainerIsNew:this.recordField.dataset.flexformsectioncontainerisnew,command:this.recordField.dataset.command};return TYPO3.settings.ajaxUrls.record_tree_data+"&"+$.param(e)}}}));
\ No newline at end of file
......@@ -10,4 +10,4 @@
*
* The TYPO3 project - inspiring people to share!
*/
define(["require","exports","./Modifier/Resizable","./Modifier/Tabbable","jquery"],(function(e,t,i,l,n){"use strict";return class{constructor(e){this.element=null,n(()=>{this.element=document.querySelector("#"+e),i.Resizable.enable(this.element),l.Tabbable.enable(this.element)})}}}));
\ No newline at end of file
define(["require","exports","./Modifier/Resizable","./Modifier/Tabbable","jquery"],(function(e,t,i,l,n){"use strict";return class{constructor(e){this.element=null,n(()=>{this.element=document.getElementById(e),i.Resizable.enable(this.element),l.Tabbable.enable(this.element)})}}}));
\ No newline at end of file
......@@ -10,4 +10,4 @@
*
* The TYPO3 project - inspiring people to share!
*/
define(["require","exports","./Modifier/Resizable","./Modifier/Tabbable","jquery"],(function(e,t,i,l,n){"use strict";return class{constructor(e){this.element=null,n(()=>{this.element=document.querySelector("#"+e),i.Resizable.enable(this.element),l.Tabbable.enable(this.element)})}}}));
\ No newline at end of file
define(["require","exports","./Modifier/Resizable","./Modifier/Tabbable","jquery"],(function(e,t,i,l,n){"use strict";return class{constructor(e){this.element=null,n(()=>{this.element=document.getElementById(e),i.Resizable.enable(this.element),l.Tabbable.enable(this.element)})}}}));
\ No newline at end of file
......@@ -10,4 +10,4 @@
*
* The TYPO3 project - inspiring people to share!
*/
define(["require","exports","jquery","./Enum/Severity","./Severity"],(function(e,t,a,s,i){"use strict";class n{static notice(e,t,a,i){n.showMessage(e,t,s.SeverityEnum.notice,a,i)}static info(e,t,a,i){n.showMessage(e,t,s.SeverityEnum.info,a,i)}static success(e,t,a,i){n.showMessage(e,t,s.SeverityEnum.ok,a,i)}static warning(e,t,a,i){n.showMessage(e,t,s.SeverityEnum.warning,a,i)}static error(e,t,a=0,i){n.showMessage(e,t,s.SeverityEnum.error,a,i)}static showMessage(e,t,n=s.SeverityEnum.info,r=this.duration,o=[]){const l=i.getCssClass(n);let c="";switch(n){case s.SeverityEnum.notice:c="lightbulb-o";break;case s.SeverityEnum.ok:c="check";break;case s.SeverityEnum.warning:c="exclamation";break;case s.SeverityEnum.error:c="times";break;case s.SeverityEnum.info:default:c="info"}r=void 0===r?this.duration:"string"==typeof r?parseFloat(r):r,null!==this.messageContainer&&null!==document.querySelector("#alert-container")||(this.messageContainer=a("<div>",{id:"alert-container"}).appendTo("body"));const d="notification-"+Math.random().toString(36).substr(2,5),u=a('<div id="'+d+'" class="alert alert-'+l+' alert-dismissible fade" role="alert"><button type="button" class="close" data-dismiss="alert"><span aria-hidden="true"><i class="fa fa-times-circle"></i></span><span class="sr-only">Close</span></button><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-'+c+' fa-stack-1x"></i></span></div><div class="media-body"><h4 class="alert-title"></h4><p class="alert-message text-pre-wrap"></p></div></div><div class="alert-actions"></div></div>');u.find(".alert-title").text(e),u.find(".alert-message").text(t);const f=u.find(".alert-actions");if(o.length>0)for(let e of o){const t=a("<a />",{href:"#",title:e.label});t.text(e.label),t.on("click",t=>{u.clearQueue();const a=t.currentTarget;a.classList.add("executing"),f.find("a").not(a).addClass("disabled"),e.action.execute(a).then(()=>{u.alert("close")})}),f.append(t)}else f.remove();u.on("close.bs.alert",e=>{e.preventDefault();const t=a(e.currentTarget);t.clearQueue().queue(e=>{t.removeClass("in"),e()}).slideUp({complete:()=>{t.remove()}})}),u.appendTo(this.messageContainer),u.delay(200).queue(e=>{u.addClass("in"),e()}),r>0&&u.delay(1e3*r).queue(e=>{u.alert("close"),e()})}}let r;n.duration=5,n.messageContainer=null;try{parent&&parent.window.TYPO3&&parent.window.TYPO3.Notification&&(r=parent.window.TYPO3.Notification),top&&top.TYPO3.Notification&&(r=top.TYPO3.Notification)}catch(e){}return r||(r=n,"undefined"!=typeof TYPO3&&(TYPO3.Notification=r)),r}));
\ No newline at end of file
define(["require","exports","jquery","./Enum/Severity","./Severity"],(function(e,t,a,s,i){"use strict";class n{static notice(e,t,a,i){n.showMessage(e,t,s.SeverityEnum.notice,a,i)}static info(e,t,a,i){n.showMessage(e,t,s.SeverityEnum.info,a,i)}static success(e,t,a,i){n.showMessage(e,t,s.SeverityEnum.ok,a,i)}static warning(e,t,a,i){n.showMessage(e,t,s.SeverityEnum.warning,a,i)}static error(e,t,a=0,i){n.showMessage(e,t,s.SeverityEnum.error,a,i)}static showMessage(e,t,n=s.SeverityEnum.info,r=this.duration,o=[]){const l=i.getCssClass(n);let c="";switch(n){case s.SeverityEnum.notice:c="lightbulb-o";break;case s.SeverityEnum.ok:c="check";break;case s.SeverityEnum.warning:c="exclamation";break;case s.SeverityEnum.error:c="times";break;case s.SeverityEnum.info:default:c="info"}r=void 0===r?this.duration:"string"==typeof r?parseFloat(r):r,null!==this.messageContainer&&null!==document.getElementById("alert-container")||(this.messageContainer=a("<div>",{id:"alert-container"}).appendTo("body"));const d="notification-"+Math.random().toString(36).substr(2,5),u=a('<div id="'+d+'" class="alert alert-'+l+' alert-dismissible fade" role="alert"><button type="button" class="close" data-dismiss="alert"><span aria-hidden="true"><i class="fa fa-times-circle"></i></span><span class="sr-only">Close</span></button><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-'+c+' fa-stack-1x"></i></span></div><div class="media-body"><h4 class="alert-title"></h4><p class="alert-message text-pre-wrap"></p></div></div><div class="alert-actions"></div></div>');u.find(".alert-title").text(e),u.find(".alert-message").text(t);const f=u.find(".alert-actions");if(o.length>0)for(let e of o){const t=a("<a />",{href:"#",title:e.label});t.text(e.label),t.on("click",t=>{u.clearQueue();const a=t.currentTarget;a.classList.add("executing"),f.find("a").not(a).addClass("disabled"),e.action.execute(a).then(()=>{u.alert("close")})}),f.append(t)}else f.remove();u.on("close.bs.alert",e=>{e.preventDefault();const t=a(e.currentTarget);t.clearQueue().queue(e=>{t.removeClass("in"),e()}).slideUp({complete:()=>{t.remove()}})}),u.appendTo(this.messageContainer),u.delay(200).queue(e=>{u.addClass("in"),e()}),r>0&&u.delay(1e3*r).queue(e=>{u.alert("close"),e()})}}let r;n.duration=5,n.messageContainer=null;try{parent&&parent.window.TYPO3&&parent.window.TYPO3.Notification&&(r=parent.window.TYPO3.Notification),top&&top.TYPO3.Notification&&(r=top.TYPO3.Notification)}catch(e){}return r||(r=n,"undefined"!=typeof TYPO3&&(TYPO3.Notification=r)),r}));
\ No newline at end of file
Markdown is supported
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