ymdp 0.1.4 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +1 -0
- data/VERSION +1 -1
- data/lib/ymdp/application.rb +22 -0
- data/lib/ymdp/application_view.rb +312 -0
- data/lib/ymdp/base.rb +119 -0
- data/lib/ymdp/commands/build.rb +0 -6
- data/lib/ymdp/compiler/base.rb +12 -10
- data/lib/ymdp/compiler/domains.rb +8 -34
- data/lib/ymdp/compiler/template.rb +58 -85
- data/lib/ymdp/configuration/config.rb +70 -28
- data/lib/ymdp/configuration/constants.rb +17 -3
- data/lib/ymdp/processor/form_post.rb +5 -1
- data/lib/ymdp/support/file.rb +29 -11
- data/lib/ymdp/tasks/keys.rake +13 -13
- data/lib/ymdp/tasks/ymdp.rake +4 -4
- data/spec/application_spec.rb +29 -0
- data/spec/application_view_spec.rb +5 -0
- data/spec/compiler_spec.rb +3 -3
- data/spec/compiler_template_spec.rb +26 -54
- data/spec/data/app/views/layouts/application.html.haml +2 -0
- data/spec/data/config/config.yml +1 -0
- data/spec/data/config/constants.rb +3 -7
- data/spec/data/script/destroy +2 -2
- data/spec/data/script/langs +1 -3
- data/spec/default_settings.rb +42 -0
- data/spec/domains_spec.rb +3 -22
- data/spec/spec_helper.rb +3 -0
- data/spec/stubs.rb +11 -0
- data/spec/ymdp_base_spec.rb +125 -0
- data/test.rb +46 -0
- data/ymdp.gemspec +15 -65
- metadata +14 -64
- data/lib/new_application/.base +0 -11
- data/lib/new_application/Gemfile +0 -13
- data/lib/new_application/Rakefile +0 -3
- data/lib/new_application/app/.gitignore +0 -1
- data/lib/new_application/app/assets/images/lightbox/lightbox_bg.png +0 -0
- data/lib/new_application/app/assets/javascripts/OpenMailIntl.js +0 -291
- data/lib/new_application/app/assets/javascripts/controls.js +0 -965
- data/lib/new_application/app/assets/javascripts/date.js +0 -104
- data/lib/new_application/app/assets/javascripts/dragdrop.js +0 -974
- data/lib/new_application/app/assets/javascripts/effects.js +0 -1123
- data/lib/new_application/app/assets/javascripts/lowpro.js +0 -320
- data/lib/new_application/app/assets/javascripts/prototype.js +0 -4874
- data/lib/new_application/app/assets/javascripts/scriptaculous.js +0 -68
- data/lib/new_application/app/assets/yrb/en-US/application_en-US.pres +0 -7
- data/lib/new_application/app/helpers/application_helper.rb +0 -3
- data/lib/new_application/app/javascripts/application.js +0 -580
- data/lib/new_application/app/javascripts/debug.js +0 -138
- data/lib/new_application/app/javascripts/flash.js +0 -96
- data/lib/new_application/app/javascripts/header.js +0 -13
- data/lib/new_application/app/javascripts/help.js +0 -76
- data/lib/new_application/app/javascripts/i18n.js +0 -235
- data/lib/new_application/app/javascripts/launcher.js +0 -159
- data/lib/new_application/app/javascripts/logger.js +0 -61
- data/lib/new_application/app/javascripts/tag_helper.js +0 -178
- data/lib/new_application/app/stylesheets/application.css +0 -0
- data/lib/new_application/app/stylesheets/ie.css +0 -0
- data/lib/new_application/app/stylesheets/ie6.css +0 -0
- data/lib/new_application/app/stylesheets/ie7.css +0 -0
- data/lib/new_application/app/stylesheets/ie8.css +0 -0
- data/lib/new_application/app/stylesheets/lightbox.css +0 -30
- data/lib/new_application/app/stylesheets/non_ie.css +0 -0
- data/lib/new_application/app/views/layouts/application.html.haml +0 -35
- data/lib/new_application/app/views/shared/_error.html.haml +0 -8
- data/lib/new_application/app/views/shared/_flash.html.haml +0 -2
- data/lib/new_application/app/views/shared/_javascripts.html.haml +0 -22
- data/lib/new_application/app/views/shared/_loading.html.haml +0 -13
- data/lib/new_application/app/views/shared/_stylesheets.html.haml +0 -23
- data/lib/new_application/config/categories.yml +0 -6
- data/lib/new_application/config/config.yml.example +0 -30
- data/lib/new_application/config/constants.rb +0 -54
- data/lib/new_application/config/servers.yml.example +0 -9
- data/lib/new_application/lib/init.rb +0 -13
- data/lib/new_application/lib/tasks/environment.rake +0 -4
- data/lib/new_application/lib/tasks/keys.rake +0 -3
- data/lib/new_application/lib/tasks/setup.rake +0 -13
- data/lib/new_application/lib/tasks/ymdp.rake +0 -4
- data/lib/new_application/script/build +0 -9
- data/lib/new_application/script/config +0 -13
- data/lib/new_application/script/destroy +0 -18
- data/lib/new_application/script/generate +0 -4
- data/lib/new_application/script/gitrm +0 -17
- data/lib/new_application/script/growl +0 -6
- data/lib/new_application/script/images +0 -48
- data/lib/new_application/script/jslint.js +0 -5072
- data/lib/new_application/script/langs +0 -31
- data/lib/new_application/script/translate +0 -5
- data/lib/new_application/script/ymdt +0 -1895
- data/lib/new_application/script/ymdt.old +0 -1890
- data/lib/new_application/script/yuicompressor-2.4.2.jar +0 -0
- data/lib/new_application/ymdp +0 -8
- data/lib/ymdp/processor/processor.rb +0 -132
- data/lib/ymdp/ymdp.rb +0 -208
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ymdp
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.6
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jeff Coleman
|
|
@@ -9,7 +9,7 @@ autorequire:
|
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
11
|
|
|
12
|
-
date: 2010-01-
|
|
12
|
+
date: 2010-01-16 00:00:00 -06:00
|
|
13
13
|
default_executable: ymdp
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
@@ -149,68 +149,11 @@ files:
|
|
|
149
149
|
- Rakefile
|
|
150
150
|
- VERSION
|
|
151
151
|
- bin/ymdp
|
|
152
|
-
- lib/new_application/.base
|
|
153
|
-
- lib/new_application/Gemfile
|
|
154
|
-
- lib/new_application/Rakefile
|
|
155
|
-
- lib/new_application/app/.gitignore
|
|
156
|
-
- lib/new_application/app/assets/images/lightbox/lightbox_bg.png
|
|
157
|
-
- lib/new_application/app/assets/javascripts/OpenMailIntl.js
|
|
158
|
-
- lib/new_application/app/assets/javascripts/controls.js
|
|
159
|
-
- lib/new_application/app/assets/javascripts/date.js
|
|
160
|
-
- lib/new_application/app/assets/javascripts/dragdrop.js
|
|
161
|
-
- lib/new_application/app/assets/javascripts/effects.js
|
|
162
|
-
- lib/new_application/app/assets/javascripts/lowpro.js
|
|
163
|
-
- lib/new_application/app/assets/javascripts/prototype.js
|
|
164
|
-
- lib/new_application/app/assets/javascripts/scriptaculous.js
|
|
165
|
-
- lib/new_application/app/assets/yrb/en-US/application_en-US.pres
|
|
166
|
-
- lib/new_application/app/helpers/application_helper.rb
|
|
167
|
-
- lib/new_application/app/javascripts/application.js
|
|
168
|
-
- lib/new_application/app/javascripts/debug.js
|
|
169
|
-
- lib/new_application/app/javascripts/flash.js
|
|
170
|
-
- lib/new_application/app/javascripts/header.js
|
|
171
|
-
- lib/new_application/app/javascripts/help.js
|
|
172
|
-
- lib/new_application/app/javascripts/i18n.js
|
|
173
|
-
- lib/new_application/app/javascripts/launcher.js
|
|
174
|
-
- lib/new_application/app/javascripts/logger.js
|
|
175
|
-
- lib/new_application/app/javascripts/tag_helper.js
|
|
176
|
-
- lib/new_application/app/stylesheets/application.css
|
|
177
|
-
- lib/new_application/app/stylesheets/ie.css
|
|
178
|
-
- lib/new_application/app/stylesheets/ie6.css
|
|
179
|
-
- lib/new_application/app/stylesheets/ie7.css
|
|
180
|
-
- lib/new_application/app/stylesheets/ie8.css
|
|
181
|
-
- lib/new_application/app/stylesheets/lightbox.css
|
|
182
|
-
- lib/new_application/app/stylesheets/non_ie.css
|
|
183
|
-
- lib/new_application/app/views/layouts/application.html.haml
|
|
184
|
-
- lib/new_application/app/views/shared/_error.html.haml
|
|
185
|
-
- lib/new_application/app/views/shared/_flash.html.haml
|
|
186
|
-
- lib/new_application/app/views/shared/_javascripts.html.haml
|
|
187
|
-
- lib/new_application/app/views/shared/_loading.html.haml
|
|
188
|
-
- lib/new_application/app/views/shared/_stylesheets.html.haml
|
|
189
|
-
- lib/new_application/config/categories.yml
|
|
190
|
-
- lib/new_application/config/config.yml.example
|
|
191
|
-
- lib/new_application/config/constants.rb
|
|
192
|
-
- lib/new_application/config/servers.yml.example
|
|
193
|
-
- lib/new_application/lib/init.rb
|
|
194
|
-
- lib/new_application/lib/tasks/environment.rake
|
|
195
|
-
- lib/new_application/lib/tasks/keys.rake
|
|
196
|
-
- lib/new_application/lib/tasks/setup.rake
|
|
197
|
-
- lib/new_application/lib/tasks/ymdp.rake
|
|
198
|
-
- lib/new_application/script/build
|
|
199
|
-
- lib/new_application/script/config
|
|
200
|
-
- lib/new_application/script/destroy
|
|
201
|
-
- lib/new_application/script/generate
|
|
202
|
-
- lib/new_application/script/gitrm
|
|
203
|
-
- lib/new_application/script/growl
|
|
204
|
-
- lib/new_application/script/images
|
|
205
|
-
- lib/new_application/script/jslint.js
|
|
206
|
-
- lib/new_application/script/langs
|
|
207
|
-
- lib/new_application/script/translate
|
|
208
|
-
- lib/new_application/script/ymdt
|
|
209
|
-
- lib/new_application/script/ymdt.old
|
|
210
|
-
- lib/new_application/script/yuicompressor-2.4.2.jar
|
|
211
|
-
- lib/new_application/ymdp
|
|
212
152
|
- lib/ymdp.rb
|
|
153
|
+
- lib/ymdp/application.rb
|
|
154
|
+
- lib/ymdp/application_view.rb
|
|
213
155
|
- lib/ymdp/asset_tag_helper.rb
|
|
156
|
+
- lib/ymdp/base.rb
|
|
214
157
|
- lib/ymdp/commands/build.rb
|
|
215
158
|
- lib/ymdp/commands/generate.rb
|
|
216
159
|
- lib/ymdp/compiler/base.rb
|
|
@@ -227,7 +170,6 @@ files:
|
|
|
227
170
|
- lib/ymdp/helpers.rb
|
|
228
171
|
- lib/ymdp/processor/compressor.rb
|
|
229
172
|
- lib/ymdp/processor/form_post.rb
|
|
230
|
-
- lib/ymdp/processor/processor.rb
|
|
231
173
|
- lib/ymdp/processor/validator.rb
|
|
232
174
|
- lib/ymdp/processor/w3c.rb
|
|
233
175
|
- lib/ymdp/support/blank.rb
|
|
@@ -236,7 +178,8 @@ files:
|
|
|
236
178
|
- lib/ymdp/tasks/keys.rake
|
|
237
179
|
- lib/ymdp/tasks/ymdp.rake
|
|
238
180
|
- lib/ymdp/translator/base.rb
|
|
239
|
-
-
|
|
181
|
+
- spec/application_spec.rb
|
|
182
|
+
- spec/application_view_spec.rb
|
|
240
183
|
- spec/compiler_spec.rb
|
|
241
184
|
- spec/compiler_template_spec.rb
|
|
242
185
|
- spec/configuration_spec.rb
|
|
@@ -302,12 +245,15 @@ files:
|
|
|
302
245
|
- spec/data/script/ymdt
|
|
303
246
|
- spec/data/script/ymdt.old
|
|
304
247
|
- spec/data/script/yuicompressor-2.4.2.jar
|
|
248
|
+
- spec/default_settings.rb
|
|
305
249
|
- spec/domains_spec.rb
|
|
306
250
|
- spec/spec.opts
|
|
307
251
|
- spec/spec_helper.rb
|
|
308
252
|
- spec/stubs.rb
|
|
309
253
|
- spec/translator_spec.rb
|
|
254
|
+
- spec/ymdp_base_spec.rb
|
|
310
255
|
- spec/ymdp_spec.rb
|
|
256
|
+
- test.rb
|
|
311
257
|
- ymdp.gemspec
|
|
312
258
|
has_rdoc: true
|
|
313
259
|
homepage: http://github.com/progressions/ymdp
|
|
@@ -338,14 +284,18 @@ signing_key:
|
|
|
338
284
|
specification_version: 3
|
|
339
285
|
summary: Framework for developing applications in the Yahoo! Mail Development Platform
|
|
340
286
|
test_files:
|
|
287
|
+
- spec/application_spec.rb
|
|
288
|
+
- spec/application_view_spec.rb
|
|
341
289
|
- spec/compiler_spec.rb
|
|
342
290
|
- spec/compiler_template_spec.rb
|
|
343
291
|
- spec/configuration_spec.rb
|
|
344
292
|
- spec/data/app/helpers/application_helper.rb
|
|
345
293
|
- spec/data/config/constants.rb
|
|
346
294
|
- spec/data/lib/init.rb
|
|
295
|
+
- spec/default_settings.rb
|
|
347
296
|
- spec/domains_spec.rb
|
|
348
297
|
- spec/spec_helper.rb
|
|
349
298
|
- spec/stubs.rb
|
|
350
299
|
- spec/translator_spec.rb
|
|
300
|
+
- spec/ymdp_base_spec.rb
|
|
351
301
|
- spec/ymdp_spec.rb
|
data/lib/new_application/.base
DELETED
data/lib/new_application/Gemfile
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
assets.zip
|
|
Binary file
|
|
@@ -1,291 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The OpenMailIntl class provides minimal internationalization
|
|
3
|
-
* support for OpenMail.
|
|
4
|
-
* @module openmailintl
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* The OpenMailIntl class provides minimal internationalization
|
|
9
|
-
* support for OpenMail.
|
|
10
|
-
* @class OpenMailIntl
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
/*global window, YAHOO, ActiveXObject, XMLHttpRequest */
|
|
14
|
-
|
|
15
|
-
var OpenMailIntl = function () {
|
|
16
|
-
|
|
17
|
-
var openmailintl = {};
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Returns the user's preferred languages as a list of
|
|
21
|
-
* RFC 4646 language tags in decreasing priority order.
|
|
22
|
-
* @method getPreferredLanguages
|
|
23
|
-
* @private
|
|
24
|
-
* @return {String[]} A list of RFC 4646 language tags.
|
|
25
|
-
*/
|
|
26
|
-
var getPreferredLanguages = function () {
|
|
27
|
-
// this is a stub until OpenMail can synchronously provide
|
|
28
|
-
// a complete and accurate language list
|
|
29
|
-
var intl, match;
|
|
30
|
-
intl = "us";
|
|
31
|
-
match = window.location.href.match(/[\?&]\.intl=([a-z0-9]{2})/);
|
|
32
|
-
if (match) {
|
|
33
|
-
intl = match[1];
|
|
34
|
-
}
|
|
35
|
-
switch (intl) {
|
|
36
|
-
// only support Mail INTLs
|
|
37
|
-
case "aa": return ["en-AA"];
|
|
38
|
-
case "ar": return ["es-AR"];
|
|
39
|
-
case "au": return ["en-AU"];
|
|
40
|
-
case "br": return ["pt-BR"];
|
|
41
|
-
case "ca": return ["en-CA"];
|
|
42
|
-
case "cf": return ["fr-CA"];
|
|
43
|
-
case "cl": return ["es-CL"];
|
|
44
|
-
case "cn": return ["zh-Hans-CN"];
|
|
45
|
-
case "co": return ["es-CO"];
|
|
46
|
-
case "de": return ["de-DE"];
|
|
47
|
-
case "dk": return ["da-DK"];
|
|
48
|
-
case "e1": return ["es-US"];
|
|
49
|
-
case "es": return ["es-ES"];
|
|
50
|
-
case "fr": return ["fr-FR"];
|
|
51
|
-
case "hk": return ["zh-Hant-HK"];
|
|
52
|
-
case "cn": return ["zh-Hant-CN"];
|
|
53
|
-
case "in": return ["en-IN"];
|
|
54
|
-
case "it": return ["it-IT"];
|
|
55
|
-
case "jp": return ["ja-JP"];
|
|
56
|
-
case "kr": return ["ko-KR"];
|
|
57
|
-
case "mx": return ["es-MX"];
|
|
58
|
-
case "my": return ["en-MY"];
|
|
59
|
-
case "nl": return ["nl-NL"];
|
|
60
|
-
case "no": return ["nb-NO"];
|
|
61
|
-
case "nz": return ["en-NZ"];
|
|
62
|
-
case "pe": return ["es-PE"];
|
|
63
|
-
case "ph": return ["en-PH"];
|
|
64
|
-
case "pl": return ["pl-PL"];
|
|
65
|
-
case "ru": return ["ru-RU"];
|
|
66
|
-
case "se": return ["sv-SE"];
|
|
67
|
-
case "sg": return ["en-SG"];
|
|
68
|
-
case "th": return ["th-TH"];
|
|
69
|
-
case "tr": return ["tr-TR"];
|
|
70
|
-
case "tw": return ["zh-Hant-TW"];
|
|
71
|
-
case "uk": return ["en-GB"];
|
|
72
|
-
case "us": return ["en-US"];
|
|
73
|
-
case "ve": return ["es-VE"];
|
|
74
|
-
case "vn": return ["vi-VN"];
|
|
75
|
-
case "id": return ["id-ID"];
|
|
76
|
-
default: return ["en-US"];
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Returns the language among those available that
|
|
82
|
-
* best matches the user's preferences, using the Lookup
|
|
83
|
-
* algorithm of RFC 4647.
|
|
84
|
-
* If none of the available languages meets the user's preferences,
|
|
85
|
-
* then <code>availableLanguages[0]</code> is returned.
|
|
86
|
-
* @method findBestLanguage
|
|
87
|
-
* @param {String[]} availableLanguages The list of languages
|
|
88
|
-
* that the application supports, represented as RFC 4646 language
|
|
89
|
-
* tags.
|
|
90
|
-
* @return {String} The available language that best matches the
|
|
91
|
-
* user's preferences.
|
|
92
|
-
*/
|
|
93
|
-
openmailintl.findBestLanguage = function (availableLanguages) {
|
|
94
|
-
|
|
95
|
-
var preferencesList, i, language, normalized, result, index, normalization;
|
|
96
|
-
|
|
97
|
-
preferencesList = getPreferredLanguages();
|
|
98
|
-
|
|
99
|
-
// check whether the list of available languages
|
|
100
|
-
// contains language; if so return it
|
|
101
|
-
function scan(language) {
|
|
102
|
-
var i;
|
|
103
|
-
for (i = 0; i < availableLanguages.length; i += 1) {
|
|
104
|
-
if (language.toLowerCase() === availableLanguages[i].toLowerCase()) {
|
|
105
|
-
return availableLanguages[i];
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
normalization = {
|
|
111
|
-
"zh-hk": "zh-Hant-TW",
|
|
112
|
-
"zh-cn": "zh-Hant-CN",
|
|
113
|
-
"zh-tw": "zh-Hant-TW",
|
|
114
|
-
"zh": "zh-Hant-CN",
|
|
115
|
-
"hk": "zh-Hant-TW",
|
|
116
|
-
"en": "en-US",
|
|
117
|
-
"es": "es-ES",
|
|
118
|
-
"fr": "fr-FR",
|
|
119
|
-
"hi": "hi-IN",
|
|
120
|
-
"id": "id-ID",
|
|
121
|
-
"it": "it-IT",
|
|
122
|
-
"ja": "ja-JP",
|
|
123
|
-
"kr": "ko-KR",
|
|
124
|
-
"nb": "nb-NO",
|
|
125
|
-
"nl": "nl-NL",
|
|
126
|
-
"pl": "pl-PL",
|
|
127
|
-
"pt": "pt-BR",
|
|
128
|
-
"ru": "ru-RU",
|
|
129
|
-
"sv": "sv-SE",
|
|
130
|
-
"th": "th-TH",
|
|
131
|
-
"tr": "tr-TR",
|
|
132
|
-
"vi": "vi-VN",
|
|
133
|
-
"zh": "zh-Hans-CN",
|
|
134
|
-
"zh-cn": "zh-Hans-CN",
|
|
135
|
-
"zh-hk": "zh-Hant-HK",
|
|
136
|
-
"zh-tw": "zh-Hant-TW"
|
|
137
|
-
};
|
|
138
|
-
if (YAHOO.lang.isString(preferencesList)) {
|
|
139
|
-
preferencesList = preferencesList.split(/[, ]/);
|
|
140
|
-
}
|
|
141
|
-
for (i = 0; i < preferencesList.length; i += 1) {
|
|
142
|
-
language = preferencesList[i];
|
|
143
|
-
if (!language) {
|
|
144
|
-
continue;
|
|
145
|
-
}
|
|
146
|
-
normalized = normalization[language.toLowerCase()];
|
|
147
|
-
if (normalized) {
|
|
148
|
-
language = normalized;
|
|
149
|
-
}
|
|
150
|
-
// check the fallback sequence for one language
|
|
151
|
-
while (language.length > 0) {
|
|
152
|
-
result = scan(language);
|
|
153
|
-
if (result) {
|
|
154
|
-
return result;
|
|
155
|
-
} else {
|
|
156
|
-
index = language.lastIndexOf("-");
|
|
157
|
-
if (index >= 0) {
|
|
158
|
-
language = language.substring(0, index);
|
|
159
|
-
// one-character subtags get cut along with the following subtag
|
|
160
|
-
if (index >= 2 && language.charAt(index - 2) === "-") {
|
|
161
|
-
language = language.substring(0, index - 2);
|
|
162
|
-
}
|
|
163
|
-
} else {
|
|
164
|
-
// nothing available for this language
|
|
165
|
-
break;
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
// we use the first available language as the default
|
|
172
|
-
return availableLanguages[0];
|
|
173
|
-
};
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
var getFile = function (url) {
|
|
177
|
-
var XHR;
|
|
178
|
-
if (window.XMLHttpRequest) {
|
|
179
|
-
XHR = new XMLHttpRequest();
|
|
180
|
-
} else {
|
|
181
|
-
XHR = new ActiveXObject("Microsoft.XMLHTTP");
|
|
182
|
-
}
|
|
183
|
-
if (XHR) {
|
|
184
|
-
XHR.open("GET", url, false);
|
|
185
|
-
XHR.send(null);
|
|
186
|
-
if (XHR.status === 200) {
|
|
187
|
-
return XHR.responseText;
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
};
|
|
191
|
-
|
|
192
|
-
/**
|
|
193
|
-
* Retrieves a language specific JSON file that's part of the application's assets,
|
|
194
|
-
* and returns the decoded JSON object.
|
|
195
|
-
* The method first looks for the asset with the name <code>assetPath + baseName + "_" + language + ".json"</code>.
|
|
196
|
-
* If that asset doesn't exist, it looks for the asset with the name <code>assetPath + baseName + ".json"</code>.
|
|
197
|
-
* @method getResources
|
|
198
|
-
* @param {String} assetPath The path to the assets of the application.
|
|
199
|
-
* @param {String} baseName The base name of a resource bundle.
|
|
200
|
-
* @param {String} language The language for which resources are needed, as an RFC 4646 language tag.
|
|
201
|
-
* @return {Object} The object decoded from the JSON file found.
|
|
202
|
-
*/
|
|
203
|
-
openmailintl.getResources = function (assetPath, baseName, language) {
|
|
204
|
-
var url, contents;
|
|
205
|
-
|
|
206
|
-
if (assetPath.charAt(assetPath.length - 1) !== "/") {
|
|
207
|
-
assetPath += "/";
|
|
208
|
-
}
|
|
209
|
-
if (language) {
|
|
210
|
-
url = assetPath + baseName + "_" + language + ".json";
|
|
211
|
-
} else {
|
|
212
|
-
url = assetPath + baseName + ".json";
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
contents = getFile(url);
|
|
216
|
-
if (contents) {
|
|
217
|
-
try {
|
|
218
|
-
return YAHOO.lang.JSON.parse(contents);
|
|
219
|
-
} catch (x) {
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
if (language) {
|
|
223
|
-
return this.getResources(assetPath, baseName);
|
|
224
|
-
} else {
|
|
225
|
-
throw new Error("bundle " + baseName + " for language " + language + " not found.");
|
|
226
|
-
}
|
|
227
|
-
};
|
|
228
|
-
|
|
229
|
-
/**
|
|
230
|
-
* Formats a string by substituting parameters into the pattern.
|
|
231
|
-
* The pattern syntax is similar to that of the Java
|
|
232
|
-
* <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/text/MessageFormat.html">MessageFormat class</a>,
|
|
233
|
-
* but currently only the following format elements are supported:
|
|
234
|
-
* <ul>
|
|
235
|
-
* <li>{ <i>ArgumentIndex</i> }
|
|
236
|
-
* <li>{ <i>ArgumentIndex</i> , number }
|
|
237
|
-
* <li>{ <i>ArgumentIndex</i> , date }
|
|
238
|
-
* </ul>
|
|
239
|
-
* Quote characters do not escape braces; if you want to use
|
|
240
|
-
* a literal brace, write it as &#x007b; or &#x007d;.
|
|
241
|
-
* @method formatMessage
|
|
242
|
-
* @param {String} pattern The pattern string into which the arguments are inserted.
|
|
243
|
-
* @param {Object[]} arguments The objects to insert into the pattern string.
|
|
244
|
-
* @param {String} language The language for which arguments such as numbers and dates
|
|
245
|
-
* should be formatted.
|
|
246
|
-
* @return {String} The pattern string with substituted parameters.
|
|
247
|
-
*/
|
|
248
|
-
openmailintl.formatMessage = function (pattern, args, language) {
|
|
249
|
-
var i, j, k, token, key, value, meta;
|
|
250
|
-
|
|
251
|
-
for (;;) {
|
|
252
|
-
i = pattern.lastIndexOf('{');
|
|
253
|
-
if (i < 0) {
|
|
254
|
-
break;
|
|
255
|
-
}
|
|
256
|
-
j = pattern.indexOf('}', i);
|
|
257
|
-
if (i + 1 >= j) {
|
|
258
|
-
break;
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
// extract format element information
|
|
262
|
-
token = pattern.substring(i + 1, j);
|
|
263
|
-
key = token;
|
|
264
|
-
meta = null;
|
|
265
|
-
k = key.indexOf(',');
|
|
266
|
-
if (k > -1) {
|
|
267
|
-
meta = key.substring(k + 1);
|
|
268
|
-
key = key.substring(0, k);
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
// lookup the value
|
|
272
|
-
value = args[key];
|
|
273
|
-
|
|
274
|
-
if (meta !== null) {
|
|
275
|
-
if (meta.indexOf("date") === 0 && value instanceof Date) {
|
|
276
|
-
value = value.toLocaleString();
|
|
277
|
-
} else if (meta.indexOf("number") === 0 && typeof value === "number") {
|
|
278
|
-
value = value.toLocaleString();
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
pattern = pattern.substring(0, i) + value + pattern.substring(j + 1);
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
return pattern;
|
|
286
|
-
};
|
|
287
|
-
|
|
288
|
-
return openmailintl;
|
|
289
|
-
|
|
290
|
-
}();
|
|
291
|
-
|