Skip to content

Commit

Permalink
[com_fields] Add Joomla loading overlay when form submit is triggered…
Browse files Browse the repository at this point in the history
… by category selector change (joomla#13320)

* Added overlay box and message box for submit and reload form after category change

* Removed commented testing code

* Added language strings

* CS fix, added missing spaces

* Used Joomla logo spinner instead of fixed message

* Reverted changes in admin lang file

* CS

* Revert frontend lang changes

* Added Joomla loading overlay to new field form when changing field type

* Added Joomla.loadingLayer show to typeHasChanged JS method too
  • Loading branch information
ggppdk authored and rdeutz committed Jan 17, 2017
1 parent bea7ff9 commit b1e7b27
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
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);
jQuery('input[name=task]').val('field.storeform');
element.form.action='" . $uri . "';
element.form.submit();
}");
}
");

return $options;
}
Expand Down

0 comments on commit b1e7b27

Please sign in to comment.