567d26a44ed6ea23822e905d6fd44ae3202391b4
[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: 'Extension Removal',
48 msg: 'The extension is currently installed. Uninstall extension?',
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('.updateAvailable').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>Update?</h1>';
79 message += '<h2>Update Comments:</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: 'Version Comments',
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, 'Extension Update', data.extension + ' updated!', 15);
98 }
99 });
100 }
101 }
102 });
103 }
104
105
106 function confirmDeletionAndDelete(url) {
107 TYPO3.Dialog.QuestionDialog({
108 title: 'Extension Removal',
109 msg: 'Are you sure you want to remove the extension?',
110 url: url,
111 fn: function(button, dummy, dialog) {
112 if (button == 'yes') {
113 jQuery('#typo3-extension-manager').mask();
114 jQuery.ajax({
115 url: dialog.url,
116 dataType: 'json',
117 success: removeExtension
118 });
119 }
120 }
121 });
122 }
123
124 function removeExtension(data) {
125 jQuery('#typo3-extension-manager').unmask();
126 if (data.success) {
127 datatable.fnDeleteRow(datatable.fnGetPosition(document.getElementById(data.extension)));
128 } else {
129 TYPO3.Flashmessage.display(TYPO3.Severity.error, 'Extension Removal', data.message, 15);
130 }
131 }