Commit 9f73c3a6 authored by Frank Nägler's avatar Frank Nägler Committed by Christian Kuhn
Browse files

[TASK] Apply code formating for all JavaScript files

This is the first step for introduce CGL for JavaScript files.
The settings of the .editorconfig file is now applied to all
JavaScript files. This will prevent merge conflicts for the
next patches.

Resolves: #83752
Releases: master, 8.7
Change-Id: Ie84691e7f7f3a3974f3c62133895a62377b22f67
Reviewed-on: https://review.typo3.org/55521

Reviewed-by: Oliver Hader's avatarOliver Hader <oliver.hader@typo3.org>
Tested-by: Oliver Hader's avatarOliver Hader <oliver.hader@typo3.org>
Tested-by: default avatarTYPO3com <no-reply@typo3.com>
Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
parent 42d45e6f
......@@ -16,252 +16,252 @@
* AjaxDataHandler - Javascript functions to work with AJAX and interacting with tce_db.php
*/
define(['jquery',
'TYPO3/CMS/Backend/Modal',
'TYPO3/CMS/Backend/Icons',
'TYPO3/CMS/Backend/Notification',
'TYPO3/CMS/Backend/Severity'
], function ($, Modal, Icons, Notification, Severity) {
'use strict';
'TYPO3/CMS/Backend/Modal',
'TYPO3/CMS/Backend/Icons',
'TYPO3/CMS/Backend/Notification',
'TYPO3/CMS/Backend/Severity'
], function($, Modal, Icons, Notification, Severity) {
'use strict';
/**
*
* @type {{identifier: {hide: string, delete: string, icon: string}}}
* @exports TYPO3/CMS/Backend/AjaxDataHandler
*/
var AjaxDataHandler = {
identifier: {
hide: '.t3js-record-hide',
delete: '.t3js-record-delete',
icon: '.t3js-icon'
}
};
/**
*
* @type {{identifier: {hide: string, delete: string, icon: string}}}
* @exports TYPO3/CMS/Backend/AjaxDataHandler
*/
var AjaxDataHandler = {
identifier: {
hide: '.t3js-record-hide',
delete: '.t3js-record-delete',
icon: '.t3js-icon'
}
};
/**
* generic function to call from the outside the script and validate directly showing errors
*
* @param {Object} parameters
* @return {Promise<Object>} a jQuery deferred object (promise)
*/
AjaxDataHandler.process = function(parameters) {
return AjaxDataHandler._call(parameters).done(function(result) {
if (result.hasErrors) {
AjaxDataHandler.handleErrors(result);
}
});
};
/**
* generic function to call from the outside the script and validate directly showing errors
*
* @param {Object} parameters
* @return {Promise<Object>} a jQuery deferred object (promise)
*/
AjaxDataHandler.process = function(parameters) {
return AjaxDataHandler._call(parameters).done(function(result) {
if (result.hasErrors) {
AjaxDataHandler.handleErrors(result);
}
});
};
/**
*
*/
AjaxDataHandler.initialize = function() {
/**
*
*/
AjaxDataHandler.initialize = function() {
// HIDE/UNHIDE: click events for all action icons to hide/unhide
$(document).on('click', AjaxDataHandler.identifier.hide, function(evt) {
evt.preventDefault();
var $anchorElement = $(this);
var $iconElement = $anchorElement.find(AjaxDataHandler.identifier.icon);
var $rowElement = $anchorElement.closest('tr[data-uid]');
var params = $anchorElement.data('params');
// HIDE/UNHIDE: click events for all action icons to hide/unhide
$(document).on('click', AjaxDataHandler.identifier.hide, function(evt) {
evt.preventDefault();
var $anchorElement = $(this);
var $iconElement = $anchorElement.find(AjaxDataHandler.identifier.icon);
var $rowElement = $anchorElement.closest('tr[data-uid]');
var params = $anchorElement.data('params');
// add a spinner
AjaxDataHandler._showSpinnerIcon($iconElement);
// add a spinner
AjaxDataHandler._showSpinnerIcon($iconElement);
// make the AJAX call to toggle the visibility
AjaxDataHandler._call(params).done(function(result) {
// print messages on errors
if (result.hasErrors) {
AjaxDataHandler.handleErrors(result);
} else {
// adjust overlay icon
AjaxDataHandler.toggleRow($rowElement);
}
});
});
// make the AJAX call to toggle the visibility
AjaxDataHandler._call(params).done(function(result) {
// print messages on errors
if (result.hasErrors) {
AjaxDataHandler.handleErrors(result);
} else {
// adjust overlay icon
AjaxDataHandler.toggleRow($rowElement);
}
});
});
// DELETE: click events for all action icons to delete
$(document).on('click', AjaxDataHandler.identifier.delete, function(evt) {
evt.preventDefault();
var $anchorElement = $(this);
var $modal = Modal.confirm($anchorElement.data('title'), $anchorElement.data('message'), Severity.warning, [
{
text: $(this).data('button-close-text') || TYPO3.lang['button.cancel'] || 'Cancel',
active: true,
btnClass: 'btn-default',
name: 'cancel'
},
{
text: $(this).data('button-ok-text') || TYPO3.lang['button.delete'] || 'Delete',
btnClass: 'btn-warning',
name: 'delete'
}
]);
$modal.on('button.clicked', function(e) {
if (e.target.name === 'cancel') {
Modal.dismiss();
} else if (e.target.name === 'delete') {
Modal.dismiss();
AjaxDataHandler.deleteRecord($anchorElement);
}
});
});
};
// DELETE: click events for all action icons to delete
$(document).on('click', AjaxDataHandler.identifier.delete, function(evt) {
evt.preventDefault();
var $anchorElement = $(this);
var $modal = Modal.confirm($anchorElement.data('title'), $anchorElement.data('message'), Severity.warning, [
{
text: $(this).data('button-close-text') || TYPO3.lang['button.cancel'] || 'Cancel',
active: true,
btnClass: 'btn-default',
name: 'cancel'
},
{
text: $(this).data('button-ok-text') || TYPO3.lang['button.delete'] || 'Delete',
btnClass: 'btn-warning',
name: 'delete'
}
]);
$modal.on('button.clicked', function(e) {
if (e.target.name === 'cancel') {
Modal.dismiss();
} else if (e.target.name === 'delete') {
Modal.dismiss();
AjaxDataHandler.deleteRecord($anchorElement);
}
});
});
};
/**
* Toggle row visibility after record has been changed
*
* @param {Object} $rowElement
*/
AjaxDataHandler.toggleRow = function($rowElement) {
var $anchorElement = $rowElement.find(AjaxDataHandler.identifier.hide);
var table = $anchorElement.closest('table[data-table]').data('table');
var params = $anchorElement.data('params');
var nextParams, nextState, iconName;
/**
* Toggle row visibility after record has been changed
*
* @param {Object} $rowElement
*/
AjaxDataHandler.toggleRow = function($rowElement) {
var $anchorElement = $rowElement.find(AjaxDataHandler.identifier.hide);
var table = $anchorElement.closest('table[data-table]').data('table');
var params = $anchorElement.data('params');
var nextParams, nextState, iconName;
if ($anchorElement.data('state') === 'hidden') {
nextState = 'visible';
nextParams = params.replace('=0', '=1');
iconName = 'actions-edit-hide';
} else {
nextState = 'hidden';
nextParams = params.replace('=1', '=0');
iconName = 'actions-edit-unhide';
}
$anchorElement.data('state', nextState).data('params', nextParams);
if ($anchorElement.data('state') === 'hidden') {
nextState = 'visible';
nextParams = params.replace('=0', '=1');
iconName = 'actions-edit-hide';
} else {
nextState = 'hidden';
nextParams = params.replace('=1', '=0');
iconName = 'actions-edit-unhide';
}
$anchorElement.data('state', nextState).data('params', nextParams);
// Update tooltip title
$anchorElement.tooltip('hide').one('hidden.bs.tooltip', function() {
var nextTitle = $anchorElement.data('toggleTitle');
// Bootstrap Tooltip internally uses only .attr('data-original-title')
$anchorElement
.data('toggleTitle', $anchorElement.attr('data-original-title'))
.attr('data-original-title', nextTitle)
.tooltip('show');
});
// Update tooltip title
$anchorElement.tooltip('hide').one('hidden.bs.tooltip', function() {
var nextTitle = $anchorElement.data('toggleTitle');
// Bootstrap Tooltip internally uses only .attr('data-original-title')
$anchorElement
.data('toggleTitle', $anchorElement.attr('data-original-title'))
.attr('data-original-title', nextTitle)
.tooltip('show');
});
var $iconElement = $anchorElement.find(AjaxDataHandler.identifier.icon);
Icons.getIcon(iconName, Icons.sizes.small).done(function(icon) {
$iconElement.replaceWith(icon);
});
var $iconElement = $anchorElement.find(AjaxDataHandler.identifier.icon);
Icons.getIcon(iconName, Icons.sizes.small).done(function(icon) {
$iconElement.replaceWith(icon);
});
// Set overlay for the record icon
var $recordIcon = $rowElement.find('.col-icon ' + AjaxDataHandler.identifier.icon);
if (nextState === 'hidden') {
Icons.getIcon('miscellaneous-placeholder', Icons.sizes.small, 'overlay-hidden').done(function(icon) {
$recordIcon.append($(icon).find('.icon-overlay'));
});
} else {
$recordIcon.find('.icon-overlay').remove();
}
// Set overlay for the record icon
var $recordIcon = $rowElement.find('.col-icon ' + AjaxDataHandler.identifier.icon);
if (nextState === 'hidden') {
Icons.getIcon('miscellaneous-placeholder', Icons.sizes.small, 'overlay-hidden').done(function(icon) {
$recordIcon.append($(icon).find('.icon-overlay'));
});
} else {
$recordIcon.find('.icon-overlay').remove();
}
$rowElement.fadeTo('fast', 0.4, function() {
$rowElement.fadeTo('fast', 1);
});
if (table === 'pages') {
AjaxDataHandler.refreshPageTree();
}
};
$rowElement.fadeTo('fast', 0.4, function() {
$rowElement.fadeTo('fast', 1);
});
if (table === 'pages') {
AjaxDataHandler.refreshPageTree();
}
};
/**
* delete record by given element (icon in table)
* don't call it directly!
*
* @param {HTMLElement} element
*/
AjaxDataHandler.deleteRecord = function(element) {
var $anchorElement = $(element);
var params = $anchorElement.data('params');
var $iconElement = $anchorElement.find(AjaxDataHandler.identifier.icon);
/**
* delete record by given element (icon in table)
* don't call it directly!
*
* @param {HTMLElement} element
*/
AjaxDataHandler.deleteRecord = function(element) {
var $anchorElement = $(element);
var params = $anchorElement.data('params');
var $iconElement = $anchorElement.find(AjaxDataHandler.identifier.icon);
// add a spinner
AjaxDataHandler._showSpinnerIcon($iconElement);
// add a spinner
AjaxDataHandler._showSpinnerIcon($iconElement);
// make the AJAX call to toggle the visibility
AjaxDataHandler._call(params).done(function(result) {
// revert to the old class
Icons.getIcon('actions-edit-delete', Icons.sizes.small).done(function(icon) {
$iconElement = $anchorElement.find(AjaxDataHandler.identifier.icon);
$iconElement.replaceWith(icon);
});
// print messages on errors
if (result.hasErrors) {
AjaxDataHandler.handleErrors(result);
} else {
var $table = $anchorElement.closest('table[data-table]');
var $panel = $anchorElement.closest('.panel');
var $panelHeading = $panel.find('.panel-heading');
var table = $table.data('table');
var $rowElements = $anchorElement.closest('tr[data-uid]');
var uid = $rowElements.data('uid');
var $translatedRowElements = $table.find('[data-l10nparent=' + uid + ']').closest('tr[data-uid]');
$rowElements = $rowElements.add($translatedRowElements);
// make the AJAX call to toggle the visibility
AjaxDataHandler._call(params).done(function(result) {
// revert to the old class
Icons.getIcon('actions-edit-delete', Icons.sizes.small).done(function(icon) {
$iconElement = $anchorElement.find(AjaxDataHandler.identifier.icon);
$iconElement.replaceWith(icon);
});
// print messages on errors
if (result.hasErrors) {
AjaxDataHandler.handleErrors(result);
} else {
var $table = $anchorElement.closest('table[data-table]');
var $panel = $anchorElement.closest('.panel');
var $panelHeading = $panel.find('.panel-heading');
var table = $table.data('table');
var $rowElements = $anchorElement.closest('tr[data-uid]');
var uid = $rowElements.data('uid');
var $translatedRowElements = $table.find('[data-l10nparent=' + uid + ']').closest('tr[data-uid]');
$rowElements = $rowElements.add($translatedRowElements);
$rowElements.fadeTo('slow', 0.4, function() {
$rowElements.slideUp('slow', 0, function() {
$rowElements.remove();
if ($table.find('tbody tr').length === 0) {
$panel.slideUp('slow');
}
});
});
if ($anchorElement.data('l10parent') === '0' || $anchorElement.data('l10parent') === '') {
var count = Number($panelHeading.find('.t3js-table-total-items').html());
$panelHeading.find('.t3js-table-total-items').html(count-1);
}
$rowElements.fadeTo('slow', 0.4, function() {
$rowElements.slideUp('slow', 0, function() {
$rowElements.remove();
if ($table.find('tbody tr').length === 0) {
$panel.slideUp('slow');
}
});
});
if ($anchorElement.data('l10parent') === '0' || $anchorElement.data('l10parent') === '') {
var count = Number($panelHeading.find('.t3js-table-total-items').html());
$panelHeading.find('.t3js-table-total-items').html(count - 1);
}
if (table === 'pages') {
AjaxDataHandler.refreshPageTree();
}
}
});
};
if (table === 'pages') {
AjaxDataHandler.refreshPageTree();
}
}
});
};
/**
* handle the errors from result object
*
* @param {Object} result
* @private
*/
AjaxDataHandler.handleErrors = function(result) {
$.each(result.messages, function(position, message) {
Notification.error(message.title, message.message);
});
};
/**
* handle the errors from result object
*
* @param {Object} result
* @private
*/
AjaxDataHandler.handleErrors = function(result) {
$.each(result.messages, function(position, message) {
Notification.error(message.title, message.message);
});
};
/**
* refresh the page tree
* @private
*/
AjaxDataHandler.refreshPageTree = function() {
if (top.TYPO3 && top.TYPO3.Backend && top.TYPO3.Backend.NavigationContainer && top.TYPO3.Backend.NavigationContainer.PageTree) {
top.TYPO3.Backend.NavigationContainer.PageTree.refreshTree();
}
};
/**
* refresh the page tree
* @private
*/
AjaxDataHandler.refreshPageTree = function() {
if (top.TYPO3 && top.TYPO3.Backend && top.TYPO3.Backend.NavigationContainer && top.TYPO3.Backend.NavigationContainer.PageTree) {
top.TYPO3.Backend.NavigationContainer.PageTree.refreshTree();
}
};
/**
* AJAX call to tce_db.php
* returns a jQuery Promise to work with
*
* @param {Object} params
* @returns {Object}
* @private
*/
AjaxDataHandler._call = function(params) {
return $.getJSON(TYPO3.settings.ajaxUrls['record_process'], params);
};
/**
* AJAX call to tce_db.php
* returns a jQuery Promise to work with
*
* @param {Object} params
* @returns {Object}
* @private
*/
AjaxDataHandler._call = function(params) {
return $.getJSON(TYPO3.settings.ajaxUrls['record_process'], params);
};
/**
* Replace the given icon with a spinner icon
*
* @param {Object} $iconElement
* @private
*/
AjaxDataHandler._showSpinnerIcon = function($iconElement) {
Icons.getIcon('spinner-circle-dark', Icons.sizes.small).done(function(icon) {
$iconElement.replaceWith(icon);
});
};
/**
* Replace the given icon with a spinner icon
*
* @param {Object} $iconElement
* @private
*/
AjaxDataHandler._showSpinnerIcon = function($iconElement) {
Icons.getIcon('spinner-circle-dark', Icons.sizes.small).done(function(icon) {
$iconElement.replaceWith(icon);
});
};
$(AjaxDataHandler.initialize);
$(AjaxDataHandler.initialize);
return AjaxDataHandler;
return AjaxDataHandler;
});
......@@ -15,233 +15,233 @@
* Module: TYPO3/CMS/Backend/ContextMenuActions
* Click menu actions for db records including tt_content and pages
*/
define(['jquery', 'TYPO3/CMS/Backend/Modal', 'TYPO3/CMS/Backend/Severity'], function ($, Modal, Severity) {
/**
*
* @exports TYPO3/CMS/Backend/ContextMenuActions
*/
var ContextMenuActions = {};
ContextMenuActions.getReturnUrl = function () {
return top.rawurlencode(top.list_frame.document.location.pathname + top.list_frame.document.location.search);
};
ContextMenuActions.editRecord = function (table, uid) {
top.TYPO3.Backend.ContentContainer.setUrl(
top.TYPO3.settings.FormEngine.moduleUrl + '&edit[' + table + '][' + uid + ']=edit&returnUrl=' + ContextMenuActions.getReturnUrl()
);
};
ContextMenuActions.viewRecord = function (table, uid) {
var $viewUrl = $(this).data('preview-url');
if ($viewUrl) {
var previewWin = window.open($viewUrl, 'newTYPO3frontendWindow');
previewWin.focus();
}
};
ContextMenuActions.openInfoPopUp = function (table, uid) {
top.launchView(table, uid);
};
ContextMenuActions.mountAsTreeRoot = function (table, uid) {
if (table === 'pages') {
top.TYPO3.Backend.NavigationContainer.PageTree.setTemporaryMountPoint(uid);
}
};
ContextMenuActions.newPageWizard = function (table, uid) {
top.TYPO3.Backend.ContentContainer.setUrl(
top.TYPO3.settings.NewRecord.moduleUrl + '&id=' + uid + '&pagesOnly=1&returnUrl=' + ContextMenuActions.getReturnUrl()
);
};
ContextMenuActions.newContentWizard = function (table, uid) {
var $wizardUrl = $(this).data('new-wizard-url');
if ($wizardUrl) {
$wizardUrl += '&returnUrl='+ ContextMenuActions.getReturnUrl();
top.TYPO3.Backend.ContentContainer.setUrl($wizardUrl);
define(['jquery', 'TYPO3/CMS/Backend/Modal', 'TYPO3/CMS/Backend/Severity'], function($, Modal, Severity) {
/**
*
* @exports TYPO3/CMS/Backend/ContextMenuActions
*/
var ContextMenuActions = {};
ContextMenuActions.getReturnUrl = function() {
return top.rawurlencode(top.list_frame.document.location.pathname + top.list_frame.document.location.search);
};
ContextMenuActions.editRecord = function(table, uid) {
top.TYPO3.Backend.ContentContainer.setUrl(
top.TYPO3.settings.FormEngine.moduleUrl + '&edit[' + table + '][' + uid + ']=edit&returnUrl=' + ContextMenuActions.getReturnUrl()
);
};