From 0be6c5dd06351449bb169ccb70062a4ba521a01c Mon Sep 17 00:00:00 2001 From: Cerdic <cedric@yterium.com> Date: Sun, 8 Jan 2012 16:54:53 +0000 Subject: [PATCH] On peut empecher le scroll au chargement ajax d'un formulaire en ajoutant la class noscroll sur le div.ajax --- prive/javascript/ajaxCallback.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/prive/javascript/ajaxCallback.js b/prive/javascript/ajaxCallback.js index 1b31b6846c..4c15a6acef 100644 --- a/prive/javascript/ajaxCallback.js +++ b/prive/javascript/ajaxCallback.js @@ -160,6 +160,7 @@ jQuery.fn.formulaire_dyn_ajax = function(target) { if (this.length) jQuery.spip.initReaderBuffer(); return this.each(function() { + var scrollwhensubmit = !jQuery(this).is('.noscroll'); var cible = target || this; jQuery(cible).formulaire_setARIA(); jQuery('form:not(.noajax):not(.bouton_action_post)', this).each(function(){ @@ -179,7 +180,9 @@ jQuery.fn.formulaire_dyn_ajax = function(target) { } jQuery(cible).wrap('<div />'); cible = jQuery(cible).parent(); - jQuery(cible).closest('.ariaformprop').animateLoading().positionner(false,false); + jQuery(cible).closest('.ariaformprop').animateLoading(); + if (scrollwhensubmit) + jQuery(cible).positionner(false,false); }, success: function(c){ if (c=='noajax'){ @@ -213,6 +216,8 @@ jQuery.fn.formulaire_dyn_ajax = function(target) { if (!d.length){ // si pas .ajax dans le form, remettre la classe sur le div que l'on a insere jQuery(cible).addClass('ajax'); + if (!scrollwhensubmit) + jQuery(cible).addClass('noscroll'); } else { // sinon nettoyer les br ajaxie -- GitLab