MediaWiki:Vector.js

From Black Forest Wiki
Jump to navigation Jump to search

Note: After publishing, 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 / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
/* All JavaScript here will be loaded for users of the Vector skin */

/**
 * Force large standalone images to appear full width on mobile
 * This avoids small-screen instances where article intro text gets squished
 */
$(function(){
	mw.util.addCSS("@media screen and (max-width: 599px){div.mobile-expand-width,div.thumb.mobile-expand-width{width:100%;margin:10px auto;float:none}div.thumb.mobile-expand-width .thumbinner{width:auto!important}.floatleft.mobile-expand-width img,.floatright.mobile-expand-width img,div.thumb.mobile-expand-width .thumbimage{width:calc(100% - 0.5em)!important;height:auto}}");
	$(".mw-parser-output > .thumb").each(function(){
		if($(this).width() > 100){
			$(this).addClass("mobile-expand-width");
		}
	});
	$(".mw-parser-output > .floatright > .image:only-child, .mw-parser-output > .floatleft > .image:only-child").each(function(){
		if($(this).width() > 100){
			$(this).parent().addClass("mobile-expand-width");
		}
	});
});