Skip to content

Commit

Permalink
Joomla.getOptions and a script options without inline JavaScript
Browse files Browse the repository at this point in the history
  • Loading branch information
Fedik committed Aug 18, 2016
1 parent 4c539c4 commit 47f5c97
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
30 changes: 29 additions & 1 deletion media/system/js/core-uncompressed.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,34 @@ Joomla.editors.instances = Joomla.editors.instances || {};
}
};

/**
* Joomla options storage
* @type {{}}
*/
Joomla.optionsStorage = Joomla.optionsStorage || null;

/**
* Get script(s) options
*
* @param {String} key Name in Storage
* @param mixed def Default value if nothing found
*
* @return mixed
*/
Joomla.getOptions = function( key, def) {

// Load options if they not exists
if (!Joomla.optionsStorage) {
var element = document.getElementById('joomla-script-options'),
str = element ? element.innerText : null,
options = str ? JSON.parse(str) : null;

Joomla.optionsStorage = options || {};
}

return Joomla.optionsStorage[key] || def;
};

/**
* Method to replace all request tokens on the page with a new one.
* Used in Joomla Installation
Expand Down Expand Up @@ -614,7 +642,7 @@ Joomla.editors.instances = Joomla.editors.instances || {};
parentElement.appendChild(loadingDiv);
}
// Show or hide the layer.
else
else
{
if (!document.getElementById('loading-logo'))
{
Expand Down
2 changes: 1 addition & 1 deletion media/system/js/core.js

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

0 comments on commit 47f5c97

Please sign in to comment.