Skip to content

Commit

Permalink
Joomla.JText use scriptOptions 'joomla.jtext'
Browse files Browse the repository at this point in the history
  • Loading branch information
Fedik committed Aug 21, 2016
1 parent b498871 commit b83b6bd
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 30 deletions.
10 changes: 0 additions & 10 deletions libraries/joomla/document/renderer/html/head.php
Original file line number Diff line number Diff line change
Expand Up @@ -268,16 +268,6 @@ public function fetchHead($document)
$buffer .= $tab . '</script>' . $lnEnd;
}

// Generate script language declarations.
if (JText::script())
{
$prettyPrint = (JDEBUG && defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : false);

$buffer .= $tab . '<script type="application/json" id="joomla-text-strings">';
$buffer .= json_encode(JText::script(), $prettyPrint);
$buffer .= '</script>' . $lnEnd;
}

// Output the custom tags - array_unique makes sure that we don't output the same tags twice
foreach (array_unique($document->_custom) as $custom)
{
Expand Down
3 changes: 3 additions & 0 deletions libraries/joomla/language/text.php
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,9 @@ public static function script($string = null, $jsSafe = false, $interpretBackSla

// Load core.js dependency
JHtml::_('behavior.core');

// Update Joomla.JText script options
JFactory::getDocument()->addScriptOptions('joomla.jtext', self::$strings, false);
}

return self::$strings;
Expand Down
21 changes: 2 additions & 19 deletions media/system/js/core-uncompressed.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ Joomla.editors.instances = Joomla.editors.instances || {};
'_': function( key, def ) {

if (!this.preloaded) {
this.preload();
this.load(Joomla.getOptions('joomla.jtext', {}));
this.preloaded = true;
}

def = def === undefined ? '' : def;
Expand All @@ -90,24 +91,6 @@ Joomla.editors.instances = Joomla.editors.instances || {};
if (!object.hasOwnProperty(key)) continue;
this.strings[ key.toUpperCase() ] = object[ key ];
}
return this;
},

/**
* Preload strings from <script type="application/json" id="joomla-text-strings"> container
*
* @param {String} id Id of the container
* @returns {Joomla.JText}
*/
preload: function( id ) {
id = id || 'joomla-text-strings';
var element = document.getElementById(id),
str = element ? (element.text || element.textContent) : null,
options = str ? JSON.parse(str) : null;

this.load(options || {});
this.preloaded = true;

return this;
}
};
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 b83b6bd

Please sign in to comment.