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

De WikiAjuda
Ir para: navegação, pesquisa
Linha 9: Linha 9:
 
         var newWindowWidth = $(window).innerWidth();
 
         var newWindowWidth = $(window).innerWidth();
 
         if (newWindowWidth < 481) {
 
         if (newWindowWidth < 481) {
           $('mw-mmv-view-expanded img').each(function() {
+
           $('.newsection img').each(function() {
 
                 $(this).removeClass().addClass('img-responsive center-block');
 
                 $(this).removeClass().addClass('img-responsive center-block');
 
           });
 
           });

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

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

    checkScreenSize();

    function checkScreenSize(){
        var newWindowWidth = $(window).innerWidth();
        if (newWindowWidth < 481) {
           $('.newsection img').each(function() {
                 $(this).removeClass().addClass('img-responsive center-block');
           });
        } else {
           $('.newsection img').each(function() {
              var width = $(this).width();    // Current image width
              var height = $(this).height();  // Current image height
              var ratio = height / width;
              if(ratio > 1.5) {
                  $(this).removeClass().addClass('img-mobile center-block');
              }
           });
        }
    }
});