ymdp 0.7.1 → 0.7.2
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/ymdp/compiler/template.rb +4 -0
- data/lib/ymdp/javascripts/jquery/ab_testing.js +23 -37
- data/lib/ymdp/javascripts/jquery/ajax.js +1 -12
- data/lib/ymdp/javascripts/jquery/application.js +3 -7
- data/lib/ymdp/javascripts/jquery/authorization.js +1 -0
- data/lib/ymdp/javascripts/jquery/data.js +11 -15
- data/lib/ymdp/javascripts/jquery/education.js +17 -30
- data/lib/ymdp/javascripts/jquery/flash.js +6 -9
- data/lib/ymdp/javascripts/jquery/help.js +42 -50
- data/lib/ymdp/javascripts/jquery/i18n.js +40 -88
- data/lib/ymdp/javascripts/jquery/init.js +32 -50
- data/lib/ymdp/javascripts/jquery/params.js +9 -17
- data/lib/ymdp/javascripts/jquery/tag_helper.js +16 -29
- data/lib/ymdp/javascripts/jquery/user.js +10 -15
- data/lib/ymdp/javascripts/prototype/ab_testing.js +25 -39
- data/lib/ymdp/javascripts/prototype/launcher.js +28 -28
- data/lib/ymdp/javascripts/prototype/user.js +3 -3
- data/lib/ymdp/view/application_view.rb +7 -1
- data/lib/ymdp/view/asset_tag_helper.rb +1 -1
- data/ymdp.gemspec +2 -2
- metadata +4 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.7.
|
1
|
+
0.7.2
|
@@ -61,20 +61,14 @@ ABTesting = {
|
|
61
61
|
},
|
62
62
|
|
63
63
|
apply: function(content_id, language) {
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
} else {
|
73
|
-
YMDP.Init.showAndFinish();
|
74
|
-
}
|
75
|
-
}
|
76
|
-
catch(e) {
|
77
|
-
Debug.log(e);
|
64
|
+
if (ABTesting.on && $.inArray(language, ABTesting.languages) >= 0) {
|
65
|
+
var index;
|
66
|
+
|
67
|
+
index = ABTesting.randomAB();
|
68
|
+
ABTesting.setVariable(index);
|
69
|
+
|
70
|
+
ABTesting.get(content_id);
|
71
|
+
} else {
|
78
72
|
YMDP.Init.showAndFinish();
|
79
73
|
}
|
80
74
|
},
|
@@ -88,36 +82,28 @@ ABTesting = {
|
|
88
82
|
},
|
89
83
|
|
90
84
|
success: function(content_id, response) {
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
experimentId = response.experiment.id;
|
85
|
+
var content, experiment, experimentId;
|
86
|
+
Debug.log("ABTesting.success", response);
|
87
|
+
|
88
|
+
experiment = response.experiment;
|
89
|
+
|
90
|
+
if (experiment) {
|
91
|
+
content = ABTesting.content(experiment);
|
92
|
+
experimentId = response.experiment.id;
|
100
93
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
}
|
106
|
-
|
107
|
-
YMDP.Init.showAndFinish();
|
108
|
-
} catch(e) {
|
109
|
-
Debug.log("ABTesting.success error" + e);
|
94
|
+
ABTesting.postView(experimentId);
|
95
|
+
ABTesting.replaceContents(content_id, content);
|
96
|
+
} else {
|
97
|
+
Debug.log("No experiment running");
|
110
98
|
}
|
99
|
+
|
100
|
+
YMDP.Init.showAndFinish();
|
111
101
|
},
|
112
102
|
|
113
103
|
replaceContents: function(content_id, content) {
|
114
104
|
openmail.Application.filterHTML({html: content}, function(response) {
|
115
105
|
if (response.html && response.html !== '') {
|
116
|
-
|
117
|
-
$("#" + content_id).html(response.html);
|
118
|
-
} catch(omg) {
|
119
|
-
Debug.error(omg);
|
120
|
-
}
|
106
|
+
$("#" + content_id).html(response.html);
|
121
107
|
}
|
122
108
|
YMDP.Init.showAndFinish();
|
123
109
|
});
|
@@ -100,18 +100,7 @@ OIB = {
|
|
100
100
|
//
|
101
101
|
// response doesn't have a parameter called "error"
|
102
102
|
//
|
103
|
-
|
104
|
-
success_function(response);
|
105
|
-
} catch(e) {
|
106
|
-
if (debug) {
|
107
|
-
Debug.log("Error in OIB.request success function", e);
|
108
|
-
}
|
109
|
-
YMDP.showError({
|
110
|
-
"method": "OIB.request",
|
111
|
-
"description": "exception caught in OIB.request success callback",
|
112
|
-
"error": e
|
113
|
-
});
|
114
|
-
}
|
103
|
+
success_function(response);
|
115
104
|
}
|
116
105
|
});
|
117
106
|
},
|
@@ -91,13 +91,9 @@ YMDP.Init.upgradeCheck = function(success_callback, failure_callback) {
|
|
91
91
|
|
92
92
|
// Minty-only code goes here
|
93
93
|
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
success_callback();
|
98
|
-
} catch(wtf) {
|
99
|
-
Debug.error(wtf);
|
100
|
-
}
|
94
|
+
Debug.log("Minty found");
|
95
|
+
|
96
|
+
success_callback();
|
101
97
|
} else {
|
102
98
|
// non-Minty
|
103
99
|
|
@@ -36,22 +36,18 @@ Data = {
|
|
36
36
|
};
|
37
37
|
|
38
38
|
openmail.Application.getData(keys, function(response) {
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
success_function(response);
|
51
|
-
}
|
39
|
+
Debug.log("Inside openmail.Application.getData callback", response);
|
40
|
+
|
41
|
+
if (response.error && (response.error !== YAHOO.openmail.ERR_NONE)) {
|
42
|
+
Debug.error("Error retrieving data", response);
|
43
|
+
if (error_function) {
|
44
|
+
error_function(response);
|
45
|
+
}
|
46
|
+
} else {
|
47
|
+
Debug.log("success in openmail.Application.getData", response);
|
48
|
+
if (success_function) {
|
49
|
+
success_function(response);
|
52
50
|
}
|
53
|
-
} catch(omg) {
|
54
|
-
Debug.error(omg);
|
55
51
|
}
|
56
52
|
});
|
57
53
|
},
|
@@ -2,23 +2,19 @@ var Education;
|
|
2
2
|
|
3
3
|
Education = {
|
4
4
|
init: function(name) {
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
Education.load();
|
19
|
-
} catch(omg) {
|
20
|
-
Debug.error(omg);
|
21
|
-
}
|
5
|
+
Debug.log("Education.init", name);
|
6
|
+
var m;
|
7
|
+
|
8
|
+
Education.name = name;
|
9
|
+
|
10
|
+
m = "";
|
11
|
+
m = m + Tags.linkToFunction("Close", "Education.educate(); return false;", {"class": "close"});
|
12
|
+
m = m + Education.educationModule();
|
13
|
+
|
14
|
+
Education.container().insert(m);
|
15
|
+
Education.container().insert({"after": Education.forcedEducation()});
|
16
|
+
|
17
|
+
Education.load();
|
22
18
|
},
|
23
19
|
|
24
20
|
educationModule: function() {
|
@@ -151,18 +147,9 @@ Education = {
|
|
151
147
|
},
|
152
148
|
|
153
149
|
load: function() {
|
154
|
-
|
155
|
-
|
156
|
-
Education.
|
157
|
-
|
158
|
-
});
|
159
|
-
} catch(err) {
|
160
|
-
YMDP.showError({
|
161
|
-
"method": "Education.load",
|
162
|
-
"type": "exception caught",
|
163
|
-
"error": err
|
164
|
-
});
|
165
|
-
Debug.error(err);
|
166
|
-
}
|
150
|
+
Debug.log('Education.load');
|
151
|
+
Education.get({}, function(response) {
|
152
|
+
Education.show(response);
|
153
|
+
});
|
167
154
|
}
|
168
155
|
};
|
@@ -14,12 +14,9 @@ Flash.duration = 0.25;
|
|
14
14
|
Flash.write = function(type, message) {
|
15
15
|
type = type || "notice";
|
16
16
|
if (message) {
|
17
|
-
$('#flash_message').
|
18
|
-
Flash.setFlashClass('flash', type);
|
19
|
-
|
20
|
-
if ($('#flash').css("display") === "none") {
|
21
|
-
$('#flash').show();
|
22
|
-
}
|
17
|
+
$('#flash_message').html(message);
|
18
|
+
Flash.setFlashClass('#flash', type);
|
19
|
+
$('#flash').show();
|
23
20
|
YMDP.setTimeoutInSeconds(Flash.close, Flash.timeout);
|
24
21
|
}
|
25
22
|
};
|
@@ -30,12 +27,12 @@ Flash.close = function() {
|
|
30
27
|
|
31
28
|
Flash.setFlashClass = function(flash_id, type) {
|
32
29
|
if (type === "error") {
|
33
|
-
$(
|
30
|
+
$(flash_id).removeClass('notice');
|
34
31
|
}
|
35
32
|
if (type === "notice") {
|
36
|
-
$(
|
33
|
+
$(flash_id).removeClass('error');
|
37
34
|
}
|
38
|
-
$(
|
35
|
+
$(flash_id).addClass(type);
|
39
36
|
};
|
40
37
|
|
41
38
|
|
@@ -4,57 +4,49 @@
|
|
4
4
|
// popup help text
|
5
5
|
//
|
6
6
|
var Help = function(content) {
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
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);
|
7
|
+
this.content = content;
|
8
|
+
|
9
|
+
// instance method
|
10
|
+
this.show = function(event) {
|
11
|
+
var x = event.clientX + 20;
|
12
|
+
var y = event.clientY - 10;
|
13
|
+
this.create(x,y);
|
14
|
+
};
|
52
15
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
16
|
+
this.create = function(x, y) {
|
17
|
+
if (!$("#" + this.css_id).length) {
|
18
|
+
var popup = new Element('div', {
|
19
|
+
"id": this.css_id,
|
20
|
+
"class": "popup"
|
21
|
+
});
|
22
|
+
popup.update(this.content);
|
23
|
+
popup.setStyle({
|
24
|
+
"display": "none",
|
25
|
+
"left": x + "px",
|
26
|
+
"top": y + "px"
|
27
|
+
});
|
28
|
+
$('body').append(popup);
|
29
|
+
setTimeout("$(\"" + this.css_id + "\").show();", 500);
|
30
|
+
}
|
31
|
+
};
|
32
|
+
|
33
|
+
this.destroy = function() {
|
34
|
+
setTimeout("$('" + this.css_id + "').remove();", 4000);
|
35
|
+
};
|
36
|
+
|
37
|
+
this.link = function(text) {
|
38
|
+
text = text || "?";
|
39
|
+
return Tags.linkToFunction(text, "", {
|
40
|
+
"onmouseover": "Help.show(event, " + this.id + ");",
|
41
|
+
"onmouseout": "Help.destroy(" + this.id + ")"
|
42
|
+
});
|
43
|
+
};
|
44
|
+
|
45
|
+
Help.popups = Help.popups || [];
|
46
|
+
Help.popups.push(this);
|
47
|
+
|
48
|
+
this.id = Help.popups.size() - 1;
|
49
|
+
this.css_id = "popup_" + this.id;
|
58
50
|
};
|
59
51
|
|
60
52
|
Help.show = function(event, id) {
|
@@ -9,20 +9,14 @@
|
|
9
9
|
Methods and constants dealing with internationalization.
|
10
10
|
*/
|
11
11
|
|
12
|
-
var
|
12
|
+
var I18n;
|
13
13
|
|
14
14
|
/* set asset version */
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
MESSAGE: "<%= @message %>",
|
19
|
-
DEPLOYED: <%= Time.now.to_i %>,
|
20
|
-
DEPLOYED_STRING: "<%= Time.now.to_s %>"
|
16
|
+
I18n = {
|
17
|
+
"keys": {}
|
21
18
|
};
|
22
19
|
|
23
|
-
|
24
|
-
I18n = {};
|
25
|
-
|
26
20
|
I18n.init = function() {
|
27
21
|
Debug.log("about to call I18n.init");
|
28
22
|
|
@@ -38,23 +32,16 @@ I18n.init = function() {
|
|
38
32
|
};
|
39
33
|
|
40
34
|
I18n.setResources = function() {
|
41
|
-
var
|
42
|
-
|
43
|
-
scope = "keys";
|
35
|
+
var asset_path;
|
44
36
|
|
45
37
|
Debug.log("begin I18n.setResources for language " + I18n.currentLanguage);
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
I18n.default_keys = I18n[scope];
|
53
|
-
}
|
54
|
-
} catch(err) {
|
55
|
-
Debug.error("error in I18n.setResources: " + err);
|
38
|
+
asset_path = "<%= @assets_directory %>/yrb/";
|
39
|
+
I18n.keys = OpenMailIntl.getResources(asset_path, "keys", I18n.currentLanguage) || {};
|
40
|
+
if (I18n.currentLanguage !== "en-US") {
|
41
|
+
I18n.default_keys = OpenMailIntl.getResources(asset_path, "keys", "en-US") || {};
|
42
|
+
} else {
|
43
|
+
I18n.default_keys = I18n.keys;
|
56
44
|
}
|
57
|
-
I18n.scope = scope;
|
58
45
|
};
|
59
46
|
|
60
47
|
I18n.english = function() {
|
@@ -120,15 +107,11 @@ I18n.translate_sentence = function(key, args) {
|
|
120
107
|
// only updates the element if the translation is not blank
|
121
108
|
//
|
122
109
|
I18n.update = function(id, key, args) {
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
}
|
129
|
-
} catch(omg) {
|
130
|
-
Debug.error("Error in I18n.update", omg, id, key, args)
|
131
|
-
}
|
110
|
+
if (typeof(id) === "string") {
|
111
|
+
I18n.updateById(id, key, args);
|
112
|
+
} else {
|
113
|
+
I18n.updateByElement(id, key, args);
|
114
|
+
}
|
132
115
|
};
|
133
116
|
|
134
117
|
I18n.updateById = function(id, key, args) {
|
@@ -161,16 +144,9 @@ I18n.u = function(id, args) {
|
|
161
144
|
I18n.u(element);
|
162
145
|
});
|
163
146
|
} else {
|
164
|
-
|
165
|
-
|
166
|
-
|
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
|
-
}
|
147
|
+
var key;
|
148
|
+
key = id.toUpperCase();
|
149
|
+
I18n.update(id, key, args);
|
174
150
|
}
|
175
151
|
};
|
176
152
|
|
@@ -183,19 +159,11 @@ I18n.u = function(id, args) {
|
|
183
159
|
// only updates the element if the translation is not blank
|
184
160
|
//
|
185
161
|
I18n.updateValue = function(id, key, args) {
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
}
|
192
|
-
} catch(omg) {
|
193
|
-
Debug.error("Error in i18n.updateValue: " + JSON.stringify({
|
194
|
-
id: id,
|
195
|
-
key: key,
|
196
|
-
args: args
|
197
|
-
}));
|
198
|
-
};
|
162
|
+
var message;
|
163
|
+
message = I18n.t(key, args);
|
164
|
+
if (message) {
|
165
|
+
$("#" + id).val(message);
|
166
|
+
}
|
199
167
|
};
|
200
168
|
|
201
169
|
|
@@ -207,23 +175,14 @@ I18n.updateValue = function(id, key, args) {
|
|
207
175
|
// within the local scope of the current view, and update the element's value with
|
208
176
|
// that translation
|
209
177
|
//
|
210
|
-
I18n.v = function(
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
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
|
-
}
|
178
|
+
I18n.v = function(elements, args) {
|
179
|
+
$(elements).each(function(i, element) {
|
180
|
+
var key;
|
181
|
+
|
182
|
+
element = $(element);
|
183
|
+
key = element.val();
|
184
|
+
element.val(I18n.t(key));
|
185
|
+
});
|
227
186
|
};
|
228
187
|
|
229
188
|
// Specific to Organizer
|
@@ -252,11 +211,7 @@ I18n.translateLoading = function() {
|
|
252
211
|
};
|
253
212
|
|
254
213
|
I18n.addLanguageToBody = function() {
|
255
|
-
|
256
|
-
$('body').addClass(I18n.currentLanguage);
|
257
|
-
} catch(omg) {
|
258
|
-
Debug.error(omg);
|
259
|
-
}
|
214
|
+
$('body').addClass(I18n.currentLanguage);
|
260
215
|
};
|
261
216
|
|
262
217
|
I18n.p = function(element) {
|
@@ -273,21 +228,18 @@ I18n.findAndTranslateAll = function() {
|
|
273
228
|
|
274
229
|
$('.p').each(function(i) {
|
275
230
|
var element = $(this);
|
276
|
-
|
277
|
-
I18n.p(element);
|
278
|
-
} catch(e) {
|
279
|
-
Debug.error("Translation error for element: " + e);
|
280
|
-
}
|
231
|
+
I18n.p(element);
|
281
232
|
});
|
282
233
|
|
283
234
|
$('.t').each(function(i) {
|
284
235
|
var element = $(this);
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
236
|
+
I18n.translate_element(element);
|
237
|
+
});
|
238
|
+
|
239
|
+
$('.v').each(function(i) {
|
240
|
+
var element = $(this);
|
241
|
+
I18n.v(element);
|
242
|
+
});
|
291
243
|
|
292
244
|
Debug.log("End I18n.findAndTranslateAll");
|
293
245
|
};
|
@@ -13,14 +13,10 @@ YMDP.Init.addBehaviors = function() {
|
|
13
13
|
// hide the loading screen and show the main body of the summary
|
14
14
|
YMDP.Init.show = function() {
|
15
15
|
Debug.log("YMDP.Init.show");
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
$('#main').show();
|
21
|
-
} catch(e) {
|
22
|
-
Debug.error("Error in YMDP.Init.show", e);
|
23
|
-
}
|
16
|
+
$('#utility').hide();
|
17
|
+
$('#error').hide();
|
18
|
+
$('#loading').hide();
|
19
|
+
$('#main').show();
|
24
20
|
};
|
25
21
|
|
26
22
|
|
@@ -43,12 +39,16 @@ YMDP.Init.startup = function() {
|
|
43
39
|
Debug.log("init.startup");
|
44
40
|
// gets the user
|
45
41
|
YMDP.getGuid(function(guid) {
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
42
|
+
Reporter.reportCurrentView(guid);
|
43
|
+
callback = function() {
|
44
|
+
try {
|
45
|
+
YMDP.Init.local();
|
46
|
+
} catch(omg) {
|
47
|
+
Debug.error("Error in YMDP.Init.local", omg);
|
48
|
+
YMDP.showError();
|
49
|
+
}
|
50
|
+
};
|
51
|
+
YMDP.getUserState(callback, callback);
|
52
52
|
});
|
53
53
|
};
|
54
54
|
|
@@ -65,24 +65,15 @@ YMDP.Init.abTesting = function() {
|
|
65
65
|
// runs the A/B testing callback, which in turn will execute the last callbacks.
|
66
66
|
//
|
67
67
|
YMDP.Init.finish = function() {
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
Debug.log("finished init.finish for view " + View.name);
|
78
|
-
// } catch(omg) {
|
79
|
-
// Debug.error("Error in YMDP.Init.finish", omg);
|
80
|
-
// YMDP.showError({
|
81
|
-
// "method": "YMDP.Init.finish",
|
82
|
-
// "description": "exception caught in YMDP.Init.finish",
|
83
|
-
// "error": omg
|
84
|
-
// });
|
85
|
-
// }
|
68
|
+
Debug.log("init.finish for view " + View.name);
|
69
|
+
YMDP.showTranslations();
|
70
|
+
Debug.log("addBehaviors:");
|
71
|
+
YMDP.Init.addBehaviors();
|
72
|
+
Debug.log("abTesting:");
|
73
|
+
YMDP.Init.abTesting();
|
74
|
+
Debug.log("page_loaded = true:");
|
75
|
+
View.page_loaded = true;
|
76
|
+
Debug.log("finished init.finish for view " + View.name);
|
86
77
|
};
|
87
78
|
|
88
79
|
// Post-initalizer. Very last thing that runs, after content has been shown.
|
@@ -94,24 +85,15 @@ YMDP.Init.after = function() {
|
|
94
85
|
// Execute the before, startup and after methods. Do not overwrite. (Change YMDP.Init.startup to create a custom initializer.)
|
95
86
|
YMDP.init = function() {
|
96
87
|
Debug.log("OIB.init for view " + View.name, "<%= @message %>");
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
YMDP.Init.startup();
|
107
|
-
} catch(err_f) {
|
108
|
-
YMDP.showError({
|
109
|
-
"method": "YMDP.init",
|
110
|
-
"description": "exception caught in YMDP.init",
|
111
|
-
"error": err_f
|
112
|
-
});
|
113
|
-
Debug.error("Error in YMDP.init", err_f);
|
114
|
-
}
|
88
|
+
Logger.init();
|
89
|
+
Tags.init();
|
90
|
+
YMDP.Init.browser();
|
91
|
+
YMDP.Init.resources();
|
92
|
+
I18n.addLanguageToBody();
|
93
|
+
I18n.translateLoading();
|
94
|
+
I18n.translateError();
|
95
|
+
YMDP.Init.before();
|
96
|
+
YMDP.Init.startup();
|
115
97
|
};
|
116
98
|
|
117
99
|
YMDP.Init.browser = function() {
|
@@ -6,29 +6,21 @@ var Params = {
|
|
6
6
|
launchParams = launchParams || {};
|
7
7
|
Debug.log("Params.init", launchParams);
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
Params.parameters = {};
|
14
|
-
}
|
15
|
-
} catch(wtf) {
|
16
|
-
Debug.error(wtf);
|
9
|
+
if (launchParams) {
|
10
|
+
Params.parameters = launchParams;
|
11
|
+
} else {
|
12
|
+
Params.parameters = {};
|
17
13
|
}
|
18
14
|
},
|
19
15
|
|
20
16
|
get: function(name) {
|
21
17
|
Debug.log("Params.get", name);
|
22
18
|
var index, result;
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
result = Params.parameters["param" + index];
|
29
|
-
}
|
30
|
-
} catch(wtf) {
|
31
|
-
Debug.error(wtf);
|
19
|
+
|
20
|
+
index = $.inArray(name, Params.names);
|
21
|
+
|
22
|
+
if (index >= 0) {
|
23
|
+
result = Params.parameters["param" + index];
|
32
24
|
}
|
33
25
|
return result;
|
34
26
|
}
|
@@ -1,25 +1,12 @@
|
|
1
1
|
/* TAG HELPERS */
|
2
2
|
|
3
|
-
|
4
3
|
// DO NOT USE the @view instance variable in any files in /app/javascripts/base.
|
5
4
|
// The way they are cached makes it not safe to do so.
|
6
5
|
|
7
6
|
var Tags;
|
8
7
|
|
9
8
|
function tagHelper(tag_name, text, options) {
|
10
|
-
|
11
|
-
|
12
|
-
m = "";
|
13
|
-
opts = "";
|
14
|
-
|
15
|
-
Object.keys(options).each(function(key) {
|
16
|
-
opts = opts + " " + key + "='" + options[key] + "'";
|
17
|
-
});
|
18
|
-
|
19
|
-
m = m + "<" + tag_name + " " + opts + ">";
|
20
|
-
m = m + text;
|
21
|
-
m = m + "<\/" + tag_name + ">";
|
22
|
-
return m;
|
9
|
+
return Tags.create(tag_name, text, options);
|
23
10
|
}
|
24
11
|
|
25
12
|
function optionTag(text, options) {
|
@@ -63,10 +50,11 @@ function submitTag(value, options) {
|
|
63
50
|
function optionsForSelect(options, selected) {
|
64
51
|
var m;
|
65
52
|
m = "";
|
66
|
-
|
53
|
+
|
54
|
+
$.each(options, function(i, option) {
|
67
55
|
var key, value, opts;
|
68
56
|
|
69
|
-
if (
|
57
|
+
if ($.isArray(option)) {
|
70
58
|
key = option[0];
|
71
59
|
value = option[1];
|
72
60
|
} else {
|
@@ -82,7 +70,7 @@ function optionsForSelect(options, selected) {
|
|
82
70
|
opts.selected = 'selected';
|
83
71
|
}
|
84
72
|
|
85
|
-
m = m + optionTag(key, opts);
|
73
|
+
m = m + optionTag(key, opts);
|
86
74
|
});
|
87
75
|
return m;
|
88
76
|
}
|
@@ -91,20 +79,21 @@ Tags = {
|
|
91
79
|
create: function(tag_name, text, options) {
|
92
80
|
options = options || {};
|
93
81
|
var m, opts;
|
82
|
+
text = text || "";
|
94
83
|
|
95
84
|
m = "";
|
96
85
|
opts = "";
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
86
|
+
|
87
|
+
$.each(options, function(i, key) {
|
88
|
+
if (options[key]) {
|
89
|
+
opts = opts + " " + key + "='" + options[key] + "'";
|
90
|
+
}
|
91
|
+
});
|
103
92
|
|
104
93
|
m = m + "<" + tag_name + " " + opts + ">";
|
105
94
|
m = m + text;
|
106
95
|
m = m + "<\/" + tag_name + ">";
|
107
|
-
return m;
|
96
|
+
return $(m);
|
108
97
|
},
|
109
98
|
|
110
99
|
input: function(value, options) {
|
@@ -163,17 +152,15 @@ Tags = {
|
|
163
152
|
return Tags.a(value, options);
|
164
153
|
},
|
165
154
|
|
166
|
-
|
167
|
-
return new Element('div', options).update(text);
|
168
|
-
},
|
155
|
+
tag_list: ["li", "ol", "ul", "span", "div", "p", "a", "option", "select", "strong", "table", "th", "tr", "td", "div"],
|
169
156
|
|
170
157
|
init: function() {
|
171
|
-
|
158
|
+
$.each(Tags.tag_list, function(i, tag_name) {
|
172
159
|
Tags[tag_name] = function(text, options) {
|
173
160
|
options = options || {};
|
174
161
|
return Tags.create(tag_name, text, options);
|
175
162
|
};
|
176
|
-
};
|
163
|
+
});
|
177
164
|
}
|
178
165
|
};
|
179
166
|
|
@@ -149,11 +149,7 @@ YMDP.getYmailWssid = function(success_function, error_function) {
|
|
149
149
|
|
150
150
|
Debug.log("YMDP.ymail_wssid is defined", YMDP.ymail_wssid);
|
151
151
|
|
152
|
-
|
153
|
-
success_function(YMDP.ymail_wssid);
|
154
|
-
} catch(omg) {
|
155
|
-
Debug.error("Error in YMDP.getYmailWssid getData callback", omg);
|
156
|
-
}
|
152
|
+
success_function(YMDP.ymail_wssid);
|
157
153
|
});
|
158
154
|
};
|
159
155
|
|
@@ -168,17 +164,16 @@ YMDP.getGuid = function(success_function, error_function) {
|
|
168
164
|
openmail.Application.getParameters(function(response) {
|
169
165
|
Debug.log("getParameters callback");
|
170
166
|
YMDP.guid = response.user.guid;
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
}
|
178
|
-
Params.init(params);
|
179
|
-
} catch(omg) {
|
180
|
-
Debug.error("error getting parameters: " + omg);
|
167
|
+
|
168
|
+
Debug.log("YMDP.getGuid getParameters response", response);
|
169
|
+
|
170
|
+
var params = {};
|
171
|
+
if (response.data) {
|
172
|
+
params = response.data.launchParams;
|
181
173
|
}
|
174
|
+
|
175
|
+
Params.init(params);
|
176
|
+
|
182
177
|
if (YMDP.guid !== undefined) {
|
183
178
|
success_function(YMDP.guid);
|
184
179
|
}
|
@@ -61,21 +61,15 @@ ABTesting = {
|
|
61
61
|
},
|
62
62
|
|
63
63
|
apply: function(content_id, language) {
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
} else {
|
74
|
-
YAHOO.init.showAndFinish();
|
75
|
-
}
|
76
|
-
}
|
77
|
-
catch(e) {
|
78
|
-
Debug.log(e);
|
64
|
+
Debug.log("ABTesting.apply", $A(arguments));
|
65
|
+
if (ABTesting.on && ABTesting.languages.include(language)) {
|
66
|
+
var index;
|
67
|
+
|
68
|
+
index = ABTesting.randomAB();
|
69
|
+
ABTesting.setVariable(index);
|
70
|
+
|
71
|
+
ABTesting.get(content_id);
|
72
|
+
} else {
|
79
73
|
YAHOO.init.showAndFinish();
|
80
74
|
}
|
81
75
|
},
|
@@ -89,36 +83,28 @@ ABTesting = {
|
|
89
83
|
},
|
90
84
|
|
91
85
|
success: function(content_id, response) {
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
experimentId = response.experiment.id;
|
86
|
+
var content, experiment, experimentId;
|
87
|
+
Debug.log("ABTesting.success", response);
|
88
|
+
|
89
|
+
experiment = response.experiment;
|
90
|
+
|
91
|
+
if (experiment) {
|
92
|
+
content = ABTesting.content(experiment);
|
93
|
+
experimentId = response.experiment.id;
|
101
94
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
}
|
107
|
-
|
108
|
-
YAHOO.init.showAndFinish();
|
109
|
-
} catch(e) {
|
110
|
-
Debug.log("ABTesting.success error" + e);
|
95
|
+
ABTesting.postView(experimentId);
|
96
|
+
ABTesting.replaceContents(content_id, content);
|
97
|
+
} else {
|
98
|
+
Debug.log("No experiment running");
|
111
99
|
}
|
100
|
+
|
101
|
+
YAHOO.init.showAndFinish();
|
112
102
|
},
|
113
103
|
|
114
104
|
replaceContents: function(content_id, content) {
|
115
105
|
openmail.Application.filterHTML({html: content}, function(response) {
|
116
|
-
if (response.html
|
117
|
-
|
118
|
-
$(content_id).update(response.html);
|
119
|
-
} catch(omg) {
|
120
|
-
Debug.error(omg);
|
121
|
-
}
|
106
|
+
if (response.html) {
|
107
|
+
$("#" + content_id).html(response.html);
|
122
108
|
}
|
123
109
|
YAHOO.init.showAndFinish();
|
124
110
|
});
|
@@ -21,9 +21,9 @@ LAUNCHER = {
|
|
21
21
|
|
22
22
|
YAHOO.namespace("launcher");
|
23
23
|
|
24
|
-
Launcher =
|
24
|
+
Launcher = Launcher;
|
25
25
|
|
26
|
-
|
26
|
+
Launcher.launch = function(view, title, type) {
|
27
27
|
openmail.Application.getParameters(function(response) {
|
28
28
|
title = I18n.t("APPLICATION_NAME");
|
29
29
|
// don't try to relaunch current tab
|
@@ -45,7 +45,7 @@ YAHOO.launcher.launch = function(view, title, type) {
|
|
45
45
|
};
|
46
46
|
|
47
47
|
|
48
|
-
|
48
|
+
Launcher.launchView = function(launch_view) {
|
49
49
|
var user;
|
50
50
|
|
51
51
|
user = YAHOO.oib.user || {"state": "active"};
|
@@ -53,10 +53,10 @@ YAHOO.launcher.launchView = function(launch_view) {
|
|
53
53
|
switch(user.state) {
|
54
54
|
case "scanning":
|
55
55
|
// formerly known as 'inspect'
|
56
|
-
|
56
|
+
Launcher.launchScanning();
|
57
57
|
break;
|
58
58
|
case "summary":
|
59
|
-
|
59
|
+
Launcher.launchSummary();
|
60
60
|
break;
|
61
61
|
case "authorized":
|
62
62
|
// authorized but not yet 'signed in'
|
@@ -72,52 +72,52 @@ YAHOO.launcher.launchView = function(launch_view) {
|
|
72
72
|
break;
|
73
73
|
default:
|
74
74
|
// other
|
75
|
-
|
75
|
+
Launcher.launchAuthorize();
|
76
76
|
}
|
77
77
|
};
|
78
78
|
|
79
79
|
|
80
|
-
|
81
|
-
|
80
|
+
Launcher.launchTab = function(view, title) {
|
81
|
+
Launcher.launch(view, title, "tab");
|
82
82
|
};
|
83
83
|
|
84
84
|
// User must be signed in for this page, we'll
|
85
85
|
// sign them in if they don't have an OIB cookie
|
86
86
|
//
|
87
|
-
|
88
|
-
|
87
|
+
Launcher.launchActiveTab = function(view, title) {
|
88
|
+
Launcher.launchTab(view, title);
|
89
89
|
};
|
90
90
|
|
91
91
|
|
92
|
-
|
93
|
-
|
92
|
+
Launcher.launchAuthorize = function() {
|
93
|
+
Launcher.launchTab("authorize", "Authorize");
|
94
94
|
};
|
95
95
|
|
96
|
-
|
97
|
-
|
96
|
+
Launcher.launchDeactivate = function() {
|
97
|
+
Launcher.launchHidden("deactivate", "Deactivate");
|
98
98
|
};
|
99
99
|
|
100
|
-
|
101
|
-
|
100
|
+
Launcher.launchHidden = function(view, title) {
|
101
|
+
Launcher.launch(view, title, "hidden");
|
102
102
|
};
|
103
103
|
|
104
|
-
|
104
|
+
Launcher.l = function(view) {
|
105
105
|
view = "launch" + view.capitalize();
|
106
|
-
|
106
|
+
Launcher[view]();
|
107
107
|
};
|
108
108
|
|
109
|
-
|
110
|
-
|
109
|
+
Launcher.launchGoodbye = function() {
|
110
|
+
Launcher.launchTab("goodbye", "Goodbye");
|
111
111
|
};
|
112
112
|
|
113
|
-
|
113
|
+
Launcher.relaunchAuthorize = Launcher.launchAuthorize;
|
114
114
|
|
115
|
-
|
116
|
-
|
115
|
+
Launcher.launchMaintenance = function() {
|
116
|
+
Launcher.launchTab("maintenance", "Maintenance");
|
117
117
|
};
|
118
118
|
|
119
|
-
|
120
|
-
|
119
|
+
Launcher.launchReauthorize = function() {
|
120
|
+
Launcher.launchTab("reauthorize", "Reauthorize");
|
121
121
|
};
|
122
122
|
|
123
123
|
Launcher.launchView = function(launch_view) {
|
@@ -132,10 +132,10 @@ Launcher.launchView = function(launch_view) {
|
|
132
132
|
switch(user.state) {
|
133
133
|
case "scanning":
|
134
134
|
// formerly known as 'inspect'
|
135
|
-
|
135
|
+
Launcher.launchScanning();
|
136
136
|
break;
|
137
137
|
case "summary":
|
138
|
-
|
138
|
+
Launcher.launchSummary();
|
139
139
|
break;
|
140
140
|
case "authorized":
|
141
141
|
// authorized but not yet 'signed in'
|
@@ -151,7 +151,7 @@ Launcher.launchView = function(launch_view) {
|
|
151
151
|
break;
|
152
152
|
default:
|
153
153
|
// other
|
154
|
-
|
154
|
+
Launcher.launchAuthorize();
|
155
155
|
}
|
156
156
|
});
|
157
157
|
});
|
@@ -88,8 +88,8 @@ YAHOO.oib.confirm = function() {
|
|
88
88
|
YAHOO.oib.ymail_wssid = response.ymail_wssid;
|
89
89
|
|
90
90
|
// now that we've got their ymail_wssid, we can sign them in:
|
91
|
-
YAHOO.oib.verifyUser(
|
92
|
-
//
|
91
|
+
YAHOO.oib.verifyUser(Launcher.launchMain);
|
92
|
+
// Launcher.launchMain();
|
93
93
|
} else {
|
94
94
|
// signin didn't work properly, display an error
|
95
95
|
Debug.log("YAHOO.oib.response was false");
|
@@ -204,7 +204,7 @@ YAHOO.oib.deactivateUser = function() {
|
|
204
204
|
},
|
205
205
|
function(response) {
|
206
206
|
if (View.name !== "deactivate") {
|
207
|
-
|
207
|
+
Launcher.launchGoodbye();
|
208
208
|
}
|
209
209
|
});
|
210
210
|
});
|
@@ -416,7 +416,13 @@ module YMDP
|
|
416
416
|
def render_without_compression(path, tags=true)
|
417
417
|
output = ""
|
418
418
|
|
419
|
-
if File.exists?(path)
|
419
|
+
if File.exists?("#{path}.coffee")
|
420
|
+
path = "#{path}.coffee"
|
421
|
+
$stdout.puts("Parsing #{path}")
|
422
|
+
template = File.read(path)
|
423
|
+
output = process_coffee(template)
|
424
|
+
elsif File.exists?(path)
|
425
|
+
$stdout.puts("Parsing #{path}")
|
420
426
|
template = File.read(path)
|
421
427
|
output = process_template(template)
|
422
428
|
end
|
@@ -18,7 +18,7 @@ module YMDP
|
|
18
18
|
options[:target] ||= "_blank"
|
19
19
|
else
|
20
20
|
# this will create an in-YMDP link
|
21
|
-
options[:onclick] = "
|
21
|
+
options[:onclick] = "Launcher.l('#{url_or_view}'); return false;"
|
22
22
|
options[:href] = "#"
|
23
23
|
end
|
24
24
|
content_tag("a", text, options)
|
data/ymdp.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{ymdp}
|
8
|
-
s.version = "0.7.
|
8
|
+
s.version = "0.7.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Isaac Priestley"]
|
12
|
-
s.date = %q{2011-05-
|
12
|
+
s.date = %q{2011-05-31}
|
13
13
|
s.description = %q{Framework for developing applications in the Yahoo! Mail Development Platform.}
|
14
14
|
s.email = %q{progressions@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ymdp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 7
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 7
|
9
|
-
-
|
10
|
-
version: 0.7.
|
9
|
+
- 2
|
10
|
+
version: 0.7.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Isaac Priestley
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-05-
|
18
|
+
date: 2011-05-31 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|