diff --git a/media/system/js/core.js b/media/system/js/core.js index babe0fbdf2327..6815bc20b0243 100644 --- a/media/system/js/core.js +++ b/media/system/js/core.js @@ -205,7 +205,7 @@ Joomla.editors.instances = Joomla.editors.instances || { // Load form the script container if (!options) { var elements = document.querySelectorAll('.joomla-script-options.new'), - str, element, option, counter = 0; + str, element, option, counter = 0; for (var i = 0, l = elements.length; i < l; i++) { element = elements[i]; @@ -244,9 +244,9 @@ Joomla.editors.instances = Joomla.editors.instances || { } else { Joomla.optionsStorage[p] = options[p]; } - } - } - } + } + } + } }; /** @@ -601,50 +601,50 @@ Joomla.editors.instances = Joomla.editors.instances || { } }; - /** - * USED IN: all over :) - * - * @param id - * @param task - * @return - * - * @deprecated 4.0 Use Joomla.listItemTask() instead - */ - window.listItemTask = function ( id, task ) { - return Joomla.listItemTask( id, task ); - }; - - /** - * USED IN: all over :) - * - * @param {string} id The id - * @param {string} task The task - * - * @return {boolean} - */ - Joomla.listItemTask = function ( id, task ) { - var f = document.adminForm, - i = 0, cbx, - cb = f[ id ]; - - if ( !cb ) return false; - - while ( true ) { - cbx = f[ 'cb' + i ]; - - if ( !cbx ) break; - - cbx.checked = false; - - i++; - } - - cb.checked = true; - f.boxchecked.value = 1; - window.submitform( task ); - - return false; - }; + /** + * USED IN: all over :) + * + * @param id + * @param task + * @return + * + * @deprecated 4.0 Use Joomla.listItemTask() instead + */ + window.listItemTask = function ( id, task ) { + return Joomla.listItemTask( id, task ); + }; + + /** + * USED IN: all over :) + * + * @param {string} id The id + * @param {string} task The task + * + * @return {boolean} + */ + Joomla.listItemTask = function ( id, task ) { + var f = document.adminForm, + i = 0, cbx, + cb = f[ id ]; + + if ( !cb ) return false; + + while ( true ) { + cbx = f[ 'cb' + i ]; + + if ( !cbx ) break; + + cbx.checked = false; + + i++; + } + + cb.checked = true; + f.boxchecked.value = 1; + window.submitform( task ); + + return false; + }; /** * Default function. Usually would be overriden by the component @@ -728,7 +728,7 @@ Joomla.editors.instances = Joomla.editors.instances || { { // Gets the site base path var systemPaths = Joomla.getOptions('system.paths') || {}, - basePath = systemPaths.root || ''; + basePath = systemPaths.root || ''; var loadingDiv = document.createElement('div'); @@ -783,7 +783,7 @@ Joomla.editors.instances = Joomla.editors.instances || { /** * Technically null is an object, but trying to treat the destination as one in this context will error out. * So emulate jQuery.extend(), and treat a destination null as an empty object. - */ + */ if (destination === null) { destination = {}; } @@ -917,12 +917,84 @@ Joomla.editors.instances = Joomla.editors.instances || { /** * Loads any needed polyfill for web components and async load any web components * + * Parts of the WebComponents method belong to The Polymer Project Authors. License http://polymer.github.io/LICENSE.txt + * * @since 4.0.0 */ Joomla.WebComponents = function() { - var polyfills = []; var wc = Joomla.getOptions('webcomponents'); + // Return early + if (!wc.length) { + return; + } + + var polyfillsLoaded = false; + var whenLoadedFns = []; + var allowUpgrades = false; + var flushFn; + + var fireEvent = function() { + window.WebComponents.ready = true; + document.dispatchEvent(new CustomEvent('WebComponentsReady', { bubbles: true })); + loadWC(); + }; + + var batchCustomElements = function() { + if (window.customElements && customElements.polyfillWrapFlushCallback) { + customElements.polyfillWrapFlushCallback(function (flushCallback) { + flushFn = flushCallback; + if (allowUpgrades) { + flushFn(); + } + }); + } + }; + + var asyncReady = function() { + batchCustomElements(); + ready(); + }; + + var ready = function() { + // bootstrap