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

De WikiAjuda
Ir para: navegação, pesquisa
 
(17 revisões intermediárias por 2 usuários não estão sendo mostradas)
Linha 6: Linha 6:
 
     checkScreenSize();
 
     checkScreenSize();
  
     function checkScreenSize(){
+
     if(mw.config.get( 'wgIsMainPage' ) === true) {
        var newWindowWidth = $(window).innerWidth();
+
    mainPageLayout();
        if (newWindowWidth < 481) {
+
    }
          $('mw-mmv-view-expanded img').each(function() {
+
    $('.gobottom').detach().appendTo('#bottom-notice-ns').show();
                $(this).removeClass().addClass('img-responsive center-block');
+
});
          });
+
 
        } else {
+
function checkScreenSize(){
          $('mw-mmv-view-expanded img').each(function() {
+
    var newWindowWidth = $(window).innerWidth();
               var width = $(this).width();   // Current image width
+
    // <!-- adjust mobile screen width here -->
               var height = $(this).height(); // Current image height
+
    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;
 
               var ratio = height / width;
 +
              // <!-- adjust mobile screenshot ratio -->
 
               if(ratio > 1.5) {
 
               if(ratio > 1.5) {
                   $(this).removeClass().addClass('img-mobile center-block');
+
                   $(this).removeClass().addClass('img-mobile center-block').css('visibility','visible').fadeIn();
 +
              } else {
 +
                  $(this).removeClass().addClass('img-responsive center-block').css('visibility','visible').fadeIn();
 
               }
 
               }
          });
+
        });
        }
 
 
     }
 
     }
});
+
}
 +
 
 +
function mainPageLayout() {
 +
      $('[role="main"]').toggleClass('col-md-9 col-md-12');
 +
}

Edição atual tal como às 20h12min de 18 de junho de 2020

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

    checkScreenSize();

    if(mw.config.get( 'wgIsMainPage' ) === true) {
     mainPageLayout();
    }
    $('.gobottom').detach().appendTo('#bottom-notice-ns').show();
});

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();
              }
        });
    }
}

function mainPageLayout() {
       $('[role="main"]').toggleClass('col-md-9 col-md-12');
}