yellow-brick-road 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rst +10 -5
- data/lib/yellow-brick-road/directive_processor.rb +10 -3
- data/lib/yellow-brick-road/version.rb +1 -1
- data/test/dummy/app/assets/javascripts/closure-deps.js +3 -3
- data/test/dummy/log/development.log +159 -0
- data/test/dummy/tmp/cache/assets/C1E/0C0/sprockets%2F9c2f7430126aff8d8514326208712832 +165 -0
- data/test/dummy/tmp/cache/assets/C29/5D0/sprockets%2F1498f4451d0836a53c7c302c49920996 +0 -0
- data/test/dummy/tmp/cache/assets/C7E/9F0/sprockets%2F89862076204c62c4593ac20de32da909 +6 -6
- data/test/dummy/tmp/cache/assets/CB4/5B0/sprockets%2Ff17618b71eca9a4621f68626572a75b2 +103 -0
- data/test/dummy/tmp/cache/assets/CC2/240/sprockets%2F9f41da672330830c3366594f7ff5e7f6 +590 -0
- data/test/dummy/tmp/cache/assets/CC4/2C0/sprockets%2F715db78c7d974ea64406ed9711793f42 +494 -0
- data/test/dummy/tmp/cache/assets/CE1/610/sprockets%2F50c01109ecf86153176ccf577595fab4 +53 -0
- data/test/dummy/tmp/cache/assets/CE1/C20/sprockets%2F58a7b0499656c97a2204b5821eadab84 +207 -0
- data/test/dummy/tmp/cache/assets/CE4/DE0/sprockets%2Fb3aab0604ee02598f339965ec583a746 +204 -0
- data/test/dummy/tmp/cache/assets/CE9/B00/sprockets%2F80b139f66661444d6a781bfe56aee076 +0 -0
- data/test/dummy/tmp/cache/assets/CEB/840/sprockets%2F38fe57c2a5963f36a49404f672cc707b +0 -0
- data/test/dummy/tmp/cache/assets/CEC/6C0/sprockets%2F01b982295748dbd09683557aebd358bd +0 -0
- data/test/dummy/tmp/cache/assets/CF0/140/sprockets%2F3974b046fe949e86ef851a0271eb9d50 +1545 -0
- data/test/dummy/tmp/cache/assets/D01/DF0/sprockets%2F2ce268622b41a173bb209465a2ced6b9 +806 -0
- data/test/dummy/tmp/cache/assets/D05/920/sprockets%2F909507434dcc270db4853e4c147f0aac +4 -5
- data/test/dummy/tmp/cache/assets/D0A/C10/sprockets%2Fd050d5ee6a2073aa708a26c589a4c974 +283 -0
- data/test/dummy/tmp/cache/assets/D0F/360/sprockets%2Fa18927874a5e02c58c14c5b5df19ec04 +300 -0
- data/test/dummy/tmp/cache/assets/D15/700/sprockets%2F2987192f402d2bdc72792b5ae17f9a2f +142 -0
- data/test/dummy/tmp/cache/assets/D15/F60/sprockets%2Fa28394e3f80365b5bc86794dd46daa22 +0 -0
- data/test/dummy/tmp/cache/assets/D1F/E60/sprockets%2Fe65796b72231e36f5573ce71e2c8bbf8 +511 -0
- data/test/dummy/tmp/cache/assets/D22/200/sprockets%2F874bd1079c304ae88fbec8434d6d7794 +187 -0
- data/test/dummy/tmp/cache/assets/D3B/6A0/sprockets%2Ff8a978a3672b4f7ba513303b91ad15fc +127 -0
- data/test/dummy/tmp/cache/assets/D3C/530/sprockets%2Fe6730ff143273d9a7471b4afc3e1c19d +0 -0
- data/test/dummy/tmp/cache/assets/D41/B30/sprockets%2Fba1b93913dd01d83ac9a96df334456f8 +0 -0
- data/test/dummy/tmp/cache/assets/D49/570/sprockets%2Fd76be81d59871518ea06d3668f2c4bbb +239 -0
- data/test/dummy/tmp/cache/assets/D49/DA0/sprockets%2Fa84f85a305cde80a4d53785d7be0892f +457 -0
- data/test/dummy/tmp/cache/assets/D5C/760/sprockets%2F5cd491e0f9106cfd4ec4938896c97de7 +256 -0
- data/test/dummy/tmp/cache/assets/D5C/A00/sprockets%2Fefe291b3012745251e2641defbe4cad0 +1529 -0
- data/test/dummy/tmp/cache/assets/D68/2B0/sprockets%2Fe51ab0aca893e08c40f9672edef71106 +0 -0
- data/test/dummy/tmp/cache/assets/D6E/EA0/sprockets%2Fb52cbc47414c9e60ad4c46824928fbbe +115 -0
- data/test/dummy/tmp/cache/assets/D70/0B0/sprockets%2F1ae574bacfb86b4d51281b5e47fe1892 +505 -0
- data/test/dummy/tmp/cache/assets/D75/A60/sprockets%2Fab64285176f11f975fb6bb40af8bce76 +0 -0
- data/test/dummy/tmp/cache/assets/D76/0A0/sprockets%2F3ad3bd078c47096b34d5bcce886d7b47 +794 -0
- data/test/dummy/tmp/cache/assets/D79/C00/sprockets%2F94449fa386c370a1ebd7628eba9afe72 +72 -0
- data/test/dummy/tmp/cache/assets/D7B/310/sprockets%2Ff56e44be18b2d65efda80e588e5229a4 +0 -0
- data/test/dummy/tmp/cache/assets/D84/210/sprockets%2Fabd0103ccec2b428ac62c94e4c40b384 +7 -8
- data/test/dummy/tmp/cache/assets/D95/D20/sprockets%2F05b19351f203fb1eadf8ef1f0e6f9a60 +173 -0
- data/test/dummy/tmp/cache/assets/D9F/250/sprockets%2F40dcbb8f852f0e6360c4afb1f39964eb +0 -0
- data/test/dummy/tmp/cache/assets/DA8/0E0/sprockets%2F1351359f5bbdb94ef7d247df9af38bd1 +2556 -0
- data/test/dummy/tmp/cache/assets/DB3/070/sprockets%2Fd98f91680433cec456e6eb7485dcfdbc +522 -0
- data/test/dummy/tmp/cache/assets/DC4/6E0/sprockets%2F72117f09fccb98e6aac4cd1124edae42 +2539 -0
- data/test/dummy/tmp/cache/assets/DCC/D50/sprockets%2F9b2b027991c15af6f8afeacdd183c14e +1260 -0
- data/test/dummy/tmp/cache/assets/DD9/FF0/sprockets%2Fdf5dcfe86e199b272742a52a4b7e5fbd +823 -0
- data/test/dummy/tmp/cache/assets/DE7/0D0/sprockets%2Fe4d9fe29b6d96cdeb070d9b595af83d7 +1354 -0
- data/test/dummy/tmp/cache/assets/E00/3A0/sprockets%2Fc1db8cbfbc94bd2736f9f067a4c06cc7 +811 -0
- data/test/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/test/dummy/tmp/cache/assets/E0C/C80/sprockets%2F55805edb5f27aaef88eef6632fd08ade +1277 -0
- data/test/dummy/tmp/cache/assets/E1B/CF0/sprockets%2Feb58b29b94f29d7da8d9fbe666e4a8dd +474 -0
- data/test/dummy/tmp/cache/assets/E1E/E00/sprockets%2Fb005d4fa3dc6cfc1c5098e0fdb3f6b2b +1371 -0
- data/test/dummy/tmp/cache/assets/E30/8E0/sprockets%2Fef4fdb83b3eefb027cbc8e19b274ec80 +607 -0
- metadata +96 -8
@@ -0,0 +1,823 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1325729947.961432:@value{I"
|
2
|
+
class:EFI"BundledAsset;
|
3
|
+
FI"id;
|
4
|
+
F"%6cd87eb40d8590e5ac6aa384edd8a458I"logical_path;
|
5
|
+
FI"closure/goog/i18n/bidi.js;
|
6
|
+
TI"
|
7
|
+
F"�/Users/ali/.rvm/gems/ruby-1.9.3-p0/bundler/gems/closure-library-wrapper-031d1d0f0e50/vendor/closure-library/closure/goog/i18n/bidi.jsI"content_type;
|
8
|
+
FI"application/javascript;
|
9
|
+
FI"
|
10
|
+
mtime;
|
11
|
+
FI"2012-01-03T00:52:24+00:00;
|
12
|
+
FI" body;
|
13
|
+
FI"9g// Copyright 2007 The Closure Library Authors. All Rights Reserved.
|
14
|
+
//
|
15
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
16
|
+
// you may not use this file except in compliance with the License.
|
17
|
+
// You may obtain a copy of the License at
|
18
|
+
//
|
19
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
20
|
+
//
|
21
|
+
// Unless required by applicable law or agreed to in writing, software
|
22
|
+
// distributed under the License is distributed on an "AS-IS" BASIS,
|
23
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
24
|
+
// See the License for the specific language governing permissions and
|
25
|
+
// limitations under the License.
|
26
|
+
|
27
|
+
/**
|
28
|
+
* @fileoverview Utility functions for supporting Bidi issues.
|
29
|
+
*/
|
30
|
+
|
31
|
+
|
32
|
+
/**
|
33
|
+
* Namespace for bidi supporting functions.
|
34
|
+
*/
|
35
|
+
|
36
|
+
goog.provide('goog.i18n.bidi');
|
37
|
+
|
38
|
+
|
39
|
+
/**
|
40
|
+
* @define {boolean} FORCE_RTL forces the {@link goog.i18n.bidi.IS_RTL} constant
|
41
|
+
* to say that the current locale is a RTL locale. This should only be used
|
42
|
+
* if you want to override the default behavior for deciding whether the
|
43
|
+
* current locale is RTL or not.
|
44
|
+
*
|
45
|
+
* {@see goog.i18n.bidi.IS_RTL}
|
46
|
+
*/
|
47
|
+
goog.i18n.bidi.FORCE_RTL = false;
|
48
|
+
|
49
|
+
|
50
|
+
/**
|
51
|
+
* Constant that defines whether or not the current locale is a RTL locale.
|
52
|
+
* If {@link goog.i18n.bidi.FORCE_RTL} is not true, this constant will default
|
53
|
+
* to check that {@link goog.LOCALE} is one of a few major RTL locales.
|
54
|
+
*
|
55
|
+
* <p>Since this constant refers to the directionality of the locale, it is up
|
56
|
+
* to the caller to determine if this constant should also be used for the
|
57
|
+
* direction of the UI.
|
58
|
+
*
|
59
|
+
* {@see goog.LOCALE}
|
60
|
+
*
|
61
|
+
* @type {boolean}
|
62
|
+
*
|
63
|
+
* TODO(user): write a test that checks that this is a compile-time constant.
|
64
|
+
* For example, for the default goog.LOCALE, compiling
|
65
|
+
* "if (goog.i18n.bidi.IS_RTL) alert('rtl') else {}" should produce no code.
|
66
|
+
*/
|
67
|
+
goog.i18n.bidi.IS_RTL = goog.i18n.bidi.FORCE_RTL ||
|
68
|
+
(goog.LOCALE.substring(0, 2).toLowerCase() == 'ar' ||
|
69
|
+
goog.LOCALE.substring(0, 2).toLowerCase() == 'fa' ||
|
70
|
+
goog.LOCALE.substring(0, 2).toLowerCase() == 'he' ||
|
71
|
+
goog.LOCALE.substring(0, 2).toLowerCase() == 'iw' ||
|
72
|
+
goog.LOCALE.substring(0, 2).toLowerCase() == 'ur' ||
|
73
|
+
goog.LOCALE.substring(0, 2).toLowerCase() == 'yi') &&
|
74
|
+
(goog.LOCALE.length == 2 ||
|
75
|
+
goog.LOCALE.substring(2, 3) == '-' ||
|
76
|
+
goog.LOCALE.substring(2, 3) == '_');
|
77
|
+
|
78
|
+
|
79
|
+
/**
|
80
|
+
* Unicode formatting characters and directionality string constants.
|
81
|
+
* @enum {string}
|
82
|
+
*/
|
83
|
+
goog.i18n.bidi.Format = {
|
84
|
+
/** Unicode "Left-To-Right Embedding" (LRE) character. */
|
85
|
+
LRE: '\u202A',
|
86
|
+
/** Unicode "Right-To-Left Embedding" (RLE) character. */
|
87
|
+
RLE: '\u202B',
|
88
|
+
/** Unicode "Pop Directional Formatting" (PDF) character. */
|
89
|
+
PDF: '\u202C',
|
90
|
+
/** Unicode "Left-To-Right Mark" (LRM) character. */
|
91
|
+
LRM: '\u200E',
|
92
|
+
/** Unicode "Right-To-Left Mark" (RLM) character. */
|
93
|
+
RLM: '\u200F'
|
94
|
+
};
|
95
|
+
|
96
|
+
|
97
|
+
/**
|
98
|
+
* Directionality enum.
|
99
|
+
* @enum {number}
|
100
|
+
*/
|
101
|
+
goog.i18n.bidi.Dir = {
|
102
|
+
RTL: -1,
|
103
|
+
UNKNOWN: 0,
|
104
|
+
LTR: 1
|
105
|
+
};
|
106
|
+
|
107
|
+
|
108
|
+
/**
|
109
|
+
* 'right' string constant.
|
110
|
+
* @type {string}
|
111
|
+
*/
|
112
|
+
goog.i18n.bidi.RIGHT = 'right';
|
113
|
+
|
114
|
+
|
115
|
+
/**
|
116
|
+
* 'left' string constant.
|
117
|
+
* @type {string}
|
118
|
+
*/
|
119
|
+
goog.i18n.bidi.LEFT = 'left';
|
120
|
+
|
121
|
+
|
122
|
+
/**
|
123
|
+
* 'left' if locale is RTL, 'right' if not.
|
124
|
+
* @type {string}
|
125
|
+
*/
|
126
|
+
goog.i18n.bidi.I18N_RIGHT = goog.i18n.bidi.IS_RTL ? goog.i18n.bidi.LEFT :
|
127
|
+
goog.i18n.bidi.RIGHT;
|
128
|
+
|
129
|
+
|
130
|
+
/**
|
131
|
+
* 'right' if locale is RTL, 'left' if not.
|
132
|
+
* @type {string}
|
133
|
+
*/
|
134
|
+
goog.i18n.bidi.I18N_LEFT = goog.i18n.bidi.IS_RTL ? goog.i18n.bidi.RIGHT :
|
135
|
+
goog.i18n.bidi.LEFT;
|
136
|
+
|
137
|
+
|
138
|
+
/**
|
139
|
+
* Convert a directionality given in various formats to a goog.i18n.bidi.Dir
|
140
|
+
* constant. Useful for interaction with different standards of directionality
|
141
|
+
* representation.
|
142
|
+
*
|
143
|
+
* @param {goog.i18n.bidi.Dir|number|boolean} givenDir Directionality given in
|
144
|
+
* one of the following formats:
|
145
|
+
* 1. A goog.i18n.bidi.Dir constant.
|
146
|
+
* 2. A number (positive = LRT, negative = RTL, 0 = unknown).
|
147
|
+
* 3. A boolean (true = RTL, false = LTR).
|
148
|
+
* @return {goog.i18n.bidi.Dir} A goog.i18n.bidi.Dir constant matching the given
|
149
|
+
* directionality.
|
150
|
+
*/
|
151
|
+
goog.i18n.bidi.toDir = function(givenDir) {
|
152
|
+
if (typeof givenDir == 'number') {
|
153
|
+
return givenDir > 0 ? goog.i18n.bidi.Dir.LTR :
|
154
|
+
givenDir < 0 ? goog.i18n.bidi.Dir.RTL : goog.i18n.bidi.Dir.UNKNOWN;
|
155
|
+
} else {
|
156
|
+
return givenDir ? goog.i18n.bidi.Dir.RTL : goog.i18n.bidi.Dir.LTR;
|
157
|
+
}
|
158
|
+
};
|
159
|
+
|
160
|
+
|
161
|
+
/**
|
162
|
+
* A practical pattern to identify strong LTR characters. This pattern is not
|
163
|
+
* theoretically correct according to the Unicode standard. It is simplified for
|
164
|
+
* performance and small code size.
|
165
|
+
* @type {string}
|
166
|
+
* @private
|
167
|
+
*/
|
168
|
+
goog.i18n.bidi.ltrChars_ =
|
169
|
+
'A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02B8\u0300-\u0590\u0800-\u1FFF' +
|
170
|
+
'\u2C00-\uFB1C\uFE00-\uFE6F\uFEFD-\uFFFF';
|
171
|
+
|
172
|
+
|
173
|
+
/**
|
174
|
+
* A practical pattern to identify strong RTL character. This pattern is not
|
175
|
+
* theoretically correct according to the Unicode standard. It is simplified
|
176
|
+
* for performance and small code size.
|
177
|
+
* @type {string}
|
178
|
+
* @private
|
179
|
+
*/
|
180
|
+
goog.i18n.bidi.rtlChars_ = '\u0591-\u07FF\uFB1D-\uFDFF\uFE70-\uFEFC';
|
181
|
+
|
182
|
+
|
183
|
+
/**
|
184
|
+
* Simplified regular expression for an HTML tag (opening or closing) or an HTML
|
185
|
+
* escape. We might want to skip over such expressions when estimating the text
|
186
|
+
* directionality.
|
187
|
+
* @type {RegExp}
|
188
|
+
* @private
|
189
|
+
*/
|
190
|
+
goog.i18n.bidi.htmlSkipReg_ = /<[^>]*>|&[^;]+;/g;
|
191
|
+
|
192
|
+
|
193
|
+
/**
|
194
|
+
* Returns the input text with spaces instead of HTML tags or HTML escapes, if
|
195
|
+
* opt_isStripNeeded is true. Else returns the input as is.
|
196
|
+
* Useful for text directionality estimation.
|
197
|
+
* Note: the function should not be used in other contexts; it is not 100%
|
198
|
+
* correct, but rather a good-enough implementation for directionality
|
199
|
+
* estimation purposes.
|
200
|
+
* @param {string} str The given string.
|
201
|
+
* @param {boolean=} opt_isStripNeeded Whether to perform the stripping.
|
202
|
+
* Default: false (to retain consistency with calling functions).
|
203
|
+
* @return {string} The given string cleaned of HTML tags / escapes.
|
204
|
+
* @private
|
205
|
+
*/
|
206
|
+
goog.i18n.bidi.stripHtmlIfNeeded_ = function(str, opt_isStripNeeded) {
|
207
|
+
return opt_isStripNeeded ? str.replace(goog.i18n.bidi.htmlSkipReg_, ' ') :
|
208
|
+
str;
|
209
|
+
};
|
210
|
+
|
211
|
+
|
212
|
+
/**
|
213
|
+
* Regular expression to check for RTL characters.
|
214
|
+
* @type {RegExp}
|
215
|
+
* @private
|
216
|
+
*/
|
217
|
+
goog.i18n.bidi.rtlCharReg_ = new RegExp('[' + goog.i18n.bidi.rtlChars_ + ']');
|
218
|
+
|
219
|
+
|
220
|
+
/**
|
221
|
+
* Regular expression to check for LTR characters.
|
222
|
+
* @type {RegExp}
|
223
|
+
* @private
|
224
|
+
*/
|
225
|
+
goog.i18n.bidi.ltrCharReg_ = new RegExp('[' + goog.i18n.bidi.ltrChars_ + ']');
|
226
|
+
|
227
|
+
|
228
|
+
/**
|
229
|
+
* Test whether the given string has any RTL characters in it.
|
230
|
+
* @param {string} str The given string that need to be tested.
|
231
|
+
* @param {boolean=} opt_isHtml Whether str is HTML / HTML-escaped.
|
232
|
+
* Default: false.
|
233
|
+
* @return {boolean} Whether the string contains RTL characters.
|
234
|
+
*/
|
235
|
+
goog.i18n.bidi.hasAnyRtl = function(str, opt_isHtml) {
|
236
|
+
return goog.i18n.bidi.rtlCharReg_.test(goog.i18n.bidi.stripHtmlIfNeeded_(
|
237
|
+
str, opt_isHtml));
|
238
|
+
};
|
239
|
+
|
240
|
+
|
241
|
+
/**
|
242
|
+
* Test whether the given string has any RTL characters in it.
|
243
|
+
* @param {string} str The given string that need to be tested.
|
244
|
+
* @return {boolean} Whether the string contains RTL characters.
|
245
|
+
* @deprecated Use hasAnyRtl.
|
246
|
+
*/
|
247
|
+
goog.i18n.bidi.hasRtlChar = goog.i18n.bidi.hasAnyRtl;
|
248
|
+
|
249
|
+
|
250
|
+
/**
|
251
|
+
* Test whether the given string has any LTR characters in it.
|
252
|
+
* @param {string} str The given string that need to be tested.
|
253
|
+
* @param {boolean=} opt_isHtml Whether str is HTML / HTML-escaped.
|
254
|
+
* Default: false.
|
255
|
+
* @return {boolean} Whether the string contains LTR characters.
|
256
|
+
*/
|
257
|
+
goog.i18n.bidi.hasAnyLtr = function(str, opt_isHtml) {
|
258
|
+
return goog.i18n.bidi.ltrCharReg_.test(goog.i18n.bidi.stripHtmlIfNeeded_(
|
259
|
+
str, opt_isHtml));
|
260
|
+
};
|
261
|
+
|
262
|
+
|
263
|
+
/**
|
264
|
+
* Regular expression pattern to check if the first character in the string
|
265
|
+
* is LTR.
|
266
|
+
* @type {RegExp}
|
267
|
+
* @private
|
268
|
+
*/
|
269
|
+
goog.i18n.bidi.ltrRe_ = new RegExp('^[' + goog.i18n.bidi.ltrChars_ + ']');
|
270
|
+
|
271
|
+
|
272
|
+
/**
|
273
|
+
* Regular expression pattern to check if the first character in the string
|
274
|
+
* is RTL.
|
275
|
+
* @type {RegExp}
|
276
|
+
* @private
|
277
|
+
*/
|
278
|
+
goog.i18n.bidi.rtlRe_ = new RegExp('^[' + goog.i18n.bidi.rtlChars_ + ']');
|
279
|
+
|
280
|
+
|
281
|
+
/**
|
282
|
+
* Check if the first character in the string is RTL or not.
|
283
|
+
* @param {string} str The given string that need to be tested.
|
284
|
+
* @return {boolean} Whether the first character in str is an RTL char.
|
285
|
+
*/
|
286
|
+
goog.i18n.bidi.isRtlChar = function(str) {
|
287
|
+
return goog.i18n.bidi.rtlRe_.test(str);
|
288
|
+
};
|
289
|
+
|
290
|
+
|
291
|
+
/**
|
292
|
+
* Check if the first character in the string is LTR or not.
|
293
|
+
* @param {string} str The given string that need to be tested.
|
294
|
+
* @return {boolean} Whether the first character in str is an LTR char.
|
295
|
+
*/
|
296
|
+
goog.i18n.bidi.isLtrChar = function(str) {
|
297
|
+
return goog.i18n.bidi.ltrRe_.test(str);
|
298
|
+
};
|
299
|
+
|
300
|
+
|
301
|
+
/**
|
302
|
+
* Check if the first character in the string is neutral or not.
|
303
|
+
* @param {string} str The given string that need to be tested.
|
304
|
+
* @return {boolean} Whether the first character in str is a neutral char.
|
305
|
+
*/
|
306
|
+
goog.i18n.bidi.isNeutralChar = function(str) {
|
307
|
+
return !goog.i18n.bidi.isLtrChar(str) && !goog.i18n.bidi.isRtlChar(str);
|
308
|
+
};
|
309
|
+
|
310
|
+
|
311
|
+
/**
|
312
|
+
* Regular expressions to check if a piece of text if of LTR directionality
|
313
|
+
* on first character with strong directionality.
|
314
|
+
* @type {RegExp}
|
315
|
+
* @private
|
316
|
+
*/
|
317
|
+
goog.i18n.bidi.ltrDirCheckRe_ = new RegExp(
|
318
|
+
'^[^' + goog.i18n.bidi.rtlChars_ + ']*[' + goog.i18n.bidi.ltrChars_ + ']');
|
319
|
+
|
320
|
+
|
321
|
+
/**
|
322
|
+
* Regular expressions to check if a piece of text if of RTL directionality
|
323
|
+
* on first character with strong directionality.
|
324
|
+
* @type {RegExp}
|
325
|
+
* @private
|
326
|
+
*/
|
327
|
+
goog.i18n.bidi.rtlDirCheckRe_ = new RegExp(
|
328
|
+
'^[^' + goog.i18n.bidi.ltrChars_ + ']*[' + goog.i18n.bidi.rtlChars_ + ']');
|
329
|
+
|
330
|
+
|
331
|
+
/**
|
332
|
+
* Check whether the first strongly directional character (if any) is RTL.
|
333
|
+
* @param {string} str String being checked.
|
334
|
+
* @param {boolean=} opt_isHtml Whether str is HTML / HTML-escaped.
|
335
|
+
* Default: false.
|
336
|
+
* @return {boolean} Whether RTL directionality is detected using the first
|
337
|
+
* strongly-directional character method.
|
338
|
+
*/
|
339
|
+
goog.i18n.bidi.startsWithRtl = function(str, opt_isHtml) {
|
340
|
+
return goog.i18n.bidi.rtlDirCheckRe_.test(goog.i18n.bidi.stripHtmlIfNeeded_(
|
341
|
+
str, opt_isHtml));
|
342
|
+
};
|
343
|
+
|
344
|
+
|
345
|
+
/**
|
346
|
+
* Check whether the first strongly directional character (if any) is RTL.
|
347
|
+
* @param {string} str String being checked.
|
348
|
+
* @param {boolean=} opt_isHtml Whether str is HTML / HTML-escaped.
|
349
|
+
* Default: false.
|
350
|
+
* @return {boolean} Whether RTL directionality is detected using the first
|
351
|
+
* strongly-directional character method.
|
352
|
+
* @deprecated Use startsWithRtl.
|
353
|
+
*/
|
354
|
+
goog.i18n.bidi.isRtlText = goog.i18n.bidi.startsWithRtl;
|
355
|
+
|
356
|
+
|
357
|
+
/**
|
358
|
+
* Check whether the first strongly directional character (if any) is LTR.
|
359
|
+
* @param {string} str String being checked.
|
360
|
+
* @param {boolean=} opt_isHtml Whether str is HTML / HTML-escaped.
|
361
|
+
* Default: false.
|
362
|
+
* @return {boolean} Whether LTR directionality is detected using the first
|
363
|
+
* strongly-directional character method.
|
364
|
+
*/
|
365
|
+
goog.i18n.bidi.startsWithLtr = function(str, opt_isHtml) {
|
366
|
+
return goog.i18n.bidi.ltrDirCheckRe_.test(goog.i18n.bidi.stripHtmlIfNeeded_(
|
367
|
+
str, opt_isHtml));
|
368
|
+
};
|
369
|
+
|
370
|
+
|
371
|
+
/**
|
372
|
+
* Check whether the first strongly directional character (if any) is LTR.
|
373
|
+
* @param {string} str String being checked.
|
374
|
+
* @param {boolean=} opt_isHtml Whether str is HTML / HTML-escaped.
|
375
|
+
* Default: false.
|
376
|
+
* @return {boolean} Whether LTR directionality is detected using the first
|
377
|
+
* strongly-directional character method.
|
378
|
+
* @deprecated Use startsWithLtr.
|
379
|
+
*/
|
380
|
+
goog.i18n.bidi.isLtrText = goog.i18n.bidi.startsWithLtr;
|
381
|
+
|
382
|
+
|
383
|
+
/**
|
384
|
+
* Regular expression to check if a string looks like something that must
|
385
|
+
* always be LTR even in RTL text, e.g. a URL. When estimating the
|
386
|
+
* directionality of text containing these, we treat these as weakly LTR,
|
387
|
+
* like numbers.
|
388
|
+
* @type {RegExp}
|
389
|
+
* @private
|
390
|
+
*/
|
391
|
+
goog.i18n.bidi.isRequiredLtrRe_ = /^http:\/\/.*/;
|
392
|
+
|
393
|
+
|
394
|
+
/**
|
395
|
+
* Check whether the input string either contains no strongly directional
|
396
|
+
* characters or looks like a url.
|
397
|
+
* @param {string} str String being checked.
|
398
|
+
* @param {boolean=} opt_isHtml Whether str is HTML / HTML-escaped.
|
399
|
+
* Default: false.
|
400
|
+
* @return {boolean} Whether neutral directionality is detected.
|
401
|
+
*/
|
402
|
+
goog.i18n.bidi.isNeutralText = function(str, opt_isHtml) {
|
403
|
+
str = goog.i18n.bidi.stripHtmlIfNeeded_(str, opt_isHtml);
|
404
|
+
return goog.i18n.bidi.isRequiredLtrRe_.test(str) ||
|
405
|
+
!goog.i18n.bidi.hasAnyLtr(str) && !goog.i18n.bidi.hasAnyRtl(str);
|
406
|
+
};
|
407
|
+
|
408
|
+
|
409
|
+
/**
|
410
|
+
* Regular expressions to check if the last strongly-directional character in a
|
411
|
+
* piece of text is LTR.
|
412
|
+
* @type {RegExp}
|
413
|
+
* @private
|
414
|
+
*/
|
415
|
+
goog.i18n.bidi.ltrExitDirCheckRe_ = new RegExp(
|
416
|
+
'[' + goog.i18n.bidi.ltrChars_ + '][^' + goog.i18n.bidi.rtlChars_ + ']*$');
|
417
|
+
|
418
|
+
|
419
|
+
/**
|
420
|
+
* Regular expressions to check if the last strongly-directional character in a
|
421
|
+
* piece of text is RTL.
|
422
|
+
* @type {RegExp}
|
423
|
+
* @private
|
424
|
+
*/
|
425
|
+
goog.i18n.bidi.rtlExitDirCheckRe_ = new RegExp(
|
426
|
+
'[' + goog.i18n.bidi.rtlChars_ + '][^' + goog.i18n.bidi.ltrChars_ + ']*$');
|
427
|
+
|
428
|
+
|
429
|
+
/**
|
430
|
+
* Check if the exit directionality a piece of text is LTR, i.e. if the last
|
431
|
+
* strongly-directional character in the string is LTR.
|
432
|
+
* @param {string} str String being checked.
|
433
|
+
* @param {boolean=} opt_isHtml Whether str is HTML / HTML-escaped.
|
434
|
+
* Default: false.
|
435
|
+
* @return {boolean} Whether LTR exit directionality was detected.
|
436
|
+
*/
|
437
|
+
goog.i18n.bidi.endsWithLtr = function(str, opt_isHtml) {
|
438
|
+
return goog.i18n.bidi.ltrExitDirCheckRe_.test(
|
439
|
+
goog.i18n.bidi.stripHtmlIfNeeded_(str, opt_isHtml));
|
440
|
+
};
|
441
|
+
|
442
|
+
|
443
|
+
/**
|
444
|
+
* Check if the exit directionality a piece of text is LTR, i.e. if the last
|
445
|
+
* strongly-directional character in the string is LTR.
|
446
|
+
* @param {string} str String being checked.
|
447
|
+
* @param {boolean=} opt_isHtml Whether str is HTML / HTML-escaped.
|
448
|
+
* Default: false.
|
449
|
+
* @return {boolean} Whether LTR exit directionality was detected.
|
450
|
+
* @deprecated Use endsWithLtr.
|
451
|
+
*/
|
452
|
+
goog.i18n.bidi.isLtrExitText = goog.i18n.bidi.endsWithLtr;
|
453
|
+
|
454
|
+
|
455
|
+
/**
|
456
|
+
* Check if the exit directionality a piece of text is RTL, i.e. if the last
|
457
|
+
* strongly-directional character in the string is RTL.
|
458
|
+
* @param {string} str String being checked.
|
459
|
+
* @param {boolean=} opt_isHtml Whether str is HTML / HTML-escaped.
|
460
|
+
* Default: false.
|
461
|
+
* @return {boolean} Whether RTL exit directionality was detected.
|
462
|
+
*/
|
463
|
+
goog.i18n.bidi.endsWithRtl = function(str, opt_isHtml) {
|
464
|
+
return goog.i18n.bidi.rtlExitDirCheckRe_.test(
|
465
|
+
goog.i18n.bidi.stripHtmlIfNeeded_(str, opt_isHtml));
|
466
|
+
};
|
467
|
+
|
468
|
+
|
469
|
+
/**
|
470
|
+
* Check if the exit directionality a piece of text is RTL, i.e. if the last
|
471
|
+
* strongly-directional character in the string is RTL.
|
472
|
+
* @param {string} str String being checked.
|
473
|
+
* @param {boolean=} opt_isHtml Whether str is HTML / HTML-escaped.
|
474
|
+
* Default: false.
|
475
|
+
* @return {boolean} Whether RTL exit directionality was detected.
|
476
|
+
* @deprecated Use endsWithRtl.
|
477
|
+
*/
|
478
|
+
goog.i18n.bidi.isRtlExitText = goog.i18n.bidi.endsWithRtl;
|
479
|
+
|
480
|
+
|
481
|
+
/**
|
482
|
+
* A regular expression for matching right-to-left language codes.
|
483
|
+
* See {@link #isRtlLanguage} for the design.
|
484
|
+
* @type {RegExp}
|
485
|
+
* @private
|
486
|
+
*/
|
487
|
+
goog.i18n.bidi.rtlLocalesRe_ = new RegExp(
|
488
|
+
'^(ar|dv|he|iw|fa|nqo|ps|sd|ug|ur|yi|.*[-_](Arab|Hebr|Thaa|Nkoo|Tfng))' +
|
489
|
+
'(?!.*[-_](Latn|Cyrl)($|-|_))($|-|_)');
|
490
|
+
|
491
|
+
|
492
|
+
/**
|
493
|
+
* Check if a BCP 47 / III language code indicates an RTL language, i.e. either:
|
494
|
+
* - a language code explicitly specifying one of the right-to-left scripts,
|
495
|
+
* e.g. "az-Arab", or<p>
|
496
|
+
* - a language code specifying one of the languages normally written in a
|
497
|
+
* right-to-left script, e.g. "fa" (Farsi), except ones explicitly specifying
|
498
|
+
* Latin or Cyrillic script (which are the usual LTR alternatives).<p>
|
499
|
+
* The list of right-to-left scripts appears in the 100-199 range in
|
500
|
+
* http://www.unicode.org/iso15924/iso15924-num.html, of which Arabic and
|
501
|
+
* Hebrew are by far the most widely used. We also recognize Thaana, N'Ko, and
|
502
|
+
* Tifinagh, which also have significant modern usage. The rest (Syriac,
|
503
|
+
* Samaritan, Mandaic, etc.) seem to have extremely limited or no modern usage
|
504
|
+
* and are not recognized to save on code size.
|
505
|
+
* The languages usually written in a right-to-left script are taken as those
|
506
|
+
* with Suppress-Script: Hebr|Arab|Thaa|Nkoo|Tfng in
|
507
|
+
* http://www.iana.org/assignments/language-subtag-registry,
|
508
|
+
* as well as Sindhi (sd) and Uyghur (ug).
|
509
|
+
* Other subtags of the language code, e.g. regions like EG (Egypt), are
|
510
|
+
* ignored.
|
511
|
+
* @param {string} lang BCP 47 (a.k.a III) language code.
|
512
|
+
* @return {boolean} Whether the language code is an RTL language.
|
513
|
+
*/
|
514
|
+
goog.i18n.bidi.isRtlLanguage = function(lang) {
|
515
|
+
return goog.i18n.bidi.rtlLocalesRe_.test(lang);
|
516
|
+
};
|
517
|
+
|
518
|
+
|
519
|
+
/**
|
520
|
+
* Regular expression for bracket guard replacement in html.
|
521
|
+
* @type {RegExp}
|
522
|
+
* @private
|
523
|
+
*/
|
524
|
+
goog.i18n.bidi.bracketGuardHtmlRe_ =
|
525
|
+
/(\(.*?\)+)|(\[.*?\]+)|(\{.*?\}+)|(<.*?(>)+)/g;
|
526
|
+
|
527
|
+
|
528
|
+
/**
|
529
|
+
* Regular expression for bracket guard replacement in text.
|
530
|
+
* @type {RegExp}
|
531
|
+
* @private
|
532
|
+
*/
|
533
|
+
goog.i18n.bidi.bracketGuardTextRe_ =
|
534
|
+
/(\(.*?\)+)|(\[.*?\]+)|(\{.*?\}+)|(<.*?>+)/g;
|
535
|
+
|
536
|
+
|
537
|
+
/**
|
538
|
+
* Apply bracket guard using html span tag. This is to address the problem of
|
539
|
+
* messy bracket display frequently happens in RTL layout.
|
540
|
+
* @param {string} s The string that need to be processed.
|
541
|
+
* @param {boolean=} opt_isRtlContext specifies default direction (usually
|
542
|
+
* direction of the UI).
|
543
|
+
* @return {string} The processed string, with all bracket guarded.
|
544
|
+
*/
|
545
|
+
goog.i18n.bidi.guardBracketInHtml = function(s, opt_isRtlContext) {
|
546
|
+
var useRtl = opt_isRtlContext === undefined ?
|
547
|
+
goog.i18n.bidi.hasAnyRtl(s) : opt_isRtlContext;
|
548
|
+
if (useRtl) {
|
549
|
+
return s.replace(goog.i18n.bidi.bracketGuardHtmlRe_,
|
550
|
+
'<span dir=rtl>$&</span>');
|
551
|
+
}
|
552
|
+
return s.replace(goog.i18n.bidi.bracketGuardHtmlRe_,
|
553
|
+
'<span dir=ltr>$&</span>');
|
554
|
+
};
|
555
|
+
|
556
|
+
|
557
|
+
/**
|
558
|
+
* Apply bracket guard using LRM and RLM. This is to address the problem of
|
559
|
+
* messy bracket display frequently happens in RTL layout.
|
560
|
+
* This version works for both plain text and html. But it does not work as
|
561
|
+
* good as guardBracketInHtml in some cases.
|
562
|
+
* @param {string} s The string that need to be processed.
|
563
|
+
* @param {boolean=} opt_isRtlContext specifies default direction (usually
|
564
|
+
* direction of the UI).
|
565
|
+
* @return {string} The processed string, with all bracket guarded.
|
566
|
+
*/
|
567
|
+
goog.i18n.bidi.guardBracketInText = function(s, opt_isRtlContext) {
|
568
|
+
var useRtl = opt_isRtlContext === undefined ?
|
569
|
+
goog.i18n.bidi.hasAnyRtl(s) : opt_isRtlContext;
|
570
|
+
var mark = useRtl ? goog.i18n.bidi.Format.RLM : goog.i18n.bidi.Format.LRM;
|
571
|
+
return s.replace(goog.i18n.bidi.bracketGuardTextRe_, mark + '$&' + mark);
|
572
|
+
};
|
573
|
+
|
574
|
+
|
575
|
+
/**
|
576
|
+
* Enforce the html snippet in RTL directionality regardless overall context.
|
577
|
+
* If the html piece was enclosed by tag, dir will be applied to existing
|
578
|
+
* tag, otherwise a span tag will be added as wrapper. For this reason, if
|
579
|
+
* html snippet start with with tag, this tag must enclose the whole piece. If
|
580
|
+
* the tag already has a dir specified, this new one will override existing
|
581
|
+
* one in behavior (tested on FF and IE).
|
582
|
+
* @param {string} html The string that need to be processed.
|
583
|
+
* @return {string} The processed string, with directionality enforced to RTL.
|
584
|
+
*/
|
585
|
+
goog.i18n.bidi.enforceRtlInHtml = function(html) {
|
586
|
+
if (html.charAt(0) == '<') {
|
587
|
+
return html.replace(/<\w+/, '$& dir=rtl');
|
588
|
+
}
|
589
|
+
// '\n' is important for FF so that it won't incorrectly merge span groups
|
590
|
+
return '\n<span dir=rtl>' + html + '</span>';
|
591
|
+
};
|
592
|
+
|
593
|
+
|
594
|
+
/**
|
595
|
+
* Enforce RTL on both end of the given text piece using unicode BiDi formatting
|
596
|
+
* characters RLE and PDF.
|
597
|
+
* @param {string} text The piece of text that need to be wrapped.
|
598
|
+
* @return {string} The wrapped string after process.
|
599
|
+
*/
|
600
|
+
goog.i18n.bidi.enforceRtlInText = function(text) {
|
601
|
+
return goog.i18n.bidi.Format.RLE + text + goog.i18n.bidi.Format.PDF;
|
602
|
+
};
|
603
|
+
|
604
|
+
|
605
|
+
/**
|
606
|
+
* Enforce the html snippet in RTL directionality regardless overall context.
|
607
|
+
* If the html piece was enclosed by tag, dir will be applied to existing
|
608
|
+
* tag, otherwise a span tag will be added as wrapper. For this reason, if
|
609
|
+
* html snippet start with with tag, this tag must enclose the whole piece. If
|
610
|
+
* the tag already has a dir specified, this new one will override existing
|
611
|
+
* one in behavior (tested on FF and IE).
|
612
|
+
* @param {string} html The string that need to be processed.
|
613
|
+
* @return {string} The processed string, with directionality enforced to RTL.
|
614
|
+
*/
|
615
|
+
goog.i18n.bidi.enforceLtrInHtml = function(html) {
|
616
|
+
if (html.charAt(0) == '<') {
|
617
|
+
return html.replace(/<\w+/, '$& dir=ltr');
|
618
|
+
}
|
619
|
+
// '\n' is important for FF so that it won't incorrectly merge span groups
|
620
|
+
return '\n<span dir=ltr>' + html + '</span>';
|
621
|
+
};
|
622
|
+
|
623
|
+
|
624
|
+
/**
|
625
|
+
* Enforce LTR on both end of the given text piece using unicode BiDi formatting
|
626
|
+
* characters LRE and PDF.
|
627
|
+
* @param {string} text The piece of text that need to be wrapped.
|
628
|
+
* @return {string} The wrapped string after process.
|
629
|
+
*/
|
630
|
+
goog.i18n.bidi.enforceLtrInText = function(text) {
|
631
|
+
return goog.i18n.bidi.Format.LRE + text + goog.i18n.bidi.Format.PDF;
|
632
|
+
};
|
633
|
+
|
634
|
+
|
635
|
+
/**
|
636
|
+
* Regular expression to find dimensions such as "padding: .3 0.4ex 5px 6;"
|
637
|
+
* @type {RegExp}
|
638
|
+
* @private
|
639
|
+
*/
|
640
|
+
goog.i18n.bidi.dimensionsRe_ =
|
641
|
+
/:\s*([.\d][.\w]*)\s+([.\d][.\w]*)\s+([.\d][.\w]*)\s+([.\d][.\w]*)/g;
|
642
|
+
|
643
|
+
|
644
|
+
/**
|
645
|
+
* Regular expression for left.
|
646
|
+
* @type {RegExp}
|
647
|
+
* @private
|
648
|
+
*/
|
649
|
+
goog.i18n.bidi.leftRe_ = /left/gi;
|
650
|
+
|
651
|
+
|
652
|
+
/**
|
653
|
+
* Regular expression for right.
|
654
|
+
* @type {RegExp}
|
655
|
+
* @private
|
656
|
+
*/
|
657
|
+
goog.i18n.bidi.rightRe_ = /right/gi;
|
658
|
+
|
659
|
+
|
660
|
+
/**
|
661
|
+
* Placeholder regular expression for swapping.
|
662
|
+
* @type {RegExp}
|
663
|
+
* @private
|
664
|
+
*/
|
665
|
+
goog.i18n.bidi.tempRe_ = /%%%%/g;
|
666
|
+
|
667
|
+
|
668
|
+
/**
|
669
|
+
* Swap location parameters and 'left'/'right' in CSS specification. The
|
670
|
+
* processed string will be suited for RTL layout. Though this function can
|
671
|
+
* cover most cases, there are always exceptions. It is suggested to put
|
672
|
+
* those exceptions in separate group of CSS string.
|
673
|
+
* @param {string} cssStr CSS spefication string.
|
674
|
+
* @return {string} Processed CSS specification string.
|
675
|
+
*/
|
676
|
+
goog.i18n.bidi.mirrorCSS = function(cssStr) {
|
677
|
+
return cssStr.
|
678
|
+
// reverse dimensions
|
679
|
+
replace(goog.i18n.bidi.dimensionsRe_, ':$1 $4 $3 $2').
|
680
|
+
replace(goog.i18n.bidi.leftRe_, '%%%%'). // swap left and right
|
681
|
+
replace(goog.i18n.bidi.rightRe_, goog.i18n.bidi.LEFT).
|
682
|
+
replace(goog.i18n.bidi.tempRe_, goog.i18n.bidi.RIGHT);
|
683
|
+
};
|
684
|
+
|
685
|
+
|
686
|
+
/**
|
687
|
+
* Regular expression for hebrew double quote substitution, finding quote
|
688
|
+
* directly after hebrew characters.
|
689
|
+
* @type {RegExp}
|
690
|
+
* @private
|
691
|
+
*/
|
692
|
+
goog.i18n.bidi.doubleQuoteSubstituteRe_ = /([\u0591-\u05f2])"/g;
|
693
|
+
|
694
|
+
|
695
|
+
/**
|
696
|
+
* Regular expression for hebrew single quote substitution, finding quote
|
697
|
+
* directly after hebrew characters.
|
698
|
+
* @type {RegExp}
|
699
|
+
* @private
|
700
|
+
*/
|
701
|
+
goog.i18n.bidi.singleQuoteSubstituteRe_ = /([\u0591-\u05f2])'/g;
|
702
|
+
|
703
|
+
|
704
|
+
/**
|
705
|
+
* Replace the double and single quote directly after a Hebrew character with
|
706
|
+
* GERESH and GERSHAYIM. In such case, most likely that's user intention.
|
707
|
+
* @param {string} str String that need to be processed.
|
708
|
+
* @return {string} Processed string with double/single quote replaced.
|
709
|
+
*/
|
710
|
+
goog.i18n.bidi.normalizeHebrewQuote = function(str) {
|
711
|
+
return str.
|
712
|
+
replace(goog.i18n.bidi.doubleQuoteSubstituteRe_, '$1\u05f4').
|
713
|
+
replace(goog.i18n.bidi.singleQuoteSubstituteRe_, '$1\u05f3');
|
714
|
+
};
|
715
|
+
|
716
|
+
|
717
|
+
/**
|
718
|
+
* Regular expression to split a string into "words" for directionality
|
719
|
+
* estimation based on relative word counts.
|
720
|
+
* @type {RegExp}
|
721
|
+
* @private
|
722
|
+
*/
|
723
|
+
goog.i18n.bidi.wordSeparatorRe_ = /\s+/;
|
724
|
+
|
725
|
+
|
726
|
+
/**
|
727
|
+
* Regular expression to check if a string contains any numerals. Used to
|
728
|
+
* differentiate between completely neutral strings and those containing
|
729
|
+
* numbers, which are weakly LTR.
|
730
|
+
* @type {RegExp}
|
731
|
+
* @private
|
732
|
+
*/
|
733
|
+
goog.i18n.bidi.hasNumeralsRe_ = /\d/;
|
734
|
+
|
735
|
+
|
736
|
+
/**
|
737
|
+
* This constant controls threshold of RTL directionality.
|
738
|
+
* @type {number}
|
739
|
+
* @private
|
740
|
+
*/
|
741
|
+
goog.i18n.bidi.rtlDetectionThreshold_ = 0.40;
|
742
|
+
|
743
|
+
|
744
|
+
/**
|
745
|
+
* Estimates the directionality of a string based on relative word counts.
|
746
|
+
* If the number of RTL words is above a certain percentage of the total number
|
747
|
+
* of strongly directional words, returns RTL.
|
748
|
+
* Otherwise, if any words are strongly or weakly LTR, returns LTR.
|
749
|
+
* Otherwise, returns UNKNOWN, which is used to mean "neutral".
|
750
|
+
* Numbers are counted as weakly LTR.
|
751
|
+
* @param {string} str The string to be checked.
|
752
|
+
* @param {boolean=} opt_isHtml Whether str is HTML / HTML-escaped.
|
753
|
+
* Default: false.
|
754
|
+
* @return {goog.i18n.bidi.Dir} Estimated overall directionality of {@code str}.
|
755
|
+
*/
|
756
|
+
goog.i18n.bidi.estimateDirection = function(str, opt_isHtml) {
|
757
|
+
var rtlCount = 0;
|
758
|
+
var totalCount = 0;
|
759
|
+
var hasWeaklyLtr = false;
|
760
|
+
var tokens = goog.i18n.bidi.stripHtmlIfNeeded_(str, opt_isHtml).
|
761
|
+
split(goog.i18n.bidi.wordSeparatorRe_);
|
762
|
+
for (var i = 0; i < tokens.length; i++) {
|
763
|
+
var token = tokens[i];
|
764
|
+
if (goog.i18n.bidi.startsWithRtl(token)) {
|
765
|
+
rtlCount++;
|
766
|
+
totalCount++;
|
767
|
+
} else if (goog.i18n.bidi.isRequiredLtrRe_.test(token)) {
|
768
|
+
hasWeaklyLtr = true;
|
769
|
+
} else if (goog.i18n.bidi.hasAnyLtr(token)) {
|
770
|
+
totalCount++;
|
771
|
+
} else if (goog.i18n.bidi.hasNumeralsRe_.test(token)) {
|
772
|
+
hasWeaklyLtr = true;
|
773
|
+
}
|
774
|
+
}
|
775
|
+
|
776
|
+
return totalCount == 0 ?
|
777
|
+
(hasWeaklyLtr ? goog.i18n.bidi.Dir.LTR : goog.i18n.bidi.Dir.UNKNOWN) :
|
778
|
+
(rtlCount / totalCount > goog.i18n.bidi.rtlDetectionThreshold_ ?
|
779
|
+
goog.i18n.bidi.Dir.RTL : goog.i18n.bidi.Dir.LTR);
|
780
|
+
};
|
781
|
+
|
782
|
+
|
783
|
+
/**
|
784
|
+
* Check the directionality of a piece of text, return true if the piece of
|
785
|
+
* text should be laid out in RTL direction.
|
786
|
+
* @param {string} str The piece of text that need to be detected.
|
787
|
+
* @param {boolean=} opt_isHtml Whether str is HTML / HTML-escaped.
|
788
|
+
* Default: false.
|
789
|
+
* @return {boolean} Whether this piece of text should be laid out in RTL.
|
790
|
+
*/
|
791
|
+
goog.i18n.bidi.detectRtlDirectionality = function(str, opt_isHtml) {
|
792
|
+
return goog.i18n.bidi.estimateDirection(str, opt_isHtml) ==
|
793
|
+
goog.i18n.bidi.Dir.RTL;
|
794
|
+
};
|
795
|
+
|
796
|
+
|
797
|
+
/**
|
798
|
+
* Sets text input element's directionality and text alignment based on a
|
799
|
+
* given directionality.
|
800
|
+
* @param {Element} element Input field element to set directionality to.
|
801
|
+
* @param {goog.i18n.bidi.Dir|number|boolean} dir Desired directionality, given
|
802
|
+
* in one of the following formats:
|
803
|
+
* 1. A goog.i18n.bidi.Dir constant.
|
804
|
+
* 2. A number (positive = LRT, negative = RTL, 0 = unknown).
|
805
|
+
* 3. A boolean (true = RTL, false = LTR).
|
806
|
+
*/
|
807
|
+
goog.i18n.bidi.setElementDirAndAlign = function(element, dir) {
|
808
|
+
if (element &&
|
809
|
+
(dir = goog.i18n.bidi.toDir(dir)) != goog.i18n.bidi.Dir.UNKNOWN) {
|
810
|
+
element.style.textAlign = dir == goog.i18n.bidi.Dir.RTL ? 'right' : 'left';
|
811
|
+
element.dir = dir == goog.i18n.bidi.Dir.RTL ? 'rtl' : 'ltr';
|
812
|
+
}
|
813
|
+
};
|
814
|
+
;
|
815
|
+
FI"asset_paths;
|
816
|
+
F["�/Users/ali/.rvm/gems/ruby-1.9.3-p0/bundler/gems/closure-library-wrapper-031d1d0f0e50/vendor/closure-library/closure/goog/i18n/bidi.jsI"dependency_paths;
|
817
|
+
F[{I" path;
|
818
|
+
F"�/Users/ali/.rvm/gems/ruby-1.9.3-p0/bundler/gems/closure-library-wrapper-031d1d0f0e50/vendor/closure-library/closure/goog/i18n/bidi.jsI"
|
819
|
+
mtime;
|
820
|
+
FIu: Time
|
821
|
+
T:offsetiI"hexdigest;
|
822
|
+
F"%8397f88bffada2f7bbf598f166c05c22I"
|
823
|
+
F"%46dde6621c301f4928e3b34efee9e3b5
|