User:Krinkle/Scripts/Vector LTR.js

From Meta, a Wikimedia project coordination wiki

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.
/**
 * Vector LTR
 *
 * @version 0.2.0 (2013-01-06)
 * @source meta.wikimedia.org/wiki/User:Krinkle/Tools/Vector_LTR
 * @license Released in the public domain
 *
 * No longer maintained. Kept for historical record. Use [[m:User:Pathoschild/Scripts/Force ltr]] instead.
 */
$( document ).ready( function () {

	// $.fn.reverseOrder = function () {
	// 	return this.each( function () {
	// 		$(this).prependTo( $(this).parent() );
	// 	});
	// };

	/* Force LTR */
	if( $('body').hasClass('sitedir-rtl') ) {
		$('link[rel="stylesheet"][href^="/w/load.php"]')
			.attr('href', function(i, val) {
				return val.replace(/&lang=[^&]+/, '&lang=en');
			});
	
		// Swap body & html direction
		$('body').removeClass('rtl').addClass('ltr');
		$('[dir="rtl"]').attr('dir', 'ltr');

		// Reverse order in the top-right things
		// $('#right-navigation > div, #p-views li, #p-namespaces li, #p-personal li').reverseOrder();
	} 
});