Mudanças entre as edições de "MediaWiki: Common.js"

De WikiAjuda
Ir para: navegação, pesquisa
Linha 5: Linha 5:
  
 
     checkScreenSize();
 
     checkScreenSize();
 +
});
  
    function checkScreenSize(){
+
function checkScreenSize(){
        var newWindowWidth = $(window).innerWidth();
+
    var newWindowWidth = $(window).innerWidth();
        // <!-- adjust mobile screen width here -->
+
    // <!-- adjust mobile screen width here -->
        if (newWindowWidth < 481) {
+
    if (newWindowWidth < 481) {
          $('.newsection img').each(function() {
+
        $('.newsection img').each(function() {
                $(this).removeClass().addClass('img-responsive center-block').css('visibility','visible').fadeIn();
+
            $(this).removeClass().addClass('img-responsive center-block').css('visibility','visible').fadeIn();
          });
+
        });
        } else {
+
    } else {
          $('.newsection img').each(function() {
+
        $('.newsection img').each(function() {
 
               var width = $(this).width();  
 
               var width = $(this).width();  
 
               var height = $(this).height();  
 
               var height = $(this).height();  
Linha 24: Linha 25:
 
                   $(this).removeClass().addClass('img-responsive center-block').css('visibility','visible').fadeIn();
 
                   $(this).removeClass().addClass('img-responsive center-block').css('visibility','visible').fadeIn();
 
               }
 
               }
          });
+
        });
        }
 
 
     }
 
     }
});
+
}

Edição das 17h18min de 26 de maio de 2019

$(document).ready(function () {
    $(window).on("resize", function (e) {
        checkScreenSize();
    });

    checkScreenSize();
});

function checkScreenSize(){
    var newWindowWidth = $(window).innerWidth();
    // <!-- adjust mobile screen width here -->
    if (newWindowWidth < 481) {
        $('.newsection img').each(function() {
             $(this).removeClass().addClass('img-responsive center-block').css('visibility','visible').fadeIn();
        });
    } else {
        $('.newsection img').each(function() {
              var width = $(this).width(); 
              var height = $(this).height(); 
              var ratio = height / width;
              // <!-- adjust mobile screenshot ratio -->
              if(ratio > 1.5) {
                  $(this).removeClass().addClass('img-mobile center-block').css('visibility','visible').fadeIn();
              } else {
                  $(this).removeClass().addClass('img-responsive center-block').css('visibility','visible').fadeIn();
              }
        });
    }
}