760bac5b35be8c4e88f4b66d8c0230bf488be597
[Packages/TYPO3.CMS.git] / typo3 / sysext / filelist / Resources / Public / JavaScript / FileDelete.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/FileDelete
16 * JavaScript for file delete
17 */
18 define(['jquery', 'TYPO3/CMS/Backend/Modal', 'TYPO3/CMS/Backend/Severity'], function ($, Modal, Severity) {
19
20 $(document).on('click', '.t3js-filelist-delete', function(e) {
21 e.preventDefault();
22 var $anchorElement = $(this);
23 var redirectUrl = $anchorElement.data('redirectUrl');
24 if (redirectUrl) {
25 redirectUrl = top.rawurlencode(redirectUrl);
26 } else {
27 redirectUrl = top.rawurlencode(top.content.list_frame.document.location.pathname+top.content.list_frame.document.location.search);
28 }
29 var identifier = $anchorElement.data('identifier');
30 var veriCode = $anchorElement.data('veriCode');
31 var deleteType = $anchorElement.data('deleteType');
32 var deleteUrl = $anchorElement.data('deleteUrl') + '&file[delete][0][data]=' + encodeURIComponent(identifier) + '&vC=' + encodeURIComponent(veriCode);
33 if ($anchorElement.data('check')) {
34 var $modal = Modal.confirm($anchorElement.data('title'), $anchorElement.data('content'), Severity.warning, [
35 {
36 text: TYPO3.lang['buttons.confirm.delete_file.no'] || 'Cancel',
37 active: true,
38 btnClass: 'btn-default',
39 name: 'no'
40 },
41 {
42 text: TYPO3.lang['buttons.confirm.' + deleteType + '.yes'] || 'Yes, delete this file or folder',
43 btnClass: 'btn-warning',
44 name: 'yes'
45 }
46 ]);
47 $modal.on('button.clicked', function(e) {
48 if (e.target.name === 'no') {
49 Modal.dismiss();
50 } else if (e.target.name === 'yes') {
51 Modal.dismiss();
52 top.content.list_frame.location.href = deleteUrl + '&redirect=' + redirectUrl;
53 }
54 });
55 } else {
56 top.content.list_frame.location.href = deleteUrl + '&redirect=' + redirectUrl;
57 }
58 });
59
60 });