MediaWiki:Mobile.js: Difference between revisions

MediaWiki interface page
(Created page with "→‎All JavaScript here will be loaded for users of the mobile site: →‎Testing table improvements suggested here: https://medium.com/allenhwkim/mobile-friendly-table-b0cb066dbc0e: window.setMobileTable = function(selector) { // if (window.innerWidth > 600) return false; const tableEl = document.querySelector(selector); const thEls = tableEl.querySelectorAll('thead th'); const tdLabels = Array.from(thEls).map(el => el.innerText); tableEl.querySelectorAll('...")
 
No edit summary
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
/* All JavaScript here will be loaded for users of the mobile site */
/* All JavaScript here will be loaded for users of the mobile site */


/* Testing table improvements suggested here: https://medium.com/allenhwkim/mobile-friendly-table-b0cb066dbc0e */
/* Ensures that mobile stylesheets load */
 
mw.loader.using('mobile.site.styles');
window.setMobileTable = function(selector) {
  // if (window.innerWidth > 600) return false;
  const tableEl = document.querySelector(selector);
  const thEls = tableEl.querySelectorAll('thead th');
  const tdLabels = Array.from(thEls).map(el => el.innerText);
  tableEl.querySelectorAll('tbody tr').forEach( tr => {
    Array.from(tr.children).forEach(
      (td, ndx) =>  td.setAttribute('label', tdLabels[ndx])
    );
  });
}

Latest revision as of 08:37, 15 October 2022

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

/* Ensures that mobile stylesheets load */
mw.loader.using('mobile.site.styles');