Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
44 changes: 0 additions & 44 deletions build/media/system/js/fields/select-colour.js

This file was deleted.

47 changes: 47 additions & 0 deletions build/media_src/system/js/fields/select-colour.es6.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/**
* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
(() => {
'use strict';

const onChange = (event) => {
const self = event.target;
const value = parseInt(self.value, 10);

self.classList.remove('custom-select-success', 'custom-select-danger');

if (value === 1) {
self.classList.add('custom-select-success');
} else if (value === 0 || value === -2) {
self.classList.add('custom-select-danger');
}
};

const updateSelectboxColour = () => {
const colourSelects = [].slice.call(document.querySelectorAll('.custom-select-color-state'));

colourSelects.forEach((colourSelect) => {
const value = parseInt(colourSelect.value, 10);

// Add class on page load
if (value === 1) {
colourSelect.classList.add('custom-select-success');
} else if (value === 0) {
colourSelect.classList.add('custom-select-danger');
}

// Add class when value is changed
colourSelect.addEventListener('change', onChange);
});

// Cleanup
document.removeEventListener('DOMContentLoaded', updateSelectboxColour, true);
};

// On docunment loaded
document.addEventListener('DOMContentLoaded', updateSelectboxColour, true);

// On Joomla updated
document.addEventListener('Joomla:update', updateSelectboxColour, true);
Copy link
Member

Choose a reason for hiding this comment

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

hmm, when we renamed joomla:updated to Joomla:update?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

damn, I thought that was the name...
Fixing it...

Copy link
Member

Choose a reason for hiding this comment

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

but they case insensitive or? I do not remember

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You wrote this don't ask me. Ok will check

Copy link
Member

Choose a reason for hiding this comment

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

nevermind, just curious 😉

})();