Skip to content

Commit

Permalink
WebAsset for com_finder
Browse files Browse the repository at this point in the history
  • Loading branch information
Fedik authored and wilsonge committed Jun 29, 2020
1 parent a89421c commit e32f4f3
Show file tree
Hide file tree
Showing 9 changed files with 127 additions and 15 deletions.
Expand Up @@ -467,7 +467,9 @@ public function dates($idxQuery, $options)
// Load the CSS/JS resources.
if ($loadMedia)
{
HTMLHelper::_('stylesheet', 'com_finder/dates.css', array('version' => 'auto', 'relative' => true));
/** @var \Joomla\CMS\WebAsset\WebAssetManager $wa */
$wa = Factory::getApplication()->getDocument()->getWebAssetManager();
$wa->useStyle('com_finder.dates');
}

// Open the widget.
Expand Down
11 changes: 6 additions & 5 deletions administrator/components/com_finder/tmpl/filter/edit.php
Expand Up @@ -15,18 +15,19 @@
use Joomla\CMS\Layout\LayoutHelper;
use Joomla\CMS\Router\Route;

HTMLHelper::_('behavior.formvalidator');
HTMLHelper::_('behavior.keepalive');
HTMLHelper::_('behavior.core');

Text::script('COM_FINDER_FILTER_SHOW_ALL', true);
Text::script('COM_FINDER_FILTER_HIDE_ALL', true);

$this->ignore_fieldsets = ['jbasic'];

$this->useCoreUI = true;

HTMLHelper::_('script', 'com_finder/finder-edit.min.js', array('version' => 'auto', 'relative' => true));
/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */
$wa = $this->document->getWebAssetManager();
$wa->useScript('keepalive')
->useScript('form.validate')
->useScript('com_finder.finder-edit');

?>

<form action="<?php echo Route::_('index.php?option=com_finder&view=filter&layout=edit&filter_id=' . (int) $this->item->filter_id); ?>" method="post" name="adminForm" id="adminForm" class="form-validate">
Expand Down
6 changes: 5 additions & 1 deletion administrator/components/com_finder/tmpl/filters/default.php
Expand Up @@ -21,7 +21,11 @@
$listDirn = $this->escape($this->state->get('list.direction'));

Text::script('COM_FINDER_INDEX_CONFIRM_DELETE_PROMPT');
HTMLHelper::_('script', 'com_finder/filters.js', ['version' => 'auto', 'relative' => true]);

/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */
$wa = $this->document->getWebAssetManager();
$wa->useScript('com_finder.filters');

?>
<form action="<?php echo Route::_('index.php?option=com_finder&view=filters'); ?>" method="post" name="adminForm" id="adminForm">
<div class="row">
Expand Down
6 changes: 5 additions & 1 deletion administrator/components/com_finder/tmpl/index/default.php
Expand Up @@ -23,7 +23,11 @@

Text::script('COM_FINDER_INDEX_CONFIRM_PURGE_PROMPT');
Text::script('COM_FINDER_INDEX_CONFIRM_DELETE_PROMPT');
HTMLHelper::_('script', 'com_finder/index.js', ['version' => 'auto', 'relative' => true]);

/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */
$wa = $this->document->getWebAssetManager();
$wa->useScript('com_finder.index');

?>
<form action="<?php echo Route::_('index.php?option=com_finder&view=index'); ?>" method="post" name="adminForm" id="adminForm">
<div class="row">
Expand Down
9 changes: 6 additions & 3 deletions administrator/components/com_finder/tmpl/indexer/default.php
Expand Up @@ -10,13 +10,16 @@
defined('_JEXEC') or die;

use Joomla\CMS\Factory;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;

Text::script('COM_FINDER_INDEXER_MESSAGE_COMPLETE', true);

HTMLHelper::_('behavior.keepalive');
HTMLHelper::_('script', 'com_finder/indexer.min.js', array('version' => 'auto', 'relative' => true));
/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */
$wa = $this->document->getWebAssetManager();
$wa->useScript('keepalive')
->useStyle('com_finder.indexer')
->useScript('com_finder.indexer');

?>

<div class="text-center">
Expand Down
7 changes: 6 additions & 1 deletion administrator/components/com_finder/tmpl/maps/default.php
Expand Up @@ -21,8 +21,13 @@
$listDirn = $this->escape($this->state->get('list.direction'));
$lang = Factory::getLanguage();
$branchFilter = $this->escape($this->state->get('filter.branch'));

Text::script('COM_FINDER_MAPS_CONFIRM_DELETE_PROMPT');
HTMLHelper::_('script', 'com_finder/maps.js', ['version' => 'auto', 'relative' => true]);

/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */
$wa = $this->document->getWebAssetManager();
$wa->useScript('com_finder.maps');

?>
<form action="<?php echo Route::_('index.php?option=com_finder&view=maps'); ?>" method="post" name="adminForm" id="adminForm">
<div class="row">
Expand Down
92 changes: 92 additions & 0 deletions build/media_source/com_finder/joomla.asset.json
@@ -0,0 +1,92 @@
{
"$schema": "https://developer.joomla.org/schemas/json-schema/web_assets.json",
"name": "com_finder",
"version": "4.0.0",
"description": "Joomla CMS",
"license": "GPL-2.0-or-later",
"assets": [
{
"name": "com_finder.dates",
"type": "style",
"uri": "com_finder/dates.min.css"
},
{
"name": "com_finder.filters",
"type": "script",
"uri": "com_finder/filters.min.js",
"dependencies": [
"core"
],
"attributes": {
"defer": true
}
},
{
"name": "com_finder.finder",
"type": "style",
"uri": "com_finder/finder.min.css"
},
{
"name": "com_finder.finder",
"type": "script",
"uri": "com_finder/finder.min.js",
"dependencies": [
"core"
],
"attributes": {
"defer": true
}
},
{
"name": "com_finder.finder-edit",
"type": "script",
"uri": "com_finder/finder-edit.min.js",
"dependencies": [
"core",
"jquery"
],
"attributes": {
"defer": true
}
},
{
"name": "com_finder.index",
"type": "script",
"uri": "com_finder/index.min.js",
"dependencies": [
"core",
"jquery"
],
"attributes": {
"defer": true
}
},
{
"name": "com_finder.indexer",
"type": "style",
"uri": "com_finder/indexer.min.css"
},
{
"name": "com_finder.indexer",
"type": "script",
"uri": "com_finder/indexer.min.js",
"dependencies": [
"core"
],
"attributes": {
"defer": true
}
},
{
"name": "com_finder.maps",
"type": "script",
"uri": "com_finder/maps.min.js",
"dependencies": [
"core"
],
"attributes": {
"defer": true
}
}
]
}
4 changes: 2 additions & 2 deletions components/com_finder/tmpl/search/default.php
Expand Up @@ -10,8 +10,8 @@
defined('_JEXEC') or die;

$this->document->getWebAssetManager()
->registerAndUseStyle('com_finder', 'com_finder/finder.css')
->registerAndUseScript('com_finder', 'com_finder/finder.js', [], ['defer' => true], ['core']);
->useStyle('com_finder.finder')
->useScript('com_finder.finder');

?>
<div class="com-finder finder">
Expand Down
3 changes: 2 additions & 1 deletion modules/mod_finder/tmpl/default.php
Expand Up @@ -45,7 +45,8 @@

/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */
$wa = $app->getDocument()->getWebAssetManager();
$wa->registerAndUseScript('com_finder', 'com_finder/finder.js', [], ['defer' => true]);
$wa->getRegistry()->addExtensionRegistryFile('com_finder');
$wa->useScript('com_finder.finder');

Text::script('MOD_FINDER_SEARCH_VALUE', true);

Expand Down

0 comments on commit e32f4f3

Please sign in to comment.