760a0d0ec2102d31cd822ed85ad0ba7f69dd42b6
[Packages/TYPO3.CMS.git] / typo3 / sysext / extensionmanager / Resources / Public / JavaScript / ter.js
1 // IIFE for faster access to $ and save $ use
2 (function ($) {
3
4 $(document).ready(function() {
5 $('#terTable').dataTable({
6 "bJQueryUI":true,
7 "bLengthChange": false,
8 'iDisplayLength': 15,
9 "bStateSave": false,
10 "bInfo": false,
11 "bPaginate": false,
12 "bFilter": false,
13 "fnDrawCallback": bindDownload
14 });
15
16 $('#terVersionTable').dataTable({
17 "bJQueryUI":true,
18 "bLengthChange":false,
19 'iDisplayLength':15,
20 "bStateSave":false,
21 "bInfo":false,
22 "bPaginate":false,
23 "bFilter":false,
24 "aaSorting":[[0, 'desc']],
25 "fnDrawCallback":bindDownload
26 });
27
28 $('#terSearchTable').dataTable({
29 "sPaginationType":"full_numbers",
30 "bJQueryUI":true,
31 "bLengthChange": false,
32 'iDisplayLength': 15,
33 "bStateSave": false,
34 "oLanguage": {
35 "sSearch": "Filter results:"
36 },
37 "aaSorting": [],
38 "fnDrawCallback": bindDownload
39 });
40 bindDownload();
41 });
42
43 function bindDownload() {
44 var installButtons = $('.downloadFromTer form.download input[type=submit]');
45 installButtons.off('click');
46 installButtons.on('click', function(event) {
47 event.preventDefault();
48 var url = $(event.currentTarget.form).attr('href');
49 downloadPath = $(event.currentTarget.form).find('input.downloadPath:checked').val();
50 $.ajax({
51 url: url,
52 dataType: 'json',
53 success: getDependencies
54 });
55 });
56 }
57
58 function getDependencies(data) {
59 if (data.hasDependencies) {
60 TYPO3.Dialog.QuestionDialog({
61 title: data.title,
62 msg: data.message,
63 url: data.url + '&tx_extensionmanager_tools_extensionmanagerextensionmanager[downloadPath]=' + downloadPath,
64 fn: getResolveDependenciesAndInstallResult
65 });
66 } else {
67 if(data.hasErrors) {
68 TYPO3.Flashmessage.display(TYPO3.Severity.error, data.title, data.message, 10);
69 } else {
70 var button = 'yes';
71 var dialog = [];
72 var dummy = '';
73 dialog['url'] = data.url + '&tx_extensionmanager_tools_extensionmanagerextensionmanager[downloadPath]=' + downloadPath;
74 getResolveDependenciesAndInstallResult(button, dummy, dialog);
75 }
76 }
77 return false;
78 }
79
80 function getResolveDependenciesAndInstallResult(button, dummy, dialog) {
81 if (button == 'yes') {
82 var newUrl = dialog.url;
83 $.ajax({
84 url: newUrl,
85 dataType: 'json',
86 success: function (data) {
87 $('.typo3-extension-manager').unmask();
88 if (data.errorMessage.length) {
89 TYPO3.Flashmessage.display(TYPO3.Severity.error, TYPO3.l10n.localize('extensionList.dependenciesResolveDownloadError.title'), data.errorMessage, 5);
90 } else {
91 var successMessage = TYPO3.l10n.localize('extensionList.dependenciesResolveDownloadSuccess.message').replace(/\{0\}/g, data.extension) + ' <br />';
92 successMessage += '<br /><h3>' + TYPO3.l10n.localize('extensionList.dependenciesResolveDownloadSuccess.header') + ':</h3>';
93 $.each(data.result, function(index, value) {
94 successMessage += TYPO3.l10n.localize('extensionList.dependenciesResolveDownloadSuccess.item') + ' ' + index + ':<br /><ul>';
95 $.each(value, function(extkey, extdata) {
96 successMessage += '<li>' + extkey + '</li>';
97 });
98 successMessage += '</ul>';
99 });
100 TYPO3.Flashmessage.display(TYPO3.Severity.information, TYPO3.l10n.localize('extensionList.dependenciesResolveFlashMessage.title').replace(/\{0\}/g, data.extension), successMessage, 15);
101 }
102 }
103 });
104 } else {
105 $('.typo3-extension-manager').unmask();
106 }
107 }
108 }(jQuery));