Révision b0dc3a2e
Ajouté par Julien Enselme il y a plus de 7 ans
drupal7/misc/drupal.js | ||
---|---|---|
413 | 413 |
return { 'start': element.selectionStart, 'end': element.selectionEnd }; |
414 | 414 |
}; |
415 | 415 |
|
416 |
/** |
|
417 |
* Add a global variable which determines if the window is being unloaded. |
|
418 |
* |
|
419 |
* This is primarily used by Drupal.displayAjaxError(). |
|
420 |
*/ |
|
421 |
Drupal.beforeUnloadCalled = false; |
|
422 |
$(window).bind('beforeunload pagehide', function () { |
|
423 |
Drupal.beforeUnloadCalled = true; |
|
424 |
}); |
|
425 |
|
|
426 |
/** |
|
427 |
* Displays a JavaScript error from an Ajax response when appropriate to do so. |
|
428 |
*/ |
|
429 |
Drupal.displayAjaxError = function (message) { |
|
430 |
// Skip displaying the message if the user deliberately aborted (for example, |
|
431 |
// by reloading the page or navigating to a different page) while the Ajax |
|
432 |
// request was still ongoing. See, for example, the discussion at |
|
433 |
// http://stackoverflow.com/questions/699941/handle-ajax-error-when-a-user-clicks-refresh. |
|
434 |
if (!Drupal.beforeUnloadCalled) { |
|
435 |
alert(message); |
|
436 |
} |
|
437 |
}; |
|
438 |
|
|
416 | 439 |
/** |
417 | 440 |
* Build an error message from an Ajax response. |
418 | 441 |
*/ |
Formats disponibles : Unified diff
Update to Drupal 7.52