User:Tks4Fish/BiDiEditing.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.
// From arwiki gadget BiDiEditing, translated by [[User:علاء]]
// v. 1 "Directional editing control script (authors Brion and Splarka)."
// v. 2 [[:he:ויקיפדיה:סקריפטים/52]] modified {{oldid|9466464}} 

if ($.inArray(mw.config.get('wgAction'), ['edit', 'submit']) + 1)
$(function() {
    $.each([
	        {l: 'Right', d: {direction: 'rtl'}}, 
	        {l: 'Left', d: {direction: 'ltr'}}, 
	        {l: 'Normal', d: {unicodeBidi: 'normal'}}, 
	        {l: 'Inverse', d: {unicodeBidi: 'bidi-override'}} 
        ],
        function(index, item) {
            $('#editform').before(
                $('<input>', {type: 'button', value: item.l})
                .click(function() {
                        $("#wpTextbox1, .ace_editor, #wpSummary").css(item.d);
                })
            );
	    }
    );
});