ff360256839abdac263c08ad702979db16ff25f2
[Packages/TYPO3.CMS.git] / Build / Sources / TypeScript / lowlevel / Resources / Public / TypeScript / ConfigurationView.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 $ from 'jquery';
15 import 'TYPO3/CMS/Backend/Input/Clearable';
16
17 /**
18 * Module: TYPO3/CMS/Lowlevel/ConfigurationView
19 * JavaScript for Configuration View
20 */
21 class ConfigurationView {
22 private searchField: HTMLInputElement = document.querySelector('input[name="searchString"]');
23 private searchResultShown: boolean = ('' !== this.searchField.value);
24
25 constructor() {
26 // make search field clearable
27 this.searchField.clearable({
28 onClear: (input: HTMLInputElement): void => {
29 if (this.searchResultShown) {
30 input.closest('form').submit();
31 }
32 },
33 });
34 if (self.location.hash) {
35 // scroll page down, so the just opened subtree is visible after reload and not hidden by doc header
36 $('html, body').scrollTop((document.documentElement.scrollTop || document.body.scrollTop) - 80);
37 }
38 }
39 }
40
41 export = new ConfigurationView();