goog.i18n.BidiFormatter |
contextDir
: goog.i18n.bidi.Dir | number | boolean | null
The context
directionality, in one of the following formats:
1. A goog.i18n.bidi.Dir constant. NEUTRAL is treated the same as null,
i.e. unknown, for backward compatibility with legacy calls.
2. A number (positive = LTR, negative = RTL, 0 = unknown).
3. A boolean (true = RTL, false = LTR).
4. A null for unknown directionality.
|
opt_alwaysSpan
: boolean=
Whether
#spanWrap should always
use a 'span' tag, even when the input directionality is neutral or
matches the context, so that the DOM structure of the output does not
depend on the combination of directionalities. Default: false. |
Returns true if two given directionalities are opposite.
Note: the implementation is based on the numeric values of the Dir enum.
Arguments:
Returns: boolean
Whether the directionalities are opposite.
|
code » | |||||
Returns 'dir="ltr"' or 'dir="rtl"', depending on
str 's estimated
directionality, if it is not the same as the context directionality.
Otherwise, returns the empty string.
|
code » | |||||
Returns "rtl" if
str 's estimated directionality is RTL, and "ltr" if
it is LTR. In case it's NEUTRAL, returns "rtl" if the context directionality
is RTL, and "ltr" otherwise.
Needed for GXP, which can't handle dirAttr.
Example use case:
<td expr:dir='bidiFormatter.dirAttrValue(foo)'>
<gxp:eval expr='foo'>
</td>
|
code » | |||||
Returns a unicode BiDi mark matching the context directionality (LRM or
RLM) if
opt_dirReset , and if either the directionality or the exit
directionality of str is opposite to the context directionality.
Otherwise returns the empty string.
|
code » | |||||
Returns 'left' for RTL context directionality. Otherwise (LTR or neutral /
unknown context directionality) returns 'right'.
Returns: string
'left' for RTL context directionality and 'right' for other
context directionality.
|
code » | |||||
![]()
Returns the directionality of input argument
str .
Identical to goog.i18n.bidi.estimateDirection .
Arguments:
Returns: goog.i18n.bidi.Dir
Estimated overall directionality of
str .
|
code » | |||||
No description.
Returns: boolean
Whether alwaysSpan is set.
|
code » | |||||
![]()
No description.
Returns: ?goog.i18n.bidi.Dir
The context directionality.
|
code » | |||||
Returns 'dir="ltr"' or 'dir="rtl"', depending on the given directionality, if
it is not the same as the context directionality. Otherwise, returns the
empty string.
Arguments:
Returns: string
'dir="rtl"' for RTL text in non-RTL context; 'dir="ltr"' for
LTR text in non-LTR context; else, the empty string.
|
code » | |||||
Returns "rtl" if the given directionality is RTL, and "ltr" if it is LTR. In
case it's NEUTRAL, returns "rtl" if the context directionality is RTL, and
"ltr" otherwise.
Arguments:
Returns: string
"rtl" or "ltr", according to the logic described above.
|
code » | |||||
Returns the Unicode BiDi mark matching the context directionality (LRM for
LTR context directionality, RLM for RTL context directionality), or the
empty string for neutral / unknown context directionality.
Returns: string
LRM for LTR context directionality and RLM for RTL context
directionality.
|
code » | |||||
Returns a Unicode BiDi mark matching the context directionality (LRM or RLM)
if the directionality or the exit directionality of
str are opposite
to the context directionality. Otherwise returns the empty string.
|
code » | |||||
Returns a Unicode BiDi mark matching the context directionality (LRM or RLM)
if the given directionality or the exit directionality of
str are
opposite to the context directionality. Otherwise returns the empty string.
Arguments:
Returns: string
A Unicode bidi mark matching the global directionality or
the empty string.
|
code » | |||||
![]()
No description.
Arguments:
|
code » | |||||
![]()
No description.
Arguments:
|
code » | |||||
Formats a string of unknown directionality for use in HTML output of the
context directionality, so an opposite-directionality string is neither
garbled nor garbles what follows it.
The algorithm: estimates the directionality of input argument
str . In
case its directionality doesn't match the context directionality, wraps it
with a 'span' tag and adds a "dir" attribute (either 'dir="rtl"' or
'dir="ltr"'). If setAlwaysSpan(true) was used, the input is always wrapped
with 'span', skipping just the dir attribute when it's not needed.
If opt_dirReset , and if the overall directionality or the exit
directionality of str are opposite to the context directionality, a
trailing unicode BiDi mark matching the context directionality is appened
(LRM or RLM).
If ! opt_isHtml , HTML-escapes str regardless of wrapping.
Arguments:
Returns: string
Input text after applying the above processing.
|
code » | |||||
Formats a string of given directionality for use in HTML output of the
context directionality, so an opposite-directionality string is neither
garbled nor garbles what follows it.
The algorithm: If
dir doesn't match the context directionality, wraps
str with a 'span' tag and adds a "dir" attribute (either 'dir="rtl"'
or 'dir="ltr"'). If setAlwaysSpan(true) was used, the input is always wrapped
with 'span', skipping just the dir attribute when it's not needed.
If opt_dirReset , and if dir or the exit directionality of
str are opposite to the context directionality, a trailing unicode
BiDi mark matching the context directionality is appened (LRM or RLM).
If ! opt_isHtml , HTML-escapes str regardless of wrapping.
Arguments:
Returns: string
Input text after applying the above processing.
|
code » | |||||
The internal implementation of spanWrapWithKnownDir for non-null dir, to help
the compiler optimize.
Arguments:
Returns: string
Input text after applying the above processing.
|
code » | |||||
Returns 'right' for RTL context directionality. Otherwise (LTR or neutral /
unknown context directionality) returns 'left'.
Returns: string
'right' for RTL context directionality and 'left' for other
context directionality.
|
code » | |||||
Formats a string of unknown directionality for use in plain-text output of
the context directionality, so an opposite-directionality string is neither
garbled nor garbles what follows it.
As opposed to
#spanWrap , this makes use of unicode BiDi formatting
characters. In HTML, its *only* valid use is inside of elements that do not
allow mark-up, e.g. an 'option' tag.
The algorithm: estimates the directionality of input argument str .
In case it doesn't match the context directionality, wraps it with Unicode
BiDi formatting characters: RLE str PDF for RTL text, and
LRE str PDF for LTR text.
If opt_dirReset , and if the overall directionality or the exit
directionality of str are opposite to the context directionality, a
trailing unicode BiDi mark matching the context directionality is appended
(LRM or RLM).
Does *not* do HTML-escaping regardless of the value of opt_isHtml .
The return value can be HTML-escaped as necessary.
Arguments:
Returns: string
Input text after applying the above processing.
|
code » | |||||
Formats a string of given directionality for use in plain-text output of the
context directionality, so an opposite-directionality string is neither
garbled nor garbles what follows it.
As opposed to
#spanWrapWithKnownDir , makes use of unicode BiDi
formatting characters. In HTML, its *only* valid use is inside of elements
that do not allow mark-up, e.g. an 'option' tag.
The algorithm: If dir doesn't match the context directionality, wraps
str with Unicode BiDi formatting characters: RLE str PDF for
RTL text, and LRE str PDF for LTR text.
If opt_dirReset , and if the overall directionality or the exit
directionality of str are opposite to the context directionality, a
trailing unicode BiDi mark matching the context directionality is appended
(LRM or RLM).
Does *not* do HTML-escaping regardless of the value of opt_isHtml .
The return value can be HTML-escaped as necessary.
Arguments:
Returns: string
Input text after applying the above processing.
|
code » | |||||
The internal implementation of unicodeWrapWithKnownDir for non-null dir, to
help the compiler optimize.
Arguments:
Returns: string
Input text after applying the above processing.
|
code » |