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