MediaWiki:Common.js
From Marathon Documentation
Note: After saving, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Internet Explorer: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Go to Menu → Settings (Opera → Preferences on a Mac) and then to Privacy & security → Clear browsing data → Cached images and files.
/* Any JavaScript here will be loaded for all users on every page load. */ function set_expand_sizes() { var t, th = $(this), r, fw, fh, mw, mh, mul, ew, eh; t = th[0]; r = (fw = parseInt(t.getAttribute('data-file-width'))) / (fh = parseInt(t.getAttribute('data-file-height'))); mw = parseInt(th.css('maxWidth')); mh = parseInt(th.css('maxHeight')); mul = Math.min(mw/fw, mh/fh); t.setAttribute('data-expand-width', (ew = Math.round(mul * fw))); t.setAttribute('data-expand-height', (eh = Math.round(mul * fh))); t.removeAttribute('width');t.removeAttribute('height'); t.style.width = ew + 'px';t.style.height = eh + 'px'; t.style.maxHeight='none';t.style.maxWidth = 'none'; } function open_in_mmv(href) { var t = $('a.image[href="' + (href || this.href) + '"]').not(":has(img.expand-image)"); return t && t.length ? (t[0].click() || false) && false : true; } $('img.expand-image').removeClass('expand-on-hover').click(function () { var t = $(this); t.toggleClass('expanded-image'); if (t.hasClass('expanded-image')) { t.height(this.naturalHeight).width(this.naturalWidth); } else { t.height(t.attr('data-expand-height')).width(t.attr('data-expand-height')); } return false; }).each(set_expand_sizes);