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

git-svn-id: http://svn.automattic.com/wordpress/trunk@20451 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
azaozz 2012-04-12 17:52:54 +00:00
parent d0dcf045e0
commit a62ef6d827
2 changed files with 24 additions and 1 deletions

View File

@ -264,6 +264,12 @@ function edButton(id, display, tagStart, tagEnd, access, open) {
html += theButtons['fullscreen'].html(name + '_');
}
if ( 'rtl' == document.getElementsByTagName('html')[0].dir ) {
theButtons['textdirection'] = new qt.TextDirectionButton();
html += theButtons['textdirection'].html(name + '_');
}
ed.toolbar.innerHTML = html;
ed.theButtons = theButtons;
}
@ -605,6 +611,21 @@ function edButton(id, display, tagStart, tagEnd, access, open) {
fullscreen.on();
};
qt.TextDirectionButton = function() {
qt.Button.call(this, 'textdirection', quicktagsL10n.textdirection, '', quicktagsL10n.toggleTextdirection)
};
qt.TextDirectionButton.prototype = new qt.Button();
qt.TextDirectionButton.prototype.callback = function(e, c) {
var isRTL = ( 'rtl' == document.getElementsByTagName('html')[0].dir ),
currentDirection = c.style.direction;
if ( ! currentDirection )
currentDirection = ( isRTL ) ? 'rtl' : 'ltr';
c.style.direction = ( 'rtl' == currentDirection ) ? 'ltr' : 'rtl';
c.focus();
}
// ensure backward compatibility
edButtons[10] = new qt.TagButton('strong','b','<strong>','</strong>','b');
edButtons[20] = new qt.TagButton('em','i','<em>','</em>','i'),

View File

@ -79,7 +79,9 @@ function wp_default_scripts( &$scripts ) {
'enterImageURL' => __('Enter the URL of the image'),
'enterImageDescription' => __('Enter a description of the image'),
'fullscreen' => __('fullscreen'),
'toggleFullscreen' => esc_attr( __('Toggle fullscreen mode') )
'toggleFullscreen' => esc_attr( __('Toggle fullscreen mode') ),
'textdirection' => esc_attr( __('text direction') ),
'toggleTextdirection' => esc_attr( __('Toggle Editor Text Direction') )
) );
$scripts->add( 'colorpicker', "/wp-includes/js/colorpicker$suffix.js", array('prototype'), '3517m' );