e1090a6a0cc4acbbed9b1f4e44ae5d28e51a0458
1 var url_chargee
= new Array();
5 // Fonctions pour mini_nav
8 function slide_horizontal (couche
, slide
, align
, depart
, etape
) {
10 var obj
= jQuery("#"+couche
);
12 if (!obj
.length
) return;
15 if (align
== 'left') depart
= obj
.scrollLeft
;
16 else depart
= obj
.firstChild
.offsetWidth
- obj
.scrollLeft
;
19 etape
= Math
.round(etape
) + 1;
20 pos
= Math
.round(depart
) + Math
.round(((slide
- depart
) / 10) * etape
);
22 if (align
== 'left') obj
.scrollLeft
= pos
;
23 else obj
.scrollLeft
= obj
.firstChild
.offsetWidth
- pos
;
24 if (etape
< 10) setTimeout("slide_horizontal('"+couche
+"', '"+slide
+"', '"+align
+"', '"+depart
+"', '"+etape
+"')", 60);
25 //else obj.scrollLeft = slide;
28 function changerhighlight (couche
) {
34 jQuery('.petite-racine.on').removeClass('on');
37 function aff_selection (arg
, idom
, url
, event
) {
38 var noeud
= jQuery("#"+idom
);
41 charger_node_url(url
+arg
, noeud
.get(0), '','',event
);
46 // selecteur de rubrique et affichage de son titre dans le bandeau
48 function aff_selection_titre(titre
, id
, idom
, nid
)
50 var t
= jQuery('#titreparent');
51 var p
= t
.closest('form');
52 t
.attr('value',titre
);
53 p
.find('#'+nid
).attr('value',id
).trigger('change'); // declencher le onchange
54 p
.find("#"+idom
).hide('fast');
55 if (p
.is('.submit_plongeur')) p
.get(p
.length
-1).submit();
56 else p
.find("#"+idom
).prev('div').find('a').eq(0).focus();
61 * Utilise dans inc/plonger
70 function aff_selection_provisoire(id
, racine
, url
, col
, sens
,informer
,event
) {
71 if(url
.href
== 'javascript:void(0)'){
72 slide_horizontal(racine
+ '_principal', ((col
-1)*150), sens
);
73 aff_selection (id
, racine
+ "_selection", informer
);
76 charger_id_url(url
.href
,
77 racine
+ '_col_' + (col
+1),
79 slide_horizontal(racine
+ '_principal', ((col
-1)*150), sens
);
80 aff_selection (id
, racine
+ "_selection", informer
);
84 // empecher le chargement non Ajax
89 * Lanche une requete Ajax a chaque frappe au clavier dans une balise de saisie.
90 * Si l'entree redevient vide, rappeler l'URL initiale si dispo.
91 * Sinon, controler au retour si le resultat est unique,
92 * auquel cas forcer la selection.
93 * utlise dans inc/selectionner
101 function onkey_rechercher(valeur
, rac
, url
, img
, nid
, init
) {
102 var Field
= jQuery("#"+rac
).get(0);
103 if (!valeur
.length
) {
104 init
= jQuery("#"+init
).get(0);
105 if (init
&& init
.href
) { charger_node_url(init
.href
, Field
);}
107 charger_node_url(url
+valeur
,
110 var n
= Field
.childNodes
.length
- 1;
111 // Safari = 0 & Firefox = 1 !
112 // et gare aux negatifs en cas d'abort
114 noeud
= Field
.childNodes
[n
].firstChild
;
116 // cas de la rubrique, pas des auteurs
117 aff_selection_titre(noeud
.firstChild
.nodeValue
, noeud
.title
, rac
, nid
);
126 // Recupere tous les formulaires de la page
127 // (ou du fragment qu'on vient de recharger en ajax)
128 // et leur applique les comportements js souhaites
130 // * utiliser ctrl-s, F8 etc comme touches de sauvegarde
131 var verifForm_clicked
=false;
132 function verifForm(racine
) {
133 verifForm_clicked
= false; // rearmer quand on passe ici (il y a eu de l'ajax par exemple)
134 if (!jQuery
) return; // appels ajax sur iframe
135 // Clavier pour sauver (cf. crayons)
136 // cf http://www.quirksmode.org/js/keys.html
137 if (!jQuery
.browser
.msie
)
138 // keypress renvoie le charcode correspondant au caractere frappe (ici s)
139 jQuery('form:not(.bouton_action_post)', racine
||document
).not('.verifformok')
140 .keypress(function(e
){
143 /* ctrl-s ou ctrl-maj-S, firefox */
144 (((e
.charCode
||e
.keyCode
) == 115) || ((e
.charCode
||e
.keyCode
) == 83))
146 || (e
.charCode
==19 && e
.keyCode
==19)
148 ) /* ctrl-s, Opera Mac */
149 || (e
.keyCode
==19 && jQuery
.browser
.opera
))
150 && !verifForm_clicked
152 verifForm_clicked
= true;
153 jQuery(this).find('input[type=submit]')
157 }).addClass('verifformok');
159 // keydown renvoie le keycode correspondant a la touche pressee (ici F8)
160 jQuery('form:not(.bouton_action_post)', racine
||document
).not('.verifformok')
161 .keydown(function(e
){
162 //jQuery('#ps').after("<div>ctrl:"+e.ctrlKey+"<br />charcode:"+e.charCode+"<br />keycode:"+e.keyCode+"<hr /></div>");
163 if (!e
.charCode
&& e
.keyCode
== 119 /* F8, windows */ && !verifForm_clicked
){
164 verifForm_clicked
= true;
165 jQuery(this).find('input[type=submit]')
169 }).addClass('verifformok');
172 // La fonction qui fait vraiment le travail decrit ci-dessus.
173 // Son premier argument est deja le noeud du DOM
174 // et son resultat booleen est inverse ce qui lui permet de retourner
175 // le gestionnaire Ajax comme valeur non fausse
176 function AjaxSqueezeNode(trig
, target
, f
, event
) {
179 // retour std si pas precise: affecter ce noeud avec ce retour
181 callback = function() { verifForm(this);}
184 callback = function(res
,status
) {
185 f
.apply(this,[res
,status
]);
191 if (typeof(window
['_OUTILS_DEVELOPPEURS']) != 'undefined'){
192 if (!(navigator
.userAgent
.toLowerCase().indexOf("firefox/1.0")))
193 valid
= (typeof event
== 'object') && (event
.altKey
|| event
.metaKey
);
196 if (typeof(trig
) == 'string') {
197 // laisser le choix de la touche enfoncee au moment du clic
198 // car beaucoup de systemes en prenne une a leur usage
200 window
.open(trig
+'&transformer_xml=valider_xml');
202 jQuery(target
).animeajax();
206 "complete": function(r
,s
) {
207 AjaxRet(r
,s
,target
, callback
);
208 jQuery(target
).endLoading();
215 //open a blank window
216 var doc
= window
.open("","valider").document
;
217 //create a document to enable receiving the result of the ajax post
220 //set the element receiving the ajax post
224 jQuery(target
).animeajax();
227 jQuery(trig
).ajaxSubmit({
229 "success": function(res
,status
) {
230 if(status
=='error') return this.html('Erreur HTTP');
231 callback
.apply(this,[res
,status
]);
233 "beforeSubmit":function (vars
) {
235 vars
.push({"name":"transformer_xml","value":"valider_xml"});
243 function AjaxRet(res
,status
, target
, callback
) {
244 if (res
.aborted
) return;
245 if (status
=='error') return jQuery(target
).html('HTTP Error');
247 // Inject the HTML into all the matched elements
249 .html(res
.responseText
)
251 .each(callback
, [res
.responseText
, status
]);
255 // Comme AjaxSqueeze,
256 // mais avec un cache sur le noeud et un cache sur la reponse
257 // et une memorisation des greffes en attente afin de les abandonner
258 // (utile surtout a la frappe interactive au clavier)
259 // De plus, la fonction optionnelle n'a pas besoin de greffer la reponse.
261 function charger_id_url(myUrl
, myField
, jjscript
, event
) {
262 var Field
= jQuery("#"+myField
);
263 if (!Field
.length
) return true;
267 retour_id_url(Field
.get(0), jjscript
);
268 return true; // url vide, c'est un self complet
271 return charger_node_url(myUrl
, Field
.get(0), jjscript
, jQuery('#'+'img_' + myField
).get(0), event
);
275 function charger_node_url(myUrl
, Field
, jjscript
, img
, event
) {
276 // disponible en cache ?
277 if (url_chargee
[myUrl
]) {
278 var el
= jQuery(Field
).html(url_chargee
[myUrl
])[0];
279 retour_id_url(el
, jjscript
);
280 jQuery
.spip
.triggerAjaxLoad(el
);
284 if (img
) img
.style
.visibility
= "visible";
285 if (xhr_actifs
[Field
]) { xhr_actifs
[Field
].aborted
= true;xhr_actifs
[Field
].abort(); }
286 xhr_actifs
[Field
] = AjaxSqueezeNode(myUrl
,
289 xhr_actifs
[Field
] = undefined;
290 if (img
) img
.style
.visibility
= "hidden";
291 url_chargee
[myUrl
] = r
;
292 retour_id_url(Field
, jjscript
);
293 slide_horizontal($(Field
).children().attr("id")+'_principal', $(Field
).width() , $(Field
).css("text-align"));
300 function retour_id_url(Field
, jjscript
) {
301 jQuery(Field
).css({'visibility':'visible','display':'block'});
302 if (jjscript
) jjscript();
305 function charger_node_url_si_vide(url
, noeud
, gifanime
, jjscript
,event
) {
307 if (noeud
.style
.display
!='none') {
308 noeud
.style
.display
='none';}
310 if (noeud
.innerHTML
!= "") {
311 noeud
.style
.visibility
= "visible";
312 noeud
.style
.display
= "block";
314 charger_node_url(url
, noeud
,'',gifanime
,event
);
323 onAjaxLoad(verifForm
);