Commit b4395139 authored by webchick's avatar webchick
Browse files

#969346 by merlinofchaos, sun: Fixed CTools AJAX regression: AJAX calls made...

#969346 by merlinofchaos, sun: Fixed CTools AJAX regression: AJAX calls made with things that are not forms cannot use the throbber.
parent 1a91990c
...@@ -37,6 +37,8 @@ Drupal.behaviors.AJAX = { ...@@ -37,6 +37,8 @@ Drupal.behaviors.AJAX = {
// Bind AJAX behaviors to all items showing the class. // Bind AJAX behaviors to all items showing the class.
$('.use-ajax:not(.ajax-processed)').addClass('ajax-processed').each(function () { $('.use-ajax:not(.ajax-processed)').addClass('ajax-processed').each(function () {
var element_settings = {}; var element_settings = {};
// Clicked links look better with the throbber than the progress bar.
element_settings.progress = { 'type': 'throbber' };
// For anchor tags, these will go to the target of the anchor rather // For anchor tags, these will go to the target of the anchor rather
// than the usual location. // than the usual location.
...@@ -146,6 +148,10 @@ Drupal.ajax = function (base, element, element_settings) { ...@@ -146,6 +148,10 @@ Drupal.ajax = function (base, element, element_settings) {
ajax.ajaxing = true; ajax.ajaxing = true;
return ajax.beforeSubmit(form_values, element_settings, options); return ajax.beforeSubmit(form_values, element_settings, options);
}, },
beforeSend: function (xmlhttprequest) {
ajax.ajaxing = true;
return ajax.beforeSend(xmlhttprequest, ajax.options);
},
success: function (response, status) { success: function (response, status) {
// Sanity check for browser support (object expected). // Sanity check for browser support (object expected).
// When using iFrame uploads, responses must be returned as a string. // When using iFrame uploads, responses must be returned as a string.
...@@ -213,7 +219,7 @@ Drupal.ajax = function (base, element, element_settings) { ...@@ -213,7 +219,7 @@ Drupal.ajax = function (base, element, element_settings) {
/** /**
* Handler for the form serialization. * Handler for the form serialization.
* *
* Runs before the beforeSubmit() handler (see below), and unlike that one, runs * Runs before the beforeSend() handler (see below), and unlike that one, runs
* before field data is collected. * before field data is collected.
*/ */
Drupal.ajax.prototype.beforeSerialize = function (element, options) { Drupal.ajax.prototype.beforeSerialize = function (element, options) {
...@@ -250,9 +256,17 @@ Drupal.ajax.prototype.beforeSerialize = function (element, options) { ...@@ -250,9 +256,17 @@ Drupal.ajax.prototype.beforeSerialize = function (element, options) {
}; };
/** /**
* Handler for the form redirection submission. * Modify form values prior to form submission.
*/ */
Drupal.ajax.prototype.beforeSubmit = function (form_values, element, options) { Drupal.ajax.prototype.beforeSubmit = function (form_values, element, options) {
// This function is left empty to make it simple to override for modules
// that wish to add functionality here.
}
/**
* Prepare the AJAX request before it is sent.
*/
Drupal.ajax.prototype.beforeSend = function (xmlhttprequest, options) {
// Disable the element that received the change. // Disable the element that received the change.
$(this.element).addClass('progress-disabled').attr('disabled', true); $(this.element).addClass('progress-disabled').attr('disabled', true);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment