a module to apply RTL text to textboxes
Automatically detects RTL (right-to-left) languages and appropriately configures the text input, without having to manually specify CSS
dir property on page load. Allows automatic switching between LTR and RTL languages.
This module will set the direction of a textarea to RTL when a threshold
of RTL characters has been reached (
rtlThreshold). It also applies Twitter-
specific RTL rules regarding the placement of @ signs, # tags, and URLs.
Bind keyup and keydown to
RTLText.onTextChange. If you have initial text,
RTLText.setText(textarea, initial_string) to set markers on that
$documentreadyvar $textarea = $'#someTextarea';$textareaon'keyup' RTLTextonTextChange;$textareaon'keydown' RTLTextonTextChange;RTLTextsetText$textareaget0 $textareaval;;
When storing or submitting the text, make sure to extract the unicode markers first:
var textToSubmit = RTLTextcleanText$"#someTextarea"val;
Get the length of the text minus the control characters:
var textLength = RTLTexttextLength$"#someTextarea"val;
Add markers to a string without affecting the text box:
var stringWithMarkers = RTLTextaddRTLMarkersstring;
We use semantic versioning, as described here: http://semver.org/
Releases are numbered and constructed with the following guidelines:
Before running the tests for the first time, install the required packages by typing:
After the packages are installed, you can run the tests by typing:
Copyright 2012 Twitter, Inc.
Licensed under the MIT License