ymdp 0.3.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/ymdp/javascripts/ab_testing.js +130 -0
- data/lib/ymdp/javascripts/ajax.js +165 -0
- data/lib/ymdp/javascripts/application.js +139 -0
- data/lib/ymdp/javascripts/browser.js +36 -0
- data/lib/ymdp/javascripts/data.js +67 -0
- data/lib/ymdp/javascripts/debug.js +109 -0
- data/lib/ymdp/javascripts/education.js +166 -0
- data/lib/ymdp/javascripts/flash.js +100 -0
- data/lib/ymdp/javascripts/help.js +79 -0
- data/lib/ymdp/javascripts/i18n.js +242 -0
- data/lib/ymdp/javascripts/init.js +159 -0
- data/lib/ymdp/javascripts/launcher.js +131 -0
- data/lib/ymdp/javascripts/logger.js +64 -0
- data/lib/ymdp/javascripts/params.js +35 -0
- data/lib/ymdp/javascripts/reporter.js +47 -0
- data/lib/ymdp/javascripts/tag_helper.js +182 -0
- data/lib/ymdp/javascripts/user.js +207 -0
- data/lib/ymdp/view/application_view.rb +34 -4
- data/ymdp.gemspec +19 -2
- metadata +22 -5
@@ -0,0 +1,67 @@
|
|
1
|
+
var Data;
|
2
|
+
|
3
|
+
Data = {
|
4
|
+
// values cannot be longer than 255 chars
|
5
|
+
//
|
6
|
+
store: function(data, success_function, error_function) {
|
7
|
+
Debug.log("Data.store", data);
|
8
|
+
|
9
|
+
var keys = {
|
10
|
+
"keys": data
|
11
|
+
};
|
12
|
+
openmail.Application.setData(keys, function(response) {
|
13
|
+
Debug.log("openmail.Application.setData response", response);
|
14
|
+
|
15
|
+
if (response.error && (response.error !== YAHOO.openmail.ERR_NONE)) {
|
16
|
+
// storage error detected
|
17
|
+
Debug.error("Error saving data", response);
|
18
|
+
if (error_function) {
|
19
|
+
error_function(response);
|
20
|
+
}
|
21
|
+
} else {
|
22
|
+
if (success_function) {
|
23
|
+
success_function(response);
|
24
|
+
}
|
25
|
+
}
|
26
|
+
});
|
27
|
+
},
|
28
|
+
|
29
|
+
// keys must be an array
|
30
|
+
//
|
31
|
+
fetch: function(keys, success_function, error_function) {
|
32
|
+
Debug.log("Data.fetch", keys);
|
33
|
+
|
34
|
+
keys = {
|
35
|
+
"keys": keys
|
36
|
+
};
|
37
|
+
|
38
|
+
openmail.Application.getData(keys, function(response) {
|
39
|
+
try {
|
40
|
+
Debug.log("Inside openmail.Application.getData callback", response);
|
41
|
+
|
42
|
+
if (response.error && (response.error !== YAHOO.openmail.ERR_NONE)) {
|
43
|
+
Debug.error("Error retrieving data", response);
|
44
|
+
if (error_function) {
|
45
|
+
error_function(response);
|
46
|
+
}
|
47
|
+
} else {
|
48
|
+
Debug.log("success in openmail.Application.getData", response);
|
49
|
+
if (success_function) {
|
50
|
+
success_function(response);
|
51
|
+
}
|
52
|
+
}
|
53
|
+
} catch(omg) {
|
54
|
+
Debug.error(omg);
|
55
|
+
}
|
56
|
+
});
|
57
|
+
},
|
58
|
+
|
59
|
+
clear: function() {
|
60
|
+
Data.store({
|
61
|
+
"ymail_wssid": null
|
62
|
+
}, function(response) {
|
63
|
+
YAHOO.oib.guid = null;
|
64
|
+
YAHOO.oib.ymail_wssid = null;
|
65
|
+
});
|
66
|
+
}
|
67
|
+
};
|
@@ -0,0 +1,109 @@
|
|
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 Debug;
|
6
|
+
|
7
|
+
Debug = {
|
8
|
+
on: false,
|
9
|
+
console: true,
|
10
|
+
logs: false,
|
11
|
+
|
12
|
+
consoleOn: function() {
|
13
|
+
return (typeof window['console'] !== 'undefined' && this.console);
|
14
|
+
},
|
15
|
+
|
16
|
+
profile: function(name) {
|
17
|
+
if (this.consoleOn()) {
|
18
|
+
console.profile(name);
|
19
|
+
}
|
20
|
+
},
|
21
|
+
|
22
|
+
profileEnd: function(name) {
|
23
|
+
if (this.consoleOn()) {
|
24
|
+
console.profileEnd(name);
|
25
|
+
}
|
26
|
+
},
|
27
|
+
|
28
|
+
call: function() {
|
29
|
+
var level, message;
|
30
|
+
var args = [].slice.call(arguments,0);
|
31
|
+
level = args.shift();
|
32
|
+
|
33
|
+
message = this.message.apply(Debug, args);
|
34
|
+
|
35
|
+
if (this.consoleOn()) {
|
36
|
+
console[level](message);
|
37
|
+
}
|
38
|
+
},
|
39
|
+
|
40
|
+
log: function() {
|
41
|
+
var args = [].slice.call(arguments,0);
|
42
|
+
args.unshift("log");
|
43
|
+
this.call.apply(this, args);
|
44
|
+
},
|
45
|
+
|
46
|
+
error: function() {
|
47
|
+
var args = [].slice.call(arguments,0);
|
48
|
+
args.unshift("error");
|
49
|
+
this.call.apply(this, args);
|
50
|
+
},
|
51
|
+
|
52
|
+
message: function() {
|
53
|
+
var parts, message;
|
54
|
+
parts = [];
|
55
|
+
|
56
|
+
parts.push(this.timestamp());
|
57
|
+
parts.push(this.generalInfo());
|
58
|
+
|
59
|
+
var args = [].slice.call(arguments,0);
|
60
|
+
|
61
|
+
args.each(function(arg) {
|
62
|
+
parts.push(Debug.object(arg));
|
63
|
+
});
|
64
|
+
|
65
|
+
message = parts.join(" ");
|
66
|
+
|
67
|
+
return message;
|
68
|
+
},
|
69
|
+
|
70
|
+
object: function(obj) {
|
71
|
+
if (typeof obj === "string") {
|
72
|
+
return obj;
|
73
|
+
} else if (obj === undefined) {
|
74
|
+
return "undefined";
|
75
|
+
} else if (obj === null) {
|
76
|
+
return "null";
|
77
|
+
} else if (obj.inspect) {
|
78
|
+
return(obj.inspect());
|
79
|
+
} else {
|
80
|
+
return(Object.toJSON(obj));
|
81
|
+
}
|
82
|
+
},
|
83
|
+
|
84
|
+
checktime: function(i) {
|
85
|
+
if (i<10) {
|
86
|
+
i="0" + i;
|
87
|
+
}
|
88
|
+
return i;
|
89
|
+
},
|
90
|
+
|
91
|
+
timestamp: function() {
|
92
|
+
var time, hour, minute, second, timestamp, checktime;
|
93
|
+
|
94
|
+
time = new Date();
|
95
|
+
hour = this.checktime(time.getHours());
|
96
|
+
minute = this.checktime(time.getMinutes());
|
97
|
+
second = this.checktime(time.getSeconds());
|
98
|
+
|
99
|
+
// timestamp = month + "/" + date + "/" + year + " " +
|
100
|
+
|
101
|
+
timestamp = hour + ":" + minute + ":" + second;
|
102
|
+
|
103
|
+
return timestamp;
|
104
|
+
},
|
105
|
+
|
106
|
+
generalInfo: function() {
|
107
|
+
return "[<%= @domain %>/<%= @server %>] [<%= @version %> <%= @sprint_name %>]";
|
108
|
+
}
|
109
|
+
};
|
@@ -0,0 +1,166 @@
|
|
1
|
+
var Education;
|
2
|
+
|
3
|
+
Education = {
|
4
|
+
init: function(name) {
|
5
|
+
try {
|
6
|
+
Debug.log("Education.init", name);
|
7
|
+
var m;
|
8
|
+
|
9
|
+
Education.name = name;
|
10
|
+
|
11
|
+
m = "";
|
12
|
+
m = m + Tags.linkToFunction("Close", "Education.educate(); return false;", {"class": "close"});
|
13
|
+
m = m + Education.educationModule();
|
14
|
+
|
15
|
+
Education.container().insert(m);
|
16
|
+
Education.container().insert({"after": Education.forcedEducation()});
|
17
|
+
|
18
|
+
Education.load();
|
19
|
+
} catch(omg) {
|
20
|
+
Debug.error(omg);
|
21
|
+
}
|
22
|
+
},
|
23
|
+
|
24
|
+
educationModule: function() {
|
25
|
+
var m;
|
26
|
+
|
27
|
+
m = Tags.div(Education.ol(), {"id": Education.name, "class": "education_module"});
|
28
|
+
|
29
|
+
return m;
|
30
|
+
},
|
31
|
+
|
32
|
+
forcedEducation: function() {
|
33
|
+
var m;
|
34
|
+
|
35
|
+
m = Tags.div(Education.minForcedEducation(), {"id": "forced_education", "style": "display: none;"});
|
36
|
+
|
37
|
+
return m;
|
38
|
+
},
|
39
|
+
|
40
|
+
minForcedEducation: function() {
|
41
|
+
var m, id;
|
42
|
+
|
43
|
+
id = "min_" + Education.name + "_education";
|
44
|
+
Debug.log("getting min forced education key", id);
|
45
|
+
m = Tags.div(I18n.t(id), {"id": id});
|
46
|
+
|
47
|
+
Debug.log("got key", m);
|
48
|
+
|
49
|
+
return m;
|
50
|
+
},
|
51
|
+
|
52
|
+
ol: function() {
|
53
|
+
var m, entries;
|
54
|
+
|
55
|
+
entries = Education.entries();
|
56
|
+
|
57
|
+
entries = entries.join("");
|
58
|
+
m = Tags.ol(entries);
|
59
|
+
|
60
|
+
return m;
|
61
|
+
},
|
62
|
+
|
63
|
+
entries: function() {
|
64
|
+
var m, entries, entry, i;
|
65
|
+
entries = [];
|
66
|
+
|
67
|
+
i = 0;
|
68
|
+
|
69
|
+
do {
|
70
|
+
i = i + 1;
|
71
|
+
entry = Education.entry(i);
|
72
|
+
entries.push(entry);
|
73
|
+
} while(entry);
|
74
|
+
|
75
|
+
return entries;
|
76
|
+
},
|
77
|
+
|
78
|
+
entry: function(index) {
|
79
|
+
var m, text, id;
|
80
|
+
|
81
|
+
id = Education.name + "_" + String(index);
|
82
|
+
text = I18n.t(id);
|
83
|
+
|
84
|
+
if (text) {
|
85
|
+
m = Tags.li(text, {"id": id});
|
86
|
+
}
|
87
|
+
return m;
|
88
|
+
},
|
89
|
+
|
90
|
+
show: function(educations) {
|
91
|
+
Debug.log('Education.init');
|
92
|
+
Education.educations = educations;
|
93
|
+
Debug.log("Educations.educations: ", educations);
|
94
|
+
if (Education.container() !== null) {
|
95
|
+
Education.getModules();
|
96
|
+
}
|
97
|
+
},
|
98
|
+
|
99
|
+
get: function(params, success_function, error_function) {
|
100
|
+
Debug.log('Education.get. About to call OIB.get');
|
101
|
+
OIB.get("educations/", params, success_function, error_function);
|
102
|
+
},
|
103
|
+
|
104
|
+
post: function(params, success_function, error_function) {
|
105
|
+
Debug.log('Education.post');
|
106
|
+
OIB.post("educations/create", params, success_function, error_function);
|
107
|
+
},
|
108
|
+
|
109
|
+
educate: function() {
|
110
|
+
// Grab the children divs of $('education') with the class education_module that are NOT HIDDEN
|
111
|
+
// For each education module returned, post the id and view as params[:title] and params[:page_name]
|
112
|
+
$$('.education_module').each(function(element) {
|
113
|
+
if (!element.hasClassName('educated')) {
|
114
|
+
Debug.log(element.identify());
|
115
|
+
Education.post({"page_name": View.name, "title": element.identify()}, function(response) {
|
116
|
+
Debug.log("Response: " + response);
|
117
|
+
});
|
118
|
+
}
|
119
|
+
});
|
120
|
+
Education.container().hide();
|
121
|
+
$('forced_education').show();
|
122
|
+
},
|
123
|
+
|
124
|
+
getModules: function() {
|
125
|
+
var showContainer = false;
|
126
|
+
$$('.education_module').each(function(element) {
|
127
|
+
Education.educations.each(function(education) {
|
128
|
+
if (element.identify() === education.title && View.name.toLowerCase() === education.page_name.toLowerCase()) {
|
129
|
+
element.addClassName('educated');
|
130
|
+
}
|
131
|
+
});
|
132
|
+
});
|
133
|
+
|
134
|
+
$$('.education_module').each(function(element) {
|
135
|
+
if(!element.hasClassName('educated')) {
|
136
|
+
showContainer = true;
|
137
|
+
}
|
138
|
+
});
|
139
|
+
|
140
|
+
if (showContainer) {
|
141
|
+
Education.container().show();
|
142
|
+
} else {
|
143
|
+
$('forced_education').show();
|
144
|
+
}
|
145
|
+
},
|
146
|
+
|
147
|
+
container: function() {
|
148
|
+
return $('education');
|
149
|
+
},
|
150
|
+
|
151
|
+
load: function() {
|
152
|
+
try {
|
153
|
+
Debug.log('Education.load');
|
154
|
+
Education.get({}, function(response) {
|
155
|
+
Education.show(response);
|
156
|
+
});
|
157
|
+
} catch(err) {
|
158
|
+
YAHOO.oib.showError({
|
159
|
+
"method": "Education.load",
|
160
|
+
"type": "exception caught",
|
161
|
+
"error": err
|
162
|
+
});
|
163
|
+
Debug.error(err);
|
164
|
+
}
|
165
|
+
}
|
166
|
+
};
|
@@ -0,0 +1,100 @@
|
|
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, Flash;
|
6
|
+
|
7
|
+
/* set asset version */
|
8
|
+
|
9
|
+
FLASH = {
|
10
|
+
VERSION: "<%= @hash %>",
|
11
|
+
MESSAGE: "<%= @message %>",
|
12
|
+
DEPLOYED: <%= Time.now.to_i %>,
|
13
|
+
DEPLOYED_STRING: "<%= Time.now.to_s %>"
|
14
|
+
};
|
15
|
+
|
16
|
+
|
17
|
+
/* FLASH MESSAGE HANDLERS */
|
18
|
+
|
19
|
+
YAHOO.namespace("flash");
|
20
|
+
|
21
|
+
Flash = {};
|
22
|
+
|
23
|
+
Flash.timeout = 8;
|
24
|
+
Flash.duration = 0.25;
|
25
|
+
|
26
|
+
Flash.write = function(type, message) {
|
27
|
+
type = type || "notice";
|
28
|
+
if (message) {
|
29
|
+
$('flash_message').update(message);
|
30
|
+
Flash.setFlashClass('flash', type);
|
31
|
+
|
32
|
+
// blindDown if the flash is currently hidden
|
33
|
+
if ($('flash').getStyle("display") === "none") {
|
34
|
+
$('flash').blindDown({queue: "end", duration: Flash.duration});
|
35
|
+
}
|
36
|
+
YAHOO.oib.setTimeoutInSeconds(Flash.close, Flash.timeout);
|
37
|
+
}
|
38
|
+
};
|
39
|
+
|
40
|
+
Flash.close = function() {
|
41
|
+
Try.these(function() {
|
42
|
+
$('flash').blindUp({queue: "end", duration: Flash.duration});
|
43
|
+
});
|
44
|
+
};
|
45
|
+
|
46
|
+
Flash.setFlashClass = function(flash_id, type) {
|
47
|
+
if (type === "error") {
|
48
|
+
Try.these(function() {
|
49
|
+
$(flash_id).removeClassName('notice');
|
50
|
+
});
|
51
|
+
}
|
52
|
+
if (type === "notice") {
|
53
|
+
Try.these(function() {
|
54
|
+
$(flash_id).removeClassName('error');
|
55
|
+
});
|
56
|
+
}
|
57
|
+
Try.these(function() {
|
58
|
+
$(flash_id).addClassName(type);
|
59
|
+
});
|
60
|
+
};
|
61
|
+
|
62
|
+
|
63
|
+
Flash.error = function(message) {
|
64
|
+
// YAHOO.logger.error(message);
|
65
|
+
Flash.write("error", message, true);
|
66
|
+
};
|
67
|
+
|
68
|
+
Flash.notice = function(message) {
|
69
|
+
Flash.write("notice", message, true);
|
70
|
+
};
|
71
|
+
|
72
|
+
Flash.success = Flash.notice;
|
73
|
+
|
74
|
+
Flash.t = {};
|
75
|
+
Flash.t.notice = function(key, args) {
|
76
|
+
var m;
|
77
|
+
|
78
|
+
m = I18n.t(key, args);
|
79
|
+
Flash.notice(m);
|
80
|
+
};
|
81
|
+
Flash.t.success = Flash.t.notice;
|
82
|
+
|
83
|
+
Flash.t.error = function(key, args) {
|
84
|
+
var m;
|
85
|
+
|
86
|
+
m = I18n.t(key, args);
|
87
|
+
Flash.error(m);
|
88
|
+
};
|
89
|
+
|
90
|
+
|
91
|
+
Flash.settingsChanged = function() {
|
92
|
+
Flash.t.success("SETTINGS_CHANGED");
|
93
|
+
};
|
94
|
+
Flash.problemSubmitting = function() {
|
95
|
+
Flash.t.error("PROBLEM_SUBMITTING");
|
96
|
+
};
|
97
|
+
|
98
|
+
YAHOO.flash = Flash;
|
99
|
+
|
100
|
+
/* ----------------------- */
|
@@ -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)) {
|
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').first().insert(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
|
+
|