1var cs_prive=window.location.pathname.match(/\/ecrire\/$/)!=null; 2jQuery.fn.cs_todo=function(){return this.not('.cs_done').addClass('cs_done');}; 3// variables modifiables afin d'initialiser l'ouverture d'un bloc (simple ou numerote) 4if(typeof(bloc_actif) == 'undefined') 5 var bloc_actif = ''; 6if(typeof(bloc_actif_num) == 'undefined') 7 var bloc_actif_num = ''; 8 9// fonction surchargeable : gestion du slide jQuery 10jQuery.fn.blocs_toggle_slide_dist = function( selector ) { 11 this.toggleClass('blocs_slide'); 12 if(typeof jQuery.fn.blocs_toggle_slide=='function') 13 return this.blocs_toggle_slide(); 14 return this.is(".blocs_slide") ? this.slideUp(blocs_slide) : this.slideDown(blocs_slide); 15}; 16 17jQuery.fn.blocs_set_title = function( selector ) { 18 var title = this.parent().find('.blocs_title:last').text(); 19 if(!title) title = blocs_title_def; 20 title = title.split(blocs_title_sep); 21 this.children('a').attr('title', title[jQuery(this).is('.blocs_replie')?0:1]); 22 return this; 23}; 24 25// fonction de de/re-pliement 26jQuery.fn.blocs_toggle = function() { 27 if(!this.length) return this; 28 if(this.length > 1) { 29 this.each(function() { $(this).eq(0).blocs_toggle(); }); 30 return this; 31 } 32 // applique-t-on la fonction sur cs_blocs ou sur blocs_titre ? 33 var cible = this.is('.cs_blocs') ? this.children('.blocs_titre').eq(0) : this; 34 // on replie/deplie la cible... 35 cible.toggleClass('blocs_replie').blocs_set_title(); 36 var dest = this[0].id.match('^cs_bloc_id_') ? jQuery('div.'+this[0].id) : cible.next(); 37 if(blocs_slide === 'aucun') { 38 dest.toggleClass('blocs_invisible'); 39 // est-on sur un resume ? 40 if (dest.is('div.blocs_resume')) dest.next().toggleClass('blocs_invisible'); 41 } else { 42 dest.blocs_toggle_slide_dist(); 43 // est-on sur un resume ? 44 if (dest.is('div.blocs_resume')) dest.next().blocs_toggle_slide_dist(); 45 } 46 // est-on sur un bloc ajax ? 47 var lien = cible.children(); 48 var url = lien.attr("href"); 49 if(url != 'javascript:;' && !url.endsWith('#_foo')) { 50 // une fois le bloc ajax en place, plus besoin de le recharger ensuite 51 lien.attr("href", '#_foo');// 'javascript:;'); 52 // ici, on charge ! 53 cible.parent().children(".blocs_destination") 54 //.animeajax() 55 .load(url); 56 } 57 return this; 58}; 59 60// replie tout sauf le bloc appelant et sa lignee parentale 61jQuery.fn.blocs_replie_tout = function() { 62 if(blocs_replier_tout) { 63 // applique-t-on la fonction sur cs_blocs ou sur blocs_titre ? 64 var cible = this.is('.cs_blocs')? this : this.parents('div.cs_blocs'); 65 // lignee du bloc 66 var lignee = cible.children('.blocs_titre'); 67 jQuery('.blocs_titre').not('.blocs_replie').not(lignee).blocs_toggle(); 68 } 69 return this; 70} 71 72// une variable globale stockant le(s) bloc(s) a deplier si un clic ajax a eu lieu 73var blocs_clic_ajax = null; 74 75// compatibilite Ajax : ajouter "this" a "jQuery" pour mieux localiser les actions 76// et tagger avec cs_done pour eviter de binder plrs fois le meme bloc 77function blocs_init() { 78 // clic sur un titre de bloc 79 jQuery('.blocs_titre', this).cs_todo() 80 .click( function(){ 81 jQuery(this).blocs_replie_tout().blocs_toggle(); 82 // annulation du clic 83 return false; 84 }) 85 .each( function(){ 86 jQuery(this).blocs_set_title(); 87 }); 88 // pour un lien 'replier_bloc' present dans le bloc 89 jQuery('.blocs_destination a.replier_bloc', this).cs_todo() 90 .click( function(){ 91 var s = jQuery(this).parents('.cs_blocs:first'); 92 // scroll vers le debut du bloc, si le plugin 'SrollTo' est present 93 if(typeof jQuery.fn.scrollTo == "function") 94 jQuery('body').scrollTo(s, 500, 95 { margin:true, /*axis:'y',*/ onAfter:function(){ s.blocs_replie_tout().blocs_toggle(); }}); 96 else 97 s.blocs_replie_tout().blocs_toggle(); 98 // annulation du clic 99 return false; 100 }); 101 102 // activation de blocs numerotes grace a l'url 103 var blocs = blocs_get_blocs(window.location, true); 104 if(blocs && (this == document)) 105 blocs_clic_blocs(blocs, true); 106 // activation de blocs simples (numerotes sur la base zero) grace a l'url 107 blocs = blocs_get_blocs(window.location); 108 if(blocs && (this == document)) 109 blocs_clic_blocs(blocs); 110 111 // clic vers une note dans un bloc 112 jQuery('.spip_note['+cs_sel_jQuery+'name^=nb], .spip_note['+cs_sel_jQuery+'id^=nb]').each(function(i) { 113 jQuery(this).click(function(e){ 114 var href = this.href.substring(this.href.lastIndexOf("#")); 115 href = jQuery(href).parents('.cs_blocs').eq(0).children('.blocs_titre').eq(0); 116 // on neutralise une eventuelle animation 117 old_blocs_slide = blocs_slide; 118 if(blocs_slide != 'aucun') 119 blocs_slide = -1; 120 if(href.is('.blocs_replie')) 121 href.click(); 122 blocs_slide = old_blocs_slide; 123 return true; 124 }); 125 }); 126 127/* 128// LA SUITE DE CE CODE NE FONCTIONNE POUR L'INSTANT QUE SUR LE PREMIER CLIC, JE NE SAIS PAS ENCORE PKOI...
129 // stockage du bloc (numerote !) a reouvrir dans le cas d'un clic ajax sur une 130 // pagination SPIP contenue a l'interieur 131 jQuery(".ajaxbloc .pagination a.noajax", this).cs_todo() 132 .click( function(){ 133 var parent = jQuery(this).parents('.cs_blocs'); 134 if(!parent.length) return true; 135 var numero = /cs_bloc\d+/.exec(parent[0].className); 136 if(numero!==null) blocs_clic_ajax = numero[0]; 137 return true; 138 }); 139 // rouvre le nouveau bloc ajax si un clic a eu lieu a l'interieur de l'ancien 140 if(blocs_clic_ajax!==null) { 141 jQuery('.'+blocs_clic_ajax, this).blocs_toggle(); 142 blocs_clic_ajax = null 143 } 144*/ 145} 146 147// un JS actif replie les blocs invisibles 148var valStyle = document.createElement('style'); 149var valHead = document.head || document.getElementsByTagName('head')[0]; 150valHead.appendChild(valStyle); 151valStyle.type = 'text/css'; 152valStyle.appendChild(document.createTextNode('div.blocs_invisible { display:none; }')); 153 154// Sauve l'etat des blocs numerotes ET deplies dans un cookie si on quitte la page 155function cs_blocs_cookie() { 156 if(typeof jQuery.cookie!='function') return; 157 var blocs_cookie_name = 'blocs' + window.location.pathname + window.location.search 158 blocs_cookie_name = blocs_cookie_name.replace(/[ ;,=]/,'_'); 159 var deplies = jQuery.cookie(blocs_cookie_name); 160 //var pourInfo = blocs_deplies(); 161 if(deplies) { 162 // on replie tous les blocs numerotes et on deplie les blocs du cookie 163 jQuery(".cs_blocs[id^='deplier_num'] .blocs_titre").not('.blocs_replie').blocs_toggle(); 164 jQuery(deplies).blocs_toggle(); 165 } 166 jQuery(window).bind('unload', function() { 167 jQuery.cookie(blocs_cookie_name, blocs_deplies()); 168 }); 169} 170 171// renvoie la liste des selecteurs de blocs ouverts 172function blocs_deplies() { 173 var deplies = ''; 174 jQuery('.cs_blocs').each(function() { 175 var numero = /cs_bloc\d+/.exec(this.className); 176 if(numero == null) return; 177 replie = jQuery(this).children('.blocs_titre').eq(0).is('.blocs_replie'); 178 if(!replie) deplies += (deplies.length?', ':'') + 'div.' + numero[0]; 179 }); 180 return deplies.length?deplies:null; 181} 182 183// clic sur les blocs (Niemes blocs en base zero pour les blocs simples) 184function blocs_clic_blocs(liste, numerote) { 185 var blocs = liste.split(','); 186 for (var i=0; i<blocs.length; i++) 187 (numerote) 188 ? jQuery('div.cs_bloc' + blocs[i] + ' .blocs_titre').eq(0).click() 189 : jQuery('div.cs_blocs .blocs_titre').eq(blocs[i]).click(); 190} 191 192// examen des parametes url (blocs simples ou numerotes) 193function blocs_get_blocs(url, numerote) { 194 tab = numerote 195 ? url.search.match(/[?&]deplier_num=([0-9,]*)/) || url.hash.match(/#deplier_num([0-9,]*)/) 196 : url.search.match(/[?&]deplier=([0-9,]*)/) || url.hash.match(/#deplier([0-9,]*)/); 197 return tab == null ? (numerote ? bloc_actif_num : bloc_actif) : tab[1]; 198} 199 200// une fonction et une variable pour reperer une pagination 201function blocs_get_pagination(url) { 202 tab = url.match(/#pagination([0-9]+)/); 203 return tab == null ? bloc_actif : tab[1]; 204} 205 206// Si une ancre est contenue dans un bloc, alors on le déplie ! 207// Cette fonction est automatiquement appelée si l'outil est configuré pour surveiller l'ancre de l'URL. 208function blocs_deplier_pour_ancre() { 209 var ancre = window.location.hash; 210 if(ancre) { 211 ancre = jQuery(ancre); 212 var bloc = ancre.parents('.cs_blocs').find('.blocs_titre.blocs_replie'); 213 if(bloc.length && (ancre.length == 1)) { 214 bloc.blocs_toggle(); 215 jQuery('html,body').animate({scrollTop: ancre.offset().top}, 'slow'); 216 } 217 } 218}; 219 220var blocs_pagination = blocs_get_pagination(window.location.hash); 221 222 223/* 224// Ouvrir un bloc qui contiendrait un formulaire renvoyant une erreur 225jQuery(document).ready(function() { 226 jQuery('.cs_blocs').has('.erreur_message').find('.blocs_titre.blocs_replie').blocs_toggle(); 227}); 228*/ 229 230/* 231// Si un bloc contient une pagination inseree dans un bloc, 232// code JS a inserer dans le header de votre squelette APRES les appels du Couteau Suisse : 233jQuery(document).ready(function() { 234 if(blocs_pagination!==false) { 235 jQuery('div.cs_bloc' + blocs_pagination + ' .blocs_titre').eq(0).click(); 236 window.location.hash = '#pagination' + blocs_pagination; 237 } 238}); 239*/ 240 241/* 242// Pour un bloc depliable du genre : 243// <BOUCLE_art(ARTICLES)> 244// #BLOC_TITRE 245// #TITRE 246// #BLOC_RESUME 247// #INTRODUCTION 248// #BLOC_DEBUT 249// #TEXTE 250// #BLOC_FIN 251// </BOUCLE_art> 252// le clic sur un point de suite cliquable de la balise #INTRODUCTION produit l'ouverture du bloc. 253// code JS a inserer dans le header de votre squelette APRES les appels du Couteau Suisse : 254jQuery(document).ready(function(){ 255 jQuery('.blocs_resume>a.pts_suite') 256 .click( function(){ 257 jQuery(this).parents('.cs_blocs:first').children('.blocs_titre')
258 .blocs_replie_tout().blocs_toggle(); 259 // annulation du clic 260 return false; 261 }); 262}); 263*/ 264/* Par defaut : blocs_slide = 'aucun' */ 265var blocs_replier_tout = 0; 266var blocs_millisec = 100; 267var blocs_slide = 'aucun'; 268var blocs_title_sep = /\|\|/g; 269var blocs_title_def = 'Déplier||Replier'; 270 271var cs_init = function() { 272 /* optimisation : 'IF(1)' */ if(!cs_prive) jQuery("a.spip_out,a.spip_url,a.spip_glossaire",this).attr("target", "_blank"); 273 blocs_init.apply(this); 274} 275if(typeof onAjaxLoad=='function') onAjaxLoad(cs_init); 276if(window.jQuery) { 277var cs_sel_jQuery=''; 278var cs_CookiePlugin="prive/javascript/js.cookie.js"; 279jQuery(document).ready(function(){ 280 /* optimisation : 'IF(0) \{if(jQuery("div.cs_blocs").length) 281 jQuery.getScript(cs_CookiePlugin, cs_blocs_cookie); \}' */ 282/* optimisation : 'IF(0) \{blocs_deplier_pour_ancre(); \}' */ 283 cs_init.apply(document); 284}); 285}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.