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,823 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1325538162.3410828:@value{I"
|
2
|
+
class:EFI"BundledAsset;
|
3
|
+
FI"id;
|
4
|
+
F"%47de2c62d8bdbf3648b908784bccacd5I"logical_path;
|
5
|
+
FI"closure/goog/i18n/bidi.js;
|
6
|
+
TI"
|
7
|
+
F"j/Volumes/Development/dev-web/closure-library-wrapper/vendor/closure-library/closure/goog/i18n/bidi.jsI"content_type;
|
8
|
+
FI"application/javascript;
|
9
|
+
FI"
|
10
|
+
mtime;
|
11
|
+
FI"2012-01-02T16:18:52+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["j/Volumes/Development/dev-web/closure-library-wrapper/vendor/closure-library/closure/goog/i18n/bidi.jsI"dependency_paths;
|
817
|
+
F[{I" path;
|
818
|
+
F"j/Volumes/Development/dev-web/closure-library-wrapper/vendor/closure-library/closure/goog/i18n/bidi.jsI"
|
819
|
+
mtime;
|
820
|
+
FIu: Time
|
821
|
+
T:offsetiI"hexdigest;
|
822
|
+
F"%8397f88bffada2f7bbf598f166c05c22I"
|
823
|
+
F"%46dde6621c301f4928e3b34efee9e3b5
|