Commit f627a2c5 authored by Benni Mack's avatar Benni Mack

[TASK] Clean up TypeScript code for Element Browser / Link Picker

The Link Picker (RecordLinkHandler) and Element Browser logic
has been simplified to avoid jQuery where possible and to reduce
HTML rendering.

The data-icon information is never evaluated in TypeScript/JavaScript
and can be removed from any kind of HTML rendering, making the
transferred amount of HTML much smaller.

In addition, the insertElement method has been cleaned up to only
use the properties that are evaluated.

As a small side-effect, the InlineControlContainer does not
throw a console.warn if a post message cannot be evaluated
(which is typically the case for non-inline references).

Resolves: #93850
Releases: master
Change-Id: Ie850a3520ba5b448f5a1d0a42aa656b972b8d3a6
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/68668Tested-by: Andreas Fernandez's avatarAndreas Fernandez <a.fernandez@scripting-base.de>
Tested-by: default avatarTYPO3com <noreply@typo3.com>
Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Richard Haeser's avatarRichard Haeser <richard@richardhaeser.com>
Reviewed-by: Andreas Fernandez's avatarAndreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: Richard Haeser's avatarRichard Haeser <richard@richardhaeser.com>
parent 198ff6e3
......@@ -365,8 +365,6 @@ class InlineControlContainer {
MessageUtility.send(message, e.source as Window);
}
});
} else {
console.warn(`Unhandled action "${e.data.actionName}"`);
}
}
......
......@@ -11,8 +11,8 @@
* The TYPO3 project - inspiring people to share!
*/
import $ from 'jquery';
import ElementBrowser = require('./ElementBrowser');
import RegularEvent from 'TYPO3/CMS/Core/Event/RegularEvent';
/**
* Module: TYPO3/CMS/Recordlist/BrowseDatabase
......@@ -21,24 +21,17 @@ import ElementBrowser = require('./ElementBrowser');
*/
class BrowseDatabase {
constructor() {
$((): void => {
$('[data-close]').on('click', (event: JQueryEventObject): void => {
event.preventDefault();
const data = $(event.currentTarget).parents('span').data();
ElementBrowser.insertElement(
data.table,
data.uid,
'db',
data.title,
'',
'',
data.icon,
'',
parseInt($(event.currentTarget).data('close'), 10) === 1,
);
});
});
new RegularEvent('click', (evt: MouseEvent, targetEl: HTMLElement): void => {
evt.preventDefault();
const data = targetEl.closest('span').dataset;
ElementBrowser.insertElement(
data.table,
data.uid,
data.title,
'',
parseInt(targetEl.dataset.close || '0', 10) === 1,
);
}).delegateTo(document, '[data-close]');
// adjust searchbox layout
const searchbox: HTMLElement = document.getElementById('db_list-searchbox-toolbar');
......
......@@ -21,13 +21,8 @@ import RegularEvent = require('TYPO3/CMS/Core/Event/RegularEvent');
import Icons = TYPO3.Icons;
interface LinkElement {
fileExt: string;
fileIcon: string;
fileName: string;
filePath: any;
table: string;
type: string;
uid: number;
uid: string;
}
interface LinkElementStorage {
......@@ -46,20 +41,20 @@ class BrowseFiles {
BrowseFiles.File = new File();
BrowseFiles.Selector = new Selector();
$((): void => {
BrowseFiles.elements = $('body').data('elements');
new RegularEvent('click', (evt: MouseEvent, targetEl: HTMLElement): void => {
evt.preventDefault();
BrowseFiles.File.insertElement(
'file_' + targetEl.dataset.fileIndex,
parseInt(targetEl.dataset.close || '0', 10) === 1,
);
}).delegateTo(document, '[data-close]');
$('[data-close]').on('click', (e: JQueryEventObject): void => {
e.preventDefault();
BrowseFiles.File.insertElement(
'file_' + $(e.currentTarget).data('fileIndex'),
parseInt($(e.currentTarget).data('close'), 10) === 1,
);
});
new RegularEvent('change', (): void => {
BrowseFiles.Selector.toggleImportButton();
}).delegateTo(document, '.typo3-bulk-item');
new RegularEvent('change', (): void => {
BrowseFiles.Selector.toggleImportButton();
}).delegateTo(document, '.typo3-bulk-item');
$((): void => {
BrowseFiles.elements = $('body').data('elements');
$('#t3js-importSelection').on('click', BrowseFiles.Selector.handle);
$('#t3js-toggleSelection').on('click', BrowseFiles.Selector.toggle);
......@@ -77,14 +72,10 @@ class File {
if (typeof BrowseFiles.elements[index] !== 'undefined') {
const element: LinkElement = BrowseFiles.elements[index];
result = ElementBrowser.insertElement(
element.table,
'sys_file',
element.uid,
element.type,
element.fileName,
element.filePath,
element.fileExt,
element.fileIcon,
'',
element.uid,
close,
);
}
......
......@@ -11,10 +11,10 @@
* The TYPO3 project - inspiring people to share!
*/
import $ from 'jquery';
import ElementBrowser = require('./ElementBrowser');
import Modal = require('TYPO3/CMS/Backend/Modal');
import Severity = require('TYPO3/CMS/Backend/Severity');
import RegularEvent = require('TYPO3/CMS/Core/Event/RegularEvent');
/**
* Module: TYPO3/CMS/Recordlist/BrowseFolders
......@@ -23,20 +23,22 @@ import Severity = require('TYPO3/CMS/Backend/Severity');
*/
class BrowseFolders {
constructor() {
$(() => {
$('[data-folder-id]').on('click', (event: JQueryEventObject): void => {
event.preventDefault();
const $element: JQuery = $(event.currentTarget);
const folderId = $element.data('folderId');
const close = parseInt($element.data('close'), 10) === 1;
ElementBrowser.insertElement('', folderId, 'folder', folderId, folderId, '', '', '', close);
});
new RegularEvent('click', (evt: MouseEvent, targetEl: HTMLElement): void => {
evt.preventDefault();
const folderId = targetEl.dataset.folderId;
ElementBrowser.insertElement(
'',
folderId,
folderId,
folderId,
parseInt(targetEl.dataset.close || '0', 10) === 1
);
}).delegateTo(document, '[data-folder-id]');
$('.t3js-folderIdError').on('click', (event: JQueryEventObject): void => {
event.preventDefault();
Modal.confirm('', $(event.currentTarget).data('message'), Severity.error, [], []);
});
});
new RegularEvent('click', (evt: MouseEvent, targetEl: HTMLElement): void => {
evt.preventDefault();
Modal.confirm('', targetEl.dataset.message, Severity.error, [], []);
}).delegateTo(document, '.t3js-folderIdError');
}
}
......
......@@ -12,7 +12,7 @@
*/
import {MessageUtility} from 'TYPO3/CMS/Backend/Utility/MessageUtility';
import $ from 'jquery';
import DocumentService = require('TYPO3/CMS/Core/DocumentService');
import Modal = require('TYPO3/CMS/Backend/Modal');
interface RTESettings {
......@@ -21,7 +21,7 @@ interface RTESettings {
}
interface InlineSettings {
objectId: number;
objectId: string;
}
declare global {
......@@ -54,12 +54,12 @@ class ElementBrowser {
configuration: '',
};
private irre: InlineSettings = {
objectId: 0,
objectId: '',
};
constructor() {
$((): void => {
const data = $('body').data();
DocumentService.ready().then((): void => {
const data = document.body.dataset;
this.thisScriptUrl = data.thisScriptUrl;
this.mode = data.mode;
this.formFieldName = data.formFieldName;
......@@ -82,18 +82,6 @@ class ElementBrowser {
}
}
/**
* Dynamically calls a function on a given context object.
*/
public executeFunctionByName(functionName: string, context: any, ...args: Array<any>): any {
const namespaces = functionName.split('.');
const func = namespaces.pop();
for (let namespace of namespaces) {
context = context[namespace];
}
return context[func].apply(context, args);
}
/**
* Returns the parent document object
*/
......@@ -128,13 +116,9 @@ class ElementBrowser {
public insertElement(
table: string,
uid: number,
type: string,
filename: string,
fp: string,
filetype: string,
imagefile: string,
action: string,
uid: string,
title: string,
value: string,
close: boolean,
): boolean {
// Call a check function in the opener window (e.g. for uniqueness handling):
......@@ -160,18 +144,27 @@ class ElementBrowser {
}
if (this.fieldReference && !this.rte.parameters && !this.rte.configuration) {
this.addElement(filename, table + '_' + uid, fp, close);
this.addElement(title, value ? value : table + '_' + uid, close);
}
return false;
}
public addElement(elName: string, elValue: string, altElValue: string, close: boolean): void {
public focusOpenerAndClose = (): void => {
if (this.getParent()) {
this.getParent().focus();
}
Modal.dismiss();
close();
}
private addElement(label: string, value: string, close: boolean): void {
if (this.getParent()) {
const message = {
actionName: 'typo3:elementBrowser:elementAdded',
fieldName: this.fieldReference,
value: altElValue ? altElValue : elValue,
label: elName
value: value,
label: label
};
MessageUtility.send(message, this.getParent());
......@@ -183,14 +176,6 @@ class ElementBrowser {
this.focusOpenerAndClose();
}
}
public focusOpenerAndClose = (): void => {
if (this.getParent()) {
this.getParent().focus();
}
Modal.dismiss();
close();
}
}
export = new ElementBrowser();
......@@ -11,8 +11,8 @@
* The TYPO3 project - inspiring people to share!
*/
import $ from 'jquery';
import LinkBrowser = require('./LinkBrowser');
import RegularEvent from 'TYPO3/CMS/Core/Event/RegularEvent';
/**
* Module: TYPO3/CMS/Recordlist/RecordLinkHandler
......@@ -23,36 +23,23 @@ class RecordLinkHandler {
private identifier: string = '';
constructor() {
$((): void => {
const body = $('body');
this.currentLink = body.data('currentLink');
this.identifier = body.data('identifier');
// adjust searchbox layout
const searchbox: HTMLElement = document.getElementById('db_list-searchbox-toolbar');
searchbox.style.display = 'block';
searchbox.style.position = 'relative';
$('[data-close]').on('click', this.linkRecord);
$('input.t3js-linkCurrent').on('click', this.linkCurrent);
});
}
/**
* @param {JQueryEventObject} event
*/
public linkRecord = (event: JQueryEventObject): void => {
event.preventDefault();
const data = $(event.currentTarget).parents('span').data();
LinkBrowser.finalizeFunction(this.identifier + data.uid);
}
/**
* @param {JQueryEventObject} event
*/
public linkCurrent = (event: JQueryEventObject): void => {
event.preventDefault();
LinkBrowser.finalizeFunction(this.currentLink);
this.currentLink = document.body.dataset.currentLink;
this.identifier = document.body.dataset.identifier;
// adjust searchbox layout
const searchbox: HTMLElement = document.getElementById('db_list-searchbox-toolbar');
searchbox.style.display = 'block';
searchbox.style.position = 'relative';
new RegularEvent('click', (evt: MouseEvent, targetEl: HTMLElement): void => {
evt.preventDefault();
const data = targetEl.closest('span').dataset;
LinkBrowser.finalizeFunction(this.identifier + data.uid);
}).delegateTo(document, '[data-close]');
new RegularEvent('click', (evt: MouseEvent, targetEl: HTMLElement): void => {
evt.preventDefault();
LinkBrowser.finalizeFunction(this.currentLink);
}).delegateTo(document, 'input.t3js-linkCurrent');
}
}
......
......@@ -56,12 +56,11 @@ class ElementBrowserRecordList extends DatabaseRecordList
$code = BackendUtility::getRecordTitlePrep($code);
}
$title = BackendUtility::getRecordTitle($table, $row, false, true);
$ficon = $this->iconFactory->getIconForRecord($table, $row, Icon::SIZE_SMALL)->render();
$ATag = '<a href="#" data-close="0" title="' . htmlspecialchars($this->getLanguageService()->getLL('addToList')) . '">';
$ATag_alt = '<a href="#" data-close="1" title="' . htmlspecialchars($this->getLanguageService()->getLL('addToList')) . '">';
$ATag_e = '</a>';
$out = '<span data-uid="' . htmlspecialchars($row['uid']) . '" data-table="' . htmlspecialchars($table) . '" data-title="' . htmlspecialchars($title) . '" data-icon="' . htmlspecialchars($ficon) . '">';
$out = '<span data-uid="' . htmlspecialchars($row['uid']) . '" data-table="' . htmlspecialchars($table) . '" data-title="' . htmlspecialchars($title) . '">';
$out .= $ATag . $this->iconFactory->getIcon('actions-add', Icon::SIZE_SMALL)->render() . $ATag_e . $ATag_alt . $code . $ATag_e;
$out .= '</span>';
......
......@@ -179,7 +179,7 @@ class DatabaseBrowser extends AbstractElementBrowser implements ElementBrowserIn
$out .= '<p>' . $this->iconFactory->getIconForRecord('pages', $mainPageRecord, Icon::SIZE_SMALL)->render() . '&nbsp;';
if (in_array('pages', $tablesArr, true)) {
$out .= '<span data-uid="' . htmlspecialchars($mainPageRecord['uid']) . '" data-table="pages" data-title="' . htmlspecialchars($mainPageRecord['title']) . '" data-icon="">';
$out .= '<span data-uid="' . htmlspecialchars($mainPageRecord['uid']) . '" data-table="pages" data-title="' . htmlspecialchars($mainPageRecord['title']) . '">';
$out .= '<a href="#" data-close="0">'
. $this->iconFactory->getIcon('actions-add', Icon::SIZE_SMALL)->render()
. '</a>'
......
......@@ -280,13 +280,8 @@ class FileBrowser extends AbstractElementBrowser implements ElementBrowserInterf
// Create links for adding the file:
$filesIndex = count($this->elements);
$this->elements['file_' . $filesIndex] = [
'type' => 'file',
'table' => 'sys_file',
'uid' => $fileObject->getUid(),
'fileName' => $fileObject->getName(),
'filePath' => $fileObject->getUid(),
'fileExt' => $fileObject->getExtension(),
'fileIcon' => $icon
];
if ($this->fileIsSelectableInFileList($fileObject, $imgInfo)) {
$ATag = '<a href="#" class="btn btn-default" title="' . htmlspecialchars($fileObject->getName()) . '" data-file-index="' . $filesIndex . '" data-close="0">';
......
......@@ -15,9 +15,6 @@
namespace TYPO3\CMS\Recordlist\Tree\View;
use TYPO3\CMS\Core\Imaging\Icon;
use TYPO3\CMS\Core\Imaging\IconFactory;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\HttpUtility;
/**
......@@ -49,9 +46,7 @@ class ElementBrowserPageTreeView extends \TYPO3\CMS\Backend\Tree\View\ElementBro
public function wrapTitle($title, $v, $ext_pArrPages = false)
{
if ($ext_pArrPages && $v['uid']) {
$iconFactory = GeneralUtility::makeInstance(IconFactory::class);
$ficon = $iconFactory->getIconForRecord('pages', $v, Icon::SIZE_SMALL)->render();
$out = '<span data-uid="' . htmlspecialchars($v['uid']) . '" data-table="pages" data-title="' . htmlspecialchars($v['title']) . '" data-icon="' . htmlspecialchars($ficon) . '">';
$out = '<span data-uid="' . htmlspecialchars($v['uid']) . '" data-table="pages" data-title="' . htmlspecialchars($v['title']) . '">';
$out .= '<a href="#" data-close="1">' . $title . '</a>';
$out .= '</span>';
return $out;
......
......@@ -10,4 +10,4 @@
*
* The TYPO3 project - inspiring people to share!
*/
var __importDefault=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};define(["require","exports","jquery","./ElementBrowser"],(function(t,e,r,a){"use strict";r=__importDefault(r);return new class{constructor(){r.default(()=>{r.default("[data-close]").on("click",t=>{t.preventDefault();const e=r.default(t.currentTarget).parents("span").data();a.insertElement(e.table,e.uid,"db",e.title,"","",e.icon,"",1===parseInt(r.default(t.currentTarget).data("close"),10))})});const t=document.getElementById("db_list-searchbox-toolbar");t.style.display="block",t.style.position="relative"}}}));
\ No newline at end of file
var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};define(["require","exports","./ElementBrowser","TYPO3/CMS/Core/Event/RegularEvent"],(function(e,t,s,l){"use strict";l=__importDefault(l);return new class{constructor(){new l.default("click",(e,t)=>{e.preventDefault();const l=t.closest("span").dataset;s.insertElement(l.table,l.uid,l.title,"",1===parseInt(t.dataset.close||"0",10))}).delegateTo(document,"[data-close]");const e=document.getElementById("db_list-searchbox-toolbar");e.style.display="block",e.style.position="relative"}}}));
\ No newline at end of file
......@@ -10,4 +10,4 @@
*
* The TYPO3 project - inspiring people to share!
*/
var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};define(["require","exports","jquery","TYPO3/CMS/Backend/Utility/MessageUtility","./ElementBrowser","nprogress","TYPO3/CMS/Backend/LegacyTree","TYPO3/CMS/Core/Event/RegularEvent"],(function(e,t,n,l,i,o,s,r){"use strict";n=__importDefault(n);var a=TYPO3.Icons;class c{constructor(){s.noop(),c.File=new d,c.Selector=new u,n.default(()=>{c.elements=n.default("body").data("elements"),n.default("[data-close]").on("click",e=>{e.preventDefault(),c.File.insertElement("file_"+n.default(e.currentTarget).data("fileIndex"),1===parseInt(n.default(e.currentTarget).data("close"),10))}),new r("change",()=>{c.Selector.toggleImportButton()}).delegateTo(document,".typo3-bulk-item"),n.default("#t3js-importSelection").on("click",c.Selector.handle),n.default("#t3js-toggleSelection").on("click",c.Selector.toggle)})}}class d{insertElement(e,t){let n=!1;if(void 0!==c.elements[e]){const l=c.elements[e];n=i.insertElement(l.table,l.uid,l.type,l.fileName,l.filePath,l.fileExt,l.fileIcon,"",t)}return n}}class u{constructor(){this.toggle=e=>{e.preventDefault();const t=this.getItems();t.length&&t.each((e,t)=>{t.checked=t.checked?null:"checked"}),this.toggleImportButton()},this.handle=e=>{e.preventDefault();const t=this.getItems(),n=[];t.length&&(t.each((e,t)=>{t.checked&&t.name&&n.unshift(t.name)}),a.getIcon("spinner-circle",a.sizes.small,null,null,a.markupIdentifiers.inline).then(t=>{e.currentTarget.classList.add("disabled"),e.currentTarget.innerHTML=t}),this.handleSelection(n))}}getItems(){return n.default("#typo3-filelist").find(".typo3-bulk-item")}toggleImportButton(){const e=document.querySelectorAll("#typo3-filelist .typo3-bulk-item:checked").length>0;document.getElementById("t3js-importSelection").classList.toggle("disabled",!e)}handleSelection(e){o.configure({parent:"#typo3-filelist",showSpinner:!1}),o.start();const t=1/e.length;this.handleNext(e),new r("message",n=>{if(!l.MessageUtility.verifyOrigin(n.origin))throw"Denied message sent by "+n.origin;"typo3:foreignRelation:inserted"===n.data.actionName&&(e.length>0?(o.inc(t),this.handleNext(e)):(o.done(),i.focusOpenerAndClose()))}).bindTo(window)}handleNext(e){if(e.length>0){const t=e.pop();c.File.insertElement(t)}}}return new c}));
\ No newline at end of file
var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};define(["require","exports","jquery","TYPO3/CMS/Backend/Utility/MessageUtility","./ElementBrowser","nprogress","TYPO3/CMS/Backend/LegacyTree","TYPO3/CMS/Core/Event/RegularEvent"],(function(e,t,n,l,i,s,o,r){"use strict";n=__importDefault(n);var c=TYPO3.Icons;class a{constructor(){o.noop(),a.File=new d,a.Selector=new u,new r("click",(e,t)=>{e.preventDefault(),a.File.insertElement("file_"+t.dataset.fileIndex,1===parseInt(t.dataset.close||"0",10))}).delegateTo(document,"[data-close]"),new r("change",()=>{a.Selector.toggleImportButton()}).delegateTo(document,".typo3-bulk-item"),n.default(()=>{a.elements=n.default("body").data("elements"),n.default("#t3js-importSelection").on("click",a.Selector.handle),n.default("#t3js-toggleSelection").on("click",a.Selector.toggle)})}}class d{insertElement(e,t){let n=!1;if(void 0!==a.elements[e]){const l=a.elements[e];n=i.insertElement("sys_file",l.uid,l.fileName,l.uid,t)}return n}}class u{constructor(){this.toggle=e=>{e.preventDefault();const t=this.getItems();t.length&&t.each((e,t)=>{t.checked=t.checked?null:"checked"}),this.toggleImportButton()},this.handle=e=>{e.preventDefault();const t=this.getItems(),n=[];t.length&&(t.each((e,t)=>{t.checked&&t.name&&n.unshift(t.name)}),c.getIcon("spinner-circle",c.sizes.small,null,null,c.markupIdentifiers.inline).then(t=>{e.currentTarget.classList.add("disabled"),e.currentTarget.innerHTML=t}),this.handleSelection(n))}}getItems(){return n.default("#typo3-filelist").find(".typo3-bulk-item")}toggleImportButton(){const e=document.querySelectorAll("#typo3-filelist .typo3-bulk-item:checked").length>0;document.getElementById("t3js-importSelection").classList.toggle("disabled",!e)}handleSelection(e){s.configure({parent:"#typo3-filelist",showSpinner:!1}),s.start();const t=1/e.length;this.handleNext(e),new r("message",n=>{if(!l.MessageUtility.verifyOrigin(n.origin))throw"Denied message sent by "+n.origin;"typo3:foreignRelation:inserted"===n.data.actionName&&(e.length>0?(s.inc(t),this.handleNext(e)):(s.done(),i.focusOpenerAndClose()))}).bindTo(window)}handleNext(e){if(e.length>0){const t=e.pop();a.File.insertElement(t)}}}return new a}));
\ No newline at end of file
......@@ -10,4 +10,4 @@
*
* The TYPO3 project - inspiring people to share!
*/
var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};define(["require","exports","jquery","./ElementBrowser","TYPO3/CMS/Backend/Modal","TYPO3/CMS/Backend/Severity"],(function(e,t,r,a,l,n){"use strict";r=__importDefault(r);return new class{constructor(){r.default(()=>{r.default("[data-folder-id]").on("click",e=>{e.preventDefault();const t=r.default(e.currentTarget),l=t.data("folderId"),n=1===parseInt(t.data("close"),10);a.insertElement("",l,"folder",l,l,"","","",n)}),r.default(".t3js-folderIdError").on("click",e=>{e.preventDefault(),l.confirm("",r.default(e.currentTarget).data("message"),n.error,[],[])})})}}}));
\ No newline at end of file
define(["require","exports","./ElementBrowser","TYPO3/CMS/Backend/Modal","TYPO3/CMS/Backend/Severity","TYPO3/CMS/Core/Event/RegularEvent"],(function(e,t,r,n,a,o){"use strict";return new class{constructor(){new o("click",(e,t)=>{e.preventDefault();const n=t.dataset.folderId;r.insertElement("",n,n,n,1===parseInt(t.dataset.close||"0",10))}).delegateTo(document,"[data-folder-id]"),new o("click",(e,t)=>{e.preventDefault(),n.confirm("",t.dataset.message,a.error,[],[])}).delegateTo(document,".t3js-folderIdError")}}}));
\ No newline at end of file
......@@ -10,4 +10,4 @@
*
* The TYPO3 project - inspiring people to share!
*/
var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};define(["require","exports","TYPO3/CMS/Backend/Utility/MessageUtility","jquery","TYPO3/CMS/Backend/Modal"],(function(e,t,r,i,n){"use strict";i=__importDefault(i);return new class{constructor(){this.opener=null,this.thisScriptUrl="",this.mode="",this.formFieldName="",this.fieldReference="",this.fieldReferenceSlashed="",this.rte={parameters:"",configuration:""},this.irre={objectId:0},this.focusOpenerAndClose=()=>{this.getParent()&&this.getParent().focus(),n.dismiss(),close()},i.default(()=>{const e=i.default("body").data();this.thisScriptUrl=e.thisScriptUrl,this.mode=e.mode,this.formFieldName=e.formFieldName,this.fieldReference=e.fieldReference,this.fieldReferenceSlashed=e.fieldReferenceSlashed,this.rte.parameters=e.rteParameters,this.rte.configuration=e.rteConfiguration,this.irre.objectId=e.irreObjectId})}setReferences(){return!!(this.getParent()&&this.getParent().content&&this.getParent().content.document.editform&&this.getParent().content.document.editform[this.formFieldName])&&(this.targetDoc=this.getParent().content.document,this.elRef=this.targetDoc.editform[this.formFieldName],!0)}executeFunctionByName(e,t,...r){const i=e.split("."),n=i.pop();for(let e of i)t=t[e];return t[n].apply(t,r)}getParent(){return null===this.opener&&(void 0!==window.parent&&void 0!==window.parent.document.list_frame&&null!==window.parent.document.list_frame.parent.document.querySelector(".t3js-modal-iframe")?this.opener=window.parent.document.list_frame:void 0!==window.parent&&void 0!==window.parent.frames.list_frame&&null!==window.parent.frames.list_frame.parent.document.querySelector(".t3js-modal-iframe")?this.opener=window.parent.frames.list_frame:void 0!==window.frames&&void 0!==window.frames.frameElement&&null!==window.frames.frameElement&&window.frames.frameElement.classList.contains("t3js-modal-iframe")?this.opener=window.frames.frameElement.contentWindow.parent:window.opener&&(this.opener=window.opener)),this.opener}insertElement(e,t,i,n,s,o,a,d,l){if(this.irre.objectId){if(this.getParent()){const i={actionName:"typo3:foreignRelation:insert",objectGroup:this.irre.objectId,table:e,uid:t};r.MessageUtility.send(i,this.getParent())}else alert("Error - reference to main window is not set properly!"),this.focusOpenerAndClose();return l&&this.focusOpenerAndClose(),!0}return!this.fieldReference||this.rte.parameters||this.rte.configuration||this.addElement(n,e+"_"+t,s,l),!1}addElement(e,t,i,n){if(this.getParent()){const s={actionName:"typo3:elementBrowser:elementAdded",fieldName:this.fieldReference,value:i||t,label:e};r.MessageUtility.send(s,this.getParent()),n&&this.focusOpenerAndClose()}else alert("Error - reference to main window is not set properly!"),this.focusOpenerAndClose()}}}));
\ No newline at end of file
define(["require","exports","TYPO3/CMS/Backend/Utility/MessageUtility","TYPO3/CMS/Core/DocumentService","TYPO3/CMS/Backend/Modal"],(function(e,t,r,i,n){"use strict";return new class{constructor(){this.opener=null,this.thisScriptUrl="",this.mode="",this.formFieldName="",this.fieldReference="",this.fieldReferenceSlashed="",this.rte={parameters:"",configuration:""},this.irre={objectId:""},this.focusOpenerAndClose=()=>{this.getParent()&&this.getParent().focus(),n.dismiss(),close()},i.ready().then(()=>{const e=document.body.dataset;this.thisScriptUrl=e.thisScriptUrl,this.mode=e.mode,this.formFieldName=e.formFieldName,this.fieldReference=e.fieldReference,this.fieldReferenceSlashed=e.fieldReferenceSlashed,this.rte.parameters=e.rteParameters,this.rte.configuration=e.rteConfiguration,this.irre.objectId=e.irreObjectId})}setReferences(){return!!(this.getParent()&&this.getParent().content&&this.getParent().content.document.editform&&this.getParent().content.document.editform[this.formFieldName])&&(this.targetDoc=this.getParent().content.document,this.elRef=this.targetDoc.editform[this.formFieldName],!0)}getParent(){return null===this.opener&&(void 0!==window.parent&&void 0!==window.parent.document.list_frame&&null!==window.parent.document.list_frame.parent.document.querySelector(".t3js-modal-iframe")?this.opener=window.parent.document.list_frame:void 0!==window.parent&&void 0!==window.parent.frames.list_frame&&null!==window.parent.frames.list_frame.parent.document.querySelector(".t3js-modal-iframe")?this.opener=window.parent.frames.list_frame:void 0!==window.frames&&void 0!==window.frames.frameElement&&null!==window.frames.frameElement&&window.frames.frameElement.classList.contains("t3js-modal-iframe")?this.opener=window.frames.frameElement.contentWindow.parent:window.opener&&(this.opener=window.opener)),this.opener}insertElement(e,t,i,n,s){if(this.irre.objectId){if(this.getParent()){const i={actionName:"typo3:foreignRelation:insert",objectGroup:this.irre.objectId,table:e,uid:t};r.MessageUtility.send(i,this.getParent())}else alert("Error - reference to main window is not set properly!"),this.focusOpenerAndClose();return s&&this.focusOpenerAndClose(),!0}return!this.fieldReference||this.rte.parameters||this.rte.configuration||this.addElement(i,n||e+"_"+t,s),!1}addElement(e,t,i){if(this.getParent()){const n={actionName:"typo3:elementBrowser:elementAdded",fieldName:this.fieldReference,value:t,label:e};r.MessageUtility.send(n,this.getParent()),i&&this.focusOpenerAndClose()}else alert("Error - reference to main window is not set properly!"),this.focusOpenerAndClose()}}}));
\ No newline at end of file
......@@ -10,4 +10,4 @@
*
* The TYPO3 project - inspiring people to share!
*/
var __importDefault=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};define(["require","exports","jquery","./LinkBrowser"],(function(t,e,i,n){"use strict";i=__importDefault(i);return new class{constructor(){this.currentLink="",this.identifier="",this.linkRecord=t=>{t.preventDefault();const e=i.default(t.currentTarget).parents("span").data();n.finalizeFunction(this.identifier+e.uid)},this.linkCurrent=t=>{t.preventDefault(),n.finalizeFunction(this.currentLink)},i.default(()=>{const t=i.default("body");this.currentLink=t.data("currentLink"),this.identifier=t.data("identifier");const e=document.getElementById("db_list-searchbox-toolbar");e.style.display="block",e.style.position="relative",i.default("[data-close]").on("click",this.linkRecord),i.default("input.t3js-linkCurrent").on("click",this.linkCurrent)})}}}));
\ No newline at end of file
var __importDefault=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};define(["require","exports","./LinkBrowser","TYPO3/CMS/Core/Event/RegularEvent"],(function(t,e,i,n){"use strict";n=__importDefault(n);return new class{constructor(){this.currentLink="",this.identifier="",this.currentLink=document.body.dataset.currentLink,this.identifier=document.body.dataset.identifier;const t=document.getElementById("db_list-searchbox-toolbar");t.style.display="block",t.style.position="relative",new n.default("click",(t,e)=>{t.preventDefault();const n=e.closest("span").dataset;i.finalizeFunction(this.identifier+n.uid)}).delegateTo(document,"[data-close]"),new n.default("click",(t,e)=>{t.preventDefault(),i.finalizeFunction(this.currentLink)}).delegateTo(document,"input.t3js-linkCurrent")}}}));
\ 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