[SPIP] ~v3.0.20-->v3.0.25
[lhc/web/clavette_www.git] / www / prive / javascript / ajaxCallback.js
index 8d5d7a0..3df5c88 100644 (file)
@@ -136,7 +136,7 @@ jQuery.fn.positionner = function(force, setfocus) {
 jQuery.spip.virtualbuffer_id='spip_virtualbufferupdate';
 jQuery.spip.initReaderBuffer = function(){
        if (jQuery('#'+jQuery.spip.virtualbuffer_id).length) return;
-       jQuery('body').append('<p style="float:left;width:0;height:0;position:absolute;left:-5000;top:-5000;"><input type="hidden" name="'+jQuery.spip.virtualbuffer_id+'" id="'+jQuery.spip.virtualbuffer_id+'" value="0" /></p>');
+       jQuery('body').append('<p style="float:left;width:0;height:0;position:absolute;left:-5000px;top:-5000px;"><input type="hidden" name="'+jQuery.spip.virtualbuffer_id+'" id="'+jQuery.spip.virtualbuffer_id+'" value="0" /></p>');
 }
 jQuery.spip.updateReaderBuffer = function(){
        var i = jQuery('#'+jQuery.spip.virtualbuffer_id);
@@ -151,7 +151,9 @@ jQuery.fn.formulaire_setARIA = function(){
                // eviter une double execution du js au moment de sa reinsertion dans le DOM par wrap()
                // cf http://bugs.jquery.com/ticket/7447
                this.find('script').remove();
-               this.wrap('<div class="ariaformprop" aria-live="assertive" aria-atomic="true"></div>');
+               this.wrap('<div class="ariaformprop" aria-live="polite" aria-atomic="true" aria-relevant="additions"></div>');
+               // dans un formulaire, le screen reader relit tout a chaque saisie d'un caractere si on est en aria-live
+               jQuery('form',this).not('[aria-live]').attr('aria-live','off');
        }
        return this;
 }
@@ -647,7 +649,12 @@ jQuery.fn.ajaxbloc = function() {
                  if (jQuery.spip.ajaxReload(blocfrag,options))
                                // don't trig reload of parent blocks
                                event.stopPropagation();
-         }).addClass('bind-ajaxReload');
+         }).addClass('bind-ajaxReload')
+                 .attr('aria-live','polite').attr('aria-atomic','true');
+
+               // dans un formulaire, le screen reader relit tout a chaque saisie d'un caractere si on est en aria-live
+         // mettre un aria-live="off" sur les forms inclus dans ce bloc aria-live="polite"
+         jQuery('form',this).not('[aria-live]').attr('aria-live','off');
 
                jQuery(ajaxbloc_selecteur,this).not('.noajax,.bind-ajax')
                        .click(function(){return jQuery.spip.ajaxClick(blocfrag,this.href,{force:jQuery(this).is('.nocache'),history:!(jQuery(this).is('.nohistory')||jQuery(this).closest('.box_modalbox').length)});})
@@ -863,12 +870,13 @@ function parametre_url(url,c,v,sep,force_vide){
                if (p>0) a=url.substring(0,p);
                args = url.substring(p+1).split('&');
        }
-        else
-            a=url;
+       else
+               a=url;
        var regexp = new RegExp('^(' + c.replace('[]','\\[\\]') + '\\[?\\]?)(=.*)?$');
        var ajouts = [];
        var u = (typeof(v)!=='object')?encodeURIComponent(v):v;
        var na = [];
+       var v_read = null;
        // lire les variables et agir
        for(var n=0;n<args.length;n++){
                var val = args[n];
@@ -878,24 +886,34 @@ function parametre_url(url,c,v,sep,force_vide){
                var r=val.match(regexp);
                if (r && r.length){
                        if (v==null){
-                               return (r.length>2 && typeof r[2]!=='undefined')?r[2].substring(1):'';
+                               // c'est un tableau, on memorise les valeurs
+                               if (r[1].substr(-2) == '[]') {
+                                       if (!v_read) v_read = [];
+                                       v_read.push((r.length>2 && typeof r[2]!=='undefined')?r[2].substring(1):'');
+                               }
+                               // c'est un scalaire, on retourne direct
+                               else {
+                                       return (r.length>2 && typeof r[2]!=='undefined')?r[2].substring(1):'';
+                               }
                        }
                        // suppression
                        else if (!v.length) {
                        }
                        // Ajout. Pour une variable, remplacer au meme endroit,
                        // pour un tableau ce sera fait dans la prochaine boucle
-                       else if (r[1].substring(-2) != '[]') {
+                       else if (r[1].substr(-2) != '[]') {
                                na.push(r[1]+'='+u);
                                ajouts.push(r[1]);
                        }
-                       else na.push(args[n]);
+                       /* Pour les tableaux ont laisse tomber les valeurs de départ, on
+                       remplira à l'étape suivante */
+                       // else na.push(args[n]);
                }
                else
                        na.push(args[n]);
        }
 
-       if (v==null) return v; // rien de trouve
+       if (v==null) return v_read; // rien de trouve ou un tableau
        // traiter les parametres pas encore trouves
        if (v || v.length || force_vide) {
                ajouts = "="+ajouts.join("=")+"=";