[TASK] Refactor EM JavaScript
authorHans Christian Reinl <info@drublic.de>
Tue, 23 Oct 2012 18:40:18 +0000 (20:40 +0200)
committerHelmut Hummel <helmut.hummel@typo3.org>
Tue, 23 Oct 2012 20:57:10 +0000 (22:57 +0200)
* Use IIFE for faster access to jQuery and save $ use
* Make JS lint-free

Resolves: #42325
Releases: 6.0

Change-Id: Ia014de44570306ce9c5cd02c97a228205a7a2849
Reviewed-on: http://review.typo3.org/15915
Reviewed-by: Helmut Hummel
Tested-by: Helmut Hummel
typo3/sysext/extensionmanager/Resources/Public/JavaScript/configuration.js
typo3/sysext/extensionmanager/Resources/Public/JavaScript/main.js
typo3/sysext/extensionmanager/Resources/Public/JavaScript/ter.js
typo3/sysext/extensionmanager/Resources/Public/JavaScript/update.js
typo3/sysext/extensionmanager/Resources/Public/JavaScript/upload.js

index b608631..ad30733 100644 (file)
@@ -1,40 +1,44 @@
-jQuery(document).ready(function() {
-       configurationFieldSupport();
-       jQuery(".validate").validator();
-});
+// IIFE for faster access to $ and save $ use
+(function ($) {
 
-function configurationFieldSupport() {
-       jQuery('.offset').each(function() {
-               jQuery(this).hide();
-               val = jQuery(this).attr('value');
-               valArr = val.split(',');
+       $(document).ready(function() {
+               configurationFieldSupport();
+               $(".validate").validator();
+       });
 
-               jQuery(this).wrap('<div class="offsetSelector"></div>');
-               jQuery(this).parent().append('x: <input value="' + jQuery.trim(valArr[0]) + '" class="tempOffset1 tempOffset">');
-               jQuery(this).parent().append('<span>, </span>');
-               jQuery(this).parent().append('y: <input value="' + jQuery.trim(valArr[1]) + '" class="tempOffset2 tempOffset">');
+       function configurationFieldSupport() {
+               $('.offset').each(function() {
+                       $(this).hide();
+                       val = $(this).attr('value');
+                       valArr = val.split(',');
 
-               jQuery(this).siblings('.tempOffset').keyup(function() {
-                       jQuery(this).siblings('.offset').attr(
-                               'value',
-                               jQuery(this).parent().children('.tempOffset1').attr('value') + ',' + jQuery(this).parent().children('.tempOffset2').attr('value'));
-               })
-       });
+                       $(this).wrap('<div class="offsetSelector"></div>');
+                       $(this).parent().append('x: <input value="' + $.trim(valArr[0]) + '" class="tempOffset1 tempOffset">');
+                       $(this).parent().append('<span>, </span>');
+                       $(this).parent().append('y: <input value="' + $.trim(valArr[1]) + '" class="tempOffset2 tempOffset">');
 
-       jQuery('.wrap').each(function() {
-               jQuery(this).hide();
-               val = jQuery(this).attr('value');
-               valArr = val.split('|');
+                       $(this).siblings('.tempOffset').keyup(function() {
+                               $(this).siblings('.offset').attr(
+                                       'value',
+                                       $(this).parent().children('.tempOffset1').attr('value') + ',' + $(this).parent().children('.tempOffset2').attr('value'));
+                       });
+               });
 
-               jQuery(this).wrap('<div class="wrapSelector"></div>');
-               jQuery(this).parent().append('<input value="' + jQuery.trim(valArr[0]) + '" class="tempWrap1 tempWrap">');
-               jQuery(this).parent().append('<span>|</span>');
-               jQuery(this).parent().append('<input value="' + jQuery.trim(valArr[1]) + '" class="tempWrap2 tempWrap">');
+               $('.wrap').each(function() {
+                       $(this).hide();
+                       val = $(this).attr('value');
+                       valArr = val.split('|');
 
-               jQuery(this).siblings('.tempWrap').keyup(function() {
-                       jQuery(this).siblings('.wrap').attr(
-                               'value',
-                               jQuery(this).parent().children('.tempWrap1').attr('value') + '|' + jQuery(this).parent().children('.tempWrap2').attr('value'));
-               })
-       });
-}
\ No newline at end of file
+                       $(this).wrap('<div class="wrapSelector"></div>');
+                       $(this).parent().append('<input value="' + $.trim(valArr[0]) + '" class="tempWrap1 tempWrap">');
+                       $(this).parent().append('<span>|</span>');
+                       $(this).parent().append('<input value="' + $.trim(valArr[1]) + '" class="tempWrap2 tempWrap">');
+
+                       $(this).siblings('.tempWrap').keyup(function() {
+                               $(this).siblings('.wrap').attr(
+                                       'value',
+                                       $(this).parent().children('.tempWrap1').attr('value') + '|' + $(this).parent().children('.tempWrap2').attr('value'));
+                       });
+               });
+       }
+}(jQuery));
index fe9704f..0145116 100644 (file)
-jQuery(document).ready(function() {
-       manageExtensionListing();
-       jQuery('th[title]').tooltip({offset: [-10, -30], position: 'bottom right', tipClass: 'headerTooltip'})
-       jQuery('td[title]').tooltip({offset: [-10, -60], position: 'bottom right'});
-       jQuery("#typo3-extension-configuration-forms ul").tabs("div.category");
-
-       jQuery('#resetSearch').live('click', function (e) {
-               datatable.fnFilter('');
-       });
+// IIFE for faster access to $ and save $ use
+(function ($) {
 
-       resetSearchField();
-});
+       $(document).ready(function() {
+               manageExtensionListing();
+               $('th[title]').tooltip({offset: [-10, -30], position: 'bottom right', tipClass: 'headerTooltip'});
+               $('td[title]').tooltip({offset: [-10, -60], position: 'bottom right'});
+               $("#typo3-extension-configuration-forms ul").tabs("div.category");
 
-function getUrlVars() {
-       var vars = [], hash;
-       var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
-       for(var i = 0; i < hashes.length; i++) {
-               hash = hashes[i].split('=');
-               vars.push(hash[0]);
-               vars[hash[0]] = hash[1];
-       }
-       return vars;
-}
-
-function manageExtensionListing() {
-       datatable = jQuery('#typo3-extension-list').dataTable({
-               "sPaginationType":"full_numbers",
-               "bJQueryUI":true,
-               "bLengthChange":false,
-               'iDisplayLength':15,
-               "bStateSave":true,
-               "fnDrawCallback": bindActions
+               $('#resetSearch').live('click', function (e) {
+                       datatable.fnFilter('');
+               });
+
+               resetSearchField();
        });
 
-       var getVars = getUrlVars();
+       function getUrlVars() {
+               var vars = [], hash;
+               var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
+               for(var i = 0; i < hashes.length; i++) {
+                       hash = hashes[i].split('=');
+                       vars.push(hash[0]);
+                       vars[hash[0]] = hash[1];
+               }
+               return vars;
+       }
 
-       // restore filter
-       if(datatable.length && getVars['search']) {
-               datatable.fnFilter(getVars['search']);
+       function manageExtensionListing() {
+               datatable = $('#typo3-extension-list').dataTable({
+                       "sPaginationType":"full_numbers",
+                       "bJQueryUI":true,
+                       "bLengthChange":false,
+                       'iDisplayLength':15,
+                       "bStateSave":true,
+                       "fnDrawCallback": bindActions
+               });
+
+               var getVars = getUrlVars();
+
+               // restore filter
+               if(datatable.length && getVars['search']) {
+                       datatable.fnFilter(getVars['search']);
+               }
        }
-}
-
-function bindActions() {
-       jQuery('td[title], tr[title]').tooltip({offset: [-10, -60], position: 'bottom right'});
-       jQuery('.removeExtension').not('.transformed').each(function() {
-               jQuery(this).data('href', jQuery(this).attr('href'));
-               jQuery(this).attr('href', 'javascript:void(0);');
-               jQuery(this).addClass('transformed');
-               jQuery(this).click(function() {
-                       if (jQuery(this).hasClass('isLoadedWarning')) {
-                               TYPO3.Dialog.QuestionDialog({
-                                       title: TYPO3.l10n.localize('extensionList.removalConfirmation.title'),
-                                       msg: TYPO3.l10n.localize('extensionList.removalConfirmation.message'),
-                                       url: jQuery(this).data('href'),
-                                       fn: function(button, dummy, dialog) {
-                                               if (button == 'yes') {
-                                                       confirmDeletionAndDelete(dialog.url)
+
+       function bindActions() {
+               $('td[title], tr[title]').tooltip({offset: [-10, -60], position: 'bottom right'});
+               $('.removeExtension').not('.transformed').each(function() {
+                       $(this).data('href', $(this).attr('href'));
+                       $(this).attr('href', '#');
+                       $(this).addClass('transformed');
+                       $(this).click(function() {
+                               if ($(this).hasClass('isLoadedWarning')) {
+                                       TYPO3.Dialog.QuestionDialog({
+                                               title: TYPO3.l10n.localize('extensionList.removalConfirmation.title'),
+                                               msg: TYPO3.l10n.localize('extensionList.removalConfirmation.message'),
+                                               url: $(this).data('href'),
+                                               fn: function(button, dummy, dialog) {
+                                                       if (button == 'yes') {
+                                                               confirmDeletionAndDelete(dialog.url);
+                                                       }
                                                }
-                                       }
-                               });
-                       } else {
-                               confirmDeletionAndDelete(jQuery(this).data('href'));
-                       }
-               })
-       });
+                                       });
+                               } else {
+                                       confirmDeletionAndDelete($(this).data('href'));
+                               }
+                       });
+               });
 
-       jQuery('.t3-icon-system-extension-update').parent().each(function() {
-               jQuery(this).data('href', jQuery(this).attr('href'));
-               jQuery(this).attr('href', 'javascript:void(0);');
-               jQuery(this).addClass('transformed');
-               jQuery(this).click(function() {
-                       jQuery('#typo3-extension-manager').mask();
-                       jQuery.ajax({
-                               url: jQuery(this).data('href'),
-                               dataType: 'json',
-                               success: updateExtension
+               $('.t3-icon-system-extension-update').parent().each(function() {
+                       $(this).data('href', $(this).attr('href'));
+                       $(this).attr('href', '#');
+                       $(this).addClass('transformed');
+                       $(this).click(function() {
+                               $('#typo3-extension-manager').mask();
+                               $.ajax({
+                                       url: $(this).data('href'),
+                                       dataType: 'json',
+                                       success: updateExtension
+                               });
                        });
                });
-       });
 
-}
+       }
 
-function updateExtension(data) {
-       var message = '<h1>' + TYPO3.l10n.localize('extensionList.updateConfirmation.title') + '</h1>';
-       message += '<h2>' + TYPO3.l10n.localize('extensionList.updateConfirmation.message') + '</h2>';
-       jQuery.each(data.updateComments, function(version, comment) {
-               message += '<h3>' + version + '</h3>';
-               message += '<div>' + comment + '</div>';
-       });
+       function updateExtension(data) {
+               var message = '<h1>' + TYPO3.l10n.localize('extensionList.updateConfirmation.title') + '</h1>';
+               message += '<h2>' + TYPO3.l10n.localize('extensionList.updateConfirmation.message') + '</h2>';
+               $.each(data.updateComments, function(version, comment) {
+                       message += '<h3>' + version + '</h3>';
+                       message += '<div>' + comment + '</div>';
+               });
 
-       TYPO3.Dialog.QuestionDialog({
-               title: TYPO3.l10n.localize('extensionList.updateConfirmation.questionVersionComments'),
-               msg: message,
-               width: 600,
-               url: data.url,
-               fn: function(button, dummy, dialog) {
-                       if (button == 'yes') {
-                               jQuery.ajax({
-                                       url: dialog.url,
-                                       dataType: 'json',
-                                       success: function(data) {
-                                               jQuery('#typo3-extension-manager').unmask();
-                                               TYPO3.Flashmessage.display(TYPO3.Severity.information, TYPO3.l10n.localize('extensionList.updateFlashMessage.title'),
-                                                               TYPO3.l10n.localize('extensionList.updateFlashMessage.message').replace(/\{0\}/g, data.extension), 15);
-                                       }
-                               });
-                       } else {
-                               jQuery('#typo3-extension-manager').unmask();
+               TYPO3.Dialog.QuestionDialog({
+                       title: TYPO3.l10n.localize('extensionList.updateConfirmation.questionVersionComments'),
+                       msg: message,
+                       width: 600,
+                       url: data.url,
+                       fn: function(button, dummy, dialog) {
+                               if (button == 'yes') {
+                                       $.ajax({
+                                               url: dialog.url,
+                                               dataType: 'json',
+                                               success: function(data) {
+                                                       $('#typo3-extension-manager').unmask();
+                                                       TYPO3.Flashmessage.display(TYPO3.Severity.information, TYPO3.l10n.localize('extensionList.updateFlashMessage.title'),
+                                                                       TYPO3.l10n.localize('extensionList.updateFlashMessage.message').replace(/\{0\}/g, data.extension), 15);
+                                               }
+                                       });
+                               } else {
+                                       $('#typo3-extension-manager').unmask();
+                               }
                        }
-               }
-       });
-}
-
-
-function confirmDeletionAndDelete(url) {
-       TYPO3.Dialog.QuestionDialog({
-               title: TYPO3.l10n.localize('extensionList.removalConfirmation.title'),
-               msg: TYPO3.l10n.localize('extensionList.removalConfirmation.question'),
-               url: url,
-               fn: function(button, dummy, dialog) {
-                       if (button == 'yes') {
-                               jQuery('#typo3-extension-manager').mask();
-                               jQuery.ajax({
-                                       url: dialog.url,
-                                       dataType: 'json',
-                                       success: removeExtension
-                               });
+               });
+       }
+
+
+       function confirmDeletionAndDelete(url) {
+               TYPO3.Dialog.QuestionDialog({
+                       title: TYPO3.l10n.localize('extensionList.removalConfirmation.title'),
+                       msg: TYPO3.l10n.localize('extensionList.removalConfirmation.question'),
+                       url: url,
+                       fn: function(button, dummy, dialog) {
+                               if (button == 'yes') {
+                                       $('#typo3-extension-manager').mask();
+                                       $.ajax({
+                                               url: dialog.url,
+                                               dataType: 'json',
+                                               success: removeExtension
+                                       });
+                               }
                        }
-               }
-       });
-}
-
-function removeExtension(data) {
-       jQuery('#typo3-extension-manager').unmask();
-       if (data.success) {
-               datatable.fnDeleteRow(datatable.fnGetPosition(document.getElementById(data.extension)));
-       } else {
-               TYPO3.Flashmessage.display(TYPO3.Severity.error, TYPO3.l10n.localize('extensionList.removalConfirmation.title'), data.message, 15);
+               });
        }
-}
-
-function resetSearchField() {
-       var dataTablesFilter = find(".dataTables_filter");
-       jQuery('.dataTables_wrapper').find('.dataTables_filter').append(jQuery('<span />', {
-               'class':'t3-icon t3-icon-actions t3-icon-actions-input t3-icon-input-clear t3-tceforms-input-clearer',
-               'id':'resetSearch',
-               'style':'display:none'
-       }));
-       jQuery('#typo3-extension-list_filter').mouseout(function() {
-               jQuery(this).find('#resetSearch').css('display', 'none');
-       });
-       jQuery('#typo3-extension-list_filter').mouseover(function() {
-               if (jQuery(this).find('input').val()) {
-                       jQuery(this).find('#resetSearch').css('display', 'inline-block');
+
+       function removeExtension(data) {
+               $('#typo3-extension-manager').unmask();
+               if (data.success) {
+                       datatable.fnDeleteRow(datatable.fnGetPosition(document.getElementById(data.extension)));
+               } else {
+                       TYPO3.Flashmessage.display(TYPO3.Severity.error, TYPO3.l10n.localize('extensionList.removalConfirmation.title'), data.message, 15);
                }
-       })
-}
\ No newline at end of file
+       }
+
+       function resetSearchField() {
+               var dataTablesFilter = find(".dataTables_filter");
+               $('.dataTables_wrapper').find('.dataTables_filter').append($('<span />', {
+                       'class':'t3-icon t3-icon-actions t3-icon-actions-input t3-icon-input-clear t3-tceforms-input-clearer',
+                       'id':'resetSearch',
+                       'style':'display:none'
+               }));
+               $('#typo3-extension-list_filter').mouseout(function() {
+                       $(this).find('#resetSearch').css('display', 'none');
+               });
+               $('#typo3-extension-list_filter').mouseover(function() {
+                       if ($(this).find('input').val()) {
+                               $(this).find('#resetSearch').css('display', 'inline-block');
+                       }
+               });
+       }
+}(jQuery));
index aed8654..3b64d0f 100644 (file)
-jQuery(document).ready(function() {
-       jQuery('#terTable').dataTable({
-               "bJQueryUI":true,
-               "bLengthChange": false,
-               'iDisplayLength': 15,
-               "bStateSave": false,
-               "bInfo": false,
-               "bPaginate": false,
-               "bFilter": false,
-               "fnDrawCallback": bindDownload
-       });
+// IIFE for faster access to $ and save $ use
+(function ($) {
 
-       jQuery('#terVersionTable').dataTable({
-               "bJQueryUI":true,
-               "bLengthChange":false,
-               'iDisplayLength':15,
-               "bStateSave":false,
-               "bInfo":false,
-               "bPaginate":false,
-               "bFilter":false,
-               "aaSorting":[[0, 'desc']],
-               "fnDrawCallback":bindDownload
-       });
+       $(document).ready(function() {
+               $('#terTable').dataTable({
+                       "bJQueryUI":true,
+                       "bLengthChange": false,
+                       'iDisplayLength': 15,
+                       "bStateSave": false,
+                       "bInfo": false,
+                       "bPaginate": false,
+                       "bFilter": false,
+                       "fnDrawCallback": bindDownload
+               });
 
-       jQuery('#terSearchTable').dataTable({
-               "sPaginationType":"full_numbers",
-               "bJQueryUI":true,
-               "bLengthChange": false,
-               'iDisplayLength': 15,
-               "bStateSave": false,
-               "oLanguage": {
-                       "sSearch": "Filter results:"
-               },
-               "aaSorting": [],
-               "fnDrawCallback": bindDownload
-       });
-       bindDownload();
-});
+               $('#terVersionTable').dataTable({
+                       "bJQueryUI":true,
+                       "bLengthChange":false,
+                       'iDisplayLength':15,
+                       "bStateSave":false,
+                       "bInfo":false,
+                       "bPaginate":false,
+                       "bFilter":false,
+                       "aaSorting":[[0, 'desc']],
+                       "fnDrawCallback":bindDownload
+               });
 
-function bindDownload() {
-       var installButtons = jQuery('.downloadFromTer form.download input[type=submit]');
-       installButtons.off('click');
-       installButtons.on('click', function(event) {
-               event.preventDefault();
-               var url = jQuery(event.currentTarget.form).attr('href');
-               downloadPath = jQuery(event.currentTarget.form).find('input.downloadPath:checked').val();
-               jQuery.ajax({
-                       url: url,
-                       dataType: 'json',
-                       success: getDependencies
+               $('#terSearchTable').dataTable({
+                       "sPaginationType":"full_numbers",
+                       "bJQueryUI":true,
+                       "bLengthChange": false,
+                       'iDisplayLength': 15,
+                       "bStateSave": false,
+                       "oLanguage": {
+                               "sSearch": "Filter results:"
+                       },
+                       "aaSorting": [],
+                       "fnDrawCallback": bindDownload
                });
+               bindDownload();
        });
-}
 
-function getDependencies(data) {
-       if (data.hasDependencies) {
-               TYPO3.Dialog.QuestionDialog({
-                       title: data.title,
-                       msg: data.message,
-                       url: data.url + '&tx_extensionmanager_tools_extensionmanagerextensionmanager[downloadPath]=' + downloadPath,
-                       fn: getResolveDependenciesAndInstallResult
+       function bindDownload() {
+               var installButtons = $('.downloadFromTer form.download input[type=submit]');
+               installButtons.off('click');
+               installButtons.on('click', function(event) {
+                       event.preventDefault();
+                       var url = $(event.currentTarget.form).attr('href');
+                       downloadPath = $(event.currentTarget.form).find('input.downloadPath:checked').val();
+                       $.ajax({
+                               url: url,
+                               dataType: 'json',
+                               success: getDependencies
+                       });
                });
-       } else {
-               if(data.hasErrors) {
-                       TYPO3.Flashmessage.display(TYPO3.Severity.error, data.title, data.message, 10);
+       }
+
+       function getDependencies(data) {
+               if (data.hasDependencies) {
+                       TYPO3.Dialog.QuestionDialog({
+                               title: data.title,
+                               msg: data.message,
+                               url: data.url + '&tx_extensionmanager_tools_extensionmanagerextensionmanager[downloadPath]=' + downloadPath,
+                               fn: getResolveDependenciesAndInstallResult
+                       });
                } else {
-                       var button = 'yes';
-                       var dialog = [];
-                       var dummy = '';
-                       dialog['url'] = data.url + '&tx_extensionmanager_tools_extensionmanagerextensionmanager[downloadPath]=' + downloadPath;
-                       getResolveDependenciesAndInstallResult(button, dummy, dialog)
+                       if(data.hasErrors) {
+                               TYPO3.Flashmessage.display(TYPO3.Severity.error, data.title, data.message, 10);
+                       } else {
+                               var button = 'yes';
+                               var dialog = [];
+                               var dummy = '';
+                               dialog['url'] = data.url + '&tx_extensionmanager_tools_extensionmanagerextensionmanager[downloadPath]=' + downloadPath;
+                               getResolveDependenciesAndInstallResult(button, dummy, dialog);
+                       }
                }
+               return false;
        }
-       return false;
-}
 
-function getResolveDependenciesAndInstallResult(button, dummy, dialog) {
-       if (button == 'yes') {
-               var newUrl = dialog.url;
-               jQuery.ajax({
-                       url: newUrl,
-                       dataType: 'json',
-                       success: function (data) {
-                               jQuery('#typo3-extension-manager').unmask();
-                               if (data.errorMessage.length) {
-                                       TYPO3.Flashmessage.display(TYPO3.Severity.error, TYPO3.l10n.localize('extensionList.dependenciesResolveDownloadError.title'), data.errorMessage, 5);
-                               } else {
-                                       var successMessage = TYPO3.l10n.localize('extensionList.dependenciesResolveDownloadSuccess.message').replace(/\{0\}/g, data.extension) + ' <br />';
-                                       successMessage += '<br /><h3>' + TYPO3.l10n.localize('extensionList.dependenciesResolveDownloadSuccess.header') + ':</h3>';
-                                       jQuery.each(data.result, function(index, value) {
-                                               successMessage += TYPO3.l10n.localize('extensionList.dependenciesResolveDownloadSuccess.item') + ' ' + index + ':<br /><ul>';
-                                               jQuery.each(value, function(extkey, extdata) {
-                                                       successMessage += '<li>' + extkey + '</li>';
+       function getResolveDependenciesAndInstallResult(button, dummy, dialog) {
+               if (button == 'yes') {
+                       var newUrl = dialog.url;
+                       $.ajax({
+                               url: newUrl,
+                               dataType: 'json',
+                               success: function (data) {
+                                       $('#typo3-extension-manager').unmask();
+                                       if (data.errorMessage.length) {
+                                               TYPO3.Flashmessage.display(TYPO3.Severity.error, TYPO3.l10n.localize('extensionList.dependenciesResolveDownloadError.title'), data.errorMessage, 5);
+                                       } else {
+                                               var successMessage = TYPO3.l10n.localize('extensionList.dependenciesResolveDownloadSuccess.message').replace(/\{0\}/g, data.extension) + ' <br />';
+                                               successMessage += '<br /><h3>' + TYPO3.l10n.localize('extensionList.dependenciesResolveDownloadSuccess.header') + ':</h3>';
+                                               $.each(data.result, function(index, value) {
+                                                       successMessage += TYPO3.l10n.localize('extensionList.dependenciesResolveDownloadSuccess.item') + ' ' + index + ':<br /><ul>';
+                                                       $.each(value, function(extkey, extdata) {
+                                                               successMessage += '<li>' + extkey + '</li>';
+                                                       });
+                                                       successMessage += '</ul>';
                                                });
-                                               successMessage += '</ul>';
-                                       });
-                                       TYPO3.Flashmessage.display(TYPO3.Severity.information, TYPO3.l10n.localize('extensionList.dependenciesResolveFlashMessage.title').replace(/\{0\}/g, data.extension), successMessage, 15);
+                                               TYPO3.Flashmessage.display(TYPO3.Severity.information, TYPO3.l10n.localize('extensionList.dependenciesResolveFlashMessage.title').replace(/\{0\}/g, data.extension), successMessage, 15);
+                                       }
                                }
-                       }
-               });
-       } else {
-               jQuery('#typo3-extension-manager').unmask();
+                       });
+               } else {
+                       $('#typo3-extension-manager').unmask();
+               }
        }
-}
\ No newline at end of file
+}(jQuery));
index 74834cd..57d0bad 100644 (file)
@@ -1,68 +1,72 @@
-jQuery(document).ready(function() {
-       jQuery('.updateFromTer a').each(function() {
-               jQuery(this).data('href', jQuery(this).attr('href'));
-               jQuery(this).attr('href', 'javascript:void(0);');
-               jQuery(this).click(function() {
-                               // force update on click
-                       updateFromTer(jQuery(this).data('href'), 1);
+// IIFE for faster access to jQuery and save $ use
+(function ($) {
+
+       $(document).ready(function() {
+               $('.updateFromTer a').each(function() {
+                       $(this).data('href', $(this).attr('href'));
+                       $(this).attr('href', '#');
+                       $(this).click(function() {
+                                       // force update on click
+                               updateFromTer($(this).data('href'), 1);
+                       });
+                       updateFromTer($(this).data('href'), 0);
                });
-               updateFromTer(jQuery(this).data('href'), 0);
        });
-});
 
-function updateFromTer(url, forceUpdate) {
-       var url = url;
-       if (forceUpdate == 1) {
-               url = url + '&tx_extensionmanager_tools_extensionmanagerextensionmanager%5BforceUpdateCheck%5D=1'
-       }
-       jQuery('.updateFromTer .spinner').show();
-       jQuery('#terTableWrapper').mask();
-       jQuery.ajax({
-               url: url,
-               dataType: 'json',
-               success: function(data) {
-                       jQuery('.updateFromTer .spinner').hide();
+       function updateFromTer(url, forceUpdate) {
+               if (forceUpdate == 1) {
+                       url = url + '&tx_extensionmanager_tools_extensionmanagerextensionmanager%5BforceUpdateCheck%5D=1';
+               }
+               $('.updateFromTer .spinner').show();
+               $('#terTableWrapper').mask();
+               $.ajax({
+                       url: url,
+                       dataType: 'json',
+                       success: function(data) {
+                               $('.updateFromTer .spinner').hide();
 
-                       if (data.errorMessage.length) {
-                               TYPO3.Flashmessage.display(TYPO3.Severity.warning, TYPO3.l10n.localize('extensionList.updateFromTerFlashMessage.title'), data.errorMessage, 10);
+                               if (data.errorMessage.length) {
+                                       TYPO3.Flashmessage.display(TYPO3.Severity.warning, TYPO3.l10n.localize('extensionList.updateFromTerFlashMessage.title'), data.errorMessage, 10);
+                               }
+                               $('.updateFromTer .text').html(
+                                       data.message
+                               );
+                               if (data.updated) {
+                                       $.ajax({
+                                               url: window.location.href + '&tx_extensionmanager_tools_extensionmanagerextensionmanager%5Bformat%5D=json',
+                                               dataType: 'json',
+                                               success: function(data) {
+                                                       $('#terTableWrapper').html(
+                                                               data
+                                                       );
+                                                       transformPaginatorToAjax();
+                                               }
+                                       });
+                               }
+                               $('#terTableWrapper').unmask();
                        }
-                       jQuery('.updateFromTer .text').html(
-                               data.message
-                       );
-                       if (data.updated) {
-                               jQuery.ajax({
-                                       url: window.location.href + '&tx_extensionmanager_tools_extensionmanagerextensionmanager%5Bformat%5D=json',
+               });
+       }
+
+       function transformPaginatorToAjax() {
+               $('.f3-widget-paginator a').each(function() {
+                       $(this).data('href', $(this).attr('href'));
+                       $(this).attr('href', '#');
+                       $(this).click(function() {
+                               $('#terTableWrapper').mask();
+                               $.ajax({
+                                       url: $(this).data('href'),
                                        dataType: 'json',
                                        success: function(data) {
-                                               jQuery('#terTableWrapper').html(
+                                               $('#terTableWrapper').html(
                                                        data
                                                );
+                                               $('#terTableWrapper').unmask();
                                                transformPaginatorToAjax();
                                        }
                                });
-                       }
-                       jQuery('#terTableWrapper').unmask();
-               }
-       });
-}
-
-function transformPaginatorToAjax() {
-       jQuery('.f3-widget-paginator a').each(function() {
-               jQuery(this).data('href', jQuery(this).attr('href'));
-               jQuery(this).attr('href', 'javascript:void(0);');
-               jQuery(this).click(function() {
-                       jQuery('#terTableWrapper').mask();
-                       jQuery.ajax({
-                               url: jQuery(this).data('href'),
-                               dataType: 'json',
-                               success: function(data) {
-                                       jQuery('#terTableWrapper').html(
-                                               data
-                                       );
-                                       jQuery('#terTableWrapper').unmask();
-                                       transformPaginatorToAjax();
-                               }
                        });
                });
-       });
-}
\ No newline at end of file
+       }
+
+}(jQuery));
index 940ff25..4750d6c 100644 (file)
@@ -1,30 +1,34 @@
+// IIFE for faster access to $ and save $ use
+(function ($) {
 
-jQuery(document).ready(function() {
-       jQuery('.t3-icon-edit-upload').parent().not('.transformed').each(function () {
-               jQuery(this).data('href', jQuery(this).attr('href'));
-               jQuery(this).attr('href', 'javascript:void(0);');
-               jQuery(this).addClass('transformed');
-               jQuery(this).click(function () {
-                       jQuery('.uploadForm').show();
-                       jQuery.ajax({
-                               url:jQuery(this).data('href'),
-                               dataType:'html',
-                               success:function (data) {
-                                       jQuery('.uploadForm').html(data);
-                                       handleUploadForm();
-                               }
+       $(document).ready(function() {
+               $('.t3-icon-edit-upload').parent().not('.transformed').each(function () {
+                       $(this).data('href', $(this).attr('href'));
+                       $(this).attr('href', '#');
+                       $(this).addClass('transformed');
+                       $(this).click(function () {
+                               $('.uploadForm').show();
+                               $.ajax({
+                                       url:$(this).data('href'),
+                                       dataType:'html',
+                                       success:function (data) {
+                                               $('.uploadForm').html(data);
+                                               handleUploadForm();
+                                       }
+                               });
                        });
                });
        });
-});
 
-function handleUploadForm() {
-       jQuery('#typo3-extensionmanager-upload-target').on('load', function() {
-               var ret = frames['typo3-extensionmanager-upload-target'].document.getElementsByTagName("body")[0].innerHTML;
-               var data = eval("("+ret+")");
-               if (data.success) {
-                       TYPO3.Flashmessage.display(TYPO3.Severity.information, TYPO3.l10n.localize('extensionList.uploadFlashMessage.title'), TYPO3.l10n.localize('extensionList.uploadFlashMessage.message').replace(/\{0\}/g, data.extension), 15);
-                       location.reload();
-               }
-       })
-}
+       function handleUploadForm() {
+               $('#typo3-extensionmanager-upload-target').on('load', function() {
+                       var ret = frames['typo3-extensionmanager-upload-target'].document.getElementsByTagName("body")[0].innerHTML;
+                       var data = eval("("+ret+")");
+                       if (data.success) {
+                               TYPO3.Flashmessage.display(TYPO3.Severity.information, TYPO3.l10n.localize('extensionList.uploadFlashMessage.title'), TYPO3.l10n.localize('extensionList.uploadFlashMessage.message').replace(/\{0\}/g, data.extension), 15);
+                               location.reload();
+                       }
+               });
+       }
+
+}(jQuery));