MediaWiki:Mobile.js: Difference between revisions
From Tardis Wiki, the free Doctor Who reference
No edit summary Tags: Mobile edit Mobile web edit |
(formatting, removing useless ;) |
||
Line 6: | Line 6: | ||
//importScript("MediaWiki:Gadget-PreloadTemplates.js"); | //importScript("MediaWiki:Gadget-PreloadTemplates.js"); | ||
var parentElement = document.querySelector('.mf-section-0'); | |||
var elementToMove1, siblingElement1; | |||
var browserWidth = $(window).width(); | |||
(function ($) { | (function ($) { | ||
Line 28: | Line 24: | ||
if (elementToMove1 !== null) { | if (elementToMove1 !== null) { | ||
parentElement.insertBefore(elementToMove1, siblingElement1); | parentElement.insertBefore(elementToMove1, siblingElement1); | ||
} | } | ||
} | } | ||
}); | }); | ||
if (elementToMove1 !== null) { | if (elementToMove1 !== null) { | ||
parentElement.insertBefore(elementToMove1, siblingElement1); | parentElement.insertBefore(elementToMove1, siblingElement1); | ||
} | } | ||
}); | }); | ||
Line 55: | Line 51: | ||
return false; | return false; | ||
} | } | ||
} | } | ||
}); | }); |
Revision as of 02:10, 6 April 2024
/* All JavaScript here will be loaded for users of the mobile site */
console.log("Running");
importScript("MediaWiki:Gadget-introedit.js");
console.log("Running1");
//importScript("MediaWiki:Gadget-PreloadTemplates.js");
var parentElement = document.querySelector('.mf-section-0');
var elementToMove1, siblingElement1;
var browserWidth = $(window).width();
(function ($) {
$(window).trigger('resize');
$(window).on('resize', function() {
if(browserWidth > 1119) {
var elementToMove1 = parentElement.querySelector('p + .portable-infobox');
var siblingElement1 = parentElement.querySelector('p:first-of-type');
} else {
var elementToMove1 = parentElement.querySelector('.dabtag + .portable-infobox');
var siblingElement1 = parentElement.querySelector('.dabtag');
if (elementToMove1 !== null) {
parentElement.insertBefore(elementToMove1, siblingElement1);
}
}
});
if (elementToMove1 !== null) {
parentElement.insertBefore(elementToMove1, siblingElement1);
}
});
console.log("Running4");
/* 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 ($('.action-edit') !== null) {
if ($(window).width() > 1119) {
$('html, body').animate({scrollTop : 0},600);
return false;
}
}
});
});
console.log("Running5");