Make WordPress Core

Changeset 20451


Ignore:
Timestamp:
04/12/2012 05:52:54 PM (13 years ago)
Author:
azaozz
Message:

Add RTL/LTR button to the html editor, props yoavf, fixes #13070

Location:
trunk/wp-includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/js/quicktags.dev.js

    r20166 r20451  
    263263                theButtons['fullscreen'] = new qt.FullscreenButton();
    264264                html += theButtons['fullscreen'].html(name + '_');
     265            }
     266
     267
     268            if ( 'rtl' == document.getElementsByTagName('html')[0].dir ) {
     269                theButtons['textdirection'] = new qt.TextDirectionButton();
     270                html += theButtons['textdirection'].html(name + '_');
    265271            }
    266272
     
    606612    };
    607613
     614    qt.TextDirectionButton = function() {
     615        qt.Button.call(this, 'textdirection', quicktagsL10n.textdirection, '', quicktagsL10n.toggleTextdirection)
     616    };
     617    qt.TextDirectionButton.prototype = new qt.Button();
     618    qt.TextDirectionButton.prototype.callback = function(e, c) {
     619        var isRTL = ( 'rtl' == document.getElementsByTagName('html')[0].dir ),
     620            currentDirection = c.style.direction;
     621
     622        if ( ! currentDirection )
     623            currentDirection = ( isRTL ) ? 'rtl' : 'ltr';
     624
     625        c.style.direction = ( 'rtl' == currentDirection ) ? 'ltr' : 'rtl';
     626        c.focus();
     627    }
     628
    608629    // ensure backward compatibility
    609630    edButtons[10] = new qt.TagButton('strong','b','<strong>','</strong>','b');
  • trunk/wp-includes/script-loader.php

    r20433 r20451  
    8080        'enterImageDescription' => __('Enter a description of the image'),
    8181        'fullscreen' => __('fullscreen'),
    82         'toggleFullscreen' => esc_attr( __('Toggle fullscreen mode') )
     82        'toggleFullscreen' => esc_attr( __('Toggle fullscreen mode') ),
     83        'textdirection' => esc_attr( __('text direction') ),
     84        'toggleTextdirection' => esc_attr( __('Toggle Editor Text Direction') )
    8385    ) );
    8486
Note: See TracChangeset for help on using the changeset viewer.