User:Tarap/common.js

mw.loader.using('mediawiki.util', function {

/********************** * auteur : Zaran **********************/

function SetCookie(name,value) { document.cookie = name + "=" + escape(value); } function GetCookie(name) { var i =0; while (i < document.cookie.length) { if (document.cookie.substr(i,name.length) == name) { var valend = document.cookie.indexOf(";",i+name.length+1); if (valend == -1) { valend = document.cookie.length; }                       return unescape(document.cookie.substring(i+name.length+1,valend)); }               i = document.cookie.indexOf(" ", i) + 1; if (i == 0) break; } }

function showPanel(animated) { var skin = mw.config.get('skin'); var content = $('#content'); if ( skin == 'vector' ) { if ( animated) { content.animate({'margin-left':content.data('margin')},function{$("#mw-panel").show;}); $("#left-navigation").animate({'left': content.data('margin')}); }   else { content.css('margin-left', content.data('margin') ); $("#mw-panel").show; $("#left-navigation").css('left', content.data('margin') ); } }  else if ( skin == 'monobook' ) { if ( animated) { content.animate({'margin-left':content.data('margin')}, function {content.css('z-index', '2');}); }   else { content.css('margin-left', content.data('margin') ); content.css('z-index', '2'); } } } function hidePanel(animated) { var skin = mw.config.get('skin'); var content = $('#content'); if ( skin == 'vector' ) { $("#mw-panel").hide; if ( animated ) { content.animate({'margin-left':'0px'}); $("#left-navigation").animate({'left':'0px'}); }   else { content.css('margin-left', '0px'); $("#left-navigation").css('left', '0px'); } }  else if ( skin == 'monobook' ) { content.css('z-index', '4'); if ( animated ) { content.animate({'margin-left':'0px'}); }   else { content.css('margin-left', '0px'); } } } function hidePanelCookie(animated) { hidePanel(animated); $("#panel-collapse").find("a").text("Afficher"); $("#panel-collapse").find("a").unbind("click"); $("#panel-collapse").find("a").click( function( e ) {   e.preventDefault;    showPanelCookie(true);  }); SetCookie("hidepanel", "true"); } function showPanelCookie(animated) { showPanel(animated); $("#panel-collapse").find("a").text("Masquer"); $("#panel-collapse").find("a").unbind("click"); $("#panel-collapse").find("a").click( function( e ) {   e.preventDefault;    hidePanelCookie(true);  }); SetCookie("hidepanel", "false"); } jQuery( function ( $ ) { var content = $('#content');  content.data('margin', content.css('margin-left'));  var collapseLink = mw.util.addPortletLink( "p-personal", "#" , "Masquer", "panel-collapse", "Afficher/Masquer le menu latéral", "", "#pt-userpage");  var hide = GetCookie("hidepanel");  if ( hide == "true") {    hidePanelCookie(false);  }  else {    $("#panel-collapse").find("a").click( function( e ) { e.preventDefault; hidePanelCookie(true); }); } });

});