yellow-brick-road 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rst +42 -20
- data/lib/generators/templates/yellow_brick_road.rb.erb +19 -0
- data/lib/generators/yellow_brick_road/install_generator.rb +14 -0
- data/lib/yellow-brick-road/config.rb +41 -8
- data/lib/yellow-brick-road/directive_processor.rb +6 -5
- data/lib/yellow-brick-road/engine.rb +2 -3
- data/lib/yellow-brick-road/soy_processor.rb +1 -1
- data/lib/yellow-brick-road/version.rb +1 -1
- data/test/dummy/app/assets/javascripts/closure-deps.js +1 -1
- data/test/dummy/config/initializers/yellow_brick_road.rb +18 -1
- data/test/dummy/log/development.log +2208 -0
- data/test/dummy/tmp/cache/assets/C33/E00/sprockets%2F50c54266987e056bca666f8951752841 +2556 -0
- data/test/dummy/tmp/cache/assets/C48/990/sprockets%2F182c7921a46c3b8603c7f5595a111407 +823 -0
- data/test/dummy/tmp/cache/assets/C53/B40/sprockets%2F48cf0c035092dc945559526a279061c6 +204 -0
- data/test/dummy/tmp/cache/assets/C60/DB0/sprockets%2F3f00684578f2a3246581db667309ed89 +187 -0
- data/test/dummy/tmp/cache/assets/C60/E40/sprockets%2F3c5422f721521f492a5f02ca00b70009 +457 -0
- data/test/dummy/tmp/cache/assets/C73/DE0/sprockets%2F21f1f4574326846114a3c106873cebc3 +0 -0
- data/test/dummy/tmp/cache/assets/C7E/9F0/sprockets%2F89862076204c62c4593ac20de32da909 +4 -4
- data/test/dummy/tmp/cache/assets/C80/6F0/sprockets%2F56459a0713f8610d7d261f8be93073a2 +115 -0
- data/test/dummy/tmp/cache/assets/C8D/E10/sprockets%2F34b84bc4732937f885707002eda3896e +511 -0
- data/test/dummy/tmp/cache/assets/C93/CB0/sprockets%2F539b403b24833ca478a6f5877f37687c +239 -0
- data/test/dummy/tmp/cache/assets/C9A/C70/sprockets%2F10933dc6d342f604514713510b9ef0ab +806 -0
- data/test/dummy/tmp/cache/assets/CA0/7C0/sprockets%2Ff591bc0af8f085501241305c04907d3e +590 -0
- data/test/dummy/tmp/cache/assets/CA1/4A0/sprockets%2F5a9ad311e7d225b530b597041714b1e9 +2539 -0
- data/test/dummy/tmp/cache/assets/CA7/310/sprockets%2F45664cf816315200b574e029fde6f10a +0 -0
- data/test/dummy/tmp/cache/assets/CA7/A80/sprockets%2F1f32590957635a5a4f35442bc22f4ca4 +0 -0
- data/test/dummy/tmp/cache/assets/CAE/1D0/sprockets%2F2e62c7733d38a817a1532a744c6287bd +72 -0
- data/test/dummy/tmp/cache/assets/CB2/3C0/sprockets%2F9c35c290501a896b82c31448a39f3d5d +142 -0
- data/test/dummy/tmp/cache/assets/CB3/F20/sprockets%2F558b00e493fb501f7d95761e7eb40273 +2539 -0
- data/test/dummy/tmp/cache/assets/CBE/550/sprockets%2Fd680cac830e0b3408ba910f0b0421147 +2 -2
- data/test/dummy/tmp/cache/assets/CCD/480/sprockets%2Ffe7e11511634a2d03e1a20980b4593cf +0 -0
- data/test/dummy/tmp/cache/assets/CD0/080/sprockets%2Ffd5cbb87741244521d013d11c55573fa +204 -0
- data/test/dummy/tmp/cache/assets/CD2/020/sprockets%2Ff97740ba22118a2c91e992aac041843b +811 -0
- data/test/dummy/tmp/cache/assets/CD8/D90/sprockets%2F55dd841661d646f0024261a08ecf8ec0 +823 -0
- data/test/dummy/tmp/cache/assets/CE3/0D0/sprockets%2F301f97a178fd839a81bd663a6e22b616 +811 -0
- data/test/dummy/tmp/cache/assets/CE4/330/sprockets%2Fbd23466639af99164ab8e1c93721f14b +127 -0
- data/test/dummy/tmp/cache/assets/CE6/8A0/sprockets%2F3c0e7c5fa31563c8e820d6771e09918d +103 -0
- data/test/dummy/tmp/cache/assets/CEB/120/sprockets%2F857a0dde6829f7a27b93a840e1c60469 +522 -0
- data/test/dummy/tmp/cache/assets/CEE/CF0/sprockets%2F376f94b987d8156056c4e1d38ec06bf0 +0 -0
- data/test/dummy/tmp/cache/assets/CF2/C10/sprockets%2Fc64ef8a9dd0a1c3101d662750105c11a +806 -0
- data/test/dummy/tmp/cache/assets/CF3/CD0/sprockets%2F4bb42a5a6b504190f10d20b1c5f93d54 +1529 -0
- data/test/dummy/tmp/cache/assets/CF6/890/sprockets%2F36007a87f140155b5a04f2ca6b262dcc +494 -0
- data/test/dummy/tmp/cache/assets/CF6/9D0/sprockets%2F34b7199e9d33994c8ec7a442d60ca985 +173 -0
- data/test/dummy/tmp/cache/assets/CFA/A90/sprockets%2F901ba405a6d6747f6412ed4d0e0ac620 +256 -0
- data/test/dummy/tmp/cache/assets/CFC/E70/sprockets%2F8ee639668b5f0e629fbe0d62d1394689 +173 -0
- data/test/dummy/tmp/cache/assets/D04/1B0/sprockets%2F418f2b3b6b08b320f6db268a0991c54c +0 -0
- data/test/dummy/tmp/cache/assets/D05/920/sprockets%2F909507434dcc270db4853e4c147f0aac +5 -4
- data/test/dummy/tmp/cache/assets/D07/DB0/sprockets%2F0c17d7dac64290e385c91eb6f1570b31 +511 -0
- data/test/dummy/tmp/cache/assets/D07/EE0/sprockets%2F4999982b09e0b786894fce44f5d783cc +1371 -0
- data/test/dummy/tmp/cache/assets/D09/380/sprockets%2F14383e18fa2faac6b561a29d8e132863 +0 -0
- data/test/dummy/tmp/cache/assets/D0D/200/sprockets%2F545a7e34cce1d4272d83d58fd4215d42 +1277 -0
- data/test/dummy/tmp/cache/assets/D0E/870/sprockets%2F84996444f4f1f3fdc0248131cfb1a3b6 +794 -0
- data/test/dummy/tmp/cache/assets/D15/F60/sprockets%2Fa28394e3f80365b5bc86794dd46daa22 +0 -0
- data/test/dummy/tmp/cache/assets/D18/950/sprockets%2Fcf650d67c5d431ffdb38552e562299b2 +474 -0
- data/test/dummy/tmp/cache/assets/D18/E10/sprockets%2Fec7c58f640556b401fcd66528352dc9d +474 -0
- data/test/dummy/tmp/cache/assets/D20/660/sprockets%2F0d2875475ced01df962f3d758cda7792 +103 -0
- data/test/dummy/tmp/cache/assets/D22/AB0/sprockets%2F0b08e7f81651aaf739a93d61ae99779c +283 -0
- data/test/dummy/tmp/cache/assets/D2E/B20/sprockets%2Feed5412a17a52b1a335925e2af1f75d3 +0 -0
- data/test/dummy/tmp/cache/assets/D36/700/sprockets%2Fd219bf9db2eacc105bb294755093a437 +505 -0
- data/test/dummy/tmp/cache/assets/D3B/A10/sprockets%2Fcf38b51682d84a04da7b8a7313de52c6 +207 -0
- data/test/dummy/tmp/cache/assets/D3C/0E0/sprockets%2Fe9d7aba138d602c4a6ac701bc9615977 +505 -0
- data/test/dummy/tmp/cache/assets/D3E/FF0/sprockets%2F6bd8ccd3e02f397c20f349d5c0960e51 +0 -0
- data/test/dummy/tmp/cache/assets/D41/B30/sprockets%2Fba1b93913dd01d83ac9a96df334456f8 +0 -0
- data/test/dummy/tmp/cache/assets/D41/DA0/sprockets%2Fe8d00810698a9fcee032022fefd084f7 +0 -0
- data/test/dummy/tmp/cache/assets/D44/CF0/sprockets%2Ffa31a45f04884493c909c5a67fcbdf23 +1371 -0
- data/test/dummy/tmp/cache/assets/D47/BE0/sprockets%2F0b5ebdf6dec160a264698e7f745061e8 +142 -0
- data/test/dummy/tmp/cache/assets/D4C/F30/sprockets%2Ff90155c10f59a3fe44959ac09bf817fe +2556 -0
- data/test/dummy/tmp/cache/assets/D4E/7C0/sprockets%2Ff01b58512d01eda23fd5cb23a2b28b60 +1529 -0
- data/test/dummy/tmp/cache/assets/D4E/860/sprockets%2F86eed0c77c47d0970345bbabb58d8939 +1277 -0
- data/test/dummy/tmp/cache/assets/D4E/C30/sprockets%2F52420c10c73ca310d026565eafdadb4e +1545 -0
- data/test/dummy/tmp/cache/assets/D4E/F60/sprockets%2F9893a3c5aeb1a9e77469f4751b4d3c3f +115 -0
- data/test/dummy/tmp/cache/assets/D4F/E60/sprockets%2F17ee65de1f78c3dd5c165a9867e810b6 +165 -0
- data/test/dummy/tmp/cache/assets/D57/0D0/sprockets%2Fa29e6e8106d9d5ed1e2889126cfbf877 +300 -0
- data/test/dummy/tmp/cache/assets/D5C/650/sprockets%2Fe1c381da3cc213a639e956ae3315a2bd +607 -0
- data/test/dummy/tmp/cache/assets/D61/860/sprockets%2Fbf032a3b4aad2c2e25704e65c966cf45 +794 -0
- data/test/dummy/tmp/cache/assets/D63/B20/sprockets%2F31fc70ce66bb80fb9421be34eb3b0287 +0 -0
- data/test/dummy/tmp/cache/assets/D64/D60/sprockets%2Fa544ea03bf0a45948a053ba76ec2a79f +239 -0
- data/test/dummy/tmp/cache/assets/D6B/F90/sprockets%2F66636712ecb1fcc777dccf7643a0e1b1 +127 -0
- data/test/dummy/tmp/cache/assets/D6E/AD0/sprockets%2Fc91cdc6a72c729d7a64119198b3d2eab +0 -0
- data/test/dummy/tmp/cache/assets/D6F/140/sprockets%2F9ddc51f4388dd5243a28dba1ce47572b +53 -0
- data/test/dummy/tmp/cache/assets/D72/800/sprockets%2F92baa375d54e16fe0a5c7f079a1ce992 +165 -0
- data/test/dummy/tmp/cache/assets/D74/220/sprockets%2F3f888bda53179cb945eab35fbd31a708 +53 -0
- data/test/dummy/tmp/cache/assets/D78/5F0/sprockets%2F638ed6af667d4fc5147f72ff34aa2d33 +0 -0
- data/test/dummy/tmp/cache/assets/D7D/640/sprockets%2F95a7c5580f957c31e1ab9d0773ed5fde +607 -0
- data/test/dummy/tmp/cache/assets/D84/210/sprockets%2Fabd0103ccec2b428ac62c94e4c40b384 +6 -5
- data/test/dummy/tmp/cache/assets/D89/020/sprockets%2Fa06df6166e70324e712e54b1cafca0ae +187 -0
- data/test/dummy/tmp/cache/assets/D8A/9F0/sprockets%2Fc06547ca33ee3d03be14ce045ae1c9e2 +207 -0
- data/test/dummy/tmp/cache/assets/D9E/B80/sprockets%2F9561df1d45c7ff4aa8ac3e2df0c99121 +0 -0
- data/test/dummy/tmp/cache/assets/DA3/F30/sprockets%2Fe015d6ccdfcf022e47c83d7906f728ae +457 -0
- data/test/dummy/tmp/cache/assets/DAE/190/sprockets%2F433c7b21968be8d1f9bfdbdf7a637c57 +0 -0
- data/test/dummy/tmp/cache/assets/DB3/600/sprockets%2F9b70ae73f15ba693886eeef4eb5d6c75 +0 -0
- data/test/dummy/tmp/cache/assets/DB4/510/sprockets%2F29cdae8e29c88fd9ddbd4831419560fe +1260 -0
- data/test/dummy/tmp/cache/assets/DC1/4A0/sprockets%2F0b63dfcf163f2faeb612724eb4545bcc +1354 -0
- data/test/dummy/tmp/cache/assets/DC4/C10/sprockets%2Fcf48f4cbad3db33146eab4c577c1d209 +300 -0
- data/test/dummy/tmp/cache/assets/DC4/CA0/sprockets%2Fd0da8a60ea4dc16b9fd3e2a50d88633c +0 -0
- data/test/dummy/tmp/cache/assets/DC7/8C0/sprockets%2F1ad68dcc9ef598d3811ba2ac5c0ea182 +1354 -0
- data/test/dummy/tmp/cache/assets/DC7/C00/sprockets%2Fba755ff3a81c3192f0e45a4f7c0c7dcb +0 -0
- data/test/dummy/tmp/cache/assets/DCA/760/sprockets%2F717c4cea10bf601090ffdfe4e668e4cb +283 -0
- data/test/dummy/tmp/cache/assets/DCA/DE0/sprockets%2F51dcced9ec2b3cd4b1cc2949f860c361 +590 -0
- data/test/dummy/tmp/cache/assets/DD7/E70/sprockets%2F2595d8c8d1d5f4deb096247fb3bfc7ab +256 -0
- data/test/dummy/tmp/cache/assets/DE1/9D0/sprockets%2F8befd77af580ee16ec42ec95b1766ff3 +1545 -0
- data/test/dummy/tmp/cache/assets/E00/D80/sprockets%2F9debc27161f7bccf2d84a36b8c36c4bf +522 -0
- data/test/dummy/tmp/cache/assets/E00/E60/sprockets%2Fac159b94b0a6d621e4f6cde9b4de87bb +0 -0
- data/test/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/test/dummy/tmp/cache/assets/E1B/D00/sprockets%2F886dff4afe55f9d3f8abe434f2689add +72 -0
- data/test/dummy/tmp/cache/assets/E1B/F20/sprockets%2Fa4bbc04eb83ebf94fd8134c3abd220dd +494 -0
- data/test/dummy/tmp/cache/assets/E71/0C0/sprockets%2F5ffdc0daa0a1f9638c787897ceefcdee +1260 -0
- metadata +186 -10
- data/test/dummy/tmp/pids/server.pid +0 -1
@@ -0,0 +1,494 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1325549268.171535:@value{ I"length:EFi�LI"digest;
|
2
|
+
F"%4f0a8e9b1528c6b0e7296c9651b2e0c3I"source;
|
3
|
+
FI"�L// Copyright 2009 The Closure Library Authors. All Rights Reserved.
|
4
|
+
//
|
5
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
// you may not use this file except in compliance with the License.
|
7
|
+
// You may obtain a copy of the License at
|
8
|
+
//
|
9
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
//
|
11
|
+
// Unless required by applicable law or agreed to in writing, software
|
12
|
+
// distributed under the License is distributed on an "AS-IS" BASIS,
|
13
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
// See the License for the specific language governing permissions and
|
15
|
+
// limitations under the License.
|
16
|
+
|
17
|
+
/**
|
18
|
+
* @fileoverview Utility for formatting text for display in a potentially
|
19
|
+
* opposite-directionality context without garbling.
|
20
|
+
* Mostly a port of http://go/formatter.cc.
|
21
|
+
*/
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
goog.provide('goog.i18n.BidiFormatter');
|
26
|
+
|
27
|
+
goog.require('goog.i18n.bidi');
|
28
|
+
goog.require('goog.string');
|
29
|
+
|
30
|
+
|
31
|
+
|
32
|
+
/**
|
33
|
+
* Utility class for formatting text for display in a potentially
|
34
|
+
* opposite-directionality context without garbling. Provides the following
|
35
|
+
* functionality:
|
36
|
+
*
|
37
|
+
* 1. BiDi Wrapping
|
38
|
+
* When text in one language is mixed into a document in another, opposite-
|
39
|
+
* directionality language, e.g. when an English business name is embedded in a
|
40
|
+
* Hebrew web page, both the inserted string and the text following it may be
|
41
|
+
* displayed incorrectly unless the inserted string is explicitly separated
|
42
|
+
* from the surrounding text in a "wrapper" that declares its directionality at
|
43
|
+
* the start and then resets it back at the end. This wrapping can be done in
|
44
|
+
* HTML mark-up (e.g. a 'span dir=rtl' tag) or - only in contexts where mark-up
|
45
|
+
* can not be used - in Unicode BiDi formatting codes (LRE|RLE and PDF).
|
46
|
+
* Providing such wrapping services is the basic purpose of the BiDi formatter.
|
47
|
+
*
|
48
|
+
* 2. Directionality estimation
|
49
|
+
* How does one know whether a string about to be inserted into surrounding
|
50
|
+
* text has the same directionality? Well, in many cases, one knows that this
|
51
|
+
* must be the case when writing the code doing the insertion, e.g. when a
|
52
|
+
* localized message is inserted into a localized page. In such cases there is
|
53
|
+
* no need to involve the BiDi formatter at all. In the remaining cases, e.g.
|
54
|
+
* when the string is user-entered or comes from a database, the language of
|
55
|
+
* the string (and thus its directionality) is not known a priori, and must be
|
56
|
+
* estimated at run-time. The BiDi formatter does this automatically.
|
57
|
+
*
|
58
|
+
* 3. Escaping
|
59
|
+
* When wrapping plain text - i.e. text that is not already HTML or HTML-
|
60
|
+
* escaped - in HTML mark-up, the text must first be HTML-escaped to prevent XSS
|
61
|
+
* attacks and other nasty business. This of course is always true, but the
|
62
|
+
* escaping can not be done after the string has already been wrapped in
|
63
|
+
* mark-up, so the BiDi formatter also serves as a last chance and includes
|
64
|
+
* escaping services.
|
65
|
+
*
|
66
|
+
* Thus, in a single call, the formatter will escape the input string as
|
67
|
+
* specified, determine its directionality, and wrap it as necessary. It is
|
68
|
+
* then up to the caller to insert the return value in the output.
|
69
|
+
*
|
70
|
+
* See http://wiki/Main/TemplatesAndBiDi for more information.
|
71
|
+
*
|
72
|
+
* @param {goog.i18n.bidi.Dir|number|boolean} contextDir The context
|
73
|
+
* directionality. May be supplied either as a goog.i18n.bidi.Dir constant,
|
74
|
+
* as a number (positive = LRT, negative = RTL, 0 = unknown) or as a boolean
|
75
|
+
* (true = RTL, false = LTR).
|
76
|
+
* @param {boolean=} opt_alwaysSpan Whether {@link #spanWrap} should always
|
77
|
+
* use a 'span' tag, even when the input directionality is neutral or
|
78
|
+
* matches the context, so that the DOM structure of the output does not
|
79
|
+
* depend on the combination of directionalities. Default: false.
|
80
|
+
* @constructor
|
81
|
+
*/
|
82
|
+
goog.i18n.BidiFormatter = function(contextDir, opt_alwaysSpan) {
|
83
|
+
/**
|
84
|
+
* The overall directionality of the context in which the formatter is being
|
85
|
+
* used.
|
86
|
+
* @type {goog.i18n.bidi.Dir}
|
87
|
+
* @private
|
88
|
+
*/
|
89
|
+
this.contextDir_ = goog.i18n.bidi.toDir(contextDir);
|
90
|
+
|
91
|
+
/**
|
92
|
+
* Whether {@link #spanWrap} and similar methods should always use the same
|
93
|
+
* span structure, regardless of the combination of directionalities, for a
|
94
|
+
* stable DOM structure.
|
95
|
+
* @type {boolean}
|
96
|
+
* @private
|
97
|
+
*/
|
98
|
+
this.alwaysSpan_ = !!opt_alwaysSpan;
|
99
|
+
};
|
100
|
+
|
101
|
+
|
102
|
+
/**
|
103
|
+
* @return {goog.i18n.bidi.Dir} The context directionality.
|
104
|
+
*/
|
105
|
+
goog.i18n.BidiFormatter.prototype.getContextDir = function() {
|
106
|
+
return this.contextDir_;
|
107
|
+
};
|
108
|
+
|
109
|
+
|
110
|
+
/**
|
111
|
+
* @return {boolean} Whether alwaysSpan is set.
|
112
|
+
*/
|
113
|
+
goog.i18n.BidiFormatter.prototype.getAlwaysSpan = function() {
|
114
|
+
return this.alwaysSpan_;
|
115
|
+
};
|
116
|
+
|
117
|
+
|
118
|
+
/**
|
119
|
+
* @param {goog.i18n.bidi.Dir|number|boolean} contextDir The context
|
120
|
+
* directionality. May be supplied either as a goog.i18n.bidi.Dir constant,
|
121
|
+
* as a number (positive = LRT, negative = RTL, 0 = unknown) or as a boolean
|
122
|
+
* (true = RTL, false = LTR).
|
123
|
+
*/
|
124
|
+
goog.i18n.BidiFormatter.prototype.setContextDir = function(contextDir) {
|
125
|
+
this.contextDir_ = goog.i18n.bidi.toDir(contextDir);
|
126
|
+
};
|
127
|
+
|
128
|
+
|
129
|
+
/**
|
130
|
+
* @param {boolean} alwaysSpan Whether {@link #spanWrap} should always use a
|
131
|
+
* 'span' tag, even when the input directionality is neutral or matches the
|
132
|
+
* context, so that the DOM structure of the output does not depend on the
|
133
|
+
* combination of directionalities.
|
134
|
+
*/
|
135
|
+
goog.i18n.BidiFormatter.prototype.setAlwaysSpan = function(alwaysSpan) {
|
136
|
+
this.alwaysSpan_ = alwaysSpan;
|
137
|
+
};
|
138
|
+
|
139
|
+
|
140
|
+
/**
|
141
|
+
* Returns the directionality of input argument {@code str}.
|
142
|
+
* Identical to {@link goog.i18n.bidi.estimateDirection}.
|
143
|
+
*
|
144
|
+
* @param {string} str The input text.
|
145
|
+
* @param {boolean=} opt_isHtml Whether {@code str} is HTML / HTML-escaped.
|
146
|
+
* Default: false.
|
147
|
+
* @return {goog.i18n.bidi.Dir} Estimated overall directionality of {@code str}.
|
148
|
+
*/
|
149
|
+
goog.i18n.BidiFormatter.prototype.estimateDirection =
|
150
|
+
goog.i18n.bidi.estimateDirection;
|
151
|
+
|
152
|
+
|
153
|
+
/**
|
154
|
+
* Returns true if two given directionalities are opposite.
|
155
|
+
* Note: the implementation is based on the numeric values of the Dir enum.
|
156
|
+
*
|
157
|
+
* @param {goog.i18n.bidi.Dir} dir1 1st directionality.
|
158
|
+
* @param {goog.i18n.bidi.Dir} dir2 2nd directionality.
|
159
|
+
* @return {boolean} Whether the directionalities are opposite.
|
160
|
+
* @private
|
161
|
+
*/
|
162
|
+
goog.i18n.BidiFormatter.prototype.areDirectionalitiesOpposite_ = function(dir1,
|
163
|
+
dir2) {
|
164
|
+
return dir1 * dir2 < 0;
|
165
|
+
};
|
166
|
+
|
167
|
+
|
168
|
+
/**
|
169
|
+
* Returns a unicode BiDi mark matching the context directionality (LRM or
|
170
|
+
* RLM) if {@code opt_dirReset}, and if either the directionality or the exit
|
171
|
+
* directionality of {@code str} is opposite to the context directionality.
|
172
|
+
* Otherwise returns the empty string.
|
173
|
+
*
|
174
|
+
* @param {string} str The input text.
|
175
|
+
* @param {goog.i18n.bidi.Dir} dir {@code str}'s overall directionality.
|
176
|
+
* @param {boolean=} opt_isHtml Whether {@code str} is HTML / HTML-escaped.
|
177
|
+
* Default: false.
|
178
|
+
* @param {boolean=} opt_dirReset Whether to perform the reset. Default: false.
|
179
|
+
* @return {string} A unicode BiDi mark or the empty string.
|
180
|
+
* @private
|
181
|
+
*/
|
182
|
+
goog.i18n.BidiFormatter.prototype.dirResetIfNeeded_ = function(str, dir,
|
183
|
+
opt_isHtml, opt_dirReset) {
|
184
|
+
// endsWithRtl and endsWithLtr are called only if needed (short-circuit).
|
185
|
+
if (opt_dirReset &&
|
186
|
+
(this.areDirectionalitiesOpposite_(dir, this.contextDir_) ||
|
187
|
+
(this.contextDir_ == goog.i18n.bidi.Dir.LTR &&
|
188
|
+
goog.i18n.bidi.endsWithRtl(str, opt_isHtml)) ||
|
189
|
+
(this.contextDir_ == goog.i18n.bidi.Dir.RTL &&
|
190
|
+
goog.i18n.bidi.endsWithLtr(str, opt_isHtml)))) {
|
191
|
+
return this.contextDir_ == goog.i18n.bidi.Dir.LTR ?
|
192
|
+
goog.i18n.bidi.Format.LRM : goog.i18n.bidi.Format.RLM;
|
193
|
+
} else {
|
194
|
+
return '';
|
195
|
+
}
|
196
|
+
};
|
197
|
+
|
198
|
+
|
199
|
+
/**
|
200
|
+
* Returns "rtl" if {@code str}'s estimated directionality is RTL, and "ltr" if
|
201
|
+
* it is LTR. In case it's UNKNOWN, returns "rtl" if the context directionality
|
202
|
+
* is RTL, and "ltr" otherwise.
|
203
|
+
* Needed for GXP, which can't handle dirAttr.
|
204
|
+
* Example use case:
|
205
|
+
* <td expr:dir='bidiFormatter.dirAttrValue(foo)'><gxp:eval expr='foo'></td>
|
206
|
+
*
|
207
|
+
* @param {string} str Text whose directionality is to be estimated.
|
208
|
+
* @param {boolean=} opt_isHtml Whether {@code str} is HTML / HTML-escaped.
|
209
|
+
* Default: false.
|
210
|
+
* @return {string} "rtl" or "ltr", according to the logic described above.
|
211
|
+
*/
|
212
|
+
goog.i18n.BidiFormatter.prototype.dirAttrValue = function(str, opt_isHtml) {
|
213
|
+
return this.knownDirAttrValue(this.estimateDirection(str, opt_isHtml));
|
214
|
+
};
|
215
|
+
|
216
|
+
|
217
|
+
/**
|
218
|
+
* Returns "rtl" if the given directionality is RTL, and "ltr" if it is LTR. In
|
219
|
+
* case it's UNKNOWN, returns "rtl" if the context directionality is RTL, and
|
220
|
+
* "ltr" otherwise.
|
221
|
+
*
|
222
|
+
* @param {goog.i18n.bidi.Dir} dir A directionality.
|
223
|
+
* @return {string} "rtl" or "ltr", according to the logic described above.
|
224
|
+
*/
|
225
|
+
goog.i18n.BidiFormatter.prototype.knownDirAttrValue = function(dir) {
|
226
|
+
if (dir == goog.i18n.bidi.Dir.UNKNOWN) {
|
227
|
+
dir = this.contextDir_;
|
228
|
+
}
|
229
|
+
|
230
|
+
return dir == goog.i18n.bidi.Dir.RTL ? 'rtl' : 'ltr';
|
231
|
+
};
|
232
|
+
|
233
|
+
|
234
|
+
/**
|
235
|
+
* Returns "dir=ltr" or "dir=rtl", depending on {@code str}'s estimated
|
236
|
+
* directionality, if it is not the same as the context directionality.
|
237
|
+
* Otherwise, returns the empty string.
|
238
|
+
*
|
239
|
+
* @param {string} str Text whose directionality is to be estimated.
|
240
|
+
* @param {boolean=} opt_isHtml Whether {@code str} is HTML / HTML-escaped.
|
241
|
+
* Default: false.
|
242
|
+
* @return {string} "dir=rtl" for RTL text in non-RTL context; "dir=ltr" for LTR
|
243
|
+
* text in non-LTR context; else, the empty string.
|
244
|
+
*/
|
245
|
+
goog.i18n.BidiFormatter.prototype.dirAttr = function(str, opt_isHtml) {
|
246
|
+
return this.knownDirAttr(this.estimateDirection(str, opt_isHtml));
|
247
|
+
};
|
248
|
+
|
249
|
+
|
250
|
+
/**
|
251
|
+
* Returns "dir=ltr" or "dir=rtl", depending on the given directionality, if it
|
252
|
+
* is not the same as the context directionality. Otherwise, returns the empty
|
253
|
+
* string.
|
254
|
+
*
|
255
|
+
* @param {goog.i18n.bidi.Dir} dir A directionality.
|
256
|
+
* @return {string} "dir=rtl" for RTL text in non-RTL context; "dir=ltr" for LTR
|
257
|
+
* text in non-LTR context; else, the empty string.
|
258
|
+
*/
|
259
|
+
goog.i18n.BidiFormatter.prototype.knownDirAttr = function(dir) {
|
260
|
+
if (dir != this.contextDir_) {
|
261
|
+
return dir == goog.i18n.bidi.Dir.RTL ? 'dir=rtl' :
|
262
|
+
dir == goog.i18n.bidi.Dir.LTR ? 'dir=ltr' : '';
|
263
|
+
}
|
264
|
+
return '';
|
265
|
+
};
|
266
|
+
|
267
|
+
|
268
|
+
/**
|
269
|
+
* Formats a string of unknown directionality for use in HTML output of the
|
270
|
+
* context directionality, so an opposite-directionality string is neither
|
271
|
+
* garbled nor garbles what follows it.
|
272
|
+
* The algorithm: estimates the directionality of input argument {@code str}. In
|
273
|
+
* case its directionality doesn't match the context directionality, wraps it
|
274
|
+
* with a 'span' tag and adds a "dir" attribute (either 'dir=rtl' or 'dir=ltr').
|
275
|
+
* If setAlwaysSpan(true) was used, the input is always wrapped with 'span',
|
276
|
+
* skipping just the dir attribute when it's not needed.
|
277
|
+
*
|
278
|
+
* If {@code opt_dirReset}, and if the overall directionality or the exit
|
279
|
+
* directionality of {@code str} are opposite to the context directionality, a
|
280
|
+
* trailing unicode BiDi mark matching the context directionality is appened
|
281
|
+
* (LRM or RLM).
|
282
|
+
*
|
283
|
+
* If !{@code opt_isHtml}, HTML-escapes {@code str} regardless of wrapping.
|
284
|
+
*
|
285
|
+
* @param {string} str The input text.
|
286
|
+
* @param {boolean=} opt_isHtml Whether {@code str} is HTML / HTML-escaped.
|
287
|
+
* Default: false.
|
288
|
+
* @param {boolean=} opt_dirReset Whether to append a trailing unicode bidi mark
|
289
|
+
* matching the context directionality, when needed, to prevent the possible
|
290
|
+
* garbling of whatever may follow {@code str}. Default: true.
|
291
|
+
* @return {string} Input text after applying the above processing.
|
292
|
+
*/
|
293
|
+
goog.i18n.BidiFormatter.prototype.spanWrap = function(str, opt_isHtml,
|
294
|
+
opt_dirReset) {
|
295
|
+
var dir = this.estimateDirection(str, opt_isHtml);
|
296
|
+
return this.spanWrapWithKnownDir(dir, str, opt_isHtml, opt_dirReset);
|
297
|
+
};
|
298
|
+
|
299
|
+
|
300
|
+
/**
|
301
|
+
* Formats a string of given directionality for use in HTML output of the
|
302
|
+
* context directionality, so an opposite-directionality string is neither
|
303
|
+
* garbled nor garbles what follows it.
|
304
|
+
* The algorithm: If {@code dir} doesn't match the context directionality, wraps
|
305
|
+
* {@code str} with a 'span' tag and adds a "dir" attribute (either 'dir=rtl' or
|
306
|
+
* 'dir=ltr'). If setAlwaysSpan(true) was used, the input is always wrapped with
|
307
|
+
* 'span', skipping just the dir attribute when it's not needed.
|
308
|
+
*
|
309
|
+
* If {@code opt_dirReset}, and if {@code dir} or the exit directionality of
|
310
|
+
* {@code str} are opposite to the context directionality, a trailing unicode
|
311
|
+
* BiDi mark matching the context directionality is appened (LRM or RLM).
|
312
|
+
*
|
313
|
+
* If !{@code opt_isHtml}, HTML-escapes {@code str} regardless of wrapping.
|
314
|
+
*
|
315
|
+
* @param {goog.i18n.bidi.Dir} dir {@code str}'s overall directionality.
|
316
|
+
* @param {string} str The input text.
|
317
|
+
* @param {boolean=} opt_isHtml Whether {@code str} is HTML / HTML-escaped.
|
318
|
+
* Default: false.
|
319
|
+
* @param {boolean=} opt_dirReset Whether to append a trailing unicode bidi mark
|
320
|
+
* matching the context directionality, when needed, to prevent the possible
|
321
|
+
* garbling of whatever may follow {@code str}. Default: true.
|
322
|
+
* @return {string} Input text after applying the above processing.
|
323
|
+
*/
|
324
|
+
goog.i18n.BidiFormatter.prototype.spanWrapWithKnownDir = function(dir, str,
|
325
|
+
opt_isHtml, opt_dirReset) {
|
326
|
+
opt_dirReset = opt_dirReset || (opt_dirReset == undefined);
|
327
|
+
// Whether to add the "dir" attribute.
|
328
|
+
var dirCondition = dir != goog.i18n.bidi.Dir.UNKNOWN && dir !=
|
329
|
+
this.contextDir_;
|
330
|
+
if (!opt_isHtml) {
|
331
|
+
str = goog.string.htmlEscape(str);
|
332
|
+
}
|
333
|
+
|
334
|
+
var result = [];
|
335
|
+
if (this.alwaysSpan_ || dirCondition) { // Wrap is needed
|
336
|
+
result.push('<span');
|
337
|
+
if (dirCondition) {
|
338
|
+
result.push(dir == goog.i18n.bidi.Dir.RTL ? ' dir=rtl' : ' dir=ltr');
|
339
|
+
}
|
340
|
+
result.push('>' + str + '</span>');
|
341
|
+
} else {
|
342
|
+
result.push(str);
|
343
|
+
}
|
344
|
+
|
345
|
+
result.push(this.dirResetIfNeeded_(str, dir, true, opt_dirReset));
|
346
|
+
return result.join('');
|
347
|
+
};
|
348
|
+
|
349
|
+
|
350
|
+
/**
|
351
|
+
* Formats a string of unknown directionality for use in plain-text output of
|
352
|
+
* the context directionality, so an opposite-directionality string is neither
|
353
|
+
* garbled nor garbles what follows it.
|
354
|
+
* As opposed to {@link #spanWrap}, this makes use of unicode BiDi formatting
|
355
|
+
* characters. In HTML, its *only* valid use is inside of elements that do not
|
356
|
+
* allow mark-up, e.g. an 'option' tag.
|
357
|
+
* The algorithm: estimates the directionality of input argument {@code str}.
|
358
|
+
* In case it doesn't match the context directionality, wraps it with Unicode
|
359
|
+
* BiDi formatting characters: RLE{@code str}PDF for RTL text, and
|
360
|
+
* LRE{@code str}PDF for LTR text.
|
361
|
+
*
|
362
|
+
* If {@code opt_dirReset}, and if the overall directionality or the exit
|
363
|
+
* directionality of {@code str} are opposite to the context directionality, a
|
364
|
+
* trailing unicode BiDi mark matching the context directionality is appended
|
365
|
+
* (LRM or RLM).
|
366
|
+
*
|
367
|
+
* Does *not* do HTML-escaping regardless of the value of {@code opt_isHtml}.
|
368
|
+
* The return value can be HTML-escaped as necessary.
|
369
|
+
*
|
370
|
+
* @param {string} str The input text.
|
371
|
+
* @param {boolean=} opt_isHtml Whether {@code str} is HTML / HTML-escaped.
|
372
|
+
* Default: false.
|
373
|
+
* @param {boolean=} opt_dirReset Whether to append a trailing unicode bidi mark
|
374
|
+
* matching the context directionality, when needed, to prevent the possible
|
375
|
+
* garbling of whatever may follow {@code str}. Default: true.
|
376
|
+
* @return {string} Input text after applying the above processing.
|
377
|
+
*/
|
378
|
+
goog.i18n.BidiFormatter.prototype.unicodeWrap = function(str, opt_isHtml,
|
379
|
+
opt_dirReset) {
|
380
|
+
var dir = this.estimateDirection(str, opt_isHtml);
|
381
|
+
return this.unicodeWrapWithKnownDir(dir, str, opt_isHtml, opt_dirReset);
|
382
|
+
};
|
383
|
+
|
384
|
+
|
385
|
+
/**
|
386
|
+
* Formats a string of given directionality for use in plain-text output of the
|
387
|
+
* context directionality, so an opposite-directionality string is neither
|
388
|
+
* garbled nor garbles what follows it.
|
389
|
+
* As opposed to {@link #spanWrapWithKnownDir}, makes use of unicode BiDi
|
390
|
+
* formatting characters. In HTML, its *only* valid use is inside of elements
|
391
|
+
* that do not allow mark-up, e.g. an 'option' tag.
|
392
|
+
* The algorithm: If {@code dir} doesn't match the context directionality, wraps
|
393
|
+
* {@code str} with Unicode BiDi formatting characters: RLE{@code str}PDF for
|
394
|
+
* RTL text, and LRE{@code str}PDF for LTR text.
|
395
|
+
*
|
396
|
+
* If {@code opt_dirReset}, and if the overall directionality or the exit
|
397
|
+
* directionality of {@code str} are opposite to the context directionality, a
|
398
|
+
* trailing unicode BiDi mark matching the context directionality is appended
|
399
|
+
* (LRM or RLM).
|
400
|
+
*
|
401
|
+
* Does *not* do HTML-escaping regardless of the value of {@code opt_isHtml}.
|
402
|
+
* The return value can be HTML-escaped as necessary.
|
403
|
+
*
|
404
|
+
* @param {goog.i18n.bidi.Dir} dir {@code str}'s overall directionality.
|
405
|
+
* @param {string} str The input text.
|
406
|
+
* @param {boolean=} opt_isHtml Whether {@code str} is HTML / HTML-escaped.
|
407
|
+
* Default: false.
|
408
|
+
* @param {boolean=} opt_dirReset Whether to append a trailing unicode bidi mark
|
409
|
+
* matching the context directionality, when needed, to prevent the possible
|
410
|
+
* garbling of whatever may follow {@code str}. Default: true.
|
411
|
+
* @return {string} Input text after applying the above processing.
|
412
|
+
*/
|
413
|
+
goog.i18n.BidiFormatter.prototype.unicodeWrapWithKnownDir = function(dir, str,
|
414
|
+
opt_isHtml, opt_dirReset) {
|
415
|
+
opt_dirReset = opt_dirReset || (opt_dirReset == undefined);
|
416
|
+
var result = [];
|
417
|
+
if (dir != goog.i18n.bidi.Dir.UNKNOWN && dir != this.contextDir_) {
|
418
|
+
result.push(dir == goog.i18n.bidi.Dir.RTL ? goog.i18n.bidi.Format.RLE :
|
419
|
+
goog.i18n.bidi.Format.LRE);
|
420
|
+
result.push(str);
|
421
|
+
result.push(goog.i18n.bidi.Format.PDF);
|
422
|
+
} else {
|
423
|
+
result.push(str);
|
424
|
+
}
|
425
|
+
|
426
|
+
result.push(this.dirResetIfNeeded_(str, dir, opt_isHtml, opt_dirReset));
|
427
|
+
return result.join('');
|
428
|
+
};
|
429
|
+
|
430
|
+
|
431
|
+
/**
|
432
|
+
* Returns a Unicode BiDi mark matching the context directionality (LRM or RLM)
|
433
|
+
* if the directionality or the exit directionality of {@code str} are opposite
|
434
|
+
* to the context directionality. Otherwise returns the empty string.
|
435
|
+
*
|
436
|
+
* @param {string} str The input text.
|
437
|
+
* @param {boolean=} opt_isHtml Whether {@code str} is HTML / HTML-escaped.
|
438
|
+
* Default: false.
|
439
|
+
* @return {string} A Unicode bidi mark matching the global directionality or
|
440
|
+
* the empty string.
|
441
|
+
*/
|
442
|
+
goog.i18n.BidiFormatter.prototype.markAfter = function(str, opt_isHtml) {
|
443
|
+
return this.dirResetIfNeeded_(str,
|
444
|
+
this.estimateDirection(str, opt_isHtml), opt_isHtml, true);
|
445
|
+
};
|
446
|
+
|
447
|
+
|
448
|
+
/**
|
449
|
+
* Returns the Unicode BiDi mark matching the context directionality (LRM for
|
450
|
+
* LTR context directionality, RLM for RTL context directionality), or the
|
451
|
+
* empty string for neutral / unknown context directionality.
|
452
|
+
*
|
453
|
+
* @return {string} LRM for LTR context directionality and RLM for RTL context
|
454
|
+
* directionality.
|
455
|
+
*/
|
456
|
+
goog.i18n.BidiFormatter.prototype.mark = function() {
|
457
|
+
switch (this.contextDir_) {
|
458
|
+
case (goog.i18n.bidi.Dir.LTR):
|
459
|
+
return goog.i18n.bidi.Format.LRM;
|
460
|
+
case (goog.i18n.bidi.Dir.RTL):
|
461
|
+
return goog.i18n.bidi.Format.RLM;
|
462
|
+
default:
|
463
|
+
return '';
|
464
|
+
}
|
465
|
+
};
|
466
|
+
|
467
|
+
|
468
|
+
/**
|
469
|
+
* Returns 'right' for RTL context directionality. Otherwise (LTR or neutral /
|
470
|
+
* unknown context directionality) returns 'left'.
|
471
|
+
*
|
472
|
+
* @return {string} 'right' for RTL context directionality and 'left' for other
|
473
|
+
* context directionality.
|
474
|
+
*/
|
475
|
+
goog.i18n.BidiFormatter.prototype.startEdge = function() {
|
476
|
+
return this.contextDir_ == goog.i18n.bidi.Dir.RTL ?
|
477
|
+
goog.i18n.bidi.RIGHT : goog.i18n.bidi.LEFT;
|
478
|
+
};
|
479
|
+
|
480
|
+
|
481
|
+
/**
|
482
|
+
* Returns 'left' for RTL context directionality. Otherwise (LTR or neutral /
|
483
|
+
* unknown context directionality) returns 'right'.
|
484
|
+
*
|
485
|
+
* @return {string} 'left' for RTL context directionality and 'right' for other
|
486
|
+
* context directionality.
|
487
|
+
*/
|
488
|
+
goog.i18n.BidiFormatter.prototype.endEdge = function() {
|
489
|
+
return this.contextDir_ == goog.i18n.bidi.Dir.RTL ?
|
490
|
+
goog.i18n.bidi.LEFT : goog.i18n.bidi.RIGHT;
|
491
|
+
};
|
492
|
+
;
|
493
|
+
FI"
|
494
|
+
F"%b319458ffe747a792465127563da4a4c
|