Skip to content

Commit

Permalink
webasset for field.modal-fields
Browse files Browse the repository at this point in the history
  • Loading branch information
Fedik authored and wilsonge committed Jun 29, 2020
1 parent 4d8983f commit 04f844a
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 18 deletions.
Expand Up @@ -69,8 +69,11 @@ protected function getInput()
// Create the modal id.
$modalId = 'Category_' . $this->id;

/** @var \Joomla\CMS\WebAsset\WebAssetManager $wa */
$wa = Factory::getApplication()->getDocument()->getWebAssetManager();

// Add the modal field script to the document head.
HTMLHelper::_('script', 'system/fields/modal-fields.min.js', array('version' => 'auto', 'relative' => true));
$wa->useScript('field.modal-fields');

// Script to proxy the select modal function to the modal-fields.js file.
if ($allowSelect)
Expand All @@ -84,10 +87,12 @@ protected function getInput()

if (!isset($scriptSelect[$this->id]))
{
Factory::getDocument()->addScriptDeclaration("
function jSelectCategory_" . $this->id . "(id, title, object) {
$wa->addInlineScript("
window.jSelectCategory_" . $this->id . " = function (id, title, object) {
window.processModalSelect('Category', '" . $this->id . "', id, title, '', object);
}"
}",
[],
['type' => 'module']
);

Text::script('JGLOBAL_ASSOCIATIONS_PROPAGATE_FAILED');
Expand Down
Expand Up @@ -60,8 +60,11 @@ protected function getInput()
// Create the modal id.
$modalId = 'Contact_' . $this->id;

/** @var \Joomla\CMS\WebAsset\WebAssetManager $wa */
$wa = Factory::getApplication()->getDocument()->getWebAssetManager();

// Add the modal field script to the document head.
HTMLHelper::_('script', 'system/fields/modal-fields.min.js', array('version' => 'auto', 'relative' => true));
$wa->useScript('field.modal-fields');

// Script to proxy the select modal function to the modal-fields.js file.
if ($allowSelect)
Expand All @@ -75,10 +78,12 @@ protected function getInput()

if (!isset($scriptSelect[$this->id]))
{
Factory::getDocument()->addScriptDeclaration("
function jSelectContact_" . $this->id . "(id, title, object) {
$wa->addInlineScript("
window.jSelectContact_" . $this->id . " = function (id, title, object) {
window.processModalSelect('Contact', '" . $this->id . "', id, title, '', object);
}"
}",
[],
['type' => 'module']
);

Text::script('JGLOBAL_ASSOCIATIONS_PROPAGATE_FAILED');
Expand Down
14 changes: 9 additions & 5 deletions administrator/components/com_menus/src/Field/Modal/MenuField.php
Expand Up @@ -180,8 +180,11 @@ protected function getInput()
// Create the modal id.
$modalId = 'Item_' . $this->id;

/** @var \Joomla\CMS\WebAsset\WebAssetManager $wa */
$wa = Factory::getApplication()->getDocument()->getWebAssetManager();

// Add the modal field script to the document head.
HTMLHelper::_('script', 'system/fields/modal-fields.min.js', array('version' => 'auto', 'relative' => true));
$wa->useScript('field.modal-fields');

// Script to proxy the select modal function to the modal-fields.js file.
if ($this->allowSelect)
Expand All @@ -195,11 +198,12 @@ protected function getInput()

if (!isset($scriptSelect[$this->id]))
{
Factory::getDocument()->addScriptDeclaration("
function jSelectMenu_" . $this->id . "(id, title, object) {
$wa->addInlineScript("
window.jSelectMenu_" . $this->id . " = function (id, title, object) {
window.processModalSelect('Item', '" . $this->id . "', id, title, '', object);
}
"
}",
[],
['type' => 'module']
);

Text::script('JGLOBAL_ASSOCIATIONS_PROPAGATE_FAILED');
Expand Down
Expand Up @@ -60,8 +60,11 @@ protected function getInput()
// Create the modal id.
$modalId = 'Newsfeed_' . $this->id;

/** @var \Joomla\CMS\WebAsset\WebAssetManager $wa */
$wa = Factory::getApplication()->getDocument()->getWebAssetManager();

// Add the modal field script to the document head.
HTMLHelper::_('script', 'system/fields/modal-fields.min.js', array('version' => 'auto', 'relative' => true));
$wa->useScript('field.modal-fields');

// Script to proxy the select modal function to the modal-fields.js file.
if ($allowSelect)
Expand All @@ -75,11 +78,12 @@ protected function getInput()

if (!isset($scriptSelect[$this->id]))
{
Factory::getDocument()->addScriptDeclaration("
function jSelectNewsfeed_" . $this->id . "(id, title, object) {
$wa->addInlineScript("
window.jSelectNewsfeed_" . $this->id . " = function (id, title, object) {
window.processModalSelect('Newsfeed', '" . $this->id . "', id, title, '', object);
}
"
}",
[],
['type' => 'module']
);

Text::script('JGLOBAL_ASSOCIATIONS_PROPAGATE_FAILED');
Expand Down

0 comments on commit 04f844a

Please sign in to comment.