Commit db2b2ca6 authored by Andreas Fernandez's avatar Andreas Fernandez
Browse files

[TASK] Use DocumentService.ready() in non-jQuery modules

Some modules have been rewritten to not use jQuery in the past. However,
there was still a dependency due to missing `ready` handling.
Since recent changes TYPO3 is capable of such handling and enables to
remove jQuery completely from some modules.

Resolves: #91598
Releases: master
Change-Id: I23fa63f9090eee8abc49cd1993df27bec12d92e2
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/64832


Tested-by: default avatarTYPO3com <noreply@typo3.com>
Tested-by: Andreas Fernandez's avatarAndreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: Oliver Hader's avatarOliver Hader <oliver.hader@typo3.org>
Reviewed-by: Andreas Fernandez's avatarAndreas Fernandez <a.fernandez@scripting-base.de>
parent 31b32c28
......@@ -12,7 +12,7 @@
*/
import {AbstractSortableSelectItems} from './AbstractSortableSelectItems';
import * as $ from 'jquery';
import DocumentService = require('TYPO3/CMS/Core/DocumentService');
import FormEngineSuggest = require('../../FormEngineSuggest');
class GroupElement extends AbstractSortableSelectItems {
......@@ -21,7 +21,7 @@ class GroupElement extends AbstractSortableSelectItems {
constructor(elementId: string) {
super();
$((): void => {
DocumentService.ready().then((): void => {
this.element = <HTMLSelectElement>document.getElementById(elementId);
this.registerEventHandler();
this.registerSuggest();
......
......@@ -13,13 +13,13 @@
import {Resizable} from './Modifier/Resizable';
import {Tabbable} from './Modifier/Tabbable';
import * as $ from 'jquery';
import DocumentService = require('TYPO3/CMS/Core/DocumentService');
class TextElement {
private element: HTMLTextAreaElement = null;
constructor(elementId: string) {
$((): void => {
DocumentService.ready().then((): void => {
this.element = <HTMLTextAreaElement>document.getElementById(elementId);
Resizable.enable(this.element);
......
......@@ -13,13 +13,13 @@
import {Resizable} from './Modifier/Resizable';
import {Tabbable} from './Modifier/Tabbable';
import * as $ from 'jquery';
import DocumentService = require('TYPO3/CMS/Core/DocumentService');
class TextTableElement {
private element: HTMLTextAreaElement = null;
constructor(elementId: string) {
$((): void => {
DocumentService.ready().then((): void => {
this.element = <HTMLTextAreaElement>document.getElementById(elementId);
Resizable.enable(this.element);
......
......@@ -11,7 +11,7 @@
* The TYPO3 project - inspiring people to share!
*/
import * as $ from 'jquery';
import DocumentService = require('TYPO3/CMS/Core/DocumentService');
import FormEngine = require('TYPO3/CMS/Backend/FormEngine');
/**
......@@ -21,7 +21,7 @@ class AddRecord {
private controlElement: HTMLElement = null;
constructor(controlElementId: string) {
$((): void => {
DocumentService.ready().then((): void => {
this.controlElement = <HTMLElement>document.querySelector(controlElementId);
this.controlElement.addEventListener('click', this.registerClickHandler);
});
......
......@@ -11,7 +11,7 @@
* The TYPO3 project - inspiring people to share!
*/
import * as $ from 'jquery';
import DocumentService = require('TYPO3/CMS/Core/DocumentService');
/**
* Handles the "Edit popup" field control that renders a new FormEngine instance
......@@ -21,7 +21,7 @@ class EditPopup {
private assignedFormField: HTMLSelectElement = null;
constructor(controlElementId: string) {
$((): void => {
DocumentService.ready().then((): void => {
this.controlElement = <HTMLAnchorElement>document.querySelector(controlElementId);
this.assignedFormField = <HTMLSelectElement>document.querySelector(
'select[data-formengine-input-name="' + this.controlElement.dataset.element + '"]',
......
......@@ -11,7 +11,7 @@
* The TYPO3 project - inspiring people to share!
*/
import * as $ from 'jquery';
import DocumentService = require('TYPO3/CMS/Core/DocumentService');
import FormEngine = require('TYPO3/CMS/Backend/FormEngine');
interface ClipboardItem {
......@@ -26,7 +26,7 @@ class InsertClipboard {
private controlElement: HTMLElement = null;
constructor(controlElementId: string) {
$((): void => {
DocumentService.ready().then((): void => {
this.controlElement = <HTMLElement>document.querySelector(controlElementId);
this.controlElement.addEventListener('click', this.registerClickHandler);
});
......
......@@ -11,7 +11,7 @@
* The TYPO3 project - inspiring people to share!
*/
import * as $ from 'jquery';
import DocumentService = require('TYPO3/CMS/Core/DocumentService');
import FormEngine = require('TYPO3/CMS/Backend/FormEngine');
import Modal = require('../../Modal');
......@@ -22,7 +22,7 @@ class LinkPopup {
private controlElement: HTMLElement = null;
constructor(controlElementId: string) {
$((): void => {
DocumentService.ready().then((): void => {
this.controlElement = <HTMLElement>document.querySelector(controlElementId);
this.controlElement.addEventListener('click', this.handleControlClick);
});
......
......@@ -11,7 +11,7 @@
* The TYPO3 project - inspiring people to share!
*/
import * as $ from 'jquery';
import DocumentService = require('TYPO3/CMS/Core/DocumentService');
import FormEngine = require('TYPO3/CMS/Backend/FormEngine');
/**
......@@ -21,7 +21,7 @@ class ListModule {
private controlElement: HTMLElement = null;
constructor(controlElementId: string) {
$((): void => {
DocumentService.ready().then((): void => {
this.controlElement = <HTMLElement>document.querySelector(controlElementId);
this.controlElement.addEventListener('click', this.registerClickHandler);
});
......
......@@ -11,7 +11,7 @@
* The TYPO3 project - inspiring people to share!
*/
import * as $ from 'jquery';
import DocumentService = require('TYPO3/CMS/Core/DocumentService');
/**
* This module is used for the field control "Reset selection" used for selectSingleBox
......@@ -20,7 +20,7 @@ class ResetSelection {
private controlElement: HTMLElement = null;
constructor(controlElementId: string) {
$((): void => {
DocumentService.ready().then((): void => {
this.controlElement = <HTMLElement>document.querySelector(controlElementId);
if (this.controlElement !== null) {
this.controlElement.addEventListener('click', this.registerClickHandler);
......
......@@ -11,7 +11,7 @@
* The TYPO3 project - inspiring people to share!
*/
import * as $ from 'jquery';
import DocumentService = require('TYPO3/CMS/Core/DocumentService');
import FormEngine = require('TYPO3/CMS/Backend/FormEngine');
/**
......@@ -21,7 +21,7 @@ class TableWizard {
private controlElement: HTMLElement = null;
constructor(controlElementId: string) {
$((): void => {
DocumentService.ready().then((): void => {
this.controlElement = <HTMLElement>document.querySelector(controlElementId);
this.controlElement.addEventListener('click', this.registerClickHandler);
});
......
......@@ -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.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
define(["require","exports","./AbstractSortableSelectItems","TYPO3/CMS/Core/DocumentService","../../FormEngineSuggest"],(function(e,t,r,s,n){"use strict";class l extends r.AbstractSortableSelectItems{constructor(e){super(),this.element=null,s.ready().then(()=>{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","./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
define(["require","exports","./Modifier/Resizable","./Modifier/Tabbable","TYPO3/CMS/Core/DocumentService"],(function(e,t,n,i,l){"use strict";return class{constructor(e){this.element=null,l.ready().then(()=>{this.element=document.getElementById(e),n.Resizable.enable(this.element),i.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.getElementById(e),i.Resizable.enable(this.element),l.Tabbable.enable(this.element)})}}}));
\ No newline at end of file
define(["require","exports","./Modifier/Resizable","./Modifier/Tabbable","TYPO3/CMS/Core/DocumentService"],(function(e,t,n,i,l){"use strict";return class{constructor(e){this.element=null,l.ready().then(()=>{this.element=document.getElementById(e),n.Resizable.enable(this.element),i.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","TYPO3/CMS/Backend/FormEngine"],(function(e,t,r,n){"use strict";return class{constructor(e){this.controlElement=null,this.registerClickHandler=e=>{e.preventDefault(),n.preventFollowLinkIfNotSaved(this.controlElement.getAttribute("href"))},r(()=>{this.controlElement=document.querySelector(e),this.controlElement.addEventListener("click",this.registerClickHandler)})}}}));
\ No newline at end of file
define(["require","exports","TYPO3/CMS/Core/DocumentService","TYPO3/CMS/Backend/FormEngine"],(function(e,t,r,n){"use strict";return class{constructor(e){this.controlElement=null,this.registerClickHandler=e=>{e.preventDefault(),n.preventFollowLinkIfNotSaved(this.controlElement.getAttribute("href"))},r.ready().then(()=>{this.controlElement=document.querySelector(e),this.controlElement.addEventListener("click",this.registerClickHandler)})}}}));
\ No newline at end of file
......@@ -10,4 +10,4 @@
*
* The TYPO3 project - inspiring people to share!
*/
define(["require","exports","jquery"],(function(e,t,s){"use strict";return class{constructor(e){this.controlElement=null,this.assignedFormField=null,this.registerChangeHandler=()=>{this.controlElement.classList.toggle("disabled",-1===this.assignedFormField.options.selectedIndex)},this.registerClickHandler=e=>{e.preventDefault();const t=[];for(let e=0;e<this.assignedFormField.selectedOptions.length;++e){const s=this.assignedFormField.selectedOptions.item(e);t.push(s.value)}const s=this.controlElement.getAttribute("href")+"&P[currentValue]="+encodeURIComponent(this.assignedFormField.value)+"&P[currentSelectedValues]="+t.join(",");window.open(s,"",this.controlElement.dataset.windowParameters).focus()},s(()=>{this.controlElement=document.querySelector(e),this.assignedFormField=document.querySelector('select[data-formengine-input-name="'+this.controlElement.dataset.element+'"]'),-1===this.assignedFormField.options.selectedIndex&&this.controlElement.classList.add("disabled"),this.assignedFormField.addEventListener("change",this.registerChangeHandler),this.controlElement.addEventListener("click",this.registerClickHandler)})}}}));
\ No newline at end of file
define(["require","exports","TYPO3/CMS/Core/DocumentService"],(function(e,t,s){"use strict";return class{constructor(e){this.controlElement=null,this.assignedFormField=null,this.registerChangeHandler=()=>{this.controlElement.classList.toggle("disabled",-1===this.assignedFormField.options.selectedIndex)},this.registerClickHandler=e=>{e.preventDefault();const t=[];for(let e=0;e<this.assignedFormField.selectedOptions.length;++e){const s=this.assignedFormField.selectedOptions.item(e);t.push(s.value)}const s=this.controlElement.getAttribute("href")+"&P[currentValue]="+encodeURIComponent(this.assignedFormField.value)+"&P[currentSelectedValues]="+t.join(",");window.open(s,"",this.controlElement.dataset.windowParameters).focus()},s.ready().then(()=>{this.controlElement=document.querySelector(e),this.assignedFormField=document.querySelector('select[data-formengine-input-name="'+this.controlElement.dataset.element+'"]'),-1===this.assignedFormField.options.selectedIndex&&this.controlElement.classList.add("disabled"),this.assignedFormField.addEventListener("change",this.registerChangeHandler),this.controlElement.addEventListener("click",this.registerClickHandler)})}}}));
\ No newline at end of file
......@@ -10,4 +10,4 @@
*
* The TYPO3 project - inspiring people to share!
*/
define(["require","exports","jquery","TYPO3/CMS/Backend/FormEngine"],(function(e,t,r,n){"use strict";return class{constructor(e){this.controlElement=null,this.registerClickHandler=e=>{e.preventDefault();const t=this.controlElement.dataset.element,r=JSON.parse(this.controlElement.dataset.clipboardItems);for(let e of r)n.setSelectOptionFromExternalSource(t,e.value,e.title,e.title)},r(()=>{this.controlElement=document.querySelector(e),this.controlElement.addEventListener("click",this.registerClickHandler)})}}}));
\ No newline at end of file
define(["require","exports","TYPO3/CMS/Core/DocumentService","TYPO3/CMS/Backend/FormEngine"],(function(e,t,r,n){"use strict";return class{constructor(e){this.controlElement=null,this.registerClickHandler=e=>{e.preventDefault();const t=this.controlElement.dataset.element,r=JSON.parse(this.controlElement.dataset.clipboardItems);for(let e of r)n.setSelectOptionFromExternalSource(t,e.value,e.title,e.title)},r.ready().then(()=>{this.controlElement=document.querySelector(e),this.controlElement.addEventListener("click",this.registerClickHandler)})}}}));
\ No newline at end of file
......@@ -10,4 +10,4 @@
*
* The TYPO3 project - inspiring people to share!
*/
define(["require","exports","jquery","TYPO3/CMS/Backend/FormEngine","../../Modal"],(function(e,t,n,o,l){"use strict";return class{constructor(e){this.controlElement=null,this.handleControlClick=e=>{e.preventDefault();const t=this.controlElement.dataset.itemName,n=this.controlElement.getAttribute("href")+"&P[currentValue]="+encodeURIComponent(document.editform[t].value)+"&P[currentSelectedValues]="+encodeURIComponent(o.getFieldElement(t).val());l.advanced({type:l.types.iframe,content:n,size:l.sizes.large})},n(()=>{this.controlElement=document.querySelector(e),this.controlElement.addEventListener("click",this.handleControlClick)})}}}));
\ No newline at end of file
define(["require","exports","TYPO3/CMS/Core/DocumentService","TYPO3/CMS/Backend/FormEngine","../../Modal"],(function(e,t,n,o,r){"use strict";return class{constructor(e){this.controlElement=null,this.handleControlClick=e=>{e.preventDefault();const t=this.controlElement.dataset.itemName,n=this.controlElement.getAttribute("href")+"&P[currentValue]="+encodeURIComponent(document.editform[t].value)+"&P[currentSelectedValues]="+encodeURIComponent(o.getFieldElement(t).val());r.advanced({type:r.types.iframe,content:n,size:r.sizes.large})},n.ready().then(()=>{this.controlElement=document.querySelector(e),this.controlElement.addEventListener("click",this.handleControlClick)})}}}));
\ No newline at end of file
......@@ -10,4 +10,4 @@
*
* The TYPO3 project - inspiring people to share!
*/
define(["require","exports","jquery","TYPO3/CMS/Backend/FormEngine"],(function(e,t,r,n){"use strict";return class{constructor(e){this.controlElement=null,this.registerClickHandler=e=>{e.preventDefault(),n.preventFollowLinkIfNotSaved(this.controlElement.getAttribute("href"))},r(()=>{this.controlElement=document.querySelector(e),this.controlElement.addEventListener("click",this.registerClickHandler)})}}}));
\ No newline at end of file
define(["require","exports","TYPO3/CMS/Core/DocumentService","TYPO3/CMS/Backend/FormEngine"],(function(e,t,r,n){"use strict";return class{constructor(e){this.controlElement=null,this.registerClickHandler=e=>{e.preventDefault(),n.preventFollowLinkIfNotSaved(this.controlElement.getAttribute("href"))},r.ready().then(()=>{this.controlElement=document.querySelector(e),this.controlElement.addEventListener("click",this.registerClickHandler)})}}}));
\ No newline at end of file
......@@ -10,4 +10,4 @@
*
* The TYPO3 project - inspiring people to share!
*/
define(["require","exports","jquery"],(function(e,t,n){"use strict";return class{constructor(e){this.controlElement=null,this.registerClickHandler=e=>{e.preventDefault();const t=this.controlElement.dataset.itemName,n=JSON.parse(this.controlElement.dataset.selectedIndices),r=document.forms.namedItem("editform").querySelector('[name="'+t+'[]"]');r.selectedIndex=-1;for(let e of n)r.options[e].selected=!0},n(()=>{this.controlElement=document.querySelector(e),null!==this.controlElement&&this.controlElement.addEventListener("click",this.registerClickHandler)})}}}));
\ No newline at end of file
define(["require","exports","TYPO3/CMS/Core/DocumentService"],(function(e,t,n){"use strict";return class{constructor(e){this.controlElement=null,this.registerClickHandler=e=>{e.preventDefault();const t=this.controlElement.dataset.itemName,n=JSON.parse(this.controlElement.dataset.selectedIndices),r=document.forms.namedItem("editform").querySelector('[name="'+t+'[]"]');r.selectedIndex=-1;for(let e of n)r.options[e].selected=!0},n.ready().then(()=>{this.controlElement=document.querySelector(e),null!==this.controlElement&&this.controlElement.addEventListener("click",this.registerClickHandler)})}}}));
\ No newline at end of file
......@@ -10,4 +10,4 @@
*
* The TYPO3 project - inspiring people to share!
*/
define(["require","exports","jquery","TYPO3/CMS/Backend/FormEngine"],(function(e,t,r,n){"use strict";return class{constructor(e){this.controlElement=null,this.registerClickHandler=e=>{e.preventDefault(),n.preventFollowLinkIfNotSaved(this.controlElement.getAttribute("href"))},r(()=>{this.controlElement=document.querySelector(e),this.controlElement.addEventListener("click",this.registerClickHandler)})}}}));
\ No newline at end of file
define(["require","exports","TYPO3/CMS/Core/DocumentService","TYPO3/CMS/Backend/FormEngine"],(function(e,t,r,n){"use strict";return class{constructor(e){this.controlElement=null,this.registerClickHandler=e=>{e.preventDefault(),n.preventFollowLinkIfNotSaved(this.controlElement.getAttribute("href"))},r.ready().then(()=>{this.controlElement=document.querySelector(e),this.controlElement.addEventListener("click",this.registerClickHandler)})}}}));
\ 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