Përdoruesi:Euriditi/Gadget-ZoomOnThumb.js

Nga Wikipedia, enciklopedia e lirë

Shënim: Pas ruajtjes së parapëlqimeve ose kryerjes së ndryshimet, për t'ju shfaqur dallimet duhet të pastroni ruajtësin (cache) e shfletuesit. Pastrimi i ruajtësit të shfletuesve bëhet duke shtypur në të njëjten kohë Ctrl+Shift+Reload për Mozilla/Safari/Konqueror ose ctrl+shift+r për IE ose Ctrl+f5 për Opera: F5.

// Permet de zoomer une image ("thumb" ou galerie) au survol de la souris ou au focus du clavier

// Documentation : [[Projet:JavaScript/Notices/ZoomOnThumb]]

// {{Catégorisation JS|ZoomOnThumb}}

//<source lang=javascript>
//<pre><nowiki>
////////////////////////////////////////////////////////////// VARIABLES PERSONNALISABLES //////////////////////////////////////////
 

////  Images thumb  ////
 
// délai avant zoom en millisecondes
if(typeof(ZoomOnThumb_Delay)=="undefined") var ZoomOnThumb_Delay = 200;
// délai entre deux étapes d'agrandissement en millisecondes
if(typeof(ZoomOnThumb_TimeOut)=="undefined") var ZoomOnThumb_TimeOut = 50;
// multiplicateur de grossissement max
if(typeof(ZoomOnThumb_MaxMultiplicator)=="undefined") var ZoomOnThumb_MaxMultiplicator = 3;  
 

////  Images galeries  //// 

// délai avant zoom en millisecondes
if(typeof(ZoomOnGallery_Delay)=="undefined") var ZoomOnGallery_Delay = 200;
// délai entre deux étapes d'agrandissement en millisecondes
if(typeof(ZoomOnGallery_TimeOut)=="undefined") var ZoomOnGallery_TimeOut = 50;
// pourcentage d'agrandissement entre deux étapes
if(typeof(ZoomOnGallery_ZoomFactor)=="undefined") var ZoomOnGallery_ZoomFactor = 4;
// multiplicateur de grossissement max
if(typeof(ZoomOnGallery_MaxMultiplicator)=="undefined") var ZoomOnGallery_MaxMultiplicator = 3;  
 
 
////  Vidéos thumb  ////
 
// activation
if(typeof(ZoomOnVideoThumb_Activated)=="undefined") var ZoomOnVideoThumb_Activated = false;
// délai en millisecondes
if(typeof(ZoomOnVideoThumb_TimeOut)=="undefined") var ZoomOnVideoThumb_TimeOut = 30;
// multiplicateur de grossissement max
if(typeof(ZoomOnVideoThumb_MaxMultiplicator)=="undefined") var ZoomOnVideoThumb_MaxMultiplicator = 3;  
// zoom automatique au début de la lecture
if(typeof(ZoomOnVideoThumb_AutoZoom)=="undefined") var ZoomOnVideoThumb_AutoZoom = false;  


////  Vidéos galeries  ////

// activation
if(typeof(ZoomOnVideoGallery_Activated)=="undefined") var ZoomOnVideoGallery_Activated = false;
// délai en millisecondes
if(typeof(ZoomOnVideoGallery_TimeOut)=="undefined") var ZoomOnVideoGallery_TimeOut = 30;
// multiplicateur de grossissement max
if(typeof(ZoomOnVideoGallery_MaxMultiplicator)=="undefined") var ZoomOnVideoGallery_MaxMultiplicator = 3;  
// zoom automatique au début de la lecture
if(typeof(ZoomOnVideoGallery_AutoZoom)=="undefined") var ZoomOnVideoGallery_AutoZoom = false;  


////////////////////////////////////////////////////////////// FONCTIONS //////////////////////////////////////////


// --------------------------------------------------- IMAGES THUMB -----------------------------------------------------------------
 
/* VARIABLES */
var ZoomOnThumb_LinkOnImage = new Array();                 // Liste des liens "image"
var ZoomOnThumb_LinkOnImageState = new Array();            // État de zoom : 1 = zoom avant, -1 = zoom arrière, 0 = taille normale
var ZoomOnThumb_LinkOnImageOriginalWidth = new Array();    // Largeur originale de l'image
var ZoomOnThumb_LinkOnImageOriginalHeight = new Array();   // Hauteur originale de l'image
var ZoomOnThumb_LinkOnImageOriginalTarget = new Array();   // Cible originale de l'image (basse résolution)
var ZoomOnThumb_LinkOnImageZoomedTarget = new Array();     // Cible zoomée de l'image (haute résolution)
 
/* LANCEMENT */
$(ZoomOnThumb_CheckLinks);
 
/* ÉTABLISSEMENT DE LA LISTE DES LIENS "IMAGE" */
function ZoomOnThumb_CheckLinks(){
     var Divs = document.getElementsByTagName('div');
     for(var a=0;a<Divs.length;a++){
          if(hasClass(Divs[a],"thumbinner")){
               var DivThumb = Divs[a];
               var Parent = DivThumb.parentNode;
               while(Parent){
                    if(Parent.className && (Parent.className.indexOf("infobox")!=-1 || Parent.className.indexOf("noZoom")!=-1)) break;
                    Parent = Parent.parentNode;
               }
               if(Parent) continue;
               addClass(DivThumb, "nopopups");
               var Links = DivThumb.getElementsByTagName('a');
               var LinkOnImage = Links[0];
               if(LinkOnImage){
                    while(LinkOnImage.className != "image"){
                         LinkOnImage = LinkOnImage.nextSibling;
                         if(!LinkOnImage) break;
                    }
               }
               if(LinkOnImage){
                    var Extension = LinkOnImage.href.replace(/.*\./,"").toLowerCase();
                    if((Extension!='ogg')&&(Extension!='ogv')&&(Extension!='pdf')){
                         ZoomOnThumb_LinkOnImage.push(LinkOnImage); 
                    }
               }              
          }
     }
     ZoomOnThumb_ModifyLinks();
}
 
/* TRANSFORMATION DES LIENS, MISE A JOUR VARIABLES */
function ZoomOnThumb_ModifyLinks(){
     for(var b=0;b<ZoomOnThumb_LinkOnImage.length;b++){
          var ThisLink = ZoomOnThumb_LinkOnImage[b];
          ThisLink.id = "ZoomLink_" +b;
          ThisLink.onmouseover = function(){
               var ID = parseInt(this.id.split('ZoomLink_').join(''));
               ZoomOnThumb_LinkOnImageState[ID] = 1; 
               ZoomOnThumb_ReplaceSrc(ID);
               setTimeout("ZoomOnThumb_ZoomIn("+ID+");", ZoomOnThumb_Delay);
          }
          ThisLink.onfocus = function(){
               var ID = parseInt(this.id.split('ZoomLink_').join(''));
               ZoomOnThumb_LinkOnImageState[ID] = 1; 
               ZoomOnThumb_ReplaceSrc(ID);
               setTimeout("ZoomOnThumb_ZoomIn("+ID+");", ZoomOnThumb_Delay);
          }
          ThisLink.onmouseout = function(){
               var ID = parseInt(this.id.split('ZoomLink_').join(''));
               ZoomOnThumb_LinkOnImageState[ID] = -1; 
               ZoomOnThumb_ZoomOut(ID);
          }
          ThisLink.onblur = function(){
               var ID = parseInt(this.id.split('ZoomLink_').join(''));
               ZoomOnThumb_LinkOnImageState[ID] = -1; 
               ZoomOnThumb_ZoomOut(ID);
          }
          var ThisDiv = ThisLink.parentNode;
          ThisDiv.id = "ZoomDiv_" +b;
          var ThisImage = ThisLink.getElementsByTagName('img')[0];
          ThisImage.id = "ZoomImage_" +b;
          ZoomOnThumb_LinkOnImageOriginalWidth[b] = ThisImage.width;
          ZoomOnThumb_LinkOnImageOriginalHeight[b] = ThisImage.height;
          ZoomOnThumb_LinkOnImageOriginalTarget[b] = ThisImage.src;
          ZoomOnThumb_LinkOnImageState[b] = 0;
     }
}
 
/* ZOOM AVANT */
function ZoomOnThumb_ZoomIn(ID){
     if(ZoomOnThumb_LinkOnImageState[ID]!= 1) return;
 
     var Image = document.getElementById('ZoomImage_'+ID);
     var Div = document.getElementById('ZoomDiv_'+ID);
     if((!Image)||(!Div)) return; 
 
     var ImageWidth = parseInt(Image.width);
     var ImageHeight = parseInt(Image.height);
 
     var Content = document.getElementById("bodyContent");
     if(!Content) Content = document.getElementById("mw_contentholder");
     if(!Content) Content = document.getElementById("article");
     var ContentWidth = (parseInt(Content.offsetWidth) - 30);

     if(ImageWidth<(ZoomOnThumb_LinkOnImageOriginalWidth[ID]*ZoomOnThumb_MaxMultiplicator)){
          var NewImageWidth = parseInt(ImageWidth * 1.05);
          var NewImageHeight = parseInt(ImageHeight * 1.05);
          if(NewImageWidth>ContentWidth) return;
          Image.width = NewImageWidth;
          Image.height = NewImageHeight;
          Div.style.width = (2+NewImageWidth) + 'px';
          setTimeout("ZoomOnThumb_ZoomIn("+ID+");", ZoomOnThumb_TimeOut);
     }
}
 
/* ZOOM ARRIÈRE */
function ZoomOnThumb_ZoomOut(ID){
     if(ZoomOnThumb_LinkOnImageState[ID]!= -1) return;
 
     var Image = document.getElementById('ZoomImage_'+ID);
     var Div = document.getElementById('ZoomDiv_'+ID);
     if((!Image)||(!Div)) return;
 
     var ImageWidth = parseInt(Image.width);
     var ImageHeight = parseInt(Image.height);
 
     if(ImageWidth>ZoomOnThumb_LinkOnImageOriginalWidth[ID]){
          var NewImageWidth = parseInt(ImageWidth * 0.8);
          var NewImageHeight = parseInt(ImageHeight * 0.8);
          if(NewImageWidth<ZoomOnThumb_LinkOnImageOriginalWidth[ID]){
               NewImageWidth = ZoomOnThumb_LinkOnImageOriginalWidth[ID];
               NewImageHeight = ZoomOnThumb_LinkOnImageOriginalHeight[ID];
               Image.src = ZoomOnThumb_LinkOnImageOriginalTarget[ID];
               ZoomOnThumb_LinkOnImageState[ID] = 0;
          }
          Image.width = NewImageWidth;
          Image.height = NewImageHeight;
          Div.style.width = (2+NewImageWidth) + 'px';
          setTimeout("ZoomOnThumb_ZoomOut("+ID+");", ZoomOnThumb_TimeOut);
     }
}
 
/* RECHERCHE CIBLE DE L'IMAGE EN HAUTE RÉSOLUTION */
function ZoomOnThumb_ReplaceSrc(ID){
     var Image = document.getElementById('ZoomImage_'+ID);
     var Link = document.getElementById('ZoomLink_'+ID);
     if((!Image)||(!Link)) return; 
     if(ZoomOnThumb_LinkOnImageZoomedTarget[ID]){
          Image.src = ZoomOnThumb_LinkOnImageZoomedTarget[ID];
          return;
     }
     var Cible = wgFormattedNamespaces[6] + ':' + Link.href.split(wgFormattedNamespaces[6] + ':')[1];
     var AdresseRequete = mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/api.php?format=xml&action=query&prop=imageinfo&iiprop=url&iiurlwidth='+(ZoomOnThumb_LinkOnImageOriginalWidth[ID]*ZoomOnThumb_MaxMultiplicator)+'&titles=' + Cible.replace(/&/g, "%26");
     var NouvelleRequete = sajax_init_object();
     NouvelleRequete.open("GET", AdresseRequete, true);
     NouvelleRequete.onreadystatechange = function() {
          if(NouvelleRequete.readyState != 4 || NouvelleRequete.status != 200) return;
          var ObjetXML = NouvelleRequete.responseXML; 
          if(!ObjetXML) return;
          var Info = ObjetXML.getElementsByTagName('ii')[0];
          if(Info){ 
               var NewSrcImage = Info.getAttribute("thumburl");
               ZoomOnThumb_LinkOnImageZoomedTarget[ID] = NewSrcImage;
               if(ZoomOnThumb_LinkOnImageState[ID]!= 1) return;
               Image.src = NewSrcImage;
          }
     }
     NouvelleRequete.send(null);
}
 
// --------------------------------------------------- IMAGES GALERIES ---------------------------------------------------------------
 
/* VARIABLES */
var ZoomOnGallery_LinkOnImage = new Array();                 // Liste des liens "image"
var ZoomOnGallery_LinkOnImageState = new Array();            // État de zoom : 1 = zoom avant, -1 = zoom arrière, 0 = taille normale
var ZoomOnGallery_LinkOnImageOriginalWidth = new Array();    // Largeur originale de l'image
var ZoomOnGallery_LinkOnImageOriginalHeight = new Array();   // Hauteur originale de l'image
var ZoomOnGallery_LinkOnImageOriginalTarget = new Array();   // Cible originale de l'image (basse résolution)
var ZoomOnGallery_LinkOnImageZoomedTarget = new Array();     // Cible zoomée de l'image (haute résolution)


/* LANCEMENT */
$(ZoomOnGallery_CheckLinks);
 
/* ÉTABLISSEMENT DE LA LISTE DES LIENS "IMAGE" */
function ZoomOnGallery_CheckLinks(){
     var Divs = document.getElementsByTagName('li');
     for(var a=0;a<Divs.length;a++){
          if(hasClass(Divs[a],"gallerybox")){
               var DivGallery = Divs[a];
               addClass(DivGallery, "nopopups");
               var Links = DivGallery.getElementsByTagName('a');
               var LinkOnImage = Links[0];
               if(LinkOnImage){
                    while(LinkOnImage.className != "image"){
                         LinkOnImage = LinkOnImage.nextSibling;
                         if(!LinkOnImage) break;
                    }
               }
               if(LinkOnImage){
                    var Extension = LinkOnImage.href.replace(/.*\./,"").toLowerCase();
                    if((Extension!='ogg')&&(Extension!='ogv')&&(Extension!='pdf')){
                         ZoomOnGallery_LinkOnImage.push(LinkOnImage); 
                    }
               } 
          }
     }
     ZoomOnGallery_ModifyLinks();
}
 
/* TRANSFORMATION DES LIENS, MISE A JOUR VARIABLES */
function ZoomOnGallery_ModifyLinks(){
     for(var b=0;b<ZoomOnGallery_LinkOnImage.length;b++){
          var ThisLink = ZoomOnGallery_LinkOnImage[b];
          ThisLink.id = "ZoomLink_" +(b+1000); 
          ThisLink.onmouseover = function(){
               var ID = parseInt(this.id.split('ZoomLink_').join(''));
               ZoomOnGallery_LinkOnImageState[ID] = 1; 
               ZoomOnGallery_ReplaceSrc(ID);
               setTimeout("ZoomOnGallery_ZoomIn("+ID+");", ZoomOnGallery_Delay);
          }
          ThisLink.onfocus = function(){
               var ID = parseInt(this.id.split('ZoomLink_').join(''));
               ZoomOnGallery_LinkOnImageState[ID] = 1; 
               ZoomOnGallery_ReplaceSrc(ID);
               setTimeout("ZoomOnGallery_ZoomIn("+ID+");", ZoomOnGallery_Delay);
          }
          ThisLink.onmouseout = function(){
               var ID = parseInt(this.id.split('ZoomLink_').join(''));
               ZoomOnGallery_LinkOnImageState[ID] = -1; 
               ZoomOnGallery_ZoomOut(ID);
          }
          ThisLink.onblur = function(){
               var ID = parseInt(this.id.split('ZoomLink_').join(''));
               ZoomOnGallery_LinkOnImageState[ID] = -1; 
               ZoomOnGallery_ZoomOut(ID);
          } 
          var ThisDiv1 = ThisLink.parentNode;
          ThisDiv1.id = "ZoomDiv1_" +(b+1000);
          var ThisThumb = ThisDiv1.parentNode;
          ThisThumb.id = "ZoomThumb_" +(b+1000);
          var ThisDiv2 = ThisThumb.parentNode;
          ThisDiv2.id = "ZoomDiv2_" +(b+1000);
          var ThisGalleryBox = ThisDiv2.parentNode;
          ThisGalleryBox.id = "ZoomGalleryBox_" +(b+1000);
          var ThisImage = ThisLink.getElementsByTagName('img')[0];
          ThisImage.id = "ZoomImage_" +(b+1000);
          ZoomOnGallery_LinkOnImageOriginalWidth[(b+1000)] = ThisImage.width;
          ZoomOnGallery_LinkOnImageOriginalHeight[(b+1000)] = ThisImage.height;
          ZoomOnGallery_LinkOnImageOriginalTarget[(b+1000)] = ThisImage.src;
          ZoomOnGallery_LinkOnImageState[(b+1000)] = 0;
     }
}
 
/* ZOOM AVANT */
function ZoomOnGallery_ZoomIn(ID){
     if(ZoomOnGallery_LinkOnImageState[ID]!= 1) return;
 
     var Image = document.getElementById('ZoomImage_'+ID);
     var Div1 = document.getElementById('ZoomDiv1_'+ID);
     var Thumb = document.getElementById('ZoomThumb_'+ID);
     var Div2 = document.getElementById('ZoomDiv2_'+ID);
     var GalleryBox = document.getElementById('ZoomGalleryBox_'+ID);
     if((!Image)||(!Div1)||(!Thumb)||(!Div2)||(!GalleryBox)) return;
 
     var ImageWidth = parseInt(Image.width);
     var ImageHeight = parseInt(Image.height);

     var Content = document.getElementById("bodyContent");
     if(!Content) Content = document.getElementById("mw_contentholder");
     if(!Content) Content = document.getElementById("article");
     var ContentWidth = (parseInt(Content.offsetWidth) - 30);
     var Factor = (100+ZoomOnGallery_ZoomFactor)/100;

     var MaxWidth = (parseInt(ZoomOnGallery_LinkOnImageOriginalWidth[ID])*parseInt(ZoomOnGallery_MaxMultiplicator));
     if(ImageWidth<MaxWidth){
          var NewImageWidth = parseInt(ImageWidth * Factor);
          var NewImageHeight = parseInt(ImageHeight * Factor);
          if(NewImageWidth>ContentWidth) return;
          var MaxSize = NewImageWidth;
          if(ImageHeight>NewImageWidth) MaxSize = NewImageHeight;
          Image.width = NewImageWidth;
          Image.height = NewImageHeight;
          Div1.style.width = NewImageWidth + 'px';
          Thumb.style.width = Math.floor( MaxSize+30 ) + 'px';
          Thumb.style.height = Math.floor( MaxSize+30 ) + 'px';
          Div2.style.width = Math.floor( MaxSize+35 ) + 'px';
          GalleryBox.style.width = Math.floor( MaxSize+35 ) + 'px';
          setTimeout("ZoomOnGallery_ZoomIn("+ID+");", ZoomOnGallery_TimeOut);
     }
}
 
function ZoomOnGallery_GetWidth(Node){
     return parseInt(Node.style.width.split("px").join(""));
}
function ZoomOnGallery_GetHeight(Node){
     return parseInt(Node.style.height.split("px").join(""));
}

/* ZOOM ARRIÈRE */
function ZoomOnGallery_ZoomOut(ID){
     if(ZoomOnGallery_LinkOnImageState[ID]!= -1) return;
 
     var Image = document.getElementById('ZoomImage_'+ID);
     var Div1 = document.getElementById('ZoomDiv1_'+ID);
     var Thumb = document.getElementById('ZoomThumb_'+ID);
     var Div2 = document.getElementById('ZoomDiv2_'+ID);
     var GalleryBox = document.getElementById('ZoomGalleryBox_'+ID);
     if((!Image)||(!Div1)||(!Thumb)||(!Div2)||(!GalleryBox)) return;
 
     var ImageWidth = parseInt(Image.width);
     var ImageHeight = parseInt(Image.height);
     var MinWidth = ZoomOnGallery_LinkOnImageOriginalWidth[ID];
     var Factor = 0.8;
     if(ImageWidth>MinWidth){
          var NewImageWidth = parseInt(ImageWidth * Factor);
          var NewImageHeight = parseInt(ImageHeight * Factor);
          if(NewImageWidth<MinWidth){
               Factor = 0.9;
               NewImageWidth = parseInt(ImageWidth * Factor);
               NewImageHeight = parseInt(ImageHeight * Factor);
               if(NewImageWidth<MinWidth){
                    Factor = 0.95;
                    NewImageWidth = parseInt(ImageWidth * Factor);
                    NewImageHeight = parseInt(ImageHeight * Factor);
                    if(NewImageWidth<MinWidth){
                         NewImageWidth = ZoomOnGallery_LinkOnImageOriginalWidth[ID];
                         NewImageHeight = ZoomOnGallery_LinkOnImageOriginalHeight[ID];
                         Image.src = ZoomOnGallery_LinkOnImageOriginalTarget[ID];
                         ZoomOnGallery_LinkOnImageState[ID] = 0;
                         return;
                    }
               }
          }
          var MaxSize = NewImageWidth;
          if(ImageHeight>NewImageWidth) MaxSize = NewImageHeight;
          Image.width = NewImageWidth;
          Image.height = NewImageHeight;
          Image.width = NewImageWidth;
          Image.height = NewImageHeight;
          Div1.style.width = NewImageWidth + 'px';
          Thumb.style.width = (MaxSize+30) + 'px';
          Thumb.style.height = (MaxSize+30) + 'px';
          Div2.style.width = (MaxSize+35) + 'px';
          GalleryBox.style.width = (MaxSize+35) + 'px';
          setTimeout("ZoomOnGallery_ZoomOut("+ID+");", ZoomOnGallery_TimeOut);
     }
}
 
/* RECHERCHE CIBLE DE L'IMAGE EN HAUTE RÉSOLUTION */
function ZoomOnGallery_ReplaceSrc(ID){
     var Image = document.getElementById('ZoomImage_'+ID);
     var Link = document.getElementById('ZoomLink_'+ID);
     if((!Image)||(!Link)) return;
     if(ZoomOnGallery_LinkOnImageZoomedTarget[ID]){
          Image.src = ZoomOnGallery_LinkOnImageZoomedTarget[ID];
          return;
     }
     var Cible = wgFormattedNamespaces[6] + ':' + Link.href.split(wgFormattedNamespaces[6] + ':')[1];
     var AdresseRequete = mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/api.php?format=xml&action=query&prop=imageinfo&iiprop=url&iiurlwidth='+(ZoomOnGallery_LinkOnImageOriginalWidth[ID]*ZoomOnGallery_MaxMultiplicator)+'&titles=' + Cible.replace(/&/g, "%26");
     var NouvelleRequete = sajax_init_object();
     NouvelleRequete.open("GET", AdresseRequete, true);
     NouvelleRequete.onreadystatechange = function() {
          if(NouvelleRequete.readyState != 4 || NouvelleRequete.status != 200) return;
          var ObjetXML = NouvelleRequete.responseXML; 
          if(!ObjetXML) return;
          var Info = ObjetXML.getElementsByTagName('ii')[0];
          if(Info){ 
               var NewSrcImage = Info.getAttribute("thumburl");
               ZoomOnGallery_LinkOnImageZoomedTarget[ID] = NewSrcImage;
               if(ZoomOnGallery_LinkOnImageState[ID]!= 1) return;
               Image.src = NewSrcImage;
          }
     }
     NouvelleRequete.send(null);
}


// --------------------------------------------------- VIDEOS THUMB ---------------------------------------------------------------

/* VARIABLES */
var ZoomOnVideoThumb_Divs = new Array();            // Liste des vidéos
var ZoomOnVideoThumb_OriginalWidth = new Array();   // Largeur originale
var ZoomOnVideoThumb_OriginalHeight = new Array();  // Hauteur originale


/* LANCEMENT */
if(ZoomOnVideoThumb_Activated) addOnloadHook(ZoomOnVideoThumb_CheckVideos);

/* ÉTABLISSEMENT DE LA LISTE DES LIENS "VIDEO" */
function ZoomOnVideoThumb_CheckVideos(){
     var Divs = document.getElementsByTagName('div');
     var Index = 0;
     var ThisDiv = Divs[Index];
     while(ThisDiv){
          var ThisDivId = ThisDiv.id;
          if(ThisDivId){
               if(ThisDivId.indexOf('ogg_player_')!=-1){
                    if(hasClass(ThisDiv.parentNode, "thumbinner"))
                    var GoodDiv = ThisDiv;
                    var Parent = GoodDiv.parentNode;
                    while(Parent){
                         if(Parent.className && Parent.className.indexOf("infobox")!=-1) break;
                         Parent = Parent.parentNode;
                    }
                    if(!Parent) ZoomOnVideoThumb_Divs.push(ThisDiv);
               }
          }
          Index++
          ThisDiv = Divs[Index];
    }
    ZoomOnVideoThumb_ModifyInputs();
}

/* MODIFICATION DES BOUTONS */
function ZoomOnVideoThumb_ModifyInputs(){
    for(var a=0;a<ZoomOnVideoThumb_Divs.length;a++){
        var ID = ZoomOnVideoThumb_Divs[a].id;
        var IDIndex = ID.split('ogg_player_').join('');
        var Button = ZoomOnVideoThumb_Divs[a].getElementsByTagName('button')[0];
        var NewButtonOnclick = Button.onclick.toString();
        if(NewButtonOnclick.indexOf('false});')!=-1) continue; // pas une vidéo
        NewButtonOnclick = NewButtonOnclick.replace(/"/g,"'");
        NewButtonOnclick = "if(typeof(wgOggPlayer)!='undefined') { wgOggPlayer.init" + NewButtonOnclick.split('wgOggPlayer.init')[1];
        NewButtonOnclick = NewButtonOnclick.split('true});')[0] + 'true});';
        Button.style.display = 'none';

        NewButtonOnclick += ' ZoomOnVideoThumb_AddZoomLinks(\''+IDIndex+'\');'
        if(ZoomOnVideoThumb_AutoZoom) NewButtonOnclick += ' ZoomOnVideoThumb_ZoomIn(\''+IDIndex+'\');';
        NewButtonOnclick += '}';
        var NewHTML = '<button title="'+Button.title+'" style="width:'+Button.style.width+'" onclick="'+NewButtonOnclick+'">'+Button.innerHTML+'</button>';

        Button.parentNode.innerHTML = NewHTML + Button.parentNode.innerHTML;
        ZoomOnVideoThumb_Divs[a].parentNode.id = "thumbinnerVideo_"+IDIndex;        
    }
}

/* AJOUT DES LIENS DE ZOOM */
function ZoomOnVideoThumb_AddZoomLinks(Index){
    var VideoOptions = document.getElementById('ogg_player_'+Index+'_options_box');
    if(!VideoOptions) return;

    var ZoomOptionsDiv = document.createElement('div');
    ZoomOptionsDiv.id = 'ogg_player_ZoomOptions_' + Index;
    var ZoomLinks = '<center>'
                  + '<a href="javascript:ZoomOnVideoThumb_ZoomIn('+Index+');" title="Agrandir la vidéo">(+)</a>'
                  + ' '
                  + '<a href="javascript:ZoomOnVideoThumb_ZoomOut('+Index+');" title="Réduire la vidéo">(-)</a>'
                  + '</center>';
    ZoomOptionsDiv.innerHTML = ZoomLinks;
    VideoOptions.parentNode.insertBefore(ZoomOptionsDiv, VideoOptions);
}

/* ZOOM AVANT */
function ZoomOnVideoThumb_ZoomIn(Index){
    var VideoThumbinner = document.getElementById("thumbinnerVideo_"+Index);
    var VideoPlayer = document.getElementById("ogg_player_"+Index);
    var Video = document.getElementById("ogg_player_"+Index+"_obj");
    if((!VideoThumbinner)||(!VideoPlayer)||(!Video)) return;

    var VideoWidth = Video.width;
    if(!ZoomOnVideoThumb_OriginalWidth[Index]) ZoomOnVideoThumb_OriginalWidth[Index] = VideoWidth;
    var VideoHeight= Video.height;
    if(!ZoomOnVideoThumb_OriginalHeight[Index]) ZoomOnVideoThumb_OriginalHeight[Index] = VideoHeight;
    var Content = document.getElementById("bodyContent");
    if(!Content) Content = document.getElementById("mw_contentholder");
    if(!Content) Content = document.getElementById("article");
    var ContentWidth = (parseInt(Content.offsetWidth) - 30);

    var MaxWidth = (ZoomOnVideoThumb_OriginalWidth[Index]*ZoomOnVideoThumb_MaxMultiplicator)
    if(VideoWidth<MaxWidth){
        var NewWidth = parseInt(VideoWidth*1.1);
        var NewHeight = parseInt(VideoHeight*1.1);
        if(NewWidth>ContentWidth) return;
        Video.width = NewWidth;
        Video.height = NewHeight;
        VideoPlayer.style.width = NewWidth + 'px';
        VideoThumbinner.style.width = (NewWidth+2) + 'px';
        setTimeout("ZoomOnVideoThumb_ZoomIn("+Index+");", ZoomOnVideoThumb_TimeOut);
    }
}

/* ZOOM ARRIÈRE */
function ZoomOnVideoThumb_ZoomOut(Index){
    var VideoThumbinner = document.getElementById("thumbinnerVideo_"+Index);
    var VideoPlayer = document.getElementById("ogg_player_"+Index);
    var Video = document.getElementById("ogg_player_"+Index+"_obj");
    if((!VideoThumbinner)||(!VideoPlayer)||(!Video)) return;

    var VideoWidth = Video.width;
    var VideoHeight= Video.height;
    var MinWidth = ZoomOnVideoThumb_OriginalWidth[Index];

    if(VideoWidth>MinWidth){
        var NewWidth = parseInt(VideoWidth*0.8);
        var NewHeight = parseInt(VideoHeight*0.8);
        if(NewWidth<MinWidth){
            NewWidth = ZoomOnVideoThumb_OriginalWidth[Index];
            NewHeight = ZoomOnVideoThumb_OriginalHeight[Index];
        }
        Video.width = NewWidth;
        Video.height = NewHeight;
        VideoPlayer.style.width = NewWidth + 'px';
        VideoThumbinner.style.width = (NewWidth+2) + 'px';
        setTimeout("ZoomOnVideoThumb_ZoomOut("+Index+");", ZoomOnVideoThumb_TimeOut);
    }
}

// --------------------------------------------------- VIDEOS GALERIES ---------------------------------------------------------------

/* VARIABLES */
var ZoomOnVideoGallery_Divs = new Array();            // Liste des vidéos
var ZoomOnVideoGallery_OriginalWidth = new Array();   // Largeur originale
var ZoomOnVideoGallery_OriginalHeight = new Array();  // Hauteur originale


/* LANCEMENT */
if(ZoomOnVideoGallery_Activated) addOnloadHook(ZoomOnVideoGallery_CheckVideos);

/* ÉTABLISSEMENT DE LA LISTE DES LIENS "VIDEO" */
function ZoomOnVideoGallery_CheckVideos(){
     var Divs = document.getElementsByTagName('div');
     var Index = 0;
     var ThisDiv = Divs[Index];
     while(ThisDiv){
          var ThisDivId = ThisDiv.id;
          if(ThisDivId){
               if(ThisDivId.indexOf('ogg_player_')!=-1){
                    if(hasClass(ThisDiv.parentNode.parentNode.parentNode, "gallerybox")) ZoomOnVideoGallery_Divs.push(ThisDiv);
               }
          }
          Index++
          ThisDiv = Divs[Index];
    }
    ZoomOnVideoGallery_ModifyInputs();
}

/* MODIFICATION DES BOUTONS */
function ZoomOnVideoGallery_ModifyInputs(){
    for(var a=0;a<ZoomOnVideoGallery_Divs.length;a++){
        var ID = ZoomOnVideoGallery_Divs[a].id;
        var IDIndex = ID.split('ogg_player_').join('');
        var Button = ZoomOnVideoGallery_Divs[a].getElementsByTagName('button')[0];
        var NewButtonOnclick = Button.onclick.toString();
        if(NewButtonOnclick.indexOf('false});')!=-1) continue; // pas une vidéo
        NewButtonOnclick = NewButtonOnclick.replace(/"/g,"'");
        NewButtonOnclick = "if(typeof(wgOggPlayer)!='undefined') { wgOggPlayer.init" + NewButtonOnclick.split('wgOggPlayer.init')[1];
        NewButtonOnclick = NewButtonOnclick.split('true});')[0] + 'true});';
        Button.style.display = 'none';

        NewButtonOnclick += ' ZoomOnVideoGallery_AddZoomLinks(\''+IDIndex+'\');'
        if(ZoomOnVideoGallery_AutoZoom) NewButtonOnclick += ' ZoomOnVideoGallery_ZoomIn(\''+IDIndex+'\');';
        NewButtonOnclick += '}';
        var NewHTML = '<button title="'+Button.title+'" style="width:'+Button.style.width+'" onclick="'+NewButtonOnclick+'">'+Button.innerHTML+'</button>';

        Button.parentNode.innerHTML = NewHTML + Button.parentNode.innerHTML;
        ZoomOnVideoGallery_Divs[a].parentNode.id = "VideoDiv_"+IDIndex;    
        ZoomOnVideoGallery_Divs[a].parentNode.parentNode.id = "VideoThumb_"+IDIndex;  
        ZoomOnVideoGallery_Divs[a].parentNode.parentNode.parentNode.id = "VideoGalleryBox_"+IDIndex;           
    }
}

/* AJOUT DES LIENS DE ZOOM */
function ZoomOnVideoGallery_AddZoomLinks(Index){
    var VideoOptions = document.getElementById('ogg_player_'+Index+'_options_box');
    if(!VideoOptions) return;

    var ZoomOptionsDiv = document.createElement('div');
    ZoomOptionsDiv.id = 'ogg_player_ZoomOptions_' + Index;
    var ZoomLinks = '<center>'
                  + '<a href="javascript:ZoomOnVideoGallery_ZoomIn('+Index+');" title="Agrandir la vidéo">(+)</a>'
                  + ' '
                  + '<a href="javascript:ZoomOnVideoGallery_ZoomOut('+Index+');" title="Réduire la vidéo">(-)</a>'
                  + '</center>';
    ZoomOptionsDiv.innerHTML = ZoomLinks;
    VideoOptions.parentNode.insertBefore(ZoomOptionsDiv, VideoOptions);
}

/* ZOOM AVANT */
function ZoomOnVideoGallery_ZoomIn(Index){
    var VideoGalleryBox = document.getElementById("VideoGalleryBox_"+Index);
    var VideoThumb = document.getElementById("VideoThumb_"+Index);
    var VideoDiv = document.getElementById("VideoDiv_"+Index);
    var VideoPlayer = document.getElementById("ogg_player_"+Index);
    var Video = document.getElementById("ogg_player_"+Index+"_obj");
    if((!VideoGalleryBox)||(!VideoThumb)||(!VideoDiv)||(!VideoPlayer)||(!Video)) return;

    var VideoWidth = Video.width;
    if(!ZoomOnVideoGallery_OriginalWidth[Index]) ZoomOnVideoGallery_OriginalWidth[Index] = VideoWidth;
    var VideoHeight= Video.height;
    if(!ZoomOnVideoGallery_OriginalHeight[Index]) ZoomOnVideoGallery_OriginalHeight[Index] = VideoHeight;
    var Content = document.getElementById("bodyContent");
    if(!Content) Content = document.getElementById("mw_contentholder");
    if(!Content) Content = document.getElementById("article");
    var ContentWidth = (parseInt(Content.offsetWidth) - 30);

    var MaxWidth = (ZoomOnVideoGallery_OriginalWidth[Index]*ZoomOnVideoGallery_MaxMultiplicator)
    if(VideoWidth<MaxWidth){
        var NewWidth = parseInt(VideoWidth*1.1);
        var NewHeight = parseInt(VideoHeight*1.1);
        if(NewWidth>ContentWidth) return;
        Video.width = NewWidth;
        Video.height = NewHeight;
        VideoPlayer.style.width = NewWidth + 'px';
        VideoDiv.style.width = NewWidth + 'px';
        VideoThumb.style.width = (NewWidth+30) + 'px';
        VideoGalleryBox.style.width = (NewWidth+35) + 'px';
        setTimeout("ZoomOnVideoGallery_ZoomIn("+Index+");", ZoomOnVideoGallery_TimeOut);
    }
}

/* ZOOM ARRIÈRE */
function ZoomOnVideoGallery_ZoomOut(Index){
    var VideoGalleryBox = document.getElementById("VideoGalleryBox_"+Index);
    var VideoThumb = document.getElementById("VideoThumb_"+Index);
    var VideoDiv = document.getElementById("VideoDiv_"+Index);
    var VideoPlayer = document.getElementById("ogg_player_"+Index);
    var Video = document.getElementById("ogg_player_"+Index+"_obj");
    if((!VideoGalleryBox)||(!VideoThumb)||(!VideoDiv)||(!VideoPlayer)||(!Video)) return;

    var VideoWidth = Video.width;
    var VideoHeight= Video.height;
    var MinWidth = ZoomOnVideoGallery_OriginalWidth[Index];

    if(VideoWidth>MinWidth){
        var NewWidth = parseInt(VideoWidth*0.8);
        var NewHeight = parseInt(VideoHeight*0.8);
        if(NewWidth<MinWidth){
            NewWidth = ZoomOnVideoGallery_OriginalWidth[Index];
            NewHeight = ZoomOnVideoGallery_OriginalHeight[Index];
        }
        Video.width = NewWidth;
        Video.height = NewHeight;
        VideoPlayer.style.width = NewWidth + 'px';
        VideoDiv.style.width = NewWidth + 'px';
        VideoThumb.style.width = (NewWidth+30) + 'px';
        VideoGalleryBox.style.width = (NewWidth+35) + 'px';
        setTimeout("ZoomOnVideoGallery_ZoomOut("+Index+");", ZoomOnVideoGallery_TimeOut);
    }
}

///////////////////////////////////////////////////////////////////////////////////////////</nowiki></pre></source>


//</nowiki></pre>
//</source>