ymdp 0.6.0 → 0.7.0
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/VERSION +1 -1
- data/lib/ymdp/configuration/config.rb +10 -0
- data/lib/ymdp/javascripts/jquery/ab_testing.js +130 -0
- data/lib/ymdp/javascripts/jquery/ajax.js +185 -0
- data/lib/ymdp/javascripts/jquery/application.js +139 -0
- data/lib/ymdp/javascripts/jquery/authorization.js +119 -0
- data/lib/ymdp/javascripts/{browser.js → jquery/browser.js} +0 -0
- data/lib/ymdp/javascripts/jquery/data.js +67 -0
- data/lib/ymdp/javascripts/jquery/debug.js +98 -0
- data/lib/ymdp/javascripts/jquery/education.js +168 -0
- data/lib/ymdp/javascripts/jquery/flash.js +76 -0
- data/lib/ymdp/javascripts/jquery/help.js +79 -0
- data/lib/ymdp/javascripts/jquery/i18n.js +293 -0
- data/lib/ymdp/javascripts/jquery/init.js +140 -0
- data/lib/ymdp/javascripts/jquery/launcher.js +153 -0
- data/lib/ymdp/javascripts/{logger.js → jquery/logger.js} +0 -0
- data/lib/ymdp/javascripts/{params.js → jquery/params.js} +0 -0
- data/lib/ymdp/javascripts/{reporter.js → jquery/reporter.js} +0 -0
- data/lib/ymdp/javascripts/jquery/tag_helper.js +180 -0
- data/lib/ymdp/javascripts/jquery/user.js +210 -0
- data/lib/ymdp/javascripts/{ab_testing.js → prototype/ab_testing.js} +0 -0
- data/lib/ymdp/javascripts/{ajax.js → prototype/ajax.js} +0 -0
- data/lib/ymdp/javascripts/{application.js → prototype/application.js} +0 -0
- data/lib/ymdp/javascripts/{authorization.js → prototype/authorization.js} +0 -0
- data/lib/ymdp/javascripts/prototype/browser.js +36 -0
- data/lib/ymdp/javascripts/{data.js → prototype/data.js} +0 -0
- data/lib/ymdp/javascripts/{debug.js → prototype/debug.js} +0 -0
- data/lib/ymdp/javascripts/{education.js → prototype/education.js} +0 -0
- data/lib/ymdp/javascripts/{flash.js → prototype/flash.js} +0 -0
- data/lib/ymdp/javascripts/{help.js → prototype/help.js} +0 -0
- data/lib/ymdp/javascripts/{i18n.js → prototype/i18n.js} +0 -0
- data/lib/ymdp/javascripts/{init.js → prototype/init.js} +0 -0
- data/lib/ymdp/javascripts/{launcher.js → prototype/launcher.js} +0 -0
- data/lib/ymdp/javascripts/prototype/logger.js +27 -0
- data/lib/ymdp/javascripts/prototype/params.js +35 -0
- data/lib/ymdp/javascripts/prototype/reporter.js +47 -0
- data/lib/ymdp/javascripts/{tag_helper.js → prototype/tag_helper.js} +0 -0
- data/lib/ymdp/javascripts/{user.js → prototype/user.js} +0 -0
- data/lib/ymdp/view/application_view.rb +5 -1
- data/ymdp.gemspec +38 -20
- metadata +40 -22
@@ -0,0 +1,76 @@
|
|
1
|
+
|
2
|
+
// DO NOT USE the @view instance variable in any files in /app/javascripts/base.
|
3
|
+
// The way they are cached makes it not safe to do so.
|
4
|
+
|
5
|
+
var Flash;
|
6
|
+
|
7
|
+
/* FLASH MESSAGE HANDLERS */
|
8
|
+
|
9
|
+
Flash = {};
|
10
|
+
|
11
|
+
Flash.timeout = 8;
|
12
|
+
Flash.duration = 0.25;
|
13
|
+
|
14
|
+
Flash.write = function(type, message) {
|
15
|
+
type = type || "notice";
|
16
|
+
if (message) {
|
17
|
+
$('#flash_message').update(message);
|
18
|
+
Flash.setFlashClass('flash', type);
|
19
|
+
|
20
|
+
if ($('#flash').css("display") === "none") {
|
21
|
+
$('#flash').show();
|
22
|
+
}
|
23
|
+
YMDP.setTimeoutInSeconds(Flash.close, Flash.timeout);
|
24
|
+
}
|
25
|
+
};
|
26
|
+
|
27
|
+
Flash.close = function() {
|
28
|
+
$('#flash').hide();
|
29
|
+
};
|
30
|
+
|
31
|
+
Flash.setFlashClass = function(flash_id, type) {
|
32
|
+
if (type === "error") {
|
33
|
+
$("#" + flash_id).removeClass('notice');
|
34
|
+
}
|
35
|
+
if (type === "notice") {
|
36
|
+
$("#" + flash_id).removeClass('error');
|
37
|
+
}
|
38
|
+
$("#" + flash_id).addClass(type);
|
39
|
+
};
|
40
|
+
|
41
|
+
|
42
|
+
Flash.error = function(message) {
|
43
|
+
Flash.write("error", message, true);
|
44
|
+
};
|
45
|
+
|
46
|
+
Flash.notice = function(message) {
|
47
|
+
Flash.write("notice", message, true);
|
48
|
+
};
|
49
|
+
|
50
|
+
Flash.success = Flash.notice;
|
51
|
+
|
52
|
+
Flash.t = {};
|
53
|
+
Flash.t.notice = function(key, args) {
|
54
|
+
var m;
|
55
|
+
|
56
|
+
m = I18n.t(key, args);
|
57
|
+
Flash.notice(m);
|
58
|
+
};
|
59
|
+
Flash.t.success = Flash.t.notice;
|
60
|
+
|
61
|
+
Flash.t.error = function(key, args) {
|
62
|
+
var m;
|
63
|
+
|
64
|
+
m = I18n.t(key, args);
|
65
|
+
Flash.error(m);
|
66
|
+
};
|
67
|
+
|
68
|
+
|
69
|
+
Flash.settingsChanged = function() {
|
70
|
+
Flash.t.success("SETTINGS_CHANGED");
|
71
|
+
};
|
72
|
+
Flash.problemSubmitting = function() {
|
73
|
+
Flash.t.error("PROBLEM_SUBMITTING");
|
74
|
+
};
|
75
|
+
|
76
|
+
/* ----------------------- */
|
@@ -0,0 +1,79 @@
|
|
1
|
+
// DO NOT USE the @view instance variable in any files in /app/javascripts/base.
|
2
|
+
// The way they are cached makes it not safe to do so.
|
3
|
+
|
4
|
+
// popup help text
|
5
|
+
//
|
6
|
+
var Help = function(content) {
|
7
|
+
try {
|
8
|
+
this.content = content;
|
9
|
+
|
10
|
+
// instance method
|
11
|
+
this.show = function(event) {
|
12
|
+
var x = event.clientX + 20;
|
13
|
+
var y = event.clientY - 10;
|
14
|
+
this.create(x,y);
|
15
|
+
};
|
16
|
+
|
17
|
+
this.create = function(x, y) {
|
18
|
+
try {
|
19
|
+
if (!$("#" + this.css_id).length) {
|
20
|
+
var popup = new Element('div', {
|
21
|
+
"id": this.css_id,
|
22
|
+
"class": "popup"
|
23
|
+
});
|
24
|
+
popup.update(this.content);
|
25
|
+
popup.setStyle({
|
26
|
+
"display": "none",
|
27
|
+
"left": x + "px",
|
28
|
+
"top": y + "px"
|
29
|
+
});
|
30
|
+
$('body').append(popup);
|
31
|
+
setTimeout("$(\"" + this.css_id + "\").show();", 500);
|
32
|
+
}
|
33
|
+
} catch(e) {
|
34
|
+
// alert(e);
|
35
|
+
}
|
36
|
+
};
|
37
|
+
|
38
|
+
this.destroy = function() {
|
39
|
+
setTimeout("$('" + this.css_id + "').remove();", 4000);
|
40
|
+
};
|
41
|
+
|
42
|
+
this.link = function(text) {
|
43
|
+
text = text || "?";
|
44
|
+
return Tags.linkToFunction(text, "", {
|
45
|
+
"onmouseover": "Help.show(event, " + this.id + ");",
|
46
|
+
"onmouseout": "Help.destroy(" + this.id + ")"
|
47
|
+
});
|
48
|
+
};
|
49
|
+
|
50
|
+
Help.popups = Help.popups || [];
|
51
|
+
Help.popups.push(this);
|
52
|
+
|
53
|
+
this.id = Help.popups.size() - 1;
|
54
|
+
this.css_id = "popup_" + this.id;
|
55
|
+
} catch(e) {
|
56
|
+
// alert(e);
|
57
|
+
}
|
58
|
+
};
|
59
|
+
|
60
|
+
Help.show = function(event, id) {
|
61
|
+
var help = Help.popups[id];
|
62
|
+
help.show(event);
|
63
|
+
};
|
64
|
+
|
65
|
+
Help.destroy = function(id) {
|
66
|
+
var help = Help.popups[id];
|
67
|
+
help.destroy();
|
68
|
+
};
|
69
|
+
|
70
|
+
Help.closeAll = function() {
|
71
|
+
$$('.popup').each(function(p) {
|
72
|
+
p.remove();
|
73
|
+
});
|
74
|
+
};
|
75
|
+
|
76
|
+
Help.init = function() {
|
77
|
+
// initialize any help popups. Overwrite this locally.
|
78
|
+
};
|
79
|
+
|
@@ -0,0 +1,293 @@
|
|
1
|
+
// DO NOT USE the @view instance variable in any files in /app/javascripts/base.
|
2
|
+
// The way they are cached makes it not safe to do so.
|
3
|
+
|
4
|
+
/*
|
5
|
+
I18N
|
6
|
+
|
7
|
+
global to every view.
|
8
|
+
|
9
|
+
Methods and constants dealing with internationalization.
|
10
|
+
*/
|
11
|
+
|
12
|
+
var I18N, I18n;
|
13
|
+
|
14
|
+
/* set asset version */
|
15
|
+
|
16
|
+
I18N = {
|
17
|
+
VERSION: "<%= @hash %>",
|
18
|
+
MESSAGE: "<%= @message %>",
|
19
|
+
DEPLOYED: <%= Time.now.to_i %>,
|
20
|
+
DEPLOYED_STRING: "<%= Time.now.to_s %>"
|
21
|
+
};
|
22
|
+
|
23
|
+
|
24
|
+
I18n = {};
|
25
|
+
|
26
|
+
I18n.init = function() {
|
27
|
+
Debug.log("about to call I18n.init");
|
28
|
+
|
29
|
+
I18n.assets_path = "<%= @assets_path %>/yrb";
|
30
|
+
|
31
|
+
I18n.availableLanguages = <%= supported_languages.to_json %>;
|
32
|
+
|
33
|
+
I18n.currentLanguage = OpenMailIntl.findBestLanguage(I18n.availableLanguages);
|
34
|
+
|
35
|
+
I18n.setResources();
|
36
|
+
|
37
|
+
Debug.log("finished calling I18n.init");
|
38
|
+
};
|
39
|
+
|
40
|
+
I18n.setResources = function() {
|
41
|
+
var scope, asset_path;
|
42
|
+
|
43
|
+
scope = "keys";
|
44
|
+
|
45
|
+
Debug.log("begin I18n.setResources for language " + I18n.currentLanguage);
|
46
|
+
try {
|
47
|
+
asset_path = "<%= @assets_directory %>/yrb/";
|
48
|
+
I18n[scope] = I18n[scope] || OpenMailIntl.getResources(asset_path, scope, I18n.currentLanguage);
|
49
|
+
if (I18n.currentLanguage !== "en-US") {
|
50
|
+
I18n.default_keys = OpenMailIntl.getResources(asset_path, scope, "en-US");
|
51
|
+
} else {
|
52
|
+
I18n.default_keys = I18n[scope];
|
53
|
+
}
|
54
|
+
} catch(err) {
|
55
|
+
Debug.error("error in I18n.setResources: " + err);
|
56
|
+
}
|
57
|
+
I18n.scope = scope;
|
58
|
+
};
|
59
|
+
|
60
|
+
I18n.english = function() {
|
61
|
+
return I18n.currentLanguage.match(/^en/);
|
62
|
+
};
|
63
|
+
|
64
|
+
I18n.translate_element = function(element) {
|
65
|
+
element = $(element);
|
66
|
+
|
67
|
+
var e;
|
68
|
+
//
|
69
|
+
// e = element.inspect();
|
70
|
+
// if (e.match(/<input/)) {
|
71
|
+
// I18n.v(element.attr("id"));
|
72
|
+
// } else {
|
73
|
+
// if (e.match(/<img/)) {
|
74
|
+
// I18n.src(element.attr("id"));
|
75
|
+
// } else {
|
76
|
+
// I18n.u(element.attr("id");
|
77
|
+
// }
|
78
|
+
// }
|
79
|
+
I18n.u(element.attr("id"));
|
80
|
+
};
|
81
|
+
|
82
|
+
// I18n.translate(key, [args])
|
83
|
+
// I18n.t(key, [args])
|
84
|
+
//
|
85
|
+
// Using .translate with a single key argument will return the simple translated string for that key
|
86
|
+
//
|
87
|
+
// Using a key argument with values after it will insert the values into the placeholders in
|
88
|
+
// the returned translated string
|
89
|
+
//
|
90
|
+
I18n.translate = function(key, args) {
|
91
|
+
key = key.toUpperCase();
|
92
|
+
key = key.replace(" ", "_");
|
93
|
+
if (args) {
|
94
|
+
var m;
|
95
|
+
m = I18n.translate_sentence(key, args);
|
96
|
+
} else
|
97
|
+
{
|
98
|
+
m = I18n.translate_phrase(key);
|
99
|
+
if (!m) {
|
100
|
+
m = I18n.default_keys[key];
|
101
|
+
}
|
102
|
+
}
|
103
|
+
return m;
|
104
|
+
};
|
105
|
+
I18n.t = I18n.translate;
|
106
|
+
|
107
|
+
I18n.translate_phrase = function(key) {
|
108
|
+
return I18n["keys"][key];
|
109
|
+
};
|
110
|
+
|
111
|
+
I18n.translate_sentence = function(key, args) {
|
112
|
+
return OpenMailIntl.formatMessage(I18n["keys"][key], args, I18n.currentLanguage);
|
113
|
+
};
|
114
|
+
|
115
|
+
// I18n.update(id, scope, key, args)
|
116
|
+
//
|
117
|
+
// updates an element with the given _id_ with the
|
118
|
+
// translation from scope, key and optional args
|
119
|
+
//
|
120
|
+
// only updates the element if the translation is not blank
|
121
|
+
//
|
122
|
+
I18n.update = function(id, key, args) {
|
123
|
+
try {
|
124
|
+
if (typeof(id) === "string") {
|
125
|
+
I18n.updateById(id, key, args);
|
126
|
+
} else {
|
127
|
+
I18n.updateByElement(id, key, args);
|
128
|
+
}
|
129
|
+
} catch(omg) {
|
130
|
+
Debug.error("Error in I18n.update", omg, id, key, args)
|
131
|
+
}
|
132
|
+
};
|
133
|
+
|
134
|
+
I18n.updateById = function(id, key, args) {
|
135
|
+
var message;
|
136
|
+
|
137
|
+
message = I18n.t(key, args);
|
138
|
+
$("#" + id).html(message);
|
139
|
+
};
|
140
|
+
|
141
|
+
I18n.updateByElement = function(id, key, args) {
|
142
|
+
var message;
|
143
|
+
|
144
|
+
message = I18n.t(key, args);
|
145
|
+
if (message) {
|
146
|
+
$(id).html(message);
|
147
|
+
}
|
148
|
+
}
|
149
|
+
|
150
|
+
// I18n.u(id, args)
|
151
|
+
//
|
152
|
+
// updates an element with a local YRB key of the same name
|
153
|
+
//
|
154
|
+
// given an id of "messages" it will look for a YRB key named "MESSAGES"
|
155
|
+
// within the local scope of the current view, and update the element with
|
156
|
+
// that translation
|
157
|
+
//
|
158
|
+
I18n.u = function(id, args) {
|
159
|
+
if ($.isArray(id)) {
|
160
|
+
$(id).each(function(i, element) {
|
161
|
+
I18n.u(element);
|
162
|
+
});
|
163
|
+
} else {
|
164
|
+
try {
|
165
|
+
var key;
|
166
|
+
key = id.toUpperCase();
|
167
|
+
I18n.update(id, key, args);
|
168
|
+
} catch(wtf) {
|
169
|
+
Debug.error("Error in i18n.u: " + JSON.stringify({
|
170
|
+
id: id,
|
171
|
+
args: args
|
172
|
+
}));
|
173
|
+
}
|
174
|
+
}
|
175
|
+
};
|
176
|
+
|
177
|
+
|
178
|
+
// I18n.updateValue(id, key, args)
|
179
|
+
//
|
180
|
+
// updates an element with the given _id_ with the
|
181
|
+
// translation from scope, key and optional args
|
182
|
+
//
|
183
|
+
// only updates the element if the translation is not blank
|
184
|
+
//
|
185
|
+
I18n.updateValue = function(id, key, args) {
|
186
|
+
try {
|
187
|
+
var message;
|
188
|
+
message = I18n.t(key, args);
|
189
|
+
if (message) {
|
190
|
+
$("#" + id).val(message);
|
191
|
+
}
|
192
|
+
} catch(omg) {
|
193
|
+
Debug.error("Error in i18n.updateValue: " + JSON.stringify({
|
194
|
+
id: id,
|
195
|
+
key: key,
|
196
|
+
args: args
|
197
|
+
}));
|
198
|
+
};
|
199
|
+
};
|
200
|
+
|
201
|
+
|
202
|
+
// I18n.v(id, args)
|
203
|
+
//
|
204
|
+
// updates the value of an element with a local YRB key of the same name
|
205
|
+
//
|
206
|
+
// given an id of "messages" it will look for a YRB key named "MESSAGES"
|
207
|
+
// within the local scope of the current view, and update the element's value with
|
208
|
+
// that translation
|
209
|
+
//
|
210
|
+
I18n.v = function(id, args) {
|
211
|
+
try {
|
212
|
+
$(id).each(function(i, element) {
|
213
|
+
I18n.v(element);
|
214
|
+
});
|
215
|
+
} catch(omg) {
|
216
|
+
try {
|
217
|
+
var key;
|
218
|
+
key = id.toUpperCase();
|
219
|
+
I18n.updateValue(id, key, args);
|
220
|
+
} catch(wtf) {
|
221
|
+
Debug.error("Error in i18n.v: " + JSON.stringify({
|
222
|
+
id: id,
|
223
|
+
args: args
|
224
|
+
}));
|
225
|
+
}
|
226
|
+
}
|
227
|
+
};
|
228
|
+
|
229
|
+
// Specific to Organizer
|
230
|
+
I18n.translateSidebar = function() {
|
231
|
+
I18n.u('faq_q1');
|
232
|
+
var link;
|
233
|
+
link = Tags.a(I18n.t('faq_link1'), {"href": 'http://go.otherinbox.com/q-custom-sender', "target": "_blank"});
|
234
|
+
I18n.u('faq_a1', [link]);
|
235
|
+
|
236
|
+
I18n.u('faq_q2');
|
237
|
+
link = Tags.a(I18n.t('faq_link2'), {"href": 'http://go.otherinbox.com/q-stop-sender', "target": "_blank"});
|
238
|
+
I18n.u('faq_a2', [link]);
|
239
|
+
};
|
240
|
+
|
241
|
+
// Specific to Organizer
|
242
|
+
I18n.translateError = function() {
|
243
|
+
I18n.update('error_1', 'ERROR_1');
|
244
|
+
I18n.update('error_2', 'ERROR_2');
|
245
|
+
I18n.update('retry', 'RETRY');
|
246
|
+
};
|
247
|
+
|
248
|
+
// Specific to Organizer
|
249
|
+
I18n.translateLoading = function() {
|
250
|
+
I18n.update('loading_subhead', 'LOADING_SUBHEAD');
|
251
|
+
I18n.update('loading_paragraph_1', 'LOADING_PARAGRAPH_1');
|
252
|
+
};
|
253
|
+
|
254
|
+
I18n.addLanguageToBody = function() {
|
255
|
+
try {
|
256
|
+
$('body').addClass(I18n.currentLanguage);
|
257
|
+
} catch(omg) {
|
258
|
+
Debug.error(omg);
|
259
|
+
}
|
260
|
+
};
|
261
|
+
|
262
|
+
I18n.p = function(element) {
|
263
|
+
element = $(element);
|
264
|
+
var key;
|
265
|
+
|
266
|
+
key = element.html();
|
267
|
+
|
268
|
+
I18n.update(element, key);
|
269
|
+
};
|
270
|
+
|
271
|
+
I18n.findAndTranslateAll = function() {
|
272
|
+
Debug.log("I18n.findAndTranslateAll");
|
273
|
+
|
274
|
+
$('.p').each(function(i) {
|
275
|
+
var element = $(this);
|
276
|
+
try {
|
277
|
+
I18n.p(element);
|
278
|
+
} catch(e) {
|
279
|
+
Debug.error("Translation error for element: " + e);
|
280
|
+
}
|
281
|
+
});
|
282
|
+
|
283
|
+
$('.t').each(function(i) {
|
284
|
+
var element = $(this);
|
285
|
+
try {
|
286
|
+
I18n.translate_element(element);
|
287
|
+
} catch(e) {
|
288
|
+
Debug.error("Translation error for element: " + e);
|
289
|
+
}
|
290
|
+
});
|
291
|
+
|
292
|
+
Debug.log("End I18n.findAndTranslateAll");
|
293
|
+
};
|