/*
* Quicktags
- *
+ *
* This is the HTML editor in WordPress. It can be attached to any textarea and will
* append a toolbar above it. This script is self-contained (does not require external libraries).
*
/**
* Inserts content at the caret in the active editor (textarea)
- *
+ *
* Added for back compatibility
* @see QTags.insertContent()
*/
/**
* Adds a button to all instances of the editor
- *
+ *
* Added for back compatibility, use QTags.addButton() as it gives more flexibility like type of button, button placement, etc.
* @see QTags.addButton()
*/
function edButton(id, display, tagStart, tagEnd, access, open) {
- return QTags.addButton( id, display, tagStart, tagEnd, access, '', -1 );
+ return QTags.addButton( id, display, tagStart, tagEnd, access, '', -1 );
}
(function(){
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;
}
/**
* Main API function for adding a button to Quicktags
- *
+ *
* Adds qt.Button or qt.TagButton depending on the args. The first three args are always required.
* To be able to add button(s) to Quicktags, your script should be enqueued as dependent
* on "quicktags" and outputted in the footer. If you are echoing JS directly from PHP,
* @param arg1 string || function required Either a starting tag to be inserted like "<span>" or a callback that is executed when the button is clicked.
* @param arg2 string optional Ending tag like "</span>"
* @param access_key string optional Access key for the button.
- * @param title string optional Button's title="..."
+ * @param title string optional Button's title="..."
* @param priority int optional Number representing the desired position of the button in the toolbar. 1 - 9 = first, 11 - 19 = second, 21 - 29 = third, etc.
* @param instance string optional Limit the button to a specifric instance of Quicktags, add to all instances if not present.
* @return mixed null or the button object that is needed for back-compat.
- */
+ */
qt.addButton = function( id, display, arg1, arg2, access_key, title, priority, instance ) {
var btn;
-
+
if ( !id || !display )
return;
};
qt.FullscreenButton.prototype = new qt.Button();
qt.FullscreenButton.prototype.callback = function(e, c) {
- if ( c.id != 'content' || typeof(fullscreen) == 'undefined' )
+ if ( !c.id || typeof(fullscreen) == 'undefined' )
return;
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'),