Skip to content

Commit

Permalink
Merge branch '4.0-dev' into cpanel-ajax
Browse files Browse the repository at this point in the history
  • Loading branch information
infograf768 committed Feb 20, 2019
2 parents 3b73b3a + d8a24fe commit a1a24ba
Show file tree
Hide file tree
Showing 6 changed files with 164 additions and 133 deletions.
2 changes: 2 additions & 0 deletions administrator/templates/atum/scss/blocks/_form.scss
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ td .form-control {

legend {
margin-bottom: 1.1rem;
font-size: 1rem;
font-weight: $normal-weight;
}

.checkboxes {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
font-weight: $normal-weight;
color: $gray-800;
white-space: nowrap;
border-bottom: 2px solid $gray-300;
}
td {
padding: 0;
Expand Down
6 changes: 5 additions & 1 deletion build/media_source/system/css/fields/calendar-rtl.css
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ div.calendar-container table body td {
line-height: 2em;
}

.calendar-container table {
border-collapse: separate;
}

div.calendar-container table td.title { /* This holds the current "month, year" */
vertical-align: middle;
text-align: center;
Expand Down Expand Up @@ -150,7 +154,7 @@ a.js-btn.btn.btn-exit, a.js-btn.btn.btn-today, a.js-btn.btn.btn-clear {
padding: 8px 8px 8px 0;
}
.time .time-title {
background-image: url("data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAABYAAAAWCAYAAADEtGw7AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAdlJREFUeNqklUsohFEUx7/5kgWGjEcRJULJSmJhITQLr8UoFko2k2SDLGZD2SglJcXOxo6Fx0ayUt4jWXgNG2rIwsgMJZPn/+o/dRvfa8yp33zfPfecM+e795x7bYqxtIAaUA2KgA3cgn3gBcsgrMQg3eAAfJtwBYa0Atg0dAugg+/3YAUcgkvqCkAVcIIy6raBCwT0/mRdymYG5Bt8VQoYBe+0Pwdpik6mwuAVNMawbJXgmr7e6FVokzKt1XBOZnYuneB54Jn+w/LEMZXTOo65nN80yNxNmyBIF4o6Ku6AXccpmzbzJstyQbs+FT/1VC6CFyU+mePTqbIBhBwp8csGn8UqO0qIz8AhstNBk8BP4As4RGCVyk8LgUVVlFvIXFXZ+4qUuZY8gn6W1QmYBKkadklM9PfLJriTYxYyEYFXpZp3s8Yj0kv9mhi0cuCTlsVMuqRWbpL0Xuo8YpAotaQnhgoQSzEAMjhuZoywfMb0UCmyKP1HmSXzJBQxpqIn9zhxA0piCJoFdqXu/bOpmeCMBiF+ZoJJ0E7gp0/AKCF71M1xCkZ4NRWSCjAIdiQ7v9UlHAcPUdfQh1QJEd7ArOg0K1dTRHJAO2hg8zhoH2IVbYElvaPgR4ABAFM/gtHnpJfxAAAAAElFTkSuQmCC");
background-image: url("data:image/svg+xml,%3C%3Fxml version='1.0' encoding='utf-8'%3F%3E%3Csvg width='22' height='22' viewBox='0 0 1792 1792' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1024 544v448q0 14-9 23t-23 9h-320q-14 0-23-9t-9-23v-64q0-14 9-23t23-9h224v-352q0-14 9-23t23-9h64q14 0 23 9t9 23zm416 352q0-148-73-273t-198-198-273-73-273 73-198 198-73 273 73 273 198 198 273 73 273-73 198-198 73-273zm224 0q0 209-103 385.5t-279.5 279.5-385.5 103-385.5-103-279.5-279.5-103-385.5 103-385.5 279.5-279.5 385.5-103 385.5 103 279.5 279.5 103 385.5z'/%3E%3C/svg%3E");
background-repeat: no-repeat;
background-position: center;
}
6 changes: 5 additions & 1 deletion build/media_source/system/css/fields/calendar.css
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ div.calendar-container table body td {
line-height: 2em;
}

.calendar-container table {
border-collapse: separate;
}

div.calendar-container table td.title { /* This holds the current "month, year" */
vertical-align: middle;
text-align: center;
Expand Down Expand Up @@ -149,7 +153,7 @@ a.js-btn.btn.btn-exit, a.js-btn.btn.btn-today, a.js-btn.btn.btn-clear {
padding: 8px 0 8px 8px;
}
.time .time-title {
background-image: url("data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAABYAAAAWCAYAAADEtGw7AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAdlJREFUeNqklUsohFEUx7/5kgWGjEcRJULJSmJhITQLr8UoFko2k2SDLGZD2SglJcXOxo6Fx0ayUt4jWXgNG2rIwsgMJZPn/+o/dRvfa8yp33zfPfecM+e795x7bYqxtIAaUA2KgA3cgn3gBcsgrMQg3eAAfJtwBYa0Atg0dAugg+/3YAUcgkvqCkAVcIIy6raBCwT0/mRdymYG5Bt8VQoYBe+0Pwdpik6mwuAVNMawbJXgmr7e6FVokzKt1XBOZnYuneB54Jn+w/LEMZXTOo65nN80yNxNmyBIF4o6Ku6AXccpmzbzJstyQbs+FT/1VC6CFyU+mePTqbIBhBwp8csGn8UqO0qIz8AhstNBk8BP4As4RGCVyk8LgUVVlFvIXFXZ+4qUuZY8gn6W1QmYBKkadklM9PfLJriTYxYyEYFXpZp3s8Yj0kv9mhi0cuCTlsVMuqRWbpL0Xuo8YpAotaQnhgoQSzEAMjhuZoywfMb0UCmyKP1HmSXzJBQxpqIn9zhxA0piCJoFdqXu/bOpmeCMBiF+ZoJJ0E7gp0/AKCF71M1xCkZ4NRWSCjAIdiQ7v9UlHAcPUdfQh1QJEd7ArOg0K1dTRHJAO2hg8zhoH2IVbYElvaPgR4ABAFM/gtHnpJfxAAAAAElFTkSuQmCC");
background-image: url("data:image/svg+xml,%3C%3Fxml version='1.0' encoding='utf-8'%3F%3E%3Csvg width='22' height='22' viewBox='0 0 1792 1792' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1024 544v448q0 14-9 23t-23 9h-320q-14 0-23-9t-9-23v-64q0-14 9-23t23-9h224v-352q0-14 9-23t23-9h64q14 0 23 9t9 23zm416 352q0-148-73-273t-198-198-273-73-273 73-198 198-73 273 73 273 198 198 273 73 273-73 198-198 73-273zm224 0q0 209-103 385.5t-279.5 279.5-385.5 103-385.5-103-279.5-279.5-103-385.5 103-385.5 279.5-279.5 385.5-103 385.5 103 279.5 279.5 103 385.5z'/%3E%3C/svg%3E");
background-repeat: no-repeat;
background-position: center;
}
280 changes: 151 additions & 129 deletions build/media_source/system/js/fields/joomla-field-fancy-select.w-c.es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,164 +24,186 @@
* placeholder="" The value of the inputs placeholder.
* search-placeholder="" The value of the search inputs placeholder.
*/
(function (customElements) {
'use strict';
window.customElements.define('joomla-field-fancy-select', class extends HTMLElement {
// Attributes to monitor
get allowCustom() { return this.hasAttribute('allow-custom'); }

class JoomlaFieldFancySelect extends HTMLElement {
// Properties getters/setters
get allowCustom() { return this.hasAttribute('allow-custom'); }
get remoteSearch() { return this.hasAttribute('remote-search'); }

get remoteSearch() { return this.hasAttribute('remote-search'); }
get url() { return this.getAttribute('url'); }

get url() { return this.getAttribute('url'); }
get termKey() { return this.getAttribute('term-key') || 'term'; }

get termKey() { return this.getAttribute('term-key') || 'term'; }
get minTermLength() { return parseInt(this.getAttribute('min-term-length')) || 1; }

get minTermLength() { return parseInt(this.getAttribute('min-term-length')) || 1; }
get newItemPrefix() { return this.getAttribute('new-item-prefix') || ''; }

get newItemPrefix() { return this.getAttribute('new-item-prefix') || ''; }
get placeholder() { return this.getAttribute('placeholder'); }

get placeholder() { return this.getAttribute('placeholder'); }
get searchPlaceholder() { return this.getAttribute('search-placeholder'); }

get searchPlaceholder() { return this.getAttribute('search-placeholder'); }
get value() {return this.choicesInstance.getValue(true); }

get value() { return this.choicesInstance.getValue(true); }
set value($val) { this.choicesInstance.setValueByChoice($val); }

set value($val) { this.choicesInstance.setValueByChoice(`${$val}`); }
/**
* Lifecycle
*/
constructor() {
super();

connectedCallback() {
if (!window.Choices) {
throw new Error('JoomlaFieldFancySelect require Choices.js to work');
}

// Get a <select> element
this.select = this.querySelector('select');
// Keycodes
this.keyCode = {
ENTER: 13,
};

if (!this.select) {
throw new Error('JoomlaFieldFancySelect require <select> element to work');
}

// Init Choices
this.choicesInstance = new Choices(this.select, {
placeholderValue: this.placeholder,
searchPlaceholderValue: this.searchPlaceholder,
removeItemButton: true,
searchFloor: this.minTermLength,
searchResultLimit: 10,
shouldSort: false,
fuseOptions: {
threshold: 0.3, // Strict search
},
noResultsText: Joomla.Text._('JGLOBAL_SELECT_NO_RESULTS_MATCH', 'No results found'),
noChoicesText: Joomla.Text._('JGLOBAL_SELECT_NO_RESULTS_MATCH', 'No results found'),
itemSelectText: Joomla.Text._('JGLOBAL_SELECT_PRESS_TO_SELECT', 'Press to select'),

// Redefine some classes
classNames: {
button: 'choices__button_joomla', // It is need because an original styling use unavailable Icon.svg file
},
});
if (!Joomla) {
throw new Error('Joomla API is not properly initiated');
}

// Collect an existing values, to avoid duplications
this.choicesCache = {};
if (!window.Choices) {
throw new Error('JoomlaFieldFancySelect requires Choices.js to work');
}

// Handle typing of custom term
if (this.allowCustom) {
this.addEventListener('keydown', (event) => {
if (event.keyCode !== 13 || event.target !== this.choicesInstance.input) return;
event.preventDefault();
this.choicesCache = {};
this.activeXHR = null;
this.choicesInstance = null;
}

if (this.choicesInstance.highlightPosition
|| !event.target.value || this.choicesCache[event.target.value]) return;
/**
* Lifecycle
*/
connectedCallback() {
// Get a <select> element
this.select = this.querySelector('select');

// Make sure nothing is highlighted
const highlighted = this.choicesInstance.dropdown.querySelector(`.${this.choicesInstance.config.classNames.highlightedState}`);
if (highlighted) return;
if (!this.select) {
throw new Error('JoomlaFieldFancySelect requires <select> element to work');
}

this.choicesInstance.setChoices([{
value: this.newItemPrefix + event.target.value,
label: event.target.value,
selected: true,
customProperties: {
value: event.target.value, // Store real value, just in case
},
}], 'value', 'label', false);
// Init Choices
this.choicesInstance = new Choices(this.select, {
placeholderValue: this.placeholder,
searchPlaceholderValue: this.searchPlaceholder,
removeItemButton: true,
searchFloor: this.minTermLength,
searchResultLimit: 10,
shouldSort: false,
fuseOptions: {
threshold: 0.3 // Strict search
},
noResultsText: Joomla.Text._('JGLOBAL_SELECT_NO_RESULTS_MATCH', 'No results found'),
noChoicesText: Joomla.Text._('JGLOBAL_SELECT_NO_RESULTS_MATCH', 'No results found'),
itemSelectText: Joomla.Text._('JGLOBAL_SELECT_PRESS_TO_SELECT', 'Press to select'),

// Redefine some classes
classNames: {
button: 'choices__button_joomla' // It is need because an original styling use unavailable Icon.svg file
}
});

// Handle typing of custom term
if (this.allowCustom) {
this.addEventListener('keydown', (event) => {
if (event.keyCode !== this.keyCode.ENTER || event.target !== this.choicesInstance.input) {
return;
}
event.preventDefault();

if (this.choicesInstance.highlightPosition || !event.target.value || this.choicesCache[event.target.value]) {
return;
}

// Make sure nothing is highlighted
const highlighted = this.choicesInstance.dropdown.querySelector(`.${this.choicesInstance.config.classNames.highlightedState}`);
if (highlighted) {
return;
};

this.choicesInstance.setChoices([{
value: this.newItemPrefix + event.target.value,
label: event.target.value,
selected: true,
customProperties: {
value: event.target.value // Store real value, just in case
}
}], 'value', 'label', false);

this.choicesCache[event.target.value] = event.target.value;
this.choicesCache[event.target.value] = event.target.value;

event.target.value = null;
this.choicesInstance.hideDropdown();
event.target.value = null;
this.choicesInstance.hideDropdown();

return false;
});
}
return false;
});
}

// Handle remote search
if (this.remoteSearch && this.url) {
// Cache existing
this.choicesInstance.presetChoices.forEach((choiceItem) => {
this.choicesCache[choiceItem.value] = choiceItem.label;
});
// Handle remote search
if (this.remoteSearch && this.url) {
// Cache existing
this.choicesInstance.presetChoices.forEach((choiceItem) => {
this.choicesCache[choiceItem.value] = choiceItem.label;
});

const lookupDelay = 300;
let lookupTimeout = null;
this.activeXHR = null;
this.select.addEventListener('search', (event) => {
clearTimeout(lookupTimeout);
lookupTimeout = setTimeout(this.requestLookup.bind(this), lookupDelay);
});
}
const lookupDelay = 300;
let lookupTimeout = null;
this.select.addEventListener('search', (event) => {
clearTimeout(lookupTimeout);
lookupTimeout = setTimeout(this.requestLookup.bind(this), lookupDelay);
});
}
}

disconnectedCallback() {
// Destroy Choices instance, to unbind an event listeners
if (this.choicesInstance) {
this.choicesInstance.destroy();
this.choicesInstance = null;
}
if (this.activeXHR) {
this.activeXHR.abort();
this.activeXHR = null;
}
/**
* Lifecycle
*/
disconnectedCallback() {
// Destroy Choices instance, to unbind event listeners
if (this.choicesInstance) {
this.choicesInstance.destroy();
this.choicesInstance = null;
}
if (this.activeXHR) {
this.activeXHR.abort();
this.activeXHR = null;
}
}

requestLookup() {
let url = this.url;
url += (url.indexOf('?') === -1 ? '?' : '&');
url += `${encodeURIComponent(this.termKey)}=${encodeURIComponent(this.choicesInstance.input.value)}`;
requestLookup() {
let url = this.url;
url += (url.indexOf('?') === -1 ? '?' : '&');
url += `${encodeURIComponent(this.termKey)}=${encodeURIComponent(this.choicesInstance.input.value)}`;

// Stop previous request if any
if (this.activeXHR) {
this.activeXHR.abort();
}
// Stop previous request if any
if (this.activeXHR) {
this.activeXHR.abort();
}

this.activeXHR = Joomla.request({
url,
onSuccess: (response, xhr) => {
this.activeXHR = null;
const items = response ? JSON.parse(response) : [];
if (!items.length) return;

// Remove duplications
let item;
for (let i = items.length - 1; i >= 0; i--) {
item = items[i];
if (this.choicesCache[item.value]) {
items.splice(i, 1);
}
this.activeXHR = Joomla.request({
url: url,
onSuccess: (response) => {
this.activeXHR = null;
const items = response ? JSON.parse(response) : [];
if (!items.length) {
return;
}

// Remove duplications
items.forEach((item, index) => {
if (this.choicesCache[item.value]) {
items.splice(index, 1);
}
});

// Add new options to field, assume that each item is object, eg {value: "foo", text: "bar"}
if (items.length) {
this.choicesInstance.setChoices(items, 'value', 'text', false);
}
},
onError: () => {
this.activeXHR = null;
},
});
}
// Add new options to field, assume that each item is object, eg {value: "foo", text: "bar"}
if (items.length) {
this.choicesInstance.setChoices(items, 'value', 'text', false);
}
},
onError: () => {
this.activeXHR = null;
}
});
}

customElements.define('joomla-field-fancy-select', JoomlaFieldFancySelect);
}(customElements));
});
2 changes: 1 addition & 1 deletion build/media_source/system/js/searchtools.es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ Joomla = window.Joomla || {};

if (sort && sort.hasAttribute('data-sort')) {
const ariasort = sort.getAttribute('data-sort');
sort.parentNode.setAttribute('aria-sorted', ariasort);
sort.parentNode.setAttribute('aria-sort', ariasort);
}

// Cleanup
Expand Down

0 comments on commit a1a24ba

Please sign in to comment.