Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion administrator/templates/atum/Service/HTML/Atum.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,9 @@ public static function rootcolors(Registry $params): void

if (count($root))
{
Factory::getDocument()->addStyleDeclaration(':root {' . implode($root) . '}');
/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */
$wa = Factory::getApplication()->getDocument()->getWebAssetManager();
$wa->addInlineStyle(':root {' . implode($root) . '}');
}
}

Expand Down
6 changes: 4 additions & 2 deletions administrator/templates/atum/error_full.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@
$this->setMetaData('viewport', 'width=device-width, initial-scale=1');
// @TODO sync with _variables.scss
$this->setMetaData('theme-color', '#1c3d5c');
$this->addScriptDeclaration('cssVars();');
$this->getWebAssetManager()
->addInlineScript('cssVars();', ['position' => 'after'], ['type' => 'module'], ['css-vars-ponyfill']);

// Opacity must be set before displaying the DOM, so don't move to a CSS file
$css = '
Expand All @@ -69,7 +70,8 @@
}
';

$this->addStyleDeclaration($css);
$this->getWebAssetManager()
->addInlineStyle($css);

$monochrome = (bool) $this->params->get('monochrome');

Expand Down
6 changes: 4 additions & 2 deletions administrator/templates/atum/error_login.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@
$this->setMetaData('viewport', 'width=device-width, initial-scale=1');
// @TODO sync with _variables.scss
$this->setMetaData('theme-color', '#1c3d5c');
$this->addScriptDeclaration('cssVars();');
$this->getWebAssetManager()
->addInlineScript('cssVars();', ['position' => 'after'], ['type' => 'module'], ['css-vars-ponyfill']);

// Opacity must be set before displaying the DOM, so don't move to a CSS file
$css = '
Expand All @@ -68,7 +69,8 @@
}
';

$this->addStyleDeclaration($css);
$this->getWebAssetManager()
->addInlineStyle($css);

$monochrome = (bool) $this->params->get('monochrome');

Expand Down
6 changes: 4 additions & 2 deletions administrator/templates/atum/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@
$this->setMetaData('viewport', 'width=device-width, initial-scale=1');
// @TODO sync with _variables.scss
$this->setMetaData('theme-color', '#1c3d5c');
$this->addScriptDeclaration('cssVars();');
$this->getWebAssetManager()
->addInlineScript('cssVars();', ['position' => 'after'], ['type' => 'module'], ['css-vars-ponyfill']);

// Opacity must be set before displaying the DOM, so don't move to a CSS file
$css = '
Expand All @@ -75,7 +76,8 @@
}
';

$this->addStyleDeclaration($css);
$this->getWebAssetManager()
->addInlineStyle($css);

$monochrome = (bool) $this->params->get('monochrome');

Expand Down
6 changes: 4 additions & 2 deletions administrator/templates/atum/login.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@
$this->setMetaData('viewport', 'width=device-width, initial-scale=1');
// @TODO sync with _variables.scss
$this->setMetaData('theme-color', '#1c3d5c');
$this->addScriptDeclaration('cssVars();');
$this->getWebAssetManager()
->addInlineScript('cssVars();', ['position' => 'after'], ['type' => 'module'], ['css-vars-ponyfill']);

// Opacity must be set before displaying the DOM, so don't move to a CSS file
$css = '
Expand All @@ -71,7 +72,8 @@
}
';

$this->addStyleDeclaration($css);
$this->getWebAssetManager()
->addInlineStyle($css);

$monochrome = (bool) $this->params->get('monochrome');

Expand Down
8 changes: 8 additions & 0 deletions libraries/src/Document/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ class Document
*
* @var array
* @since 1.7.0
*
* @deprecated 5.0 Use WebAssetManager
*/
public $_script = array();

Expand All @@ -175,6 +177,8 @@ class Document
*
* @var array
* @since 1.7.0
*
* @deprecated 5.0 Use WebAssetManager
*/
public $_style = array();

Expand Down Expand Up @@ -545,6 +549,8 @@ public function addScript($url, $options = array(), $attribs = array())
* @return Document instance of $this to allow chaining
*
* @since 1.7.0
*
* @deprecated 5.0 Use WebAssetManager
*/
public function addScriptDeclaration($content, $type = 'text/javascript')
{
Expand Down Expand Up @@ -655,6 +661,8 @@ public function addStyleSheet($url, $options = array(), $attribs = array())
* @return Document instance of $this to allow chaining
*
* @since 1.7.0
*
* @deprecated 5.0 Use WebAssetManager
*/
public function addStyleDeclaration($content, $type = 'text/css')
{
Expand Down
27 changes: 21 additions & 6 deletions libraries/src/Document/Renderer/Html/MetasRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,6 @@ public function render($head, $params = array(), $content = null)
$wa = $this->_doc->getWebAssetManager();
$wc = $this->_doc->getScriptOptions('webcomponents');

if ($this->_doc->getScriptOptions())
{
$wa->useScript('core');
}

// Check for AttachBehavior and web components
foreach ($wa->getAssets('script', true) as $asset)
{
Expand All @@ -68,11 +63,31 @@ public function render($head, $params = array(), $content = null)
}
}

$this->_doc->addScriptOptions('webcomponents', $wc);
if ($wc)
{
$this->_doc->addScriptOptions('webcomponents', array_unique($wc));
}

// Trigger the onBeforeCompileHead event
$app->triggerEvent('onBeforeCompileHead');

// Add Script Options as inline asset
$scriptOptions = $this->_doc->getScriptOptions();

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

$wa->addInlineScript(
$jsonOptions,
['name' => 'joomla.script.options', 'position' => 'before'],
['type' => 'application/json', 'class' => 'joomla-script-options new'],
['core']
);
}

// Lock the AssetManager
$wa->lock();

Expand Down
Loading