Skip to content
This repository was archived by the owner on May 10, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
9b7bef7
create language constant for Add Module Button field
YatharthVyas Jun 5, 2021
7793279
switcher for Add Module field
YatharthVyas Jun 5, 2021
300e295
add module button field value to param in installation sql script
YatharthVyas Jun 5, 2021
cd3cfc1
display Add Module Here button when pm is passed as a get parameter
YatharthVyas Jun 5, 2021
50ca7ce
add module button added to the frontend that links to the place modul…
YatharthVyas Jun 5, 2021
e7ce2f1
Make Add Module Here button accessible by mentioning the position
YatharthVyas Jun 6, 2021
246391e
Permissions Check for Add Module Frontend Flow
YatharthVyas Jun 6, 2021
75f6d64
Added language constant for Invalid Position Error
YatharthVyas Jun 6, 2021
ffca089
added links for passing data from add module btn
YatharthVyas Jun 6, 2021
5c5de2d
init new controller for set position of module
YatharthVyas Jun 6, 2021
e84db87
Separate HTML tags from language constants for Place Module
YatharthVyas Jun 7, 2021
80cf9a7
Rephrase Add Module to Place Module
YatharthVyas Jun 7, 2021
792bfc1
Remove redundant Template ID from URL params for place modules
YatharthVyas Jun 7, 2021
9297169
Controller for Set Position works and clear new state vars after save
YatharthVyas Jun 7, 2021
e21bd09
Pre select module position
YatharthVyas Jun 8, 2021
696a524
rename menuId to menu_id
YatharthVyas Jun 8, 2021
6260cfa
Rephrase setPosition controller to selectPosition
YatharthVyas Jun 9, 2021
e18a07b
Pre select Module Menu Item
YatharthVyas Jun 9, 2021
c6a6248
Removed redundant permission check
YatharthVyas Jun 9, 2021
42bf2b8
made place module layout flexible for backend edit position modal
YatharthVyas Jun 9, 2021
626675c
add comment
YatharthVyas Jun 9, 2021
4c79545
new js file for submitting the place module modal form
YatharthVyas Jun 9, 2021
ff563d8
remove extra semicolon
YatharthVyas Jun 10, 2021
11a1c71
Backend Preview Modal
YatharthVyas Jun 10, 2021
3c9ef2a
Add language constant for select position
YatharthVyas Jun 11, 2021
8a4aa38
Rephrase template preview constant
YatharthVyas Jun 11, 2021
34f7f56
new tmpl for the modal
YatharthVyas Jun 11, 2021
09bf231
template
YatharthVyas Jun 12, 2021
18a63b7
change a to span and fix modal link
YatharthVyas Jun 12, 2021
0f735db
add script for onchange of template select field
YatharthVyas Jun 12, 2021
2128169
fix modal view of positions preview
YatharthVyas Jun 12, 2021
d8de85f
preview route works for both admin and user
YatharthVyas Jun 13, 2021
2749f86
remove redundant string
YatharthVyas Jun 13, 2021
15c34b5
fix bug in admin template positions view
YatharthVyas Jun 13, 2021
7e2b4de
make new form file for template select field
YatharthVyas Jun 13, 2021
197a0df
conditionally render template select field for site and admin
YatharthVyas Jun 13, 2021
a948661
show inactive positions also while placing modules
YatharthVyas Jun 13, 2021
596a834
show place modules view only for site
YatharthVyas Jun 13, 2021
9b08d99
phpcs cleanup
YatharthVyas Jun 14, 2021
d84808b
code cleanup
YatharthVyas Jun 14, 2021
a97beb4
indentation
YatharthVyas Jun 14, 2021
3cca444
add client id to redirect
YatharthVyas Jun 14, 2021
9d2a6bc
comment for client_id 0
YatharthVyas Jun 14, 2021
83d122f
php cs
YatharthVyas Jun 15, 2021
8602d2e
js cs
YatharthVyas Jun 15, 2021
9efc49f
rephrase add module button so its similar to the backend button text
YatharthVyas Jun 15, 2021
74efa49
Place Add Module button outside of main and improve its css
YatharthVyas Jun 15, 2021
7048e3d
remove margin top from Add Module btn
YatharthVyas Jun 15, 2021
08e764d
Hide frontend editing icon from place module view
YatharthVyas Jun 15, 2021
3f22e74
backend flow modal view set to select position
YatharthVyas Jun 17, 2021
3146773
positions are selectable via modal in backend flow
YatharthVyas Jun 17, 2021
d6834a1
Rephrase preview template position
YatharthVyas Jun 17, 2021
b9ec435
redesign position preview modal button
YatharthVyas Jun 18, 2021
c5820aa
remove extra permission check
YatharthVyas Jun 18, 2021
fa4add8
missing permissions warning message for pm view
YatharthVyas Jun 18, 2021
81288ee
enhance code readability
YatharthVyas Jun 18, 2021
4c555ba
fix typo
YatharthVyas Jun 18, 2021
3e67371
Merge branch '4.1-dev' of https://github.com/joomla-projects/gsoc21_c…
YatharthVyas Jun 21, 2021
a6ac050
Update signature
bembelimen Jun 23, 2021
bb3b387
Merge branch 'joomla-projects:4.1-dev' into feature-place-modules
YatharthVyas Jun 23, 2021
2529769
Fixes https://github.com/joomla-projects/gsoc21_core-enhancements/iss…
YatharthVyas Jun 26, 2021
db7ce9d
remove add module button from template file
YatharthVyas Jun 27, 2021
a6bd732
do not display card style for pm view
YatharthVyas Jun 27, 2021
ece3764
addmodulebutton plugin xml file
YatharthVyas Jun 27, 2021
9ac80b3
addmodulebutton plugin file
YatharthVyas Jun 27, 2021
bf2bc07
script file to render the add module button
YatharthVyas Jun 27, 2021
dc29916
language constants for plugin
YatharthVyas Jun 27, 2021
18f6907
sql install script for addmodulebutton plugin
YatharthVyas Jun 27, 2021
bd5bb9e
sql update script for addmodulebutton plugin
YatharthVyas Jun 27, 2021
0aa28f1
js lint
YatharthVyas Jun 27, 2021
5afd605
remove the add module button switcher
YatharthVyas Jun 27, 2021
9ad30e8
Update administrator/components/com_admin/sql/updates/mysql/4.1.0-202…
YatharthVyas Jun 27, 2021
cd269b4
Update administrator/components/com_admin/sql/updates/postgresql/4.1.…
YatharthVyas Jun 27, 2021
f3c6fd8
remove language constants from cassiopeia
YatharthVyas Jun 27, 2021
4dc8b45
add language constants to the plugin
YatharthVyas Jun 27, 2021
1720df0
fix error message for users without permissions
YatharthVyas Jun 27, 2021
b278a4b
Merge branch 'feature-place-modules' of https://github.com/YatharthVy…
YatharthVyas Jun 27, 2021
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
2 changes: 1 addition & 1 deletion .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,6 @@ steps:

---
kind: signature
hmac: 71729a12ae3556e03f924ac95c8a5cd14bb6a3c2d20ef6768fdd1e853397fd22
hmac: 53e23beca546bde246f812a726320210f33d231106cb154a65cc900ecbf7502e

...
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
INSERT INTO `#__extensions` (`package_id`, `name`, `type`, `element`, `folder`, `client_id`, `enabled`, `access`, `protected`, `locked`, `manifest_cache`, `params`, `custom_data`, `checked_out`, `checked_out_time`, `ordering`, `state`) VALUES
(0, 'plg_system_addmodulebutton', 'plugin', 'addmodulebutton', 'system', 0, 1, 1, 0, 1, '', '', '', NULL, NULL, 0, 0);
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
INSERT INTO `#__extensions` (`package_id`, `name`, `type`, `element`, `folder`, `client_id`, `enabled`, `access`, `protected`, `locked`, `manifest_cache`, `params`, `custom_data`, `checked_out`, `checked_out_time`, `ordering`, `state`) VALUES
(0, 'plg_system_addmodulebutton', 'plugin', 'addmodulebutton', 'system', 0, 1, 1, 0, 1, '', '', '', NULL, NULL, 0, 0);
24 changes: 24 additions & 0 deletions administrator/components/com_modules/forms/preview_positions.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<form>
<fieldset addfieldprefix="Joomla\Component\Modules\Administrator\Field">
<field
name="template_style_site"
id="template-style-select"
type="templatestyle"
client="site"
label="COM_MODULES_MODULE_TEMPLATE_SELECT"
>
<option value="">JOPTION_USE_DEFAULT</option>
</field>

<field
name="template_style_admin"
id="template-style-select"
type="templatestyle"
client="administrator"
label="COM_MODULES_MODULE_TEMPLATE_SELECT"
>
<option value="">JOPTION_USE_DEFAULT</option>
</field>
</fieldset>
</form>
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,38 @@
->usePreset('choicesjs')
->useScript('webcomponent.field-fancy-select');

?>
<joomla-field-fancy-select <?php echo implode(' ', $attributes); ?>><?php
echo HTMLHelper::_('select.groupedlist', $positions, $name, array(
'id' => $id,
'list.select' => $value,
'list.attr' => implode(' ', $selectAttr),
)
);
?></joomla-field-fancy-select>
$app = Factory::getApplication();
$clientId = $app->input->getBool('client_id', 0);

$modalUrl = 'index.php?option=com_modules&view=module&layout=preview_positions&id=1&client_id=' . $clientId;

// &tmpl=component doesn't redirect if the user isn't logged into backend hence we are adding it conditionally
$modalUrl = $app->isClient('site') ? 'administrator/' . $modalUrl : $modalUrl . '&tmpl=component';

?>
<joomla-field-fancy-select <?php echo implode(' ', $attributes); ?>>
<?php
echo HTMLHelper::_('select.groupedlist', $positions, $name, array(
'id' => $id,
'list.select' => $value,
'list.attr' => implode(' ', $selectAttr),
)
);
?>
</joomla-field-fancy-select>
<?php
echo HTMLHelper::_(
'bootstrap.renderModal',
'Modal_position',
array(
'title' => Text::_('COM_MODULES_MODULE_SELECT_POSITION'),
'url' => $modalUrl,
'bodyHeight' => 70,
'modalWidth' => 95,
'footer' => '<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">' . Text::_('JLIB_HTML_BEHAVIOR_CLOSE') . '</button>',
)
);
?>
<button data-bs-toggle="modal" type="button" data-bs-target="#Modal_position" class="btn btn-primary mt-1 w-100">
<?php echo Text::_('COM_MODULES_MODULE_SELECT_POSITION_BUTTON'); ?>
</button>
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,38 @@ public function add()
$app->setUserState('com_modules.add.module.params', $params);
}

/**
* Set Position and Menu ID in State for the New Module in Frontend Module Placement.
*
* @return void
*
* @since __DEPLOY_VERSION__
*/
public function selectPosition()
{
$app = $this->app;

// Get the Menu ID and Position.
$menuId = $this->input->getInt('menu', 0);
$position = $this->input->get('position');

if (empty($position))
{
$redirectUrl = $this->input->server->getString('HTTP_REFERER');

$this->setRedirect(Route::_($redirectUrl, false));

$app->enqueueMessage(Text::_('COM_MODULES_ERROR_INVALID_POSITION'), 'warning');
}

$app->setUserState('com_modules.add.module.menu_id', $menuId);
$app->setUserState('com_modules.add.module.position', $position);

// Select Position is only used in the Frontend Module Placement so we pass client_id as 0
$redirectUrl = 'index.php?option=com_modules&view=select&client_id=0';
$this->setRedirect(Route::_($redirectUrl, false));
}

/**
* Override parent cancel method to reset the add module state.
*
Expand All @@ -82,7 +114,9 @@ public function cancel($key = null)
$result = parent::cancel();

$this->app->setUserState('com_modules.add.module.extension_id', null);
$this->app->setUserState('com_modules.add.module.menu_id', null);
$this->app->setUserState('com_modules.add.module.params', null);
$this->app->setUserState('com_modules.add.module.position', null);

if ($return = $this->input->get('return', '', 'BASE64'))
{
Expand Down Expand Up @@ -205,7 +239,9 @@ protected function postSaveHook(BaseDatabaseModel $model, $validData = array())
break;
}

$this->app->setUserState('com_modules.add.module.menu_id', null);
$this->app->setUserState('com_modules.add.module.params', null);
$this->app->setUserState('com_modules.add.module.position', null);
}

/**
Expand Down
53 changes: 41 additions & 12 deletions administrator/components/com_modules/src/Model/ModuleModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,8 @@ public function &getClient()
*/
public function getForm($data = array(), $loadData = true)
{
$app = Factory::getApplication();

// The folder and element vars are passed when saving the form.
if (empty($data))
{
Expand All @@ -572,19 +574,26 @@ public function getForm($data = array(), $loadData = true)
$this->setState('item.module', $module);

// Get the form.
if ($clientId == 1)
if ($app->input->getCMD('layout') == 'preview_positions')
{
$form = $this->loadForm('com_modules.module.admin', 'moduleadmin', array('control' => 'jform', 'load_data' => $loadData), true);

// Display language field to filter admin custom menus per language
if (!ModuleHelper::isAdminMultilang())
{
$form->setFieldAttribute('language', 'type', 'hidden');
}
$form = $this->loadForm('com_modules.preview_positions', 'preview_positions', array('control' => 'jform', 'load_data' => $loadData), true);
}
else
{
$form = $this->loadForm('com_modules.module', 'module', array('control' => 'jform', 'load_data' => $loadData), true);
if ($clientId == 1)
{
$form = $this->loadForm('com_modules.module.admin', 'moduleadmin', array('control' => 'jform', 'load_data' => $loadData), true);

// Display language field to filter admin custom menus per language
if (!ModuleHelper::isAdminMultilang())
{
$form->setFieldAttribute('language', 'type', 'hidden');
}
}
else
{
$form = $this->loadForm('com_modules.module', 'module', array('control' => 'jform', 'load_data' => $loadData), true);
}
}

if (empty($form))
Expand Down Expand Up @@ -642,7 +651,17 @@ protected function loadFormData()
$clientId = $app->input->getInt('client_id', 0);
$filters = (array) $app->getUserState('com_modules.modules.' . $clientId . '.filter');
$data->set('published', $app->input->getInt('published', ((isset($filters['state']) && $filters['state'] !== '') ? $filters['state'] : null)));
$data->set('position', $app->input->getInt('position', (!empty($filters['position']) ? $filters['position'] : null)));

// Pre-select Module Position set by Frontend Placement if it exists.
if ($position = $app->getUserState('com_modules.add.module.position'))
{
$data->set('position', $position);
}
else
{
$data->set('position', $app->input->getInt('position', (!empty($filters['position']) ? $filters['position'] : null)));
}

$data->set('language', $app->input->getString('language', (!empty($filters['language']) ? $filters['language'] : null)));
$data->set('access', $app->input->getInt('access', (!empty($filters['access']) ? $filters['access'] : $app->get('access'))));
}
Expand Down Expand Up @@ -676,6 +695,7 @@ protected function loadFormData()
*/
public function getItem($pk = null)
{
$app = Factory::getApplication();
$pk = (!empty($pk)) ? (int) $pk : (int) $this->getState('module.id');
$db = $this->getDbo();

Expand Down Expand Up @@ -757,8 +777,17 @@ public function getItem($pk = null)

if (empty($pk))
{
// If this is a new module, assign to all pages.
$assignment = 0;
if ($menuId = (int) $app->getUserState('com_modules.add.module.menu_id'))
{
// If a Menu ID is selected via Frontend Placements then use that.
$assignment = 1;
$assigned[] = $menuId;
}
else
{
// If this is a new module, assign to all pages.
$assignment = 0;
}
}
elseif (empty($assigned))
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_modules
*
* @copyright (C) 2021 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

defined('_JEXEC') or die;

use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Uri\Uri;

/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */
$wa = $this->document->getWebAssetManager();
$wa->useScript('com_modules.admin-modules-preview_positions');

$isAdmin = Factory::getApplication()->input->get('client_id');

// Get the URL of the iframe that displays template preview.
$iframeBaseURL = Uri::root();
$iframeBaseURL .= $isAdmin ? 'administrator' : '';

// Conditionally render the admin or site template select field.
$templateField = 'template_style_';
$templateField .= $isAdmin ? 'admin' : 'site';

// Render the template select field.
$this->fieldsets = $this->form->getFieldsets();
echo $this->form->renderField($templateField);
?>
<div class="jviewport-height90">
<iframe
src=<?php echo $iframeBaseURL . '?pm=1&edit=1&templateStyle='; ?>
id="module-position-select"
name="module-position-select"
title="module-position-select"
height="100%"width="100%">
</iframe>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
<?php echo HTMLHelper::_('jgrid.checkedout', $i, $item->editor, $item->checked_out_time, 'modules.', $canCheckin); ?>
<?php endif; ?>
<?php if ($canEdit) : ?>
<a href="<?php echo Route::_('index.php?option=com_modules&task=module.edit&id=' . (int) $item->id); ?>" title="<?php echo Text::_('JACTION_EDIT'); ?> <?php echo $this->escape($item->title); ?>">
<a href="<?php echo Route::_('index.php?option=com_modules&task=module.edit&id=' . (int) $item->id . '&client_id=' . $clientId); ?>" title="<?php echo Text::_('JACTION_EDIT'); ?> <?php echo $this->escape($item->title); ?>">
<?php echo $this->escape($item->title); ?></a>
<?php else : ?>
<?php echo $this->escape($item->title); ?>
Expand Down
4 changes: 4 additions & 0 deletions administrator/language/en-GB/com_modules.ini
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ COM_MODULES_EMPTYSTATE_TITLE_SITE="No Site Modules have been created yet."
COM_MODULES_ERR_XML="Module XML data not available"
COM_MODULES_ERROR_CANNOT_FIND_MODULE="Can't find module"
COM_MODULES_ERROR_INVALID_EXTENSION="Invalid module"
COM_MODULES_ERROR_INVALID_POSITION="Invalid position"
COM_MODULES_ERROR_NO_MODULES_SELECTED="No module selected."
COM_MODULES_EXPAND="Expand"
COM_MODULES_EXTENSION_PUBLISHED_DISABLED="Module disabled and published."
Expand Down Expand Up @@ -90,7 +91,10 @@ COM_MODULES_MENU_ITEM_URL="URL"
COM_MODULES_MODULE="Module"
COM_MODULES_MODULE_ASSIGN="Module Assignment"
COM_MODULES_MODULE_DESCRIPTION="Module Description"
COM_MODULES_MODULE_SELECT_POSITION="Select Module Position from Template Preview"
COM_MODULES_MODULE_SELECT_POSITION_BUTTON="Select from Template Preview"
COM_MODULES_MODULE_TEMPLATE_POSITION="%1$s (%2$s)"
COM_MODULES_MODULE_TEMPLATE_SELECT="Select Template to Preview"
COM_MODULES_MODULES="Modules"
COM_MODULES_MODULES_FILTER_SEARCH_DESC="Search in module title and note. Prefix with ID: to search for a module ID."
COM_MODULES_MODULES_FILTER_SEARCH_LABEL="Search Modules"
Expand Down
2 changes: 2 additions & 0 deletions administrator/language/en-GB/joomla.ini
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,8 @@ JGLOBAL_PASSWORD="Password"
JGLOBAL_PASSWORD_RESET_REQUIRED="You are required to reset your password before proceeding."
JGLOBAL_PERMISSIONS_ANCHOR="Set Permissions"
JGLOBAL_PREVIEW="Preview"
JGLOBAL_PREVIEW_PLACE_MODULE="Place Module Here"
JGLOBAL_PREVIEW_PLACE_MODULE_POSITION="in Position: %s"
JGLOBAL_PREVIEW_POSITION="<span>Position:</span> %s"
JGLOBAL_PREVIEW_STYLE="<span>Style:</span> %s"
JGLOBAL_PUBLISHED_DATE="Published Date"
Expand Down
10 changes: 10 additions & 0 deletions administrator/language/en-GB/plg_system_addmodulebutton.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
; Joomla! Project
; (C) 2021 Open Source Matters, Inc. <https://www.joomla.org>
; License GNU General Public License version 2 or later; see LICENSE.txt
; Note : All ini files need to be saved as UTF-8

PLG_SYSTEM_ADDMODULEBUTTON="System - Add Module Button"
PLG_SYSTEM_ADD_MODULE_BUTTON_LABEL="Add Module to this Menu"
PLG_ADD_MODULE_BUTTON_XML_DESCRIPTION="Displays a button to insert a module in a menu directly from the Frontend."
PLG_SYSTEM_ADD_MODULE_BUTTON_CREATE_MODULE_PERMISSIONS_WARNING="Please login with an account having permission to Select Module Position"
PLG_SYSTEM_ADD_MODULE_BUTTON_EDIT_MODULE_PERMISSIONS_WARNING="Please login with an account having permission to Edit Module Position"
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
; Joomla! Project
; (C) 2021 Open Source Matters, Inc. <https://www.joomla.org>
; License GNU General Public License version 2 or later; see LICENSE.txt
; Note : All ini files need to be saved as UTF-8

PLG_SYSTEM_ADDMODULEBUTTON="System - Add Module Button"
PLG_ADD_MODULE_BUTTON_XML_DESCRIPTION="Displays a button to insert a module in a menu directly from the Frontend."
2 changes: 2 additions & 0 deletions api/language/en-GB/joomla.ini
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,8 @@ JGLOBAL_PASSWORD="Password"
JGLOBAL_PASSWORD_RESET_REQUIRED="You are required to reset your password before proceeding."
JGLOBAL_PERMISSIONS_ANCHOR="Set Permissions"
JGLOBAL_PREVIEW="Preview"
JGLOBAL_PREVIEW_PLACE_MODULE="Place Module Here"
JGLOBAL_PREVIEW_PLACE_MODULE_POSITION="in Position: %s"
JGLOBAL_PREVIEW_POSITION="<span>Position:</span> %s"
JGLOBAL_PREVIEW_STYLE="<span>Style:</span> %s"
JGLOBAL_PUBLISHED_DATE="Published Date"
Expand Down
23 changes: 23 additions & 0 deletions build/media_source/com_modules/joomla.asset.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,29 @@
"type": "module"
}
},
{
"name": "com_modules.admin-modules-preview_positions.es5",
"type": "script",
"uri": "com_modules/admin-modules-preview_positions-es5.min.js",
"dependencies": [
"core"
],
"attributes": {
"nomodule": true,
"defer": true
}
},
{
"name": "com_modules.admin-modules-preview_positions",
"type": "script",
"uri": "com_modules/admin-modules-preview_positions.min.js",
"dependencies": [
"com_modules.admin-modules-preview_positions.es5"
],
"attributes": {
"type": "module"
}
},
{
"name": "com_modules.admin-select-modal.es5",
"type": "script",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* @copyright (C) 2021 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

/**
* Add a keyboard event listener to the Select Template Style element.
*
* This script is meant to be loaded deferred. This means that it's non-blocking
* (the browser can load it whenever) and it doesn't need an on DOMContentLoaded event handler
* because the browser is guaranteed to execute it only after the DOM content has loaded, the
* whole point of it being deferred.
*
*/

const elIframe = document.getElementById('module-position-select');
const elTemplateSelect = document.getElementById('jform_template_style_select');

elTemplateSelect.addEventListener('change', (event) => {
elIframe.src = elIframe.src.substring(0, elIframe.src.indexOf('templateStyle=') + 14) + event.target.value;
});
Loading