Skip to content

Commit

Permalink
Options rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
Fedik committed Aug 18, 2016
1 parent 47f5c97 commit 6f6c6f7
Showing 1 changed file with 10 additions and 20 deletions.
30 changes: 10 additions & 20 deletions libraries/joomla/document/renderer/html/head.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ public function fetchHead($document)
$document->_metaTags['name']['tags'] = implode(', ', $tagsHelper->getTagNames($document->_metaTags['name']['tags']));
}

$scriptOptions = $document->getScriptOptions();

if (!empty($scriptOptions))
{
JHtml::_('behavior.core');
}

// Trigger the onBeforeCompileHead event
$app = JFactory::getApplication();
$app->triggerEvent('onBeforeCompileHead');
Expand Down Expand Up @@ -220,33 +227,16 @@ public function fetchHead($document)
}

// Generate scripts options
$scriptOptions = $document->getScriptOptions();

if (!empty($scriptOptions))
{
$buffer .= $tab . '<script type="text/javascript">' . $lnEnd;

// This is for full XHTML support.
if ($document->_mime != 'text/html')
{
$buffer .= $tab . $tab . '//<![CDATA[' . $lnEnd;
}
$buffer .= $tab . '<script type="text/joomla-script-options" id="joomla-script-options">';

$pretyPrint = (JDEBUG && defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : false);
$jsonOptions = json_encode($scriptOptions, $pretyPrint);
$jsonOptions = $jsonOptions ? $jsonOptions : '{}';

// TODO: use .extend(Joomla.optionsStorage, options) when it will be safe
$buffer .= $tab . 'var Joomla = Joomla || {};' . $lnEnd;
$buffer .= $tab . 'Joomla.optionsStorage = ' . $jsonOptions . ';' . $lnEnd;

// See above note
if ($document->_mime != 'text/html')
{
$buffer .= $tab . $tab . '//]]>' . $lnEnd;
}

$buffer .= $tab . '</script>' . $lnEnd;
$buffer .= $jsonOptions;
$buffer .= '</script>' . $lnEnd;
}

// Generate script declarations
Expand Down

0 comments on commit 6f6c6f7

Please sign in to comment.