Valider 99de6b6f rédigé par cerdic's avatar cerdic
Parcourir les fichiers

Report de r21297 : Amelioration de r21296 : on stocke l'eventuel ajax-id-xx...

Report de r21297 : Amelioration de r21296 : on stocke l'eventuel ajax-id-xx dans le history.state, ainsi lorsque l'id du bloc ajax n'est plus dans le HTML, on essaye de le retrouver avec la class ajax-id-xx. Si un seul bloc correspond, c'est lui et on lui applique le rechargement. Sinon on utilise le window.location.href comme fallback dont on est sur.
parent d659e756
Chargement en cours
Chargement en cours
Chargement en cours
Chargement en cours
+13 −4
Numéro de ligne d'origine Numéro de ligne de diff Ligne de diff
@@ -478,6 +478,9 @@ jQuery.spip.setHistoryState = function(blocfrag){
		id:blocfrag.attr('id'),
		href: href
	};
	var ajaxid = blocfrag.attr('class').match(/\bajax-id-[\w-]+\b/);
	if (ajaxid.length)
		state["ajaxid"] = ajaxid[0];
	// on remplace la variable qui decrit l'etat courant
	// initialement vide
	// -> elle servira a revenir dans l'etat courant
@@ -491,15 +494,21 @@ jQuery.spip.pushHistoryState = function(href, title){
}

window.onpopstate = function(popState){
	if (popState.state && popState.state.id){
		var blocfrag=jQuery('#'+popState.state.id);
		if (blocfrag.length && popState.state.href) {
	if (popState.state && popState.state.href){
		var blocfrag=false;
		if (popState.state.id){
			blocfrag=jQuery('#'+popState.state.id);
		}
		if ((!blocfrag || !blocfrag.length) && popState.state.ajaxid){
			blocfrag=jQuery('.ajaxbloc.'+popState.state.ajaxid);
		}
		if (blocfrag && blocfrag.length==1) {
			jQuery.spip.ajaxClick(blocfrag,popState.state.href,{history:false});
			return true;
		}
		// si on revient apres avoir rompu la chaine ajax, on a pu perdre l'id #ghsidxx ajoute en JS
		// dans ce cas on redirige hors ajax
		else if(popState.state.href){
		else {
			window.location.href = popState.state.href;
		}
	}