12,787
edits
No edit summary |
(Add Purge link to page tools) |
||
(5 intermediate revisions by 2 users not shown) | |||
Line 550: | Line 550: | ||
if (!isOverflown) { | if (!isOverflown) { | ||
var headElem = document.getElementById('mw-header-container'); | var headElem = document.getElementById('mw-header-container'); | ||
if (headElem !== undefined) { | if ((headElem !== undefined) && (headElem !== null)) { | ||
var headStyles = getComputedStyle(headElem); | var headStyles = getComputedStyle(headElem); | ||
if ((headStyles !== undefined) && (headStyles.position !== 'static')) { | if ((headStyles !== undefined) && (headStyles.position !== 'static')) { | ||
Line 671: | Line 671: | ||
}); | }); | ||
} | } | ||
} | |||
function initCollapsibleElements() { | |||
/* 2024-02-18 Allow collapsing of elements with class 'mw-collapsible', in line | |||
* with desktop view behaviour. Extension:MobileFrontend disables this, but | |||
* it is still desirable for our use case | |||
*/ | |||
mw.loader.using('jquery.makeCollapsible').then(function () { $('.mw-collapsible').makeCollapsible(); }); | |||
} | } | ||
Line 764: | Line 772: | ||
return true; | return true; | ||
} | } | ||
} | |||
function addToPageTools() { | |||
if (isUserLoggedIn()) { | |||
$.when(mw.loader.using(['mediawiki.util']), $.ready).then( function() { | |||
mw.util.addPortletLink( | |||
'p-cactions', | |||
mw.util.getUrl() + '?action=purge', | |||
'Purge', | |||
't-purgecache', | |||
'Purge the cache for this page', | |||
null, | |||
null | |||
); | |||
}); | |||
} | |||
} | } | ||
Line 772: | Line 796: | ||
} else { | } else { | ||
$('.ios-app-download').addClass('d-none'); | $('.ios-app-download').addClass('d-none'); | ||
} | |||
} | |||
function showAndroidAppDownloadLink() { | |||
var shouldShowDownload = /Android/i.test(window.navigator.userAgent) && window.navigator.userAgent.indexOf('gonative melvorwiki') === -1; | |||
if (shouldShowDownload) { | |||
$('.android-app-download').removeClass('d-none'); | |||
} else { | |||
$('.android-app-download').addClass('d-none'); | |||
} | } | ||
} | } | ||
Line 778: | Line 811: | ||
// Table sticky headers | // Table sticky headers | ||
initStickyHeaders(); | initStickyHeaders(); | ||
// Collapsible elements (for Extension:MobileFrontend) | |||
initCollapsibleElements(); | |||
// Wiki app native navigation | // Wiki app native navigation | ||
initWikiAppSidebar(); | initWikiAppSidebar(); | ||
// Show iOS App download link | // Show iOS App download link | ||
showIOSAppDownloadLink(); | showIOSAppDownloadLink(); | ||
// Show Android App download link | |||
showAndroidAppDownloadLink(); | |||
// Add links to Page Tools navigation | |||
addToPageTools(); | |||
}); | }); |