MediaWiki:Common.js: mudanças entre as edições

De otPokemon Wiki
Ir para navegação Ir para pesquisar
Sem resumo de edição
Sem resumo de edição
Linha 1: Linha 1:
/* Códigos JavaScript aqui colocados serão carregados por todos aqueles que acessarem alguma página deste wiki */
/* Códigos JavaScript aqui colocados serão carregados por todos aqueles que acessarem alguma página deste wiki */


$('document').ready(function() {
  var slideshow = document.getElementById('slideshow');
  var images = $('.image');
  var num_images = images.length;
  var bars = $('.bar');
  var titles = $('.image-title');
  var active = 0;
  var next;


var slideIndex = 1;
  function changeTitleToLeft(slide) {
showDivs(slideIndex);


function plusDivs(n) {
    $(titles[active]).addClass('slide-out-to-left');
  showDivs(slideIndex += n);
    $(titles[active]).one('animationend', function(e) {
}
      $(titles[active]).addClass('hidden');
      $(titles[active]).removeClass('slide-out-to-left');
      if ($(titles[active]).hasClass('slide-in-from-right')) {
        $(titles[active]).removeClass('slide-in-from-right');
      }
      else if ($(titles[active]).hasClass('slide-in-from-left')) {
        $(titles[active]).removeClass('slide-in-from-left');
      }
      $(titles[slide]).removeClass('hidden');
      $(titles[slide]).addClass('slide-in-from-right');
      active=slide;
    });


function showDivs(n) {
  var i;
  var x = document.getElementsByClassName("mySlides");
  if (n > x.length) {slideIndex = 1}
  if (n < 1) {slideIndex = x.length} ;
  for (i = 0; i < x.length; i++) {
    x[i].style.display = "none";
   }
   }
   x[slideIndex-1].style.display = "block";
 
}
 
  function changeTitleToRight(slide) {
 
    $(titles[active]).addClass('slide-out-to-right');
    $(titles[active]).one('animationend', function(e) {
      $(titles[active]).addClass('hidden');
      $(titles[active]).removeClass('slide-out-to-right');
      if ($(titles[active]).hasClass('slide-in-from-right')) {
        $(titles[active]).removeClass('slide-in-from-right');
      }
      else if ($(titles[active]).hasClass('slide-in-from-left')) {
        $(titles[active]).removeClass('slide-in-from-left');
      }
      $(titles[slide]).removeClass('hidden');
      $(titles[slide]).addClass('slide-in-from-left');
      active=slide;
    });
 
 
  }
 
   function changeActiveBar(slide) {
    $(bars[active]).toggleClass('active-bar');
    $(bars[slide]).toggleClass('active-bar');
  }
 
 
  function showSlide(slide) {
    $(images[active]).toggleClass('hidden');
    $(images[slide]).toggleClass('hidden');
  }
 
 
  $('#prev').click(function() {
    if (active == 0) {
      next = num_images-1;
      showSlide(next);
      changeActiveBar(next);
      changeTitleToLeft(next);
    }
    else {
      next = active-1
      showSlide(next);
      changeActiveBar(next);
      changeTitleToLeft(next);
    }
  });
 
  $('#next').click(function() {
    if (active == num_images - 1) {
      next = 0;
      showSlide(next);
      changeActiveBar(next);
      changeTitleToRight(next);
    }
    else {
      next = active + 1;
      showSlide(next);
      changeActiveBar(next);
      changeTitleToRight(next);
    }
  });
 
});

Edição das 22h27min de 24 de julho de 2023

/* Códigos JavaScript aqui colocados serão carregados por todos aqueles que acessarem alguma página deste wiki */

$('document').ready(function() {
  var slideshow = document.getElementById('slideshow');
  var images = $('.image');
  var num_images = images.length;
  var bars = $('.bar');
  var titles = $('.image-title');
  var active = 0;
  var next;

  function changeTitleToLeft(slide) {

    $(titles[active]).addClass('slide-out-to-left');
    $(titles[active]).one('animationend', function(e) {
      $(titles[active]).addClass('hidden');
      $(titles[active]).removeClass('slide-out-to-left');
      if ($(titles[active]).hasClass('slide-in-from-right')) {
        $(titles[active]).removeClass('slide-in-from-right');
      }
      else if ($(titles[active]).hasClass('slide-in-from-left')) {
        $(titles[active]).removeClass('slide-in-from-left');
      }
      $(titles[slide]).removeClass('hidden');
      $(titles[slide]).addClass('slide-in-from-right');
      active=slide;
    });

  }


  function changeTitleToRight(slide) {

    $(titles[active]).addClass('slide-out-to-right');
    $(titles[active]).one('animationend', function(e) {
      $(titles[active]).addClass('hidden');
      $(titles[active]).removeClass('slide-out-to-right');
      if ($(titles[active]).hasClass('slide-in-from-right')) {
        $(titles[active]).removeClass('slide-in-from-right');
      }
      else if ($(titles[active]).hasClass('slide-in-from-left')) {
        $(titles[active]).removeClass('slide-in-from-left');
      }
      $(titles[slide]).removeClass('hidden');
      $(titles[slide]).addClass('slide-in-from-left');
      active=slide;
    });


  }

  function changeActiveBar(slide) {
    $(bars[active]).toggleClass('active-bar');
    $(bars[slide]).toggleClass('active-bar');
  }


  function showSlide(slide) {
    $(images[active]).toggleClass('hidden');
    $(images[slide]).toggleClass('hidden');
  }


  $('#prev').click(function() {
    if (active == 0) {
      next = num_images-1;
      showSlide(next);
      changeActiveBar(next);
      changeTitleToLeft(next);
    }
    else {
      next = active-1
      showSlide(next);
      changeActiveBar(next);
      changeTitleToLeft(next);
    }
  });

  $('#next').click(function() {
    if (active == num_images - 1) {
      next = 0;
      showSlide(next);
      changeActiveBar(next);
      changeTitleToRight(next);
    }
    else {
      next = active + 1;
      showSlide(next);
      changeActiveBar(next);
      changeTitleToRight(next);
    }
  });

});