Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# A list of files to ignore from linting
*.js
!*.es6.js
build/**/**/*.js ## Exclude webcomponents till we fix the CS!
*.vue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@

HTMLHelper::_('behavior.formvalidator');
HTMLHelper::_('behavior.keepalive');
HTMLHelper::_('formbehavior.chosen', 'select');
HTMLHelper::_('jquery.framework');
//HTMLHelper::_('formbehavior.chosen', 'select');

HTMLHelper::_('script', 'com_associations/sidebyside.js', false, true);
HTMLHelper::_('stylesheet', 'com_associations/sidebyside.css', array(), true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@
Session::checkToken('get') or die(Text::_('JINVALID_TOKEN'));
}

HTMLHelper::_('jquery.framework');
HTMLHelper::_('behavior.multiselect');
HTMLHelper::_('formbehavior.chosen', 'select');

$function = $app->input->getCmd('function', 'jSelectAssociation');
$listOrder = $this->escape($this->state->get('list.ordering'));
Expand Down
18 changes: 18 additions & 0 deletions media/com_associations/js/admin-associations-default.es6.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
Joomla.submitbutton = (pressbutton) => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expected to return a value at the end of arrow function consistent-return

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expected to return a value at the end of arrow function consistent-return

if (pressbutton === 'associations.purge') {
// eslint-disable-next-line no-restricted-globals
if (confirm(Joomla.JText._('COM_ASSOCIATIONS_PURGE_CONFIRM_PROMPT'))) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unexpected use of 'confirm' no-restricted-globals

Joomla.submitform(pressbutton);
} else {
return false;
}
} else {
Joomla.submitform(pressbutton);
}

return true;
};

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 18 additions & 10 deletions media/com_associations/js/admin-associations-default.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
/**

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expected space or tab before '*/' in comment spaced-comment

* PLEASE DO NOT MODIFY THIS FILE. WORK ON THE ES6 VERSION.
* OTHERWISE YOUR CHANGES WILL BE REPLACED ON THE NEXT BUILD.
**/

/**
* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
Joomla.submitbutton = function(pressbutton) {
if (pressbutton == 'associations.purge') {
if (confirm(Joomla.JText._('COM_ASSOCIATIONS_PURGE_CONFIRM_PROMPT'))) {
Joomla.submitform(pressbutton);
} else {
return false;
}
} else {
Joomla.submitform(pressbutton);
}
Joomla.submitbutton = function (pressbutton) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expected to return a value at the end of function consistent-return
Unexpected unnamed function func-names

if (pressbutton === 'associations.purge') {
// eslint-disable-next-line no-restricted-globals
if (confirm(Joomla.JText._('COM_ASSOCIATIONS_PURGE_CONFIRM_PROMPT'))) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unexpected use of 'confirm' no-restricted-globals

Joomla.submitform(pressbutton);
} else {
return false;
}
} else {
Joomla.submitform(pressbutton);
}

return true;
};

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions media/com_associations/js/admin-associations-modal.es6.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
Joomla = window.Joomla || {};

((Joomla, document) => {
'use strict';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expected newline after "use strict" directive lines-around-directive


document.addEventListener('DOMContentLoaded', () => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Block must not be padded by blank lines padded-blocks

const target = window.parent.document.getElementById("target-association");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strings must use singlequote quotes

const links = [].slice.call(document.querySelectorAll('.select-link'));

links.forEach((item) => {
item.addEventListener('click', (event) => {
target.src = target.getAttribute("data-editurl") + '"&task="' + target.getAttribute("data-item") + ".edit" + "&id=" + parseInt(event.target.getAttribute('data-id'), 10);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unexpected string concatenation prefer-template
Strings must use singlequote quotes
Unexpected string concatenation of literals no-useless-concat

window.parent.Joomla.Modal.getCurrent().close();
});
});
});
})(Joomla, document);

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 18 additions & 19 deletions media/com_associations/js/admin-associations-modal.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,26 @@
/**

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expected space or tab before '*/' in comment spaced-comment

* PLEASE DO NOT MODIFY THIS FILE. WORK ON THE ES6 VERSION.
* OTHERWISE YOUR CHANGES WILL BE REPLACED ON THE NEXT BUILD.
**/

/**
* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

Joomla = window.Joomla || {};

(function( Joomla, document ) {
'use strict';
(function (Joomla, document) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move the invocation into the parens that contain the function wrap-iife
Unexpected unnamed function func-names

'use strict';

document.addEventListener('DOMContentLoaded', function() {

if (Joomla.getOptions('modal-associations')) {
var fnName = Joomla.getOptions('modal-associations').func,
links = [].slice.call(document.querySelectorAll('.select-link'));
document.addEventListener('DOMContentLoaded', function () {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unexpected function expression prefer-arrow-callback
Unexpected unnamed function func-names
Block must not be padded by blank lines padded-blocks

var target = window.parent.document.getElementById("target-association");
var links = [].slice.call(document.querySelectorAll('.select-link'));

links.forEach(function (item) {
item.addEventListener('click', function (event) {
if (self != top) {
// Run function on parent window.
window.parent[fnName](event.target.getAttribute('data-id'));
}
});
});
}
});
})();
links.forEach(function (item) {
item.addEventListener('click', function (event) {
target.src = target.getAttribute("data-editurl") + '"&task="' + target.getAttribute("data-item") + ".edit" + "&id=" + parseInt(event.target.getAttribute('data-id'), 10);
window.parent.Joomla.Modal.getCurrent().close();
});
});
});
})(Joomla, document);
2 changes: 1 addition & 1 deletion media/com_associations/js/admin-associations-modal.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

112 changes: 112 additions & 0 deletions media/com_associations/js/associations-edit.es6.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
/**
* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
Joomla = window.Joomla || {};

((Joomla, document) => {
'use strict';

Joomla.hideAssociation = (formControl, languageCode) => {
const controlGroup = [].slice.call(document.querySelectorAll('#associations .control-group'));

controlGroup.forEach((element) => {
// Current selected language. Hide it
const el = element.querySelector('.control-label label');

if (el) {
const attribute = el.getAttribute('for');

if (attribute.replace('_id', '') === `${formControl}_associations_${languageCode.replace('-', '_')}`) {
element.style.display = 'none';
}
}
});
};

Joomla.showAssociationMessage = () => {
const controlGroup = [].slice.call(document.querySelectorAll('#associations .control-group'));

controlGroup.forEach((element) => {
element.style.display = 'none';

const associations = document.getElementById('associations');

if (associations) {
const html = document.createElement('div');
html.classList.add('alert');
html.classList.add('alert-info');
html.id = 'associations-notice';
html.innerHTML = Joomla.JText._('JGLOBAL_ASSOC_NOT_POSSIBLE');

associations.insertAdjacentElement('afterbegin', html);
}
});
};

document.addEventListener('DOMContentLoaded', () => {
const associationsEditOptions = Joomla.getOptions('system.associations.edit');
const formControl = associationsEditOptions.formControl || 'jform';
const formControlLanguage = document.getElementById(`${formControl}_language`);

// Hide the associations tab if needed
if (parseInt(associationsEditOptions.hidden, 10) === 1) {
Joomla.showAssociationMessage();
} else if (formControlLanguage) {
// Hide only the associations for the current language
Joomla.hideAssociation(formControl, formControlLanguage.value);
}

// When changing the language
if (formControlLanguage) {
formControlLanguage.addEventListener('change', (event) => {
// Remove message if any
Joomla.removeMessages();

let existsAssociations = false;

/** For each language, remove the associations, ie,
* empty the associations fields and reset the buttons to Select/Create
*/
const controlGroup = [].slice.call(document.querySelectorAll('#associations .control-group'));

controlGroup.forEach((element) => {
const attribute = element.querySelector('.control-label label').getAttribute('for');
const languageCode = attribute.replace('_id', '').replace('jform_associations_', '');

// Show the association fields
element.style.display = 'block';

// Check if there was an association selected for this language
if (!existsAssociations && document.getElementById(`${formControl}_associations_${languageCode}_id`).value !== '') {
existsAssociations = true;
}

// Call the modal clear button
const clear = document.getElementById(`${formControl}_associations_${languageCode}_clear`);

if (clear.onclick) {
clear.onclick();
} else if (clear.click) {
clear.click();
}
});

// If associations existed, send a warning to the user
if (existsAssociations) {
Joomla.renderMessages({ warning: [Joomla.JText._('JGLOBAL_ASSOCIATIONS_RESET_WARNING')] });
}

// If the selected language is All hide the fields and add a message
const selectedLanguage = event.target.value;

if (selectedLanguage === '*') {
Joomla.showAssociationMessage();
} else {
// Else show the associations fields/buttons and hide the current selected language
Joomla.hideAssociation(formControl, selectedLanguage);
}
});
}
});
})(Joomla, document);
1 change: 1 addition & 0 deletions media/com_associations/js/associations-edit.es6.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading