b2a08d18f9fa078b43e9cce453c2bf0b3063fdb9
[Packages/TYPO3.CMS.git] / typo3 / sysext / filelist / Resources / Public / JavaScript / FileSearch.js
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 /**
15 * Module: TYPO3/CMS/Filelist/FileSearch
16 * JavaScript for file search
17 * @exports TYPO3/CMS/Filelist/FileSearch
18 */
19 define(['jquery', 'TYPO3/CMS/Backend/jquery.clearable'], function($) {
20
21 var $searchFields = $('input[name="tx_filelist_file_filelistlist[searchWord]"]');
22 var searchResultShown = ('' !== $searchFields.first().val());
23
24 // make search field clearable
25 $searchFields.clearable({
26 onClear: function() {
27 if (searchResultShown) {
28 $(this).closest('form').submit();
29 }
30 }
31 });
32
33 });