Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[com_fields] Add Joomla loading overlay when form submit is triggered by category selector change #13320

Merged
merged 11 commits into from
Jan 14, 2017
8 changes: 6 additions & 2 deletions administrator/components/com_fields/helpers/fields.php
Original file line number Diff line number Diff line change
Expand Up @@ -320,15 +320,19 @@ public static function prepareForm($context, JForm $form, $data)
* has changed
*/
$form->setFieldAttribute('catid', 'onchange', 'categoryHasChanged(this);');
JFactory::getDocument()->addScriptDeclaration(
"function categoryHasChanged(element){

// Preload spindle-wheel when we need to submit form due to category selector changed
JFactory::getDocument()->addScriptDeclaration("
function categoryHasChanged(element) {
Joomla.loadingLayer('show');
var cat = jQuery(element);
if (cat.val() == '" . $assignedCatids . "')return;
jQuery('input[name=task]').val('field.storeform');
element.form.action='" . $uri . "';
element.form.submit();
}
jQuery( document ).ready(function() {
Joomla.loadingLayer('load');
var formControl = '#" . $form->getFormControl() . "_catid';
if (!jQuery(formControl).val() != '" . $assignedCatids . "'){jQuery(formControl).val('" . $assignedCatids . "');}
});");
Expand Down
12 changes: 9 additions & 3 deletions administrator/components/com_fields/models/fields/type.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,19 @@ function ($a, $b)
$uri->setVar('view', null);
$uri->setVar('layout', null);

JFactory::getDocument()->addScriptDeclaration(
"function typeHasChanged(element){

JFactory::getDocument()->addScriptDeclaration("
jQuery( document ).ready(function() {
Joomla.loadingLayer('load');
});
function typeHasChanged(element){
Joomla.loadingLayer('show');
var cat = jQuery(element);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is Joomla.loadingLayer('show'); needed, otherwise it doesn't show up when the type got changed.

jQuery('input[name=task]').val('field.storeform');
element.form.action='" . $uri . "';
element.form.submit();
}");
}
");

return $options;
}
Expand Down