MediaWiki:Monobook.js : Différence entre versions

Un article de Témoins de Jéhovah: TJ-Encyclopedie, l'encyclopédie libre sur les Témoins de Jéhovah.
Aller à : navigation, rechercher
 
Ligne 1: Ligne 1:
//============================================================ // Introduction de la possibilité de faire un lien vers le texte // de la traduction du Monde Nouveau en ligne par une balise // spécifique créée pour l'occasion // //=============================================================
 
  
// This code is not copyrighted. // VERSION 1.0
 
  
 
function noaccent(chaine) {
 
function noaccent(chaine) {
Ligne 12: Ligne 10:
 
   return temp
 
   return temp
 
   }
 
   }
 +
/////////////////////////////////////////////////////////
 +
// Code snippet to make your sidebar items expandable  //
 +
// Use this code ONLY for the Monobook skin.          //
 +
/////////////////////////////////////////////////////////
 +
 +
$( document ).ready( function() {
 +
// Set the default expanded items by their headline
 +
var defaultExpandItems = ['Navigation', 'Orga'];
 +
// Set the basic-name for the cookies, which save the current state of expanding
 +
var expandCookieName = 'disdance_project_wiki_nav_expanded_';
 +
 +
var maxHeights = [];
 +
var expandeds = [];
 +
var labels = [];
 +
initNav();
 +
});
 +
 +
function initNav() {
 +
$( '#p-logo' ).css({'position': 'relative', 'display': 'block'});
 +
$( '.generated-sidebar h5,#p-tb h5 ').each( function( i ) {
 +
var id = $( this ).parent().attr( 'id' );
 +
maxHeights[id] = $( this ).next( 'div' ).height();
 +
var str = $( this ).html();
 +
labels[id] = str;
 +
 +
if ( $.cookie( expandCookieName + id ) == 'false' ) {
 +
expandeds[id] = false;
 +
minimize( $( this ) );
 +
} else if ( $.cookie( expandCookieName + id ) == 'true' ) {
 +
expandeds[id] = true;
 +
maximize( $( this ) );
 +
} else if ( defaultExpandItems.indexOf( str ) == -1 ) {
 +
expandeds[id] = false;
 +
minimize( $( this ) );
 +
} else {
 +
expandeds[id] = true;
 +
maximize( $( this ) );
 +
}
 +
$( this ).css({'cursor': 'pointer'});
 +
$( this ).click( toggleNav );
 +
} );
 +
}
 +
 +
function minimize( target ) {
 +
var id = $( target ).parent().attr( 'id' );
 +
// You can change the expires parameter to save the cookie longer/shorter than 7 days like in this code
 +
$.cookie( expandCookieName + id, 'false', { expires: 7} );
 +
var str = labels[id] + '  ►';
 +
$( target ).next( 'div' ).animate({'height': '0px'});
 +
$( target ).html( str );
 +
}
 +
 +
function maximize( target ) {
 +
var id = $( target ).parent().attr( 'id' );
 +
// You can change the expires parameter to save the cookie longer/shorter than 7 days like in this code
 +
$.cookie( expandCookieName + id, 'true', { expires: 7} );
 +
var str = labels[id] + '  ▼';
 +
var newHeight = maxHeights[id];
 +
$( target ).next( 'div' ).animate({'height': newHeight + 'px'});
 +
$( target ).html( str );
 +
}
 +
 +
function toggleNav( e ) {
 +
var id = $(e.target ).parent().attr( 'id' );
 +
expandeds[id] = !expandeds[id];
 +
if( expandeds[id] == true ) {
 +
maximize( e.target );
 +
} else {
 +
minimize( e.target );
 +
}
 +
}
 +
 +
///////////////////////////////////////////////////////
 +
///////////////////////////////////////////////////////

Version du 2 mars 2014 à 21:48



function noaccent(chaine) {

 temp = chaine.replace(/[àâä]/gi,"a")
  temp = temp.replace(/[éèêë]/gi,"e")
  temp = temp.replace(/[îï]/gi,"i")
  temp = temp.replace(/[ôö]/gi,"o")
  temp = temp.replace(/[ùûü]/gi,"u")
  return temp
  }
/////////////////////////////////////////////////////////
// Code snippet to make your sidebar items expandable  //
// Use this code ONLY for the Monobook skin.           //
/////////////////////////////////////////////////////////
 
$( document ).ready( function() {
	// Set the default expanded items by their headline
	var defaultExpandItems = ['Navigation', 'Orga'];
	// Set the basic-name for the cookies, which save the current state of expanding
	var expandCookieName = 'disdance_project_wiki_nav_expanded_';
 
	var maxHeights = [];
	var expandeds = [];
	var labels = [];
	initNav();
});
 
function initNav() {
	$( '#p-logo' ).css({'position': 'relative', 'display': 'block'});
	$( '.generated-sidebar h5,#p-tb h5 ').each( function( i ) {
		var id = $( this ).parent().attr( 'id' );
		maxHeights[id] = $( this ).next( 'div' ).height();
		var str = $( this ).html();
		labels[id] = str;
 
		if ( $.cookie( expandCookieName + id ) == 'false' ) {
			expandeds[id] = false;
			minimize( $( this ) );
		} else if ( $.cookie( expandCookieName + id ) == 'true' ) {
			expandeds[id] = true;
			maximize( $( this ) );
		} else if ( defaultExpandItems.indexOf( str ) == -1 ) {
			expandeds[id] = false;
			minimize( $( this ) );
		} else {
			expandeds[id] = true;
			maximize( $( this ) );
		}
		$( this ).css({'cursor': 'pointer'});
		$( this ).click( toggleNav );
	} );
}
 
function minimize( target ) {
	var id = $( target ).parent().attr( 'id' );
	// You can change the expires parameter to save the cookie longer/shorter than 7 days like in this code
	$.cookie( expandCookieName + id, 'false', { expires: 7} );
	var str = labels[id] + '  ►';
	$( target ).next( 'div' ).animate({'height': '0px'});
	$( target ).html( str );
}
 
function maximize( target ) {
	var id = $( target ).parent().attr( 'id' );
	// You can change the expires parameter to save the cookie longer/shorter than 7 days like in this code
	$.cookie( expandCookieName + id, 'true', { expires: 7} );
	var str = labels[id] + '  ▼';
	var newHeight = maxHeights[id];
	$( target ).next( 'div' ).animate({'height': newHeight + 'px'});
	$( target ).html( str );
}
 
function toggleNav( e ) {
	var id = $(e.target ).parent().attr( 'id' );
	expandeds[id] = !expandeds[id];
	if( expandeds[id] == true ) {
		maximize( e.target );
	} else {
		minimize( e.target );
	}
}
 
///////////////////////////////////////////////////////
///////////////////////////////////////////////////////