595dff5406636ea1f0e985ae207e1c500a71b463
[Packages/TYPO3.CMS.git] / typo3 / sysext / recordlist / Resources / Public / JavaScript / FileLinkHandler.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 * File link interaction
16 */
17 define('TYPO3/CMS/Recordlist/FileLinkHandler', ['jquery', 'TYPO3/CMS/Recordlist/LinkBrowser', 'TYPO3/CMS/Backend/LegacyTree'], function($, LinkBrowser, Tree) {
18 "use strict";
19
20 var FileLinkHandler = {
21 currentLink: ''
22 };
23
24 FileLinkHandler.linkFile = function(event) {
25 event.preventDefault();
26
27 LinkBrowser.updateValueInMainForm($(this).data('file'));
28
29 close();
30 };
31
32 FileLinkHandler.linkCurrent = function(event) {
33 event.preventDefault();
34
35 LinkBrowser.updateValueInMainForm(FileLinkHandler.currentLink);
36
37 close();
38
39 };
40
41 Tree.ajaxID = 'sc_alt_file_navframe_expandtoggle';
42
43 $(function() {
44 FileLinkHandler.currentLink = $('body').data('currentLink');
45
46 $('a.t3-js-fileLink').on('click', FileLinkHandler.linkFile);
47 $('input.t3-js-linkCurrent').on('click', FileLinkHandler.linkCurrent);
48 });
49
50 return FileLinkHandler;
51 });