d51e67e26083ec69be176e1a88e299f716e7f330
[Packages/TYPO3.CMS.git] / typo3 / sysext / extensionmanager / Resources / Public / JavaScript / main.js
1 jQuery(document).ready(function() {
2 manageExtensionListing();
3 jQuery('th[title]').tooltip({offset: [-10, -30], position: 'bottom right', tipClass: 'headerTooltip'})
4 jQuery('td[title]').tooltip({offset: [-10, -60], position: 'bottom right'});
5 jQuery("#typo3-extension-configuration-forms ul").tabs("div.category");
6
7 });
8
9 function getUrlVars() {
10 var vars = [], hash;
11 var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
12 for(var i = 0; i < hashes.length; i++) {
13 hash = hashes[i].split('=');
14 vars.push(hash[0]);
15 vars[hash[0]] = hash[1];
16 }
17 return vars;
18 }
19
20 function manageExtensionListing() {
21 datatable = jQuery('#typo3-extension-list').dataTable({
22 "sPaginationType":"full_numbers",
23 "bJQueryUI":true,
24 "bLengthChange":false,
25 'iDisplayLength':15,
26 "bStateSave":true,
27 "fnDrawCallback": bindActions
28 });
29
30 var getVars = getUrlVars();
31
32 // restore filter
33 if(datatable.length && getVars['search']) {
34 datatable.fnFilter(getVars['search']);
35 }
36 }
37
38 function bindActions() {
39 jQuery('td[title], tr[title]').tooltip({offset: [-10, -60], position: 'bottom right'});
40 jQuery('.removeExtension').not('.transformed').each(function() {
41 jQuery(this).data('href', jQuery(this).attr('href'));
42 jQuery(this).attr('href', 'javascript:void(0);');
43 jQuery(this).addClass('transformed');
44 jQuery(this).click(function() {
45 if (jQuery(this).hasClass('isLoadedWarning')) {
46 TYPO3.Dialog.QuestionDialog({
47 title: TYPO3.l10n.localize('extensionList.removalConfirmation.title'),
48 msg: TYPO3.l10n.localize('extensionList.removalConfirmation.message'),
49 url: jQuery(this).data('href'),
50 fn: function(button, dummy, dialog) {
51 if (button == 'yes') {
52 confirmDeletionAndDelete(dialog.url)
53 }
54 }
55 });
56 } else {
57 confirmDeletionAndDelete(jQuery(this).data('href'));
58 }
59 })
60 });
61
62 jQuery('.t3-icon-system-extension-update').parent().each(function() {
63 jQuery(this).data('href', jQuery(this).attr('href'));
64 jQuery(this).attr('href', 'javascript:void(0);');
65 jQuery(this).addClass('transformed');
66 jQuery(this).click(function() {
67 jQuery('#typo3-extension-manager').mask();
68 jQuery.ajax({
69 url: jQuery(this).data('href'),
70 dataType: 'json',
71 success: updateExtension
72 });
73 });
74 })
75 }
76
77 function updateExtension(data) {
78 var message = '<h1>' + TYPO3.l10n.localize('extensionList.updateConfirmation.title') + '</h1>';
79 message += '<h2>' + TYPO3.l10n.localize('extensionList.updateConfirmation.message') + '</h2>';
80 jQuery.each(data.updateComments, function(version, comment) {
81 message += '<h3>' + version + '</h3>';
82 message += '<div>' + comment + '</div>';
83 });
84
85 TYPO3.Dialog.QuestionDialog({
86 title: TYPO3.l10n.localize('extensionList.updateConfirmation.questionVersionComments'),
87 msg: message,
88 width: 600,
89 url: data.url,
90 fn: function(button, dummy, dialog) {
91 if (button == 'yes') {
92 jQuery.ajax({
93 url: dialog.url,
94 dataType: 'json',
95 success: function(data) {
96 jQuery('#typo3-extension-manager').unmask();
97 TYPO3.Flashmessage.display(TYPO3.Severity.information, TYPO3.l10n.localize('extensionList.updateFlashMessage.title'),
98 TYPO3.l10n.localize('extensionList.updateFlashMessage.message').replace(/\{0\}/g, data.extension), 15);
99 }
100 });
101 } else {
102 jQuery('#typo3-extension-manager').unmask();
103 }
104 }
105 });
106 }
107
108
109 function confirmDeletionAndDelete(url) {
110 TYPO3.Dialog.QuestionDialog({
111 title: TYPO3.l10n.localize('extensionList.removalConfirmation.title'),
112 msg: TYPO3.l10n.localize('extensionList.removalConfirmation.question'),
113 url: url,
114 fn: function(button, dummy, dialog) {
115 if (button == 'yes') {
116 jQuery('#typo3-extension-manager').mask();
117 jQuery.ajax({
118 url: dialog.url,
119 dataType: 'json',
120 success: removeExtension
121 });
122 }
123 }
124 });
125 }
126
127 function removeExtension(data) {
128 jQuery('#typo3-extension-manager').unmask();
129 if (data.success) {
130 datatable.fnDeleteRow(datatable.fnGetPosition(document.getElementById(data.extension)));
131 } else {
132 TYPO3.Flashmessage.display(TYPO3.Severity.error, TYPO3.l10n.localize('extensionList.removalConfirmation.title'), data.message, 15);
133 }
134 }