[TASK] Move FieldControl/ListModule handling to module
[Packages/TYPO3.CMS.git] / typo3 / sysext / backend / Resources / Private / TypeScript / FormEngine / FieldControl / ListModule.ts
1 /*
2 * This file is part of the TYPO3 CMS project.
3 *
4 * It is free software; you can redistribute it and/or modify it under
5 * the terms of the GNU General Public License, either version 2
6 * of the License, or any later version.
7 *
8 * For the full copyright and license information, please read the
9 * LICENSE.txt file that was distributed with this source code.
10 *
11 * The TYPO3 project - inspiring people to share!
12 */
13
14 import * as $ from 'jquery';
15 import FormEngine = require('TYPO3/CMS/Backend/FormEngine');
16
17 /**
18 * This module is used for the field control "List module" used for "group" fields
19 */
20 class ListModule {
21 private controlElement: HTMLElement = null;
22
23 constructor(controlElementId: string) {
24 $((): void => {
25 this.controlElement = <HTMLElement>document.querySelector(controlElementId);
26 this.controlElement.addEventListener('click', this.registerClickHandler);
27 });
28 }
29
30 /**
31 * @param {Event} e
32 */
33 private registerClickHandler = (e: Event): void => {
34 e.preventDefault();
35
36 FormEngine.preventFollowLinkIfNotSaved(this.controlElement.getAttribute('href'));
37 }
38 }
39
40 export = ListModule;