Skip to content

Commit

Permalink
Merge branch '4.0-dev' into path1
Browse files Browse the repository at this point in the history
  • Loading branch information
amitranjan2 committed Jan 31, 2019
2 parents b5bc22b + 3bd4df6 commit 9f84151
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 99 deletions.
29 changes: 27 additions & 2 deletions build/media/legacy/js/bootstrap-init.js
@@ -1,7 +1,32 @@
Joomla = window.Joomla || {};

;(function() {
(function(Joomla) {
"use strict";

/**
* Method to invoke a click on button inside an iframe
*
* @param {object} options Object with the css selector for the parent element of an iframe
* and the selector of the button in the iframe that will be clicked
* { iframeSelector: '', buttonSelector: '' }
* @returns {boolean}
*
* @since 4.0
*/
Joomla.iframeButtonClick = function(options) {
if (!options.iframeSelector || !options.buttonSelector) {
throw new Error('Selector is missing');
}

var iframe = document.querySelector(options.iframeSelector + ' iframe');
if (iframe) {
var button = iframe.contentWindow.document.querySelector(options.buttonSelector);
if (button) {
button.click();
}
}
};

jQuery(document).ready(function($) {

// Initialize some variables
Expand Down Expand Up @@ -186,4 +211,4 @@
});
}
});
})();
})(Joomla);
16 changes: 16 additions & 0 deletions build/media_src/mod_menu/js/admin-menu.es6.js
Expand Up @@ -5,6 +5,22 @@
((Joomla, document) => {
'use strict';

/**
* Check if HTML5 localStorage enabled on the browser
*
* @since 4.0.0
*/
Joomla.localStorageEnabled = () => {
const test = 'joomla-cms';
try {
localStorage.setItem(test, test);
localStorage.removeItem(test);
return true;
} catch (e) {
return false;
}
};

// eslint-disable-next-line no-new
new window.MetisMenu('#menu');

Expand Down
112 changes: 17 additions & 95 deletions build/media_src/system/js/core.es6.js
Expand Up @@ -4,8 +4,10 @@
*/

// eslint-disable max-len
// Patch Custom Events
// https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent
/**
* Patch Custom Events
* https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent
*/
(() => {
if (typeof window.CustomEvent === 'function') {
return false;
Expand Down Expand Up @@ -193,8 +195,8 @@ window.Joomla.Modal = window.Joomla.Modal || {
*
* @type {{}}
*
* Allows you to call Joomla.JText._() to get a translated JavaScript string
* pushed in with JText::script() in Joomla.
* Allows you to call Joomla.Text._() to get a translated JavaScript string
* pushed in with Text::script() in Joomla.
*/
Joomla.Text = {
strings: {},
Expand Down Expand Up @@ -226,10 +228,10 @@ window.Joomla.Modal = window.Joomla.Modal || {
},

/**
* Load new strings in to Joomla.JText
* Load new strings in to Joomla.Text
*
* @param {Object} object Object with new strings
* @returns {Joomla.JText}
* @returns {Joomla.Text}
*/
load: (object) => {
[].slice.call(Object.keys(object)).forEach((key) => {
Expand Down Expand Up @@ -473,13 +475,13 @@ window.Joomla.Modal = window.Joomla.Modal || {
}

// Title
title = Joomla.JText._(type);
title = Joomla.Text._(type);

// Skip titles with untranslated strings
if (typeof title !== 'undefined') {
titleWrapper = document.createElement('h4');
titleWrapper.className = 'alert-heading';
titleWrapper.innerHTML = Joomla.JText._(type) ? Joomla.JText._(type) : type;
titleWrapper.innerHTML = Joomla.Text._(type) ? Joomla.Text._(type) : type;
messagesBox.appendChild(titleWrapper);
}

Expand All @@ -502,7 +504,6 @@ window.Joomla.Modal = window.Joomla.Modal || {
});
};


/**
* Remove messages
*
Expand Down Expand Up @@ -571,20 +572,20 @@ window.Joomla.Modal = window.Joomla.Modal || {

encodedJson = buf.join('');

msg.error = [Joomla.JText._('JLIB_JS_AJAX_ERROR_PARSE').replace('%s', encodedJson)];
msg.error = [Joomla.Text._('JLIB_JS_AJAX_ERROR_PARSE').replace('%s', encodedJson)];
} else if (textStatus === 'nocontent') {
msg.error = [Joomla.JText._('JLIB_JS_AJAX_ERROR_NO_CONTENT')];
msg.error = [Joomla.Text._('JLIB_JS_AJAX_ERROR_NO_CONTENT')];
} else if (textStatus === 'timeout') {
msg.error = [Joomla.JText._('JLIB_JS_AJAX_ERROR_TIMEOUT')];
msg.error = [Joomla.Text._('JLIB_JS_AJAX_ERROR_TIMEOUT')];
} else if (textStatus === 'abort') {
msg.error = [Joomla.JText._('JLIB_JS_AJAX_ERROR_CONNECTION_ABORT')];
msg.error = [Joomla.Text._('JLIB_JS_AJAX_ERROR_CONNECTION_ABORT')];
} else if (xhr.responseJSON && xhr.responseJSON.message) {
// For vanilla XHR
msg.error = [`${Joomla.JText._('JLIB_JS_AJAX_ERROR_OTHER').replace('%s', xhr.status)} <em>${xhr.responseJSON.message}</em>`];
msg.error = [`${Joomla.Text._('JLIB_JS_AJAX_ERROR_OTHER').replace('%s', xhr.status)} <em>${xhr.responseJSON.message}</em>`];
} else if (xhr.statusText) {
msg.error = [`${Joomla.JText._('JLIB_JS_AJAX_ERROR_OTHER').replace('%s', xhr.status)} <em>${xhr.statusText}</em>`];
msg.error = [`${Joomla.Text._('JLIB_JS_AJAX_ERROR_OTHER').replace('%s', xhr.status)} <em>${xhr.statusText}</em>`];
} else {
msg.error = [Joomla.JText._('JLIB_JS_AJAX_ERROR_OTHER').replace('%s', xhr.status)];
msg.error = [Joomla.Text._('JLIB_JS_AJAX_ERROR_OTHER').replace('%s', xhr.status)];
}

return msg;
Expand Down Expand Up @@ -909,22 +910,6 @@ window.Joomla.Modal = window.Joomla.Modal || {
return xhr;
};

/**
* Check if HTML5 localStorage enabled on the browser
*
* @since 4.0.0
*/
Joomla.localStorageEnabled = () => {
const test = 'joomla-cms';
try {
localStorage.setItem(test, test);
localStorage.removeItem(test);
return true;
} catch (e) {
return false;
}
};

/**
* Loads any needed polyfill for web components and async load any web components
*
Expand Down Expand Up @@ -1139,69 +1124,6 @@ window.Joomla.Modal = window.Joomla.Modal || {
}
}
};

/**
* Method that resets the filter inputs and submits the relative form
*
* @param {HTMLElement} The element that initiates the call
* @returns {void}
* @since 4.0
*/
Joomla.resetFilters = (element) => {
const { form } = element;

if (!form) {
throw new Error('Element must be inside a form!');
}

const elementsArray = [].slice.call(form.elements);

if (elementsArray.length) {
const newElementsArray = [];
elementsArray.forEach((elem) => {
// Skip the token, the task, the boxchecked and the calling element
if (elem.getAttribute('name') === 'task'
|| elem.getAttribute('name') === 'boxchecked'
|| (elem.value === '1' && /^[0-9A-F]{32}$/i.test(elem.name))
|| elem === element) {
return;
}

newElementsArray.push(elem);
});

// Reset all filters
newElementsArray.forEach((elem) => {
elem.value = '';
});

form.submit();
}
};

/*
* Method to invoke a click on button inside an iframe
*
* @param {object} options Object with the css selector for the parent element of an iframe
* and the selector of the button in the iframe that will be clicked
* @returns {boolean}
* @since 4.0
*/
Joomla.iframeButtonClick = (options = { iframeSelector: '', buttonSelector: '' }) => {
if (!options.iframeSelector || !options.buttonSelector) {
throw new Error('Selector is missing');
}

const iframe = document.querySelector(`${options.iframeSelector} > iframe`);
if (iframe) {
const button = iframe.contentWindow.document.querySelector(options.buttonSelector);
if (button) {
button.click();
}
}

return false;
};
})(Joomla, document);

/**
Expand Down
45 changes: 43 additions & 2 deletions build/media_src/system/js/searchtools.es6.js
@@ -1,6 +1,47 @@
(() => {
Joomla = window.Joomla || {};

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

/**
* Method that resets the filter inputs and submits the relative form
*
* @param {HTMLElement} element The element that initiates the call
* @returns {void}
* @since 4.0
*/
Joomla.resetFilters = (element) => {
const { form } = element;

if (!form) {
throw new Error('Element must be inside a form!');
}

const elementsArray = [].slice.call(form.elements);

if (elementsArray.length) {
const newElementsArray = [];
elementsArray.forEach((elem) => {
// Skip the token, the task, the boxchecked and the calling element
if (elem.getAttribute('name') === 'task'
|| elem.getAttribute('name') === 'boxchecked'
|| (elem.value === '1' && /^[0-9A-F]{32}$/i.test(elem.name))
|| elem === element) {
return;
}

newElementsArray.push(elem);
});

// Reset all filters
newElementsArray.forEach((elem) => {
elem.value = '';
});

form.submit();
}
};

class Searchtools {
constructor(elem, options) {
const defaults = {
Expand Down Expand Up @@ -486,4 +527,4 @@

// Execute on DOM Loaded Event
document.addEventListener('DOMContentLoaded', onBoot);
})();
})(Joomla);

0 comments on commit 9f84151

Please sign in to comment.