Skip to content

Commit

Permalink
WebAsset HtmlBehavior use assets
Browse files Browse the repository at this point in the history
  • Loading branch information
Fedik committed Sep 30, 2018
1 parent d05d9e7 commit 8681e75
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 24 deletions.
10 changes: 10 additions & 0 deletions build/media_src/system/joomla.asset.json
Expand Up @@ -45,6 +45,16 @@
"js": [
"media/system/js/showon.min.js"
]
},
"fields.validate": {
"name": "fields.validate",
"dependencies": [
"core",
"punycode"
],
"js": [
"media/system/js/fields/validate.min.js"
]
}
}
}
29 changes: 5 additions & 24 deletions libraries/cms/html/behavior.php
Expand Up @@ -68,7 +68,7 @@ public static function core()
}

HTMLHelper::_('form.csrf');
HTMLHelper::_('script', 'system/core.min.js', array('version' => 'auto', 'relative' => true));
Factory::getContainer()->get('webasset')->enableAsset('core');

// Add core and base uri paths so javascript scripts can use them.
Factory::getDocument()->addScriptOptions(
Expand Down Expand Up @@ -140,8 +140,7 @@ public static function formvalidator()
Text::script('JLIB_FORM_FIELD_REQUIRED_CHECK');
Text::script('JLIB_FORM_FIELD_INVALID_VALUE');

HTMLHelper::_('script', 'vendor/punycode/punycode.js', array('version' => 'auto', 'relative' => true));
HTMLHelper::_('script', 'system/fields/validate.min.js', array('version' => 'auto', 'relative' => true));
Factory::getContainer()->get('webasset')->enableAsset('fields.validate');

static::$loaded[__METHOD__] = true;
}
Expand Down Expand Up @@ -170,18 +169,7 @@ public static function switcher()
*/
public static function combobox()
{
if (isset(static::$loaded[__METHOD__]))
{
return;
}

// Include core
static::core();

HTMLHelper::_('stylesheet', 'vendor/awesomplete/awesomplete.css', array('version' => 'auto', 'relative' => true));
HTMLHelper::_('script', 'vendor/awesomplete/awesomplete.js', array('version' => 'auto', 'relative' => true));

static::$loaded[__METHOD__] = true;
Factory::getContainer()->get('webasset')->enableAsset('awesomplete');
}

/**
Expand Down Expand Up @@ -259,10 +247,7 @@ public static function multiselect($id = 'adminForm')
return;
}

// Include core
static::core();

HTMLHelper::_('script', 'system/multiselect.min.js', array('version' => 'auto', 'relative' => true));
Factory::getContainer()->get('webasset')->enableAsset('multiselect');

// Pass the required options to the javascript
Factory::getDocument()->addScriptOptions('js-multiselect', ['formName' => $id]);
Expand Down Expand Up @@ -438,14 +423,10 @@ public static function keepalive()
// If we are in the frontend or logged in as a user, we can use the ajax component to reduce the load
$uri = 'index.php' . ($app->isClient('site') || !Factory::getUser()->guest ? '?option=com_ajax&format=json' : '');

// Include core
static::core();

// Add keepalive script options.
Factory::getDocument()->addScriptOptions('system.keepalive', array('interval' => $refreshTime * 1000, 'uri' => Route::_($uri)));

// Add script.
HTMLHelper::_('script', 'system/keepalive.js', array('version' => 'auto', 'relative' => true));
Factory::getContainer()->get('webasset')->enableAsset('keepalive');

static::$loaded[__METHOD__] = true;

Expand Down

0 comments on commit 8681e75

Please sign in to comment.