PageSourceSearch

https://www.vernosc.fr/local/couteau-suisse/header.js

js vernosc.fr collected 2026-10-02 22:59:54 UTC 15,795 bytes, 395 lines download raw bytes

1var cs_prive=window.location.pathname.match(/\/ecrire\/$/)!=null;
2jQuery.fn.cs_todo=function(){return this.not('.cs_done').addClass('cs_done');};
3var gloss_el = null;
4var gloss_dt = null;
5var gloss_dd = null;
6var gloss_dl = null;
7
8// compatibilite Ajax : ajouter "this" a "jQuery" pour mieux localiser les actions
9// et tagger avec cs_done pour eviter de binder plrs fois le meme bloc
10function glossaire_init() {
11  if(jQuery('span.gl_js', this).length) {
12	if(!jQuery('#glossOverDiv').length) {
13		jQuery('body').append('<div id="glossOverDiv" style="position:absolute; display:none; visibility: hidden;"><span class="gl_dl"><span class="gl_dt">TITRE</span><span class="gl_dd">Definition</span></span></div>');
14		gloss_el = document.getElementById('glossOverDiv');
15		gloss_dl = gloss_el.firstChild;
16		gloss_dt = gloss_dl.firstChild;
17		gloss_dd = gloss_dl.lastChild;
18	}
19	jQuery('span.gl_mot', this).cs_todo().hover(
20		function(e) {
21			$this = jQuery(this);	  
22			// cas du surligneur (SPIP 2)
23			if(this.firstChild.className=="spip_surligne") {
24				this.className = "gl_mot spip_surligne";
25				this.innerHTML = this.firstChild.innerHTML;
26			}
27			gloss_dt.innerHTML = $this.parent().children('.gl_js')[0].title;  // titre
28			gloss_dd.innerHTML = $this.parent().children('.gl_jst')[0].title; // definition
29			reg = $this.css('font-size').match(/^\d\d?(?:\.\d+)?px/);
30			if(reg) gloss_el.style.fontSize = reg[0];
31			jQuery(gloss_el)
32				.css('top', e.pageY.toString()+"px")
33				.css('left', e.pageX.toString()+"px")
34				.css('font-family', jQuery(this).css('font-family'));
35			gloss_el.style.display    = 'block';
36			gloss_el.style.visibility = 'visible';
37			if(typeof jQuery.fn.offset=="function") { // plugin jquery.dimensions disponible a partir de SPIP 2
38if(1) {///////////////////////// optimisation du placement, encore en test...
39	var $glossOverDiv = jQuery('#glossOverDiv');
40	var $gloss_dl = jQuery(gloss_dl);
41	positionBy = 'auto'; // Type de positionnement : 'dessus', 'dessous', 'auto', 'mouse' (a tester...)
42	ombre = 0;  // Taille d'une ombre, en pixels (non implemente)
43	decalX = 2; // decalage entre le glossaire et le lien appelant
44	width = 180; // largeur totale de #glossOverDiv : definie dans glossaire.css
45	height = 'auto'; // hauteur totale de #glossOverDiv : 'auto' ou nombre de pixels
46	// initiation verticale
47	var glossHeight, wHeight;
48	var linkHeight = this.offsetHeight;
49	var defHeight = isNaN(parseInt(height, 10)) ? 'auto' : (/\D/g).test(height) ? height : height + 'px';
50	var sTop, linkTop, posY, mouseY, baseLine;
51	sTop = jQuery(document).scrollTop();
52	// initiation horizontale
53	var glossWidth = width + ombre;
54	var linkWidth = this.offsetWidth;
55	var linkLeft, posX, mouseX, winWidth;
56	winWidth = jQuery(window).width();
57	// c'est parti !
58	linkTop = posY = $this.offset().top;
59	linkLeft = $this.offset().left;
60	mouseX = e.pageX;
61	mouseY = e.pageY;
62// securite pour l'instant
63$glossOverDiv.css({margin:'0px'}); $gloss_dl.css({margin:'0px'});
64	// calcul de la position horizontale : glossaire au centre du lien
65	posX = Math.max(linkLeft - (glossWidth-linkWidth)/2,0);
66	if (positionBy == 'dessous' || positionBy == 'dessus') { // glossaire fixe
67		$glossOverDiv.css({left: posX + 'px'});
68	} else {
69		// au cas ou, glossaire a droite ou a gauche du lien ?
70		posX2 = (linkWidth > linkLeft && linkLeft > glossWidth) || (linkLeft + linkWidth + glossWidth + decalX > winWidth)
71		  ? linkLeft - glossWidth - decalX 
72		  : linkWidth + linkLeft + decalX;
73		// suivre la souris ?
74		if (positionBy == 'mouse' || linkWidth + glossWidth > winWidth) {
75		  posX = Math.max(mouseX - (glossWidth-linkWidth)/2,0); // glossaire au centre de la souris
76		/*if (mouseX + 20 + glossWidth > winWidth)
77			posX = (mouseX - glossWidth) >= 0 ? mouseX - glossWidth :  mouseX - (glossWidth/2);
78		else posX = mouseX;*/
79	}
80	var pY = e.pageY;
81	$glossOverDiv.css({left: (posX > 0 && positionBy != 'dessus') ? posX : (mouseX + (glossWidth/2) > winWidth) ? winWidth/2 - glossWidth/2 : Math.max(mouseX - (glossWidth/2),0)});
82	}
83	// calcul de la position verticale
84	wHeight = jQuery(window).height();
85	$glossOverDiv.css({overflow: defHeight == 'auto' ? 'visible' : 'auto', height: defHeight});
86	glossHeight = defHeight == 'auto' ? Math.max($gloss_dl.outerHeight(),$gloss_dl.height()) : parseInt(defHeight,10);   
87	glossHeight += ombre;
88	tipY = posY;
89	baseLine = sTop + wHeight;
90	if (positionBy == 'dessous') tipY = posY + linkHeight + 2; // glossaire fixe sous le lien
91	else if (positionBy == 'dessus') tipY = posY - glossHeight - 2; // glossaire fixe au-dessus du lien
92	else if ( posX < mouseX && Math.max(posX, 0) + glossWidth > mouseX ) { // glossaire cache le lien
93		if (posY + glossHeight > baseLine && mouseY - sTop > glossHeight) { 
94		  tipY = posY - glossHeight - 2;
95		} else { 
96		  tipY = posY + linkHeight + 2;
97		}
98	} else if ( posY + glossHeight > baseLine ) {
99		tipY = (glossHeight >= wHeight) ? sTop : baseLine - glossHeight;
100	} else if ($this.css('display') == 'block' || positionBy == 'mouse') {
101		tipY = pY;
102	} else {
103		tipY = posY /*- ombre*/;
104	}
105	$glossOverDiv.css({top: tipY + 'px'});
106}////////////////////////////////////////
107
108			} // typeof jQuery.fn.offset=="function"
109			gloss_el.style.visibility = 'visible';
110		},
111		function(e) {
112			gloss_el.style.display    = 'none';
113			gloss_el.style.visibility = 'hidden';
114		}
115	);
116
117	// accessibilite au clavier
118	if(typeof jQuery.fn.offset=="function") { // plugin jquery.dimensions disponible a partir de SPIP 2
119		jQuery('a.cs_glossaire').focus(
120			function() {
121				legl_mot = this.firstChild;
122				gloss_dt.innerHTML = jQuery(this).children('.gl_js')[0].title;  // titre
123				gloss_dd.innerHTML = jQuery(this).children('.gl_jst')[0].title; // definition
124				reg = jQuery(this.firstChild).css('font-size').match(/^\d\d?(?:\.\d+)?px/);
125				if(reg) gloss_el.style.fontSize = reg[0];
126				var result = jQuery(this).offset({ scroll: false });
127				jQuery(gloss_el)
128					.css('top',result.top+"px")
129					.css('left', result.left+"px")
130					.css('font-family', jQuery(this.firstChild).css('font-family'));
131				gloss_el.style.display    = 'block';
132				gloss_el.style.visibility = 'visible';
133			}
134		);
135		jQuery('a.cs_glossaire').blur(
136			function() {
137				gloss_el.style.display    = 'none';
138				gloss_el.style.visibility = 'hidden';
139			}
140		);
141	} // typeof jQuery.fn.offset=="function"
142  }
143}
144function lancerlien(a,b){ return 'ma'+'ilto'+':'+a.replace(new RegExp(b,'g'),'@'); }
145// variables modifiables afin d'initialiser l'ouverture d'un bloc (simple ou numerote)
146if(typeof(bloc_actif)=='undefined') var bloc_actif = '';
147if(typeof(bloc_actif_num)=='undefined') var bloc_actif_num = '';
148
149// fonction surchargeable : gestion du slide jQuery
150jQuery.fn.blocs_toggle_slide_dist = function( selector ) {
151	this.toggleClass('blocs_slide');
152	if(typeof jQuery.fn.blocs_toggle_slide=='function')
153		return this.blocs_toggle_slide();
154	return this.is(".blocs_slide")?this.slideUp(blocs_slide):this.slideDown(blocs_slide);
155};
156
157jQuery.fn.blocs_set_title = function( selector ) {
158	var title = this.parent().find('.blocs_title:last').text();
159	if(!title) title = blocs_title_def;
160	title = title.split(blocs_title_sep);
161	this.children('a').attr('title', title[jQuery(this).is('.blocs_replie')?0:1]);
162	return this;
163};
164
165// fonction de de/re-pliement
166jQuery.fn.blocs_toggle = function() {
167	if (!this.length) return this;
168	// applique-t-on la fonction sur cs_blocs ou sur blocs_titre ?
169	var cible = this.is('.cs_blocs')? this.children('.blocs_titre').eq(0) : this;
170	// on replie/deplie la cible...
171	cible.toggleClass('blocs_replie').blocs_set_title();
172	var dest = this[0].id.match('^cs_bloc_id_')?jQuery('div.'+this[0].id):cible.next();
173	if(blocs_slide==='aucun') {
174		dest.toggleClass('blocs_invisible');
175		// est-on sur un resume ?
176		if (dest.is('div.blocs_resume')) dest.next().toggleClass('blocs_invisible');
177	} else {
178		dest.blocs_toggle_slide_dist();
179		// est-on sur un resume ?
180		if (dest.is('div.blocs_resume')) dest.next().blocs_toggle_slide_dist();
181	}
182	// est-on sur un bloc ajax ?
183	var lien = cible.children();
184	var url = lien.attr("href");
185	if(url != 'javascript:;') {
186		// une fois le bloc ajax en place, plus besoin de le recharger ensuite
187		lien.attr("href", 'javascript:;');
188		// ici, on charge !
189		cible.parent().children(".blocs_destination")
190		//.animeajax()
191		.load(url);
192	}
193	return this;
194};
195
196// replie tout sauf le bloc appelant et sa lignee parentale
197jQuery.fn.blocs_replie_tout = function() {
198	if(blocs_replier_tout) {
199		// applique-t-on la fonction sur cs_blocs ou sur blocs_titre ?
200		var cible = this.is('.cs_blocs')? this : this.parents('div.cs_blocs');
201		// lignee du bloc
202		var lignee = cible.children('.blocs_titre');
203		jQuery('.blocs_titre').not('.blocs_replie').not(lignee).blocs_toggle();
204	}
205	return this;
206}
207
208// une variable globale stockant le(s) bloc(s) a deplier si un clic ajax a eu lieu
209var blocs_clic_ajax = null;
210
211// compatibilite Ajax : ajouter "this" a "jQuery" pour mieux localiser les actions 
212// et tagger avec cs_done pour eviter de binder plrs fois le meme bloc
213function blocs_init() {
214	// clic sur un titre de bloc
215	jQuery('.blocs_titre', this).cs_todo()
216	  .click( function(){
217		jQuery(this).blocs_replie_tout().blocs_toggle();
218		// annulation du clic
219		return false;
220	   })
221	  .each( function(){
222		jQuery(this).blocs_set_title();
223	  });
224	// pour un lien 'replier_bloc' present dans le bloc
225	jQuery('.blocs_destination a.replier_bloc', this).cs_todo()
226	 .click( function(){
227		s = jQuery(this).parents('.cs_blocs:first');
228		// scroll vers le debut du bloc, si le plugin 'SrollTo' est present
229		if(typeof jQuery.fn.scrollTo=="function") jQuery('body').scrollTo(s, 500, 
230			{margin:true, /*axis:'y',*/ onAfter:function(){s.blocs_replie_tout().blocs_toggle();}});
231		else s.blocs_replie_tout().blocs_toggle();
232		// annulation du clic
233		return false;
234	   });
235	// activation de blocs numerotes grace a l'url
236	var blocs = blocs_get_blocs(window.location, true);
237	if(blocs && (this==document)) blocs_clic_blocs(blocs, true);
238	// activation de blocs simples (numerotes sur la base zero) grace a l'url
239	blocs = blocs_get_blocs(window.location);
240	if(blocs && (this==document)) blocs_clic_blocs(blocs);
241	// clic vers une note dans un bloc
242	jQuery('.spip_note['+cs_sel_jQuery+'name^=nb], .spip_note['+cs_sel_jQuery+'id^=nb]').each(function(i) {
243		jQuery(this).click(function(e){
244			var href = this.href.substring(this.href.lastIndexOf("#"));
245			href = jQuery(href).parents('.cs_blocs').eq(0).children('.blocs_titre').eq(0);
246			// on neutralise une eventuelle animation
247			old_blocs_slide = blocs_slide;
248			if(blocs_slide!='aucun') blocs_slide = -1;
249			if(href.is('.blocs_replie')) href.click();
250			blocs_slide = old_blocs_slide;
251			return true;
252		});
253	});
254
255/*
256// LA SUITE DE CE CODE NE FONCTIONNE POUR L'INSTANT QUE SUR LE PREMIER CLIC, JE NE SAIS PAS ENCORE PKOI...
257	// stockage du bloc (numerote !) a reouvrir dans le cas d'un clic ajax sur une 
258	// pagination SPIP contenue a l'interieur
259	jQuery(".ajaxbloc .pagination a.noajax", this).cs_todo()
260	  .click( function(){
261		var parent = jQuery(this).parents('.cs_blocs');
262		if(!parent.length) return true;
263		var numero = /cs_bloc\d+/.exec(parent[0].className);
264		if(numero!==null) blocs_clic_ajax = numero[0];
265		return true;
266	   });
267	// rouvre le nouveau bloc ajax si un clic a eu lieu a l'interieur de l'ancien
268	if(blocs_clic_ajax!==null) {
269		jQuery('.'+blocs_clic_ajax, this).blocs_toggle();
270		blocs_clic_ajax = null
271	}
272*/
273}
274
275// un JS actif replie les blocs invisibles
276document.write('<style type="text/css">div.blocs_invisible{display:none;}</style>');
277
278// Sauve l'etat des blocs numerotes dans un cookie si on quitte la page
279function cs_blocs_cookie() {
280	if(typeof jQuery.cookie!='function') return;
281	var blocs_cookie_name = 'blocs' + window.location.pathname + window.location.search
282	blocs_cookie_name = blocs_cookie_name.replace(/[ ;,=]/,'_');
283	var deplies = jQuery.cookie(blocs_cookie_name);
284	jQuery.cookie(blocs_cookie_name, null);
285	if(deplies)
286		jQuery(deplies).blocs_replie_tout().blocs_toggle();
287	jQuery(window).bind('unload', function() {
288		jQuery.cookie(blocs_cookie_name, blocs_deplies());
289	});
290}
291
292// renvoie la liste des selecteurs de blocs ouverts
293function blocs_deplies() {
294	var deplies = '';
295	jQuery('.cs_blocs').each(function() {
296		var numero = /cs_bloc\d+/.exec(this.className);
297		if(numero==null) return;
298		replie = jQuery(this).children('.blocs_titre').eq(0).is('.blocs_replie');
299		if(!replie) deplies += (deplies.length?', ':'') + 'div.' + numero[0];
300	});
301	return deplies.length?deplies:null;
302}
303
304// clic sur les blocs (Niemes blocs en base zero pour les blocs simples)
305function blocs_clic_blocs(liste, numerote) {
306	var blocs = liste.split(',');
307	for (var i=0; i<blocs.length; i++)
308		(numerote)
309			?jQuery('div.cs_bloc' + blocs[i] + ' .blocs_titre').eq(0).click()
310			:jQuery('div.cs_blocs .blocs_titre').eq(blocs[i]).click();
311}
312
313// examen des parametes url (blocs simples ou numerotes)
314function blocs_get_blocs(url, numerote) {
315	tab = numerote
316		?url.search.match(/[?&]deplier_num=([0-9,]*)/) || url.hash.match(/#deplier_num([0-9,]*)/)
317		:url.search.match(/[?&]deplier=([0-9,]*)/) || url.hash.match(/#deplier([0-9,]*)/);
318	return tab==null?(numerote?bloc_actif_num:bloc_actif):tab[1];
319}
320
321// une fonction et une variable pour reperer une pagination
322function blocs_get_pagination(url) {
323	tab = url.match(/#pagination([0-9]+)/);
324	return tab==null?bloc_actif:tab[1];
325}
326
327var blocs_pagination = blocs_get_pagination(window.location.hash);
328
329/*
330// Ouvrir un bloc qui contiendrait un formulaire renvoyant une erreur
331jQuery(document).ready(function() {
332	jQuery('.cs_blocs').has('.erreur_message').find('.blocs_titre.blocs_replie').blocs_toggle();
333});
334*/
335
336/*
337// Si un bloc contient une pagination inseree dans un bloc,
338// code JS a inserer dans le header de votre squelette APRES les appels du Couteau Suisse :
339jQuery(document).ready(function() {
340	if(blocs_pagination!==false) {
341		jQuery('div.cs_bloc' + blocs_pagination + ' .blocs_titre').eq(0).click();
342		window.location.hash = '#pagination' + blocs_pagination;
343	}
344});
345*/
346
347/*
348//	Pour un bloc depliable du genre :
349//	<BOUCLE_art(ARTICLES)>
350//		#BLOC_TITRE
351//		#TITRE
352//		#BLOC_RESUME
353//		#INTRODUCTION
354//		#BLOC_DEBUT
355//		#TEXTE
356//		#BLOC_FIN
357//	</BOUCLE_art>
358//	le clic sur un point de suite cliquable de la balise #INTRODUCTION produit l'ouverture du bloc.
359//	code JS a inserer dans le header de votre squelette APRES les appels du Couteau Suisse :
360jQuery(document).ready(function(){
361	jQuery('.blocs_resume>a.pts_suite')
362	  .click( function(){
363		jQuery(this).parents('.cs_blocs:first').children('.blocs_titre')
364			.blocs_replie_tout().blocs_toggle();
365		// annulation du clic
366		return false;
367		});
368});
369*/
370/* Par defaut : blocs_slide = 'aucun' */
371var blocs_replier_tout = 0;
372var blocs_millisec = 100;
373var blocs_slide = 'aucun';
374var blocs_title_sep = /\|\|/g;
375var blocs_title_def = 'Déplier||Replier';
376
377var cs_init = function() {
378	/* optimisation : 'IF(1)' */ if(!cs_prive) jQuery("a.spip_out,a.spip_url,a.spip_glossaire",this).attr("target", "_blank"); 
379	glossaire_init.apply(this);
380	jQuery('span.mcrypt', this).attr('class','cryptOK').html('&#6'+'4;');
381	jQuery("a["+cs_sel_jQuery+"title*='..']", this).each(function () {
382		this.title = this.title.replace(/\.\..t\.\./g,'[@]');
383	});
384	blocs_init.apply(this);
385}
386if(typeof onAjaxLoad=='function') onAjaxLoad(cs_init);
387if(window.jQuery) {
388var cs_sel_jQuery=typeof jQuery(document).selector=='undefined'?'@':'';
389var cs_CookiePlugin="prive/javascript/jquery.cookie.js";
390jQuery(document).ready(function(){
391	/* optimisation : 'IF(0) \{if(jQuery("div.cs_blocs").length)
392		jQuery.getScript(cs_CookiePlugin, cs_blocs_cookie); \}' */
393	cs_init.apply(document);
394});
395}

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.