[TASK] Align configuration module search bar
[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 DocumentService = require('TYPO3/CMS/Core/DocumentService');
15 import RegularEvent = require('TYPO3/CMS/Core/Event/RegularEvent');
16
17 /**
18 * Module: TYPO3/CMS/Lowlevel/ConfigurationView
19 * JavaScript for Configuration View
20 */
21 class ConfigurationView {
22 private searchForm: HTMLFormElement = document.querySelector('#ConfigurationView');
23 private searchField: HTMLInputElement = this.searchForm.querySelector('input[name="searchString"]');
24 private searchResultShown: boolean = ('' !== this.searchField.value);
25
26 constructor() {
27 DocumentService.ready().then((): void => {
28 // Respond to browser related clearable event
29 new RegularEvent('search', (): void => {
30 if (this.searchField.value === '' && this.searchResultShown) {
31 this.searchForm.submit();
32 }
33 }).bindTo(this.searchField);
34 });
35
36 if (self.location.hash) {
37 // scroll page down, so the just opened subtree is visible after reload and not hidden by doc header
38 $('html, body').scrollTop((document.documentElement.scrollTop || document.body.scrollTop) - 80);
39 }
40 }
41 }
42
43 export = new ConfigurationView();