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.
Files changed (109) hide show
  1. data/README.rst +42 -20
  2. data/lib/generators/templates/yellow_brick_road.rb.erb +19 -0
  3. data/lib/generators/yellow_brick_road/install_generator.rb +14 -0
  4. data/lib/yellow-brick-road/config.rb +41 -8
  5. data/lib/yellow-brick-road/directive_processor.rb +6 -5
  6. data/lib/yellow-brick-road/engine.rb +2 -3
  7. data/lib/yellow-brick-road/soy_processor.rb +1 -1
  8. data/lib/yellow-brick-road/version.rb +1 -1
  9. data/test/dummy/app/assets/javascripts/closure-deps.js +1 -1
  10. data/test/dummy/config/initializers/yellow_brick_road.rb +18 -1
  11. data/test/dummy/log/development.log +2208 -0
  12. data/test/dummy/tmp/cache/assets/C33/E00/sprockets%2F50c54266987e056bca666f8951752841 +2556 -0
  13. data/test/dummy/tmp/cache/assets/C48/990/sprockets%2F182c7921a46c3b8603c7f5595a111407 +823 -0
  14. data/test/dummy/tmp/cache/assets/C53/B40/sprockets%2F48cf0c035092dc945559526a279061c6 +204 -0
  15. data/test/dummy/tmp/cache/assets/C60/DB0/sprockets%2F3f00684578f2a3246581db667309ed89 +187 -0
  16. data/test/dummy/tmp/cache/assets/C60/E40/sprockets%2F3c5422f721521f492a5f02ca00b70009 +457 -0
  17. data/test/dummy/tmp/cache/assets/C73/DE0/sprockets%2F21f1f4574326846114a3c106873cebc3 +0 -0
  18. data/test/dummy/tmp/cache/assets/C7E/9F0/sprockets%2F89862076204c62c4593ac20de32da909 +4 -4
  19. data/test/dummy/tmp/cache/assets/C80/6F0/sprockets%2F56459a0713f8610d7d261f8be93073a2 +115 -0
  20. data/test/dummy/tmp/cache/assets/C8D/E10/sprockets%2F34b84bc4732937f885707002eda3896e +511 -0
  21. data/test/dummy/tmp/cache/assets/C93/CB0/sprockets%2F539b403b24833ca478a6f5877f37687c +239 -0
  22. data/test/dummy/tmp/cache/assets/C9A/C70/sprockets%2F10933dc6d342f604514713510b9ef0ab +806 -0
  23. data/test/dummy/tmp/cache/assets/CA0/7C0/sprockets%2Ff591bc0af8f085501241305c04907d3e +590 -0
  24. data/test/dummy/tmp/cache/assets/CA1/4A0/sprockets%2F5a9ad311e7d225b530b597041714b1e9 +2539 -0
  25. data/test/dummy/tmp/cache/assets/CA7/310/sprockets%2F45664cf816315200b574e029fde6f10a +0 -0
  26. data/test/dummy/tmp/cache/assets/CA7/A80/sprockets%2F1f32590957635a5a4f35442bc22f4ca4 +0 -0
  27. data/test/dummy/tmp/cache/assets/CAE/1D0/sprockets%2F2e62c7733d38a817a1532a744c6287bd +72 -0
  28. data/test/dummy/tmp/cache/assets/CB2/3C0/sprockets%2F9c35c290501a896b82c31448a39f3d5d +142 -0
  29. data/test/dummy/tmp/cache/assets/CB3/F20/sprockets%2F558b00e493fb501f7d95761e7eb40273 +2539 -0
  30. data/test/dummy/tmp/cache/assets/CBE/550/sprockets%2Fd680cac830e0b3408ba910f0b0421147 +2 -2
  31. data/test/dummy/tmp/cache/assets/CCD/480/sprockets%2Ffe7e11511634a2d03e1a20980b4593cf +0 -0
  32. data/test/dummy/tmp/cache/assets/CD0/080/sprockets%2Ffd5cbb87741244521d013d11c55573fa +204 -0
  33. data/test/dummy/tmp/cache/assets/CD2/020/sprockets%2Ff97740ba22118a2c91e992aac041843b +811 -0
  34. data/test/dummy/tmp/cache/assets/CD8/D90/sprockets%2F55dd841661d646f0024261a08ecf8ec0 +823 -0
  35. data/test/dummy/tmp/cache/assets/CE3/0D0/sprockets%2F301f97a178fd839a81bd663a6e22b616 +811 -0
  36. data/test/dummy/tmp/cache/assets/CE4/330/sprockets%2Fbd23466639af99164ab8e1c93721f14b +127 -0
  37. data/test/dummy/tmp/cache/assets/CE6/8A0/sprockets%2F3c0e7c5fa31563c8e820d6771e09918d +103 -0
  38. data/test/dummy/tmp/cache/assets/CEB/120/sprockets%2F857a0dde6829f7a27b93a840e1c60469 +522 -0
  39. data/test/dummy/tmp/cache/assets/CEE/CF0/sprockets%2F376f94b987d8156056c4e1d38ec06bf0 +0 -0
  40. data/test/dummy/tmp/cache/assets/CF2/C10/sprockets%2Fc64ef8a9dd0a1c3101d662750105c11a +806 -0
  41. data/test/dummy/tmp/cache/assets/CF3/CD0/sprockets%2F4bb42a5a6b504190f10d20b1c5f93d54 +1529 -0
  42. data/test/dummy/tmp/cache/assets/CF6/890/sprockets%2F36007a87f140155b5a04f2ca6b262dcc +494 -0
  43. data/test/dummy/tmp/cache/assets/CF6/9D0/sprockets%2F34b7199e9d33994c8ec7a442d60ca985 +173 -0
  44. data/test/dummy/tmp/cache/assets/CFA/A90/sprockets%2F901ba405a6d6747f6412ed4d0e0ac620 +256 -0
  45. data/test/dummy/tmp/cache/assets/CFC/E70/sprockets%2F8ee639668b5f0e629fbe0d62d1394689 +173 -0
  46. data/test/dummy/tmp/cache/assets/D04/1B0/sprockets%2F418f2b3b6b08b320f6db268a0991c54c +0 -0
  47. data/test/dummy/tmp/cache/assets/D05/920/sprockets%2F909507434dcc270db4853e4c147f0aac +5 -4
  48. data/test/dummy/tmp/cache/assets/D07/DB0/sprockets%2F0c17d7dac64290e385c91eb6f1570b31 +511 -0
  49. data/test/dummy/tmp/cache/assets/D07/EE0/sprockets%2F4999982b09e0b786894fce44f5d783cc +1371 -0
  50. data/test/dummy/tmp/cache/assets/D09/380/sprockets%2F14383e18fa2faac6b561a29d8e132863 +0 -0
  51. data/test/dummy/tmp/cache/assets/D0D/200/sprockets%2F545a7e34cce1d4272d83d58fd4215d42 +1277 -0
  52. data/test/dummy/tmp/cache/assets/D0E/870/sprockets%2F84996444f4f1f3fdc0248131cfb1a3b6 +794 -0
  53. data/test/dummy/tmp/cache/assets/D15/F60/sprockets%2Fa28394e3f80365b5bc86794dd46daa22 +0 -0
  54. data/test/dummy/tmp/cache/assets/D18/950/sprockets%2Fcf650d67c5d431ffdb38552e562299b2 +474 -0
  55. data/test/dummy/tmp/cache/assets/D18/E10/sprockets%2Fec7c58f640556b401fcd66528352dc9d +474 -0
  56. data/test/dummy/tmp/cache/assets/D20/660/sprockets%2F0d2875475ced01df962f3d758cda7792 +103 -0
  57. data/test/dummy/tmp/cache/assets/D22/AB0/sprockets%2F0b08e7f81651aaf739a93d61ae99779c +283 -0
  58. data/test/dummy/tmp/cache/assets/D2E/B20/sprockets%2Feed5412a17a52b1a335925e2af1f75d3 +0 -0
  59. data/test/dummy/tmp/cache/assets/D36/700/sprockets%2Fd219bf9db2eacc105bb294755093a437 +505 -0
  60. data/test/dummy/tmp/cache/assets/D3B/A10/sprockets%2Fcf38b51682d84a04da7b8a7313de52c6 +207 -0
  61. data/test/dummy/tmp/cache/assets/D3C/0E0/sprockets%2Fe9d7aba138d602c4a6ac701bc9615977 +505 -0
  62. data/test/dummy/tmp/cache/assets/D3E/FF0/sprockets%2F6bd8ccd3e02f397c20f349d5c0960e51 +0 -0
  63. data/test/dummy/tmp/cache/assets/D41/B30/sprockets%2Fba1b93913dd01d83ac9a96df334456f8 +0 -0
  64. data/test/dummy/tmp/cache/assets/D41/DA0/sprockets%2Fe8d00810698a9fcee032022fefd084f7 +0 -0
  65. data/test/dummy/tmp/cache/assets/D44/CF0/sprockets%2Ffa31a45f04884493c909c5a67fcbdf23 +1371 -0
  66. data/test/dummy/tmp/cache/assets/D47/BE0/sprockets%2F0b5ebdf6dec160a264698e7f745061e8 +142 -0
  67. data/test/dummy/tmp/cache/assets/D4C/F30/sprockets%2Ff90155c10f59a3fe44959ac09bf817fe +2556 -0
  68. data/test/dummy/tmp/cache/assets/D4E/7C0/sprockets%2Ff01b58512d01eda23fd5cb23a2b28b60 +1529 -0
  69. data/test/dummy/tmp/cache/assets/D4E/860/sprockets%2F86eed0c77c47d0970345bbabb58d8939 +1277 -0
  70. data/test/dummy/tmp/cache/assets/D4E/C30/sprockets%2F52420c10c73ca310d026565eafdadb4e +1545 -0
  71. data/test/dummy/tmp/cache/assets/D4E/F60/sprockets%2F9893a3c5aeb1a9e77469f4751b4d3c3f +115 -0
  72. data/test/dummy/tmp/cache/assets/D4F/E60/sprockets%2F17ee65de1f78c3dd5c165a9867e810b6 +165 -0
  73. data/test/dummy/tmp/cache/assets/D57/0D0/sprockets%2Fa29e6e8106d9d5ed1e2889126cfbf877 +300 -0
  74. data/test/dummy/tmp/cache/assets/D5C/650/sprockets%2Fe1c381da3cc213a639e956ae3315a2bd +607 -0
  75. data/test/dummy/tmp/cache/assets/D61/860/sprockets%2Fbf032a3b4aad2c2e25704e65c966cf45 +794 -0
  76. data/test/dummy/tmp/cache/assets/D63/B20/sprockets%2F31fc70ce66bb80fb9421be34eb3b0287 +0 -0
  77. data/test/dummy/tmp/cache/assets/D64/D60/sprockets%2Fa544ea03bf0a45948a053ba76ec2a79f +239 -0
  78. data/test/dummy/tmp/cache/assets/D6B/F90/sprockets%2F66636712ecb1fcc777dccf7643a0e1b1 +127 -0
  79. data/test/dummy/tmp/cache/assets/D6E/AD0/sprockets%2Fc91cdc6a72c729d7a64119198b3d2eab +0 -0
  80. data/test/dummy/tmp/cache/assets/D6F/140/sprockets%2F9ddc51f4388dd5243a28dba1ce47572b +53 -0
  81. data/test/dummy/tmp/cache/assets/D72/800/sprockets%2F92baa375d54e16fe0a5c7f079a1ce992 +165 -0
  82. data/test/dummy/tmp/cache/assets/D74/220/sprockets%2F3f888bda53179cb945eab35fbd31a708 +53 -0
  83. data/test/dummy/tmp/cache/assets/D78/5F0/sprockets%2F638ed6af667d4fc5147f72ff34aa2d33 +0 -0
  84. data/test/dummy/tmp/cache/assets/D7D/640/sprockets%2F95a7c5580f957c31e1ab9d0773ed5fde +607 -0
  85. data/test/dummy/tmp/cache/assets/D84/210/sprockets%2Fabd0103ccec2b428ac62c94e4c40b384 +6 -5
  86. data/test/dummy/tmp/cache/assets/D89/020/sprockets%2Fa06df6166e70324e712e54b1cafca0ae +187 -0
  87. data/test/dummy/tmp/cache/assets/D8A/9F0/sprockets%2Fc06547ca33ee3d03be14ce045ae1c9e2 +207 -0
  88. data/test/dummy/tmp/cache/assets/D9E/B80/sprockets%2F9561df1d45c7ff4aa8ac3e2df0c99121 +0 -0
  89. data/test/dummy/tmp/cache/assets/DA3/F30/sprockets%2Fe015d6ccdfcf022e47c83d7906f728ae +457 -0
  90. data/test/dummy/tmp/cache/assets/DAE/190/sprockets%2F433c7b21968be8d1f9bfdbdf7a637c57 +0 -0
  91. data/test/dummy/tmp/cache/assets/DB3/600/sprockets%2F9b70ae73f15ba693886eeef4eb5d6c75 +0 -0
  92. data/test/dummy/tmp/cache/assets/DB4/510/sprockets%2F29cdae8e29c88fd9ddbd4831419560fe +1260 -0
  93. data/test/dummy/tmp/cache/assets/DC1/4A0/sprockets%2F0b63dfcf163f2faeb612724eb4545bcc +1354 -0
  94. data/test/dummy/tmp/cache/assets/DC4/C10/sprockets%2Fcf48f4cbad3db33146eab4c577c1d209 +300 -0
  95. data/test/dummy/tmp/cache/assets/DC4/CA0/sprockets%2Fd0da8a60ea4dc16b9fd3e2a50d88633c +0 -0
  96. data/test/dummy/tmp/cache/assets/DC7/8C0/sprockets%2F1ad68dcc9ef598d3811ba2ac5c0ea182 +1354 -0
  97. data/test/dummy/tmp/cache/assets/DC7/C00/sprockets%2Fba755ff3a81c3192f0e45a4f7c0c7dcb +0 -0
  98. data/test/dummy/tmp/cache/assets/DCA/760/sprockets%2F717c4cea10bf601090ffdfe4e668e4cb +283 -0
  99. data/test/dummy/tmp/cache/assets/DCA/DE0/sprockets%2F51dcced9ec2b3cd4b1cc2949f860c361 +590 -0
  100. data/test/dummy/tmp/cache/assets/DD7/E70/sprockets%2F2595d8c8d1d5f4deb096247fb3bfc7ab +256 -0
  101. data/test/dummy/tmp/cache/assets/DE1/9D0/sprockets%2F8befd77af580ee16ec42ec95b1766ff3 +1545 -0
  102. data/test/dummy/tmp/cache/assets/E00/D80/sprockets%2F9debc27161f7bccf2d84a36b8c36c4bf +522 -0
  103. data/test/dummy/tmp/cache/assets/E00/E60/sprockets%2Fac159b94b0a6d621e4f6cde9b4de87bb +0 -0
  104. data/test/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af +0 -0
  105. data/test/dummy/tmp/cache/assets/E1B/D00/sprockets%2F886dff4afe55f9d3f8abe434f2689add +72 -0
  106. data/test/dummy/tmp/cache/assets/E1B/F20/sprockets%2Fa4bbc04eb83ebf94fd8134c3abd220dd +494 -0
  107. data/test/dummy/tmp/cache/assets/E71/0C0/sprockets%2F5ffdc0daa0a1f9638c787897ceefcdee +1260 -0
  108. metadata +186 -10
  109. data/test/dummy/tmp/pids/server.pid +0 -1
@@ -0,0 +1,806 @@
1
+ o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1325549268.153433: @value{ I" length:EFi9gI" digest;
2
+ F"%5d5ae819480b79a87174478b33aec607I" source;
3
+ FI"9g// Copyright 2007 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 functions for supporting Bidi issues.
19
+ */
20
+
21
+
22
+ /**
23
+ * Namespace for bidi supporting functions.
24
+ */
25
+
26
+ goog.provide('goog.i18n.bidi');
27
+
28
+
29
+ /**
30
+ * @define {boolean} FORCE_RTL forces the {@link goog.i18n.bidi.IS_RTL} constant
31
+ * to say that the current locale is a RTL locale. This should only be used
32
+ * if you want to override the default behavior for deciding whether the
33
+ * current locale is RTL or not.
34
+ *
35
+ * {@see goog.i18n.bidi.IS_RTL}
36
+ */
37
+ goog.i18n.bidi.FORCE_RTL = false;
38
+
39
+
40
+ /**
41
+ * Constant that defines whether or not the current locale is a RTL locale.
42
+ * If {@link goog.i18n.bidi.FORCE_RTL} is not true, this constant will default
43
+ * to check that {@link goog.LOCALE} is one of a few major RTL locales.
44
+ *
45
+ * <p>Since this constant refers to the directionality of the locale, it is up
46
+ * to the caller to determine if this constant should also be used for the
47
+ * direction of the UI.
48
+ *
49
+ * {@see goog.LOCALE}
50
+ *
51
+ * @type {boolean}
52
+ *
53
+ * TODO(user): write a test that checks that this is a compile-time constant.
54
+ * For example, for the default goog.LOCALE, compiling
55
+ * "if (goog.i18n.bidi.IS_RTL) alert('rtl') else {}" should produce no code.
56
+ */
57
+ goog.i18n.bidi.IS_RTL = goog.i18n.bidi.FORCE_RTL ||
58
+ (goog.LOCALE.substring(0, 2).toLowerCase() == 'ar' ||
59
+ goog.LOCALE.substring(0, 2).toLowerCase() == 'fa' ||
60
+ goog.LOCALE.substring(0, 2).toLowerCase() == 'he' ||
61
+ goog.LOCALE.substring(0, 2).toLowerCase() == 'iw' ||
62
+ goog.LOCALE.substring(0, 2).toLowerCase() == 'ur' ||
63
+ goog.LOCALE.substring(0, 2).toLowerCase() == 'yi') &&
64
+ (goog.LOCALE.length == 2 ||
65
+ goog.LOCALE.substring(2, 3) == '-' ||
66
+ goog.LOCALE.substring(2, 3) == '_');
67
+
68
+
69
+ /**
70
+ * Unicode formatting characters and directionality string constants.
71
+ * @enum {string}
72
+ */
73
+ goog.i18n.bidi.Format = {
74
+ /** Unicode "Left-To-Right Embedding" (LRE) character. */
75
+ LRE: '\u202A',
76
+ /** Unicode "Right-To-Left Embedding" (RLE) character. */
77
+ RLE: '\u202B',
78
+ /** Unicode "Pop Directional Formatting" (PDF) character. */
79
+ PDF: '\u202C',
80
+ /** Unicode "Left-To-Right Mark" (LRM) character. */
81
+ LRM: '\u200E',
82
+ /** Unicode "Right-To-Left Mark" (RLM) character. */
83
+ RLM: '\u200F'
84
+ };
85
+
86
+
87
+ /**
88
+ * Directionality enum.
89
+ * @enum {number}
90
+ */
91
+ goog.i18n.bidi.Dir = {
92
+ RTL: -1,
93
+ UNKNOWN: 0,
94
+ LTR: 1
95
+ };
96
+
97
+
98
+ /**
99
+ * 'right' string constant.
100
+ * @type {string}
101
+ */
102
+ goog.i18n.bidi.RIGHT = 'right';
103
+
104
+
105
+ /**
106
+ * 'left' string constant.
107
+ * @type {string}
108
+ */
109
+ goog.i18n.bidi.LEFT = 'left';
110
+
111
+
112
+ /**
113
+ * 'left' if locale is RTL, 'right' if not.
114
+ * @type {string}
115
+ */
116
+ goog.i18n.bidi.I18N_RIGHT = goog.i18n.bidi.IS_RTL ? goog.i18n.bidi.LEFT :
117
+ goog.i18n.bidi.RIGHT;
118
+
119
+
120
+ /**
121
+ * 'right' if locale is RTL, 'left' if not.
122
+ * @type {string}
123
+ */
124
+ goog.i18n.bidi.I18N_LEFT = goog.i18n.bidi.IS_RTL ? goog.i18n.bidi.RIGHT :
125
+ goog.i18n.bidi.LEFT;
126
+
127
+
128
+ /**
129
+ * Convert a directionality given in various formats to a goog.i18n.bidi.Dir
130
+ * constant. Useful for interaction with different standards of directionality
131
+ * representation.
132
+ *
133
+ * @param {goog.i18n.bidi.Dir|number|boolean} givenDir Directionality given in
134
+ * one of the following formats:
135
+ * 1. A goog.i18n.bidi.Dir constant.
136
+ * 2. A number (positive = LRT, negative = RTL, 0 = unknown).
137
+ * 3. A boolean (true = RTL, false = LTR).
138
+ * @return {goog.i18n.bidi.Dir} A goog.i18n.bidi.Dir constant matching the given
139
+ * directionality.
140
+ */
141
+ goog.i18n.bidi.toDir = function(givenDir) {
142
+ if (typeof givenDir == 'number') {
143
+ return givenDir > 0 ? goog.i18n.bidi.Dir.LTR :
144
+ givenDir < 0 ? goog.i18n.bidi.Dir.RTL : goog.i18n.bidi.Dir.UNKNOWN;
145
+ } else {
146
+ return givenDir ? goog.i18n.bidi.Dir.RTL : goog.i18n.bidi.Dir.LTR;
147
+ }
148
+ };
149
+
150
+
151
+ /**
152
+ * A practical pattern to identify strong LTR characters. This pattern is not
153
+ * theoretically correct according to the Unicode standard. It is simplified for
154
+ * performance and small code size.
155
+ * @type {string}
156
+ * @private
157
+ */
158
+ goog.i18n.bidi.ltrChars_ =
159
+ 'A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02B8\u0300-\u0590\u0800-\u1FFF' +
160
+ '\u2C00-\uFB1C\uFE00-\uFE6F\uFEFD-\uFFFF';
161
+
162
+
163
+ /**
164
+ * A practical pattern to identify strong RTL character. This pattern is not
165
+ * theoretically correct according to the Unicode standard. It is simplified
166
+ * for performance and small code size.
167
+ * @type {string}
168
+ * @private
169
+ */
170
+ goog.i18n.bidi.rtlChars_ = '\u0591-\u07FF\uFB1D-\uFDFF\uFE70-\uFEFC';
171
+
172
+
173
+ /**
174
+ * Simplified regular expression for an HTML tag (opening or closing) or an HTML
175
+ * escape. We might want to skip over such expressions when estimating the text
176
+ * directionality.
177
+ * @type {RegExp}
178
+ * @private
179
+ */
180
+ goog.i18n.bidi.htmlSkipReg_ = /<[^>]*>|&[^;]+;/g;
181
+
182
+
183
+ /**
184
+ * Returns the input text with spaces instead of HTML tags or HTML escapes, if
185
+ * opt_isStripNeeded is true. Else returns the input as is.
186
+ * Useful for text directionality estimation.
187
+ * Note: the function should not be used in other contexts; it is not 100%
188
+ * correct, but rather a good-enough implementation for directionality
189
+ * estimation purposes.
190
+ * @param {string} str The given string.
191
+ * @param {boolean=} opt_isStripNeeded Whether to perform the stripping.
192
+ * Default: false (to retain consistency with calling functions).
193
+ * @return {string} The given string cleaned of HTML tags / escapes.
194
+ * @private
195
+ */
196
+ goog.i18n.bidi.stripHtmlIfNeeded_ = function(str, opt_isStripNeeded) {
197
+ return opt_isStripNeeded ? str.replace(goog.i18n.bidi.htmlSkipReg_, ' ') :
198
+ str;
199
+ };
200
+
201
+
202
+ /**
203
+ * Regular expression to check for RTL characters.
204
+ * @type {RegExp}
205
+ * @private
206
+ */
207
+ goog.i18n.bidi.rtlCharReg_ = new RegExp('[' + goog.i18n.bidi.rtlChars_ + ']');
208
+
209
+
210
+ /**
211
+ * Regular expression to check for LTR characters.
212
+ * @type {RegExp}
213
+ * @private
214
+ */
215
+ goog.i18n.bidi.ltrCharReg_ = new RegExp('[' + goog.i18n.bidi.ltrChars_ + ']');
216
+
217
+
218
+ /**
219
+ * Test whether the given string has any RTL characters in it.
220
+ * @param {string} str The given string that need to be tested.
221
+ * @param {boolean=} opt_isHtml Whether str is HTML / HTML-escaped.
222
+ * Default: false.
223
+ * @return {boolean} Whether the string contains RTL characters.
224
+ */
225
+ goog.i18n.bidi.hasAnyRtl = function(str, opt_isHtml) {
226
+ return goog.i18n.bidi.rtlCharReg_.test(goog.i18n.bidi.stripHtmlIfNeeded_(
227
+ str, opt_isHtml));
228
+ };
229
+
230
+
231
+ /**
232
+ * Test whether the given string has any RTL characters in it.
233
+ * @param {string} str The given string that need to be tested.
234
+ * @return {boolean} Whether the string contains RTL characters.
235
+ * @deprecated Use hasAnyRtl.
236
+ */
237
+ goog.i18n.bidi.hasRtlChar = goog.i18n.bidi.hasAnyRtl;
238
+
239
+
240
+ /**
241
+ * Test whether the given string has any LTR characters in it.
242
+ * @param {string} str The given string that need to be tested.
243
+ * @param {boolean=} opt_isHtml Whether str is HTML / HTML-escaped.
244
+ * Default: false.
245
+ * @return {boolean} Whether the string contains LTR characters.
246
+ */
247
+ goog.i18n.bidi.hasAnyLtr = function(str, opt_isHtml) {
248
+ return goog.i18n.bidi.ltrCharReg_.test(goog.i18n.bidi.stripHtmlIfNeeded_(
249
+ str, opt_isHtml));
250
+ };
251
+
252
+
253
+ /**
254
+ * Regular expression pattern to check if the first character in the string
255
+ * is LTR.
256
+ * @type {RegExp}
257
+ * @private
258
+ */
259
+ goog.i18n.bidi.ltrRe_ = new RegExp('^[' + goog.i18n.bidi.ltrChars_ + ']');
260
+
261
+
262
+ /**
263
+ * Regular expression pattern to check if the first character in the string
264
+ * is RTL.
265
+ * @type {RegExp}
266
+ * @private
267
+ */
268
+ goog.i18n.bidi.rtlRe_ = new RegExp('^[' + goog.i18n.bidi.rtlChars_ + ']');
269
+
270
+
271
+ /**
272
+ * Check if the first character in the string is RTL or not.
273
+ * @param {string} str The given string that need to be tested.
274
+ * @return {boolean} Whether the first character in str is an RTL char.
275
+ */
276
+ goog.i18n.bidi.isRtlChar = function(str) {
277
+ return goog.i18n.bidi.rtlRe_.test(str);
278
+ };
279
+
280
+
281
+ /**
282
+ * Check if the first character in the string is LTR 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 LTR char.
285
+ */
286
+ goog.i18n.bidi.isLtrChar = function(str) {
287
+ return goog.i18n.bidi.ltrRe_.test(str);
288
+ };
289
+
290
+
291
+ /**
292
+ * Check if the first character in the string is neutral or not.
293
+ * @param {string} str The given string that need to be tested.
294
+ * @return {boolean} Whether the first character in str is a neutral char.
295
+ */
296
+ goog.i18n.bidi.isNeutralChar = function(str) {
297
+ return !goog.i18n.bidi.isLtrChar(str) && !goog.i18n.bidi.isRtlChar(str);
298
+ };
299
+
300
+
301
+ /**
302
+ * Regular expressions to check if a piece of text if of LTR directionality
303
+ * on first character with strong directionality.
304
+ * @type {RegExp}
305
+ * @private
306
+ */
307
+ goog.i18n.bidi.ltrDirCheckRe_ = new RegExp(
308
+ '^[^' + goog.i18n.bidi.rtlChars_ + ']*[' + goog.i18n.bidi.ltrChars_ + ']');
309
+
310
+
311
+ /**
312
+ * Regular expressions to check if a piece of text if of RTL directionality
313
+ * on first character with strong directionality.
314
+ * @type {RegExp}
315
+ * @private
316
+ */
317
+ goog.i18n.bidi.rtlDirCheckRe_ = new RegExp(
318
+ '^[^' + goog.i18n.bidi.ltrChars_ + ']*[' + goog.i18n.bidi.rtlChars_ + ']');
319
+
320
+
321
+ /**
322
+ * Check whether the first strongly directional character (if any) is RTL.
323
+ * @param {string} str String being checked.
324
+ * @param {boolean=} opt_isHtml Whether str is HTML / HTML-escaped.
325
+ * Default: false.
326
+ * @return {boolean} Whether RTL directionality is detected using the first
327
+ * strongly-directional character method.
328
+ */
329
+ goog.i18n.bidi.startsWithRtl = function(str, opt_isHtml) {
330
+ return goog.i18n.bidi.rtlDirCheckRe_.test(goog.i18n.bidi.stripHtmlIfNeeded_(
331
+ str, opt_isHtml));
332
+ };
333
+
334
+
335
+ /**
336
+ * Check whether the first strongly directional character (if any) is RTL.
337
+ * @param {string} str String being checked.
338
+ * @param {boolean=} opt_isHtml Whether str is HTML / HTML-escaped.
339
+ * Default: false.
340
+ * @return {boolean} Whether RTL directionality is detected using the first
341
+ * strongly-directional character method.
342
+ * @deprecated Use startsWithRtl.
343
+ */
344
+ goog.i18n.bidi.isRtlText = goog.i18n.bidi.startsWithRtl;
345
+
346
+
347
+ /**
348
+ * Check whether the first strongly directional character (if any) is LTR.
349
+ * @param {string} str String being checked.
350
+ * @param {boolean=} opt_isHtml Whether str is HTML / HTML-escaped.
351
+ * Default: false.
352
+ * @return {boolean} Whether LTR directionality is detected using the first
353
+ * strongly-directional character method.
354
+ */
355
+ goog.i18n.bidi.startsWithLtr = function(str, opt_isHtml) {
356
+ return goog.i18n.bidi.ltrDirCheckRe_.test(goog.i18n.bidi.stripHtmlIfNeeded_(
357
+ str, opt_isHtml));
358
+ };
359
+
360
+
361
+ /**
362
+ * Check whether the first strongly directional character (if any) is LTR.
363
+ * @param {string} str String being checked.
364
+ * @param {boolean=} opt_isHtml Whether str is HTML / HTML-escaped.
365
+ * Default: false.
366
+ * @return {boolean} Whether LTR directionality is detected using the first
367
+ * strongly-directional character method.
368
+ * @deprecated Use startsWithLtr.
369
+ */
370
+ goog.i18n.bidi.isLtrText = goog.i18n.bidi.startsWithLtr;
371
+
372
+
373
+ /**
374
+ * Regular expression to check if a string looks like something that must
375
+ * always be LTR even in RTL text, e.g. a URL. When estimating the
376
+ * directionality of text containing these, we treat these as weakly LTR,
377
+ * like numbers.
378
+ * @type {RegExp}
379
+ * @private
380
+ */
381
+ goog.i18n.bidi.isRequiredLtrRe_ = /^http:\/\/.*/;
382
+
383
+
384
+ /**
385
+ * Check whether the input string either contains no strongly directional
386
+ * characters or looks like a url.
387
+ * @param {string} str String being checked.
388
+ * @param {boolean=} opt_isHtml Whether str is HTML / HTML-escaped.
389
+ * Default: false.
390
+ * @return {boolean} Whether neutral directionality is detected.
391
+ */
392
+ goog.i18n.bidi.isNeutralText = function(str, opt_isHtml) {
393
+ str = goog.i18n.bidi.stripHtmlIfNeeded_(str, opt_isHtml);
394
+ return goog.i18n.bidi.isRequiredLtrRe_.test(str) ||
395
+ !goog.i18n.bidi.hasAnyLtr(str) && !goog.i18n.bidi.hasAnyRtl(str);
396
+ };
397
+
398
+
399
+ /**
400
+ * Regular expressions to check if the last strongly-directional character in a
401
+ * piece of text is LTR.
402
+ * @type {RegExp}
403
+ * @private
404
+ */
405
+ goog.i18n.bidi.ltrExitDirCheckRe_ = new RegExp(
406
+ '[' + goog.i18n.bidi.ltrChars_ + '][^' + goog.i18n.bidi.rtlChars_ + ']*$');
407
+
408
+
409
+ /**
410
+ * Regular expressions to check if the last strongly-directional character in a
411
+ * piece of text is RTL.
412
+ * @type {RegExp}
413
+ * @private
414
+ */
415
+ goog.i18n.bidi.rtlExitDirCheckRe_ = new RegExp(
416
+ '[' + goog.i18n.bidi.rtlChars_ + '][^' + goog.i18n.bidi.ltrChars_ + ']*$');
417
+
418
+
419
+ /**
420
+ * Check if the exit directionality a piece of text is LTR, i.e. if the last
421
+ * strongly-directional character in the string is LTR.
422
+ * @param {string} str String being checked.
423
+ * @param {boolean=} opt_isHtml Whether str is HTML / HTML-escaped.
424
+ * Default: false.
425
+ * @return {boolean} Whether LTR exit directionality was detected.
426
+ */
427
+ goog.i18n.bidi.endsWithLtr = function(str, opt_isHtml) {
428
+ return goog.i18n.bidi.ltrExitDirCheckRe_.test(
429
+ goog.i18n.bidi.stripHtmlIfNeeded_(str, opt_isHtml));
430
+ };
431
+
432
+
433
+ /**
434
+ * Check if the exit directionality a piece of text is LTR, i.e. if the last
435
+ * strongly-directional character in the string is LTR.
436
+ * @param {string} str String being checked.
437
+ * @param {boolean=} opt_isHtml Whether str is HTML / HTML-escaped.
438
+ * Default: false.
439
+ * @return {boolean} Whether LTR exit directionality was detected.
440
+ * @deprecated Use endsWithLtr.
441
+ */
442
+ goog.i18n.bidi.isLtrExitText = goog.i18n.bidi.endsWithLtr;
443
+
444
+
445
+ /**
446
+ * Check if the exit directionality a piece of text is RTL, i.e. if the last
447
+ * strongly-directional character in the string is RTL.
448
+ * @param {string} str String being checked.
449
+ * @param {boolean=} opt_isHtml Whether str is HTML / HTML-escaped.
450
+ * Default: false.
451
+ * @return {boolean} Whether RTL exit directionality was detected.
452
+ */
453
+ goog.i18n.bidi.endsWithRtl = function(str, opt_isHtml) {
454
+ return goog.i18n.bidi.rtlExitDirCheckRe_.test(
455
+ goog.i18n.bidi.stripHtmlIfNeeded_(str, opt_isHtml));
456
+ };
457
+
458
+
459
+ /**
460
+ * Check if the exit directionality a piece of text is RTL, i.e. if the last
461
+ * strongly-directional character in the string is RTL.
462
+ * @param {string} str String being checked.
463
+ * @param {boolean=} opt_isHtml Whether str is HTML / HTML-escaped.
464
+ * Default: false.
465
+ * @return {boolean} Whether RTL exit directionality was detected.
466
+ * @deprecated Use endsWithRtl.
467
+ */
468
+ goog.i18n.bidi.isRtlExitText = goog.i18n.bidi.endsWithRtl;
469
+
470
+
471
+ /**
472
+ * A regular expression for matching right-to-left language codes.
473
+ * See {@link #isRtlLanguage} for the design.
474
+ * @type {RegExp}
475
+ * @private
476
+ */
477
+ goog.i18n.bidi.rtlLocalesRe_ = new RegExp(
478
+ '^(ar|dv|he|iw|fa|nqo|ps|sd|ug|ur|yi|.*[-_](Arab|Hebr|Thaa|Nkoo|Tfng))' +
479
+ '(?!.*[-_](Latn|Cyrl)($|-|_))($|-|_)');
480
+
481
+
482
+ /**
483
+ * Check if a BCP 47 / III language code indicates an RTL language, i.e. either:
484
+ * - a language code explicitly specifying one of the right-to-left scripts,
485
+ * e.g. "az-Arab", or<p>
486
+ * - a language code specifying one of the languages normally written in a
487
+ * right-to-left script, e.g. "fa" (Farsi), except ones explicitly specifying
488
+ * Latin or Cyrillic script (which are the usual LTR alternatives).<p>
489
+ * The list of right-to-left scripts appears in the 100-199 range in
490
+ * http://www.unicode.org/iso15924/iso15924-num.html, of which Arabic and
491
+ * Hebrew are by far the most widely used. We also recognize Thaana, N'Ko, and
492
+ * Tifinagh, which also have significant modern usage. The rest (Syriac,
493
+ * Samaritan, Mandaic, etc.) seem to have extremely limited or no modern usage
494
+ * and are not recognized to save on code size.
495
+ * The languages usually written in a right-to-left script are taken as those
496
+ * with Suppress-Script: Hebr|Arab|Thaa|Nkoo|Tfng in
497
+ * http://www.iana.org/assignments/language-subtag-registry,
498
+ * as well as Sindhi (sd) and Uyghur (ug).
499
+ * Other subtags of the language code, e.g. regions like EG (Egypt), are
500
+ * ignored.
501
+ * @param {string} lang BCP 47 (a.k.a III) language code.
502
+ * @return {boolean} Whether the language code is an RTL language.
503
+ */
504
+ goog.i18n.bidi.isRtlLanguage = function(lang) {
505
+ return goog.i18n.bidi.rtlLocalesRe_.test(lang);
506
+ };
507
+
508
+
509
+ /**
510
+ * Regular expression for bracket guard replacement in html.
511
+ * @type {RegExp}
512
+ * @private
513
+ */
514
+ goog.i18n.bidi.bracketGuardHtmlRe_ =
515
+ /(\(.*?\)+)|(\[.*?\]+)|(\{.*?\}+)|(&lt;.*?(&gt;)+)/g;
516
+
517
+
518
+ /**
519
+ * Regular expression for bracket guard replacement in text.
520
+ * @type {RegExp}
521
+ * @private
522
+ */
523
+ goog.i18n.bidi.bracketGuardTextRe_ =
524
+ /(\(.*?\)+)|(\[.*?\]+)|(\{.*?\}+)|(<.*?>+)/g;
525
+
526
+
527
+ /**
528
+ * Apply bracket guard using html span tag. This is to address the problem of
529
+ * messy bracket display frequently happens in RTL layout.
530
+ * @param {string} s The string that need to be processed.
531
+ * @param {boolean=} opt_isRtlContext specifies default direction (usually
532
+ * direction of the UI).
533
+ * @return {string} The processed string, with all bracket guarded.
534
+ */
535
+ goog.i18n.bidi.guardBracketInHtml = function(s, opt_isRtlContext) {
536
+ var useRtl = opt_isRtlContext === undefined ?
537
+ goog.i18n.bidi.hasAnyRtl(s) : opt_isRtlContext;
538
+ if (useRtl) {
539
+ return s.replace(goog.i18n.bidi.bracketGuardHtmlRe_,
540
+ '<span dir=rtl>$&</span>');
541
+ }
542
+ return s.replace(goog.i18n.bidi.bracketGuardHtmlRe_,
543
+ '<span dir=ltr>$&</span>');
544
+ };
545
+
546
+
547
+ /**
548
+ * Apply bracket guard using LRM and RLM. This is to address the problem of
549
+ * messy bracket display frequently happens in RTL layout.
550
+ * This version works for both plain text and html. But it does not work as
551
+ * good as guardBracketInHtml in some cases.
552
+ * @param {string} s The string that need to be processed.
553
+ * @param {boolean=} opt_isRtlContext specifies default direction (usually
554
+ * direction of the UI).
555
+ * @return {string} The processed string, with all bracket guarded.
556
+ */
557
+ goog.i18n.bidi.guardBracketInText = function(s, opt_isRtlContext) {
558
+ var useRtl = opt_isRtlContext === undefined ?
559
+ goog.i18n.bidi.hasAnyRtl(s) : opt_isRtlContext;
560
+ var mark = useRtl ? goog.i18n.bidi.Format.RLM : goog.i18n.bidi.Format.LRM;
561
+ return s.replace(goog.i18n.bidi.bracketGuardTextRe_, mark + '$&' + mark);
562
+ };
563
+
564
+
565
+ /**
566
+ * Enforce the html snippet in RTL directionality regardless overall context.
567
+ * If the html piece was enclosed by tag, dir will be applied to existing
568
+ * tag, otherwise a span tag will be added as wrapper. For this reason, if
569
+ * html snippet start with with tag, this tag must enclose the whole piece. If
570
+ * the tag already has a dir specified, this new one will override existing
571
+ * one in behavior (tested on FF and IE).
572
+ * @param {string} html The string that need to be processed.
573
+ * @return {string} The processed string, with directionality enforced to RTL.
574
+ */
575
+ goog.i18n.bidi.enforceRtlInHtml = function(html) {
576
+ if (html.charAt(0) == '<') {
577
+ return html.replace(/<\w+/, '$& dir=rtl');
578
+ }
579
+ // '\n' is important for FF so that it won't incorrectly merge span groups
580
+ return '\n<span dir=rtl>' + html + '</span>';
581
+ };
582
+
583
+
584
+ /**
585
+ * Enforce RTL on both end of the given text piece using unicode BiDi formatting
586
+ * characters RLE and PDF.
587
+ * @param {string} text The piece of text that need to be wrapped.
588
+ * @return {string} The wrapped string after process.
589
+ */
590
+ goog.i18n.bidi.enforceRtlInText = function(text) {
591
+ return goog.i18n.bidi.Format.RLE + text + goog.i18n.bidi.Format.PDF;
592
+ };
593
+
594
+
595
+ /**
596
+ * Enforce the html snippet in RTL directionality regardless overall context.
597
+ * If the html piece was enclosed by tag, dir will be applied to existing
598
+ * tag, otherwise a span tag will be added as wrapper. For this reason, if
599
+ * html snippet start with with tag, this tag must enclose the whole piece. If
600
+ * the tag already has a dir specified, this new one will override existing
601
+ * one in behavior (tested on FF and IE).
602
+ * @param {string} html The string that need to be processed.
603
+ * @return {string} The processed string, with directionality enforced to RTL.
604
+ */
605
+ goog.i18n.bidi.enforceLtrInHtml = function(html) {
606
+ if (html.charAt(0) == '<') {
607
+ return html.replace(/<\w+/, '$& dir=ltr');
608
+ }
609
+ // '\n' is important for FF so that it won't incorrectly merge span groups
610
+ return '\n<span dir=ltr>' + html + '</span>';
611
+ };
612
+
613
+
614
+ /**
615
+ * Enforce LTR on both end of the given text piece using unicode BiDi formatting
616
+ * characters LRE and PDF.
617
+ * @param {string} text The piece of text that need to be wrapped.
618
+ * @return {string} The wrapped string after process.
619
+ */
620
+ goog.i18n.bidi.enforceLtrInText = function(text) {
621
+ return goog.i18n.bidi.Format.LRE + text + goog.i18n.bidi.Format.PDF;
622
+ };
623
+
624
+
625
+ /**
626
+ * Regular expression to find dimensions such as "padding: .3 0.4ex 5px 6;"
627
+ * @type {RegExp}
628
+ * @private
629
+ */
630
+ goog.i18n.bidi.dimensionsRe_ =
631
+ /:\s*([.\d][.\w]*)\s+([.\d][.\w]*)\s+([.\d][.\w]*)\s+([.\d][.\w]*)/g;
632
+
633
+
634
+ /**
635
+ * Regular expression for left.
636
+ * @type {RegExp}
637
+ * @private
638
+ */
639
+ goog.i18n.bidi.leftRe_ = /left/gi;
640
+
641
+
642
+ /**
643
+ * Regular expression for right.
644
+ * @type {RegExp}
645
+ * @private
646
+ */
647
+ goog.i18n.bidi.rightRe_ = /right/gi;
648
+
649
+
650
+ /**
651
+ * Placeholder regular expression for swapping.
652
+ * @type {RegExp}
653
+ * @private
654
+ */
655
+ goog.i18n.bidi.tempRe_ = /%%%%/g;
656
+
657
+
658
+ /**
659
+ * Swap location parameters and 'left'/'right' in CSS specification. The
660
+ * processed string will be suited for RTL layout. Though this function can
661
+ * cover most cases, there are always exceptions. It is suggested to put
662
+ * those exceptions in separate group of CSS string.
663
+ * @param {string} cssStr CSS spefication string.
664
+ * @return {string} Processed CSS specification string.
665
+ */
666
+ goog.i18n.bidi.mirrorCSS = function(cssStr) {
667
+ return cssStr.
668
+ // reverse dimensions
669
+ replace(goog.i18n.bidi.dimensionsRe_, ':$1 $4 $3 $2').
670
+ replace(goog.i18n.bidi.leftRe_, '%%%%'). // swap left and right
671
+ replace(goog.i18n.bidi.rightRe_, goog.i18n.bidi.LEFT).
672
+ replace(goog.i18n.bidi.tempRe_, goog.i18n.bidi.RIGHT);
673
+ };
674
+
675
+
676
+ /**
677
+ * Regular expression for hebrew double quote substitution, finding quote
678
+ * directly after hebrew characters.
679
+ * @type {RegExp}
680
+ * @private
681
+ */
682
+ goog.i18n.bidi.doubleQuoteSubstituteRe_ = /([\u0591-\u05f2])"/g;
683
+
684
+
685
+ /**
686
+ * Regular expression for hebrew single quote substitution, finding quote
687
+ * directly after hebrew characters.
688
+ * @type {RegExp}
689
+ * @private
690
+ */
691
+ goog.i18n.bidi.singleQuoteSubstituteRe_ = /([\u0591-\u05f2])'/g;
692
+
693
+
694
+ /**
695
+ * Replace the double and single quote directly after a Hebrew character with
696
+ * GERESH and GERSHAYIM. In such case, most likely that's user intention.
697
+ * @param {string} str String that need to be processed.
698
+ * @return {string} Processed string with double/single quote replaced.
699
+ */
700
+ goog.i18n.bidi.normalizeHebrewQuote = function(str) {
701
+ return str.
702
+ replace(goog.i18n.bidi.doubleQuoteSubstituteRe_, '$1\u05f4').
703
+ replace(goog.i18n.bidi.singleQuoteSubstituteRe_, '$1\u05f3');
704
+ };
705
+
706
+
707
+ /**
708
+ * Regular expression to split a string into "words" for directionality
709
+ * estimation based on relative word counts.
710
+ * @type {RegExp}
711
+ * @private
712
+ */
713
+ goog.i18n.bidi.wordSeparatorRe_ = /\s+/;
714
+
715
+
716
+ /**
717
+ * Regular expression to check if a string contains any numerals. Used to
718
+ * differentiate between completely neutral strings and those containing
719
+ * numbers, which are weakly LTR.
720
+ * @type {RegExp}
721
+ * @private
722
+ */
723
+ goog.i18n.bidi.hasNumeralsRe_ = /\d/;
724
+
725
+
726
+ /**
727
+ * This constant controls threshold of RTL directionality.
728
+ * @type {number}
729
+ * @private
730
+ */
731
+ goog.i18n.bidi.rtlDetectionThreshold_ = 0.40;
732
+
733
+
734
+ /**
735
+ * Estimates the directionality of a string based on relative word counts.
736
+ * If the number of RTL words is above a certain percentage of the total number
737
+ * of strongly directional words, returns RTL.
738
+ * Otherwise, if any words are strongly or weakly LTR, returns LTR.
739
+ * Otherwise, returns UNKNOWN, which is used to mean "neutral".
740
+ * Numbers are counted as weakly LTR.
741
+ * @param {string} str The string to be checked.
742
+ * @param {boolean=} opt_isHtml Whether str is HTML / HTML-escaped.
743
+ * Default: false.
744
+ * @return {goog.i18n.bidi.Dir} Estimated overall directionality of {@code str}.
745
+ */
746
+ goog.i18n.bidi.estimateDirection = function(str, opt_isHtml) {
747
+ var rtlCount = 0;
748
+ var totalCount = 0;
749
+ var hasWeaklyLtr = false;
750
+ var tokens = goog.i18n.bidi.stripHtmlIfNeeded_(str, opt_isHtml).
751
+ split(goog.i18n.bidi.wordSeparatorRe_);
752
+ for (var i = 0; i < tokens.length; i++) {
753
+ var token = tokens[i];
754
+ if (goog.i18n.bidi.startsWithRtl(token)) {
755
+ rtlCount++;
756
+ totalCount++;
757
+ } else if (goog.i18n.bidi.isRequiredLtrRe_.test(token)) {
758
+ hasWeaklyLtr = true;
759
+ } else if (goog.i18n.bidi.hasAnyLtr(token)) {
760
+ totalCount++;
761
+ } else if (goog.i18n.bidi.hasNumeralsRe_.test(token)) {
762
+ hasWeaklyLtr = true;
763
+ }
764
+ }
765
+
766
+ return totalCount == 0 ?
767
+ (hasWeaklyLtr ? goog.i18n.bidi.Dir.LTR : goog.i18n.bidi.Dir.UNKNOWN) :
768
+ (rtlCount / totalCount > goog.i18n.bidi.rtlDetectionThreshold_ ?
769
+ goog.i18n.bidi.Dir.RTL : goog.i18n.bidi.Dir.LTR);
770
+ };
771
+
772
+
773
+ /**
774
+ * Check the directionality of a piece of text, return true if the piece of
775
+ * text should be laid out in RTL direction.
776
+ * @param {string} str The piece of text that need to be detected.
777
+ * @param {boolean=} opt_isHtml Whether str is HTML / HTML-escaped.
778
+ * Default: false.
779
+ * @return {boolean} Whether this piece of text should be laid out in RTL.
780
+ */
781
+ goog.i18n.bidi.detectRtlDirectionality = function(str, opt_isHtml) {
782
+ return goog.i18n.bidi.estimateDirection(str, opt_isHtml) ==
783
+ goog.i18n.bidi.Dir.RTL;
784
+ };
785
+
786
+
787
+ /**
788
+ * Sets text input element's directionality and text alignment based on a
789
+ * given directionality.
790
+ * @param {Element} element Input field element to set directionality to.
791
+ * @param {goog.i18n.bidi.Dir|number|boolean} dir Desired directionality, given
792
+ * in one of the following formats:
793
+ * 1. A goog.i18n.bidi.Dir constant.
794
+ * 2. A number (positive = LRT, negative = RTL, 0 = unknown).
795
+ * 3. A boolean (true = RTL, false = LTR).
796
+ */
797
+ goog.i18n.bidi.setElementDirAndAlign = function(element, dir) {
798
+ if (element &&
799
+ (dir = goog.i18n.bidi.toDir(dir)) != goog.i18n.bidi.Dir.UNKNOWN) {
800
+ element.style.textAlign = dir == goog.i18n.bidi.Dir.RTL ? 'right' : 'left';
801
+ element.dir = dir == goog.i18n.bidi.Dir.RTL ? 'rtl' : 'ltr';
802
+ }
803
+ };
804
+ ;
805
+ FI"
806
+ F"%61a86d44b71d0ce84ed59333032907ff