MediaWiki:Mobile.js: Difference between revisions

From Tardis Wiki, the free Doctor Who reference
No edit summary
Tags: Mobile edit Mobile web edit
(No, that part was correct.)
Tags: Mobile edit Mobile web edit
Line 13: Line 13:
$(function() {
$(function() {
   $(window).trigger('resize');
   $(window).trigger('resize');
   $(window).on('resize'), function() {   
   $(window).on('resize', function() {   
if($(window).width() > 1119) {
if($(window).width() > 1119) {
      
      

Revision as of 20:28, 1 April 2024

/* All JavaScript here will be loaded for users of the mobile site */

mw.loader.load('https://tardis.wiki/w/load.php?modules=ext.gadget.introedit');

var parentElement = document.querySelector('.mf-section-0');

var elementToMove1 = parentElement.querySelector('p + .portable-infobox');
var siblingElement1 = parentElement.querySelector('p:first-of-type');

var elementToMove2 = parentElement.querySelector('.dabtag + .portable-infobox');
var siblingElement2 = parentElement.querySelector('.dabtag');
  
$(function() {
  $(window).trigger('resize');
  $(window).on('resize', function() {  
	 if($(window).width() > 1119) {
    
    	parentElement.insertBefore(elementToMove1, siblingElement1);
  
	 } else {

    	parentElement.insertBefore(elementToMove2, siblingElement2);
    	parentElement.insertBefore(elementToMove2, siblingElement2);
	
	 }
  });
});

/* TABLET OPTIMISATION:
   
   Causes navbar buttons to bring the
   user to the top of the page (NOT the
   top of the edit box) while editing.
            */

(function ($) {
$('.action-edit .citizen-header__item').click(function(){
  
   if($(window).width() > 1119) {
    
      $('html, body').animate({scrollTop : 0},600);
      return false;
    
   }

});
})