ymdp 0.8.5 → 0.8.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.
@@ -1,120 +0,0 @@
1
- /*
2
- AUTHORIZE USER
3
-
4
- Authorize and sign in the user.
5
- */
6
-
7
- var Authorize;
8
-
9
- Authorize = {
10
- init: function(guid, default_state, params) {
11
- Debug.log("Authorize.init");
12
- params = params || {};
13
- if (Params.get("invitation")) {
14
- params["invitation"] = Params.get("invitation");
15
- }
16
- params["application"] = View.application;
17
- Authorize.url = YMDP.Constants.controller_url + "/authorize/" + guid;
18
- Authorize.locale = params.locale;
19
- Authorize.default_state = default_state;
20
-
21
- Authorize.params = params;
22
- Debug.log("end of Authorize.init");
23
- },
24
-
25
- assignUrl: function(url) {
26
- url = url || Authorize.url;
27
- url = url + "?" + $.param(Authorize.params);
28
-
29
- $("#get_started_1").attr("href", url).attr("target", "_blank");
30
- $("#get_started_2").attr("href", url).attr("target", "_blank");
31
- $(".get_started").attr("href", url).attr("target", "_blank");
32
- },
33
-
34
- authorize: function() {
35
- Debug.log("Authorize.authorize");
36
- YMDP.getUserState(function(response) {
37
- if (Authorize.authorized(response)) {
38
- Authorize.confirm();
39
- } else {
40
- Debug.log("About to startScanning");
41
- Authorize.startScanning();
42
- }
43
- });
44
- },
45
-
46
- startScanning: function() {
47
- Debug.log("Authorize.startScanning", Authorize.scanner);
48
- if (!Authorize.scanner) {
49
- Debug.log("Authorize.scanner doesnt exist", Authorize.scanner);
50
- Authorize.scanner = window.setInterval(Authorize.scan, 5000);
51
- } else {
52
- Debug.log("Authorize.scanner does exist", Authorize.scanner);
53
- }
54
- },
55
-
56
- authorized: function(response) {
57
- Debug.log("Authorize.authorized", response);
58
- return !!(response.state !== Authorize.default_state && View.authorized(response));
59
- },
60
-
61
- confirm: YMDP.confirm,
62
-
63
- scan: function() {
64
- Debug.log("Authorize.scan");
65
- if (Authorize.stop_scanning) {
66
- Debug.log("Authorize.stop_scanning is true", Authorize.stop_scanning);
67
- window.clearInterval(Authorize.scanner);
68
- } else {
69
- Debug.log("Authorize.stop_scanning is not true", Authorize.stop_scanning);
70
- }
71
-
72
- Debug.log("About to getUserState");
73
-
74
- YMDP.getUserState(function(response) {
75
- Debug.log("inside Authorize.scan's getUserState callback", response);
76
- if (response.state !== Authorize.default_state) {
77
- Debug.log("not default state, about to Authorize.confirm()");
78
-
79
- Authorize.confirm();
80
- if (Authorize.scanner) {
81
- window.clearInterval(Authorize.scanner);
82
- }
83
- Authorize.scanner = undefined;
84
- Debug.log("just set Authorize.scanner to undefined");
85
- }
86
- }, function(response) {
87
- // error function
88
- Debug.error("Error in Authorize.scan's getUserState", response);
89
-
90
- if (Authorize.scanner) {
91
- window.clearInterval(Authorize.scanner);
92
- }
93
- });
94
- },
95
-
96
- addBehaviors: function() {
97
- Debug.log("Authorize.addBehaviors");
98
- $("#get_started_1").click(Authorize.authorize);
99
- $("#get_started_2").click(Authorize.authorize);
100
- $(".get_started").click(Authorize.authorize);
101
- },
102
-
103
- verify: function() {
104
- // call /ymdp/verify and return data about the user
105
- YMDP.verifyUser(function(user) {
106
- Debug.log("inside YMDP.verifyUser callback", user);
107
-
108
- YMDP.user = user;
109
- YMDP.login = user.login;
110
- YMDP.Init.switchOnState(user);
111
- }, function(response) {
112
- // call to ymdp/verify was not a 200 response, show error
113
- YMDP.showError({
114
- "method_name": "YMDP.verifyUser",
115
- "description": "error response"
116
- });
117
- });
118
- }
119
- };
120
-
@@ -1,36 +0,0 @@
1
- var Browser;
2
-
3
- Browser = {
4
- version: function(v) {
5
- var version, app_version;
6
- app_version = navigator.appVersion;
7
- Debug.log("Browser app_version: ", app_version);
8
-
9
- if (app_version.match("MSIE 6.0")) {
10
- version = 6.0;
11
- }
12
-
13
- if (v) {
14
- return (version === v);
15
- } else {
16
- return version;
17
- }
18
- },
19
-
20
- ie: function() {
21
- return navigator.appName.match("Internet Explorer");
22
- },
23
-
24
- ie6: function() {
25
- return (Browser.ie() && Browser.version(6.0));
26
- },
27
-
28
- ie7: function() {
29
- return (Browser.ie() && Browser.version(7.0));
30
- },
31
-
32
- ie8: function() {
33
- return (Browser.ie() && Browser.version(8.0));
34
- }
35
- };
36
-
@@ -1,98 +0,0 @@
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
- call: function() {
17
- var level, message;
18
- var args = [].slice.call(arguments,0);
19
- level = args.shift();
20
-
21
- message = this.message.apply(Debug, args);
22
-
23
- if (this.consoleOn()) {
24
- console[level](message);
25
- }
26
- Logger.observe(message);
27
- },
28
-
29
- log: function() {
30
- var args = [].slice.call(arguments,0);
31
- args.unshift("log");
32
- this.call.apply(this, args);
33
- },
34
-
35
- error: function() {
36
- var args = [].slice.call(arguments,0);
37
- args.unshift("error");
38
- this.call.apply(this, args);
39
- },
40
-
41
- message: function() {
42
- var parts, message;
43
- parts = [];
44
-
45
- parts.push(this.timestamp());
46
- parts.push(this.generalInfo());
47
-
48
- var args = [].slice.call(arguments,0);
49
-
50
- $(args).each(function(i, arg) {
51
- parts.push(Debug.object(arg));
52
- });
53
-
54
- message = parts.join(" ");
55
-
56
- return message;
57
- },
58
-
59
- object: function(obj) {
60
- if (typeof obj === "string") {
61
- return obj;
62
- } else if (obj === undefined) {
63
- return "undefined";
64
- } else if (obj === null) {
65
- return "null";
66
- } else if (obj.inspect) {
67
- return(obj.inspect());
68
- } else {
69
- return(JSON.stringify(obj));
70
- }
71
- },
72
-
73
- checktime: function(i) {
74
- if (i<10) {
75
- i="0" + i;
76
- }
77
- return i;
78
- },
79
-
80
- timestamp: function() {
81
- var time, hour, minute, second, timestamp, checktime;
82
-
83
- time = new Date();
84
- hour = this.checktime(time.getHours());
85
- minute = this.checktime(time.getMinutes());
86
- second = this.checktime(time.getSeconds());
87
-
88
- // timestamp = month + "/" + date + "/" + year + " " +
89
-
90
- timestamp = hour + ":" + minute + ":" + second;
91
-
92
- return timestamp;
93
- },
94
-
95
- generalInfo: function() {
96
- return "[<%= @version %> <%= @sprint_name %>]";
97
- }
98
- };
@@ -1,140 +0,0 @@
1
- /*
2
-
3
- INITIALIZER CODE
4
-
5
- */
6
-
7
- // Adds behaviors/observers to elements on the page
8
- //
9
- YMDP.Init.addBehaviors = function() {
10
- // overwrite this function locally
11
- };
12
-
13
- // hide the loading screen and show the main body of the summary
14
- YMDP.Init.show = function() {
15
- Debug.log("YMDP.Init.show");
16
- $('#utility').hide();
17
- $('#error').hide();
18
- $('#loading').hide();
19
- $('#main').show();
20
- };
21
-
22
-
23
- // Local initializer. When your page starts up, this method will be called after fetching the user's guid and ymail wssid.
24
- //
25
- YMDP.Init.local = function() {
26
- throw("This hasn't been overwritten.");
27
- // overwrite this function locally
28
- };
29
-
30
- // To be run before any other initializers have run.
31
- //
32
- YMDP.Init.before = function() {
33
- // overwrite this function locally
34
- };
35
-
36
- // Main startup code. Overwrite this function to execute after YMDP.Init.before and before YMDP.Init.after.
37
- //
38
- YMDP.Init.startup = function() {
39
- Debug.log("init.startup");
40
- // gets the user
41
- YMDP.getGuid(function(guid) {
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
- });
53
- };
54
-
55
- YMDP.Init.abTesting = function() {
56
- // to enable abTesting in your view, overwrite this file locally.
57
- //
58
- // be sure to finish your post-Ajax callback with YMDP.Init.show()
59
- //
60
- YMDP.Init.show();
61
- YMDP.Init.after();
62
- };
63
-
64
- // Finishing code. Runs after startup, executes translations and behaviors. Shows the page and then
65
- // runs the A/B testing callback, which in turn will execute the last callbacks.
66
- //
67
- YMDP.Init.finish = function() {
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);
77
- };
78
-
79
- // Post-initalizer. Very last thing that runs, after content has been shown.
80
- //
81
- YMDP.Init.after = function() {
82
- // overwrite this function locally
83
- };
84
-
85
- YMDP.setJSON = function() {
86
- if (typeof(JSON) !== 'undefined') {
87
- return true;
88
- }
89
- if (typeof(YUI) !== 'undefined') {
90
- YUI().use('json', function(Y) {
91
- return window.JSON = Y.JSON;
92
- });
93
- } else if (typeof(YAHOO) !== 'undefined' && typeof(YAHOO.lang) !== 'undefined') {
94
- window.JSON = YAHOO.lang.JSON;
95
- }
96
- };
97
-
98
- // Execute the before, startup and after methods. Do not overwrite. (Change YMDP.Init.startup to create a custom initializer.)
99
- YMDP.init = function() {
100
- try {
101
- YMDP.setJSON(); // must set JSON first because Debug uses it
102
- Debug.log("OIB.init for view " + View.name, "<%= @message %>");
103
- Logger.init();
104
- Tags.init();
105
- YMDP.Init.browser();
106
- YMDP.Init.resources();
107
- I18n.addLanguageToBody();
108
- I18n.translateLoading();
109
- I18n.translateError();
110
- YMDP.Init.before();
111
- YMDP.Init.startup();
112
- } catch(wtff) {
113
- Debug.error(wtff.message);
114
- }
115
- };
116
-
117
- YMDP.Init.browser = function() {
118
- if ($.browser.webkit) {
119
- $('body').addClass('webkit');
120
- }
121
- };
122
-
123
- YMDP.Init.resources = function() {
124
- Debug.log("about to call I18n.setResources");
125
-
126
- I18n.availableLanguages = <%= supported_languages.to_json %>;
127
-
128
- I18n.currentLanguage = OpenMailIntl.findBestLanguage(I18n.availableLanguages);
129
-
130
- I18n.setResources();
131
-
132
- Debug.log("finished calling I18n.setResources");
133
- };
134
-
135
- // Contains the last two callbacks, to show the page contents and run post-show function. Do not overwrite.
136
- YMDP.Init.showAndFinish = function() {
137
- Debug.log("YMDP.Init.showAndFinish");
138
- YMDP.Init.show();
139
- YMDP.Init.after();
140
- };
@@ -1,153 +0,0 @@
1
- /*
2
- LAUNCHING
3
-
4
- global to every view. launches new views and closes the current one.
5
-
6
- // DO NOT USE the @view instance variable in any files in /app/javascripts/base.
7
- // The way they are cached makes it not safe to do so.
8
-
9
- */
10
-
11
- /* set asset version */
12
-
13
- var Launcher;
14
-
15
- Launcher = {};
16
-
17
- Launcher.launch = function(view, title, type) {
18
- openmail.Application.getParameters(function(response) {
19
- title = I18n.t("APPLICATION_NAME");
20
- // don't try to relaunch current tab
21
- if (response.data === null || response.data.view !== view) {
22
- openmail.Application.openView(
23
- {
24
- id: view,
25
- view: view,
26
- target: type,
27
- title: title,
28
- parameters: {
29
- launchParams: Params.parameters,
30
- view: view
31
- }
32
- });
33
- openmail.Application.closeView(null);
34
- }
35
- });
36
- };
37
-
38
-
39
- Launcher.launchView = function(launch_view) {
40
- var user;
41
-
42
- user = YMDP.user || {"state": "active"};
43
-
44
- switch(user.state) {
45
- case "scanning":
46
- // formerly known as 'inspect'
47
- Launcher.launchScanning();
48
- break;
49
- case "summary":
50
- Launcher.launchSummary();
51
- break;
52
- case "authorized":
53
- // authorized but not yet 'signed in'
54
- YMDP.signInUser();
55
- break;
56
- case "new_active":
57
- // no messages processed yet
58
- case "processing":
59
- // activated but we have synced fewer than 80% of their messages
60
- case "active":
61
- // active, launch the view this method was intended for
62
- launch_view();
63
- break;
64
- default:
65
- // other
66
- Launcher.launchAuthorize();
67
- }
68
- };
69
-
70
-
71
- Launcher.launchTab = function(view, title) {
72
- Launcher.launch(view, title, "tab");
73
- };
74
-
75
- // User must be signed in for this page, we'll
76
- // sign them in if they don't have an OIB cookie
77
- //
78
- Launcher.launchActiveTab = function(view, title) {
79
- Launcher.launchTab(view, title);
80
- };
81
-
82
-
83
- Launcher.launchAuthorize = function() {
84
- Launcher.launchTab("authorize", "Authorize");
85
- };
86
-
87
- Launcher.launchDeactivate = function() {
88
- Launcher.launchHidden("deactivate", "Deactivate");
89
- };
90
-
91
- Launcher.launchHidden = function(view, title) {
92
- Launcher.launch(view, title, "hidden");
93
- };
94
-
95
- Launcher.l = function(view) {
96
- view = "launch" + view.capitalize();
97
- Launcher[view]();
98
- };
99
-
100
- Launcher.launchGoodbye = function() {
101
- Launcher.launchTab("goodbye", "Goodbye");
102
- };
103
-
104
- Launcher.relaunchAuthorize = Launcher.launchAuthorize;
105
-
106
- Launcher.launchMaintenance = function() {
107
- Launcher.launchTab("maintenance", "Maintenance");
108
- };
109
-
110
- Launcher.launchReauthorize = function() {
111
- Launcher.launchTab("reauthorize", "Reauthorize");
112
- };
113
-
114
- Launcher.launchView = function(launch_view) {
115
- // get Yahoo! user's guid and ymail_wssid
116
- YMDP.getGuidAndYmailWssid(function(guid, ymail_wssid) {
117
-
118
- // call /ymdp/verify and return data about the user
119
- YMDP.verifyUser(function(user) {
120
-
121
- YMDP.login = user.login;
122
-
123
- switch(user.state) {
124
- case "scanning":
125
- // formerly known as 'inspect'
126
- Launcher.launchScanning();
127
- break;
128
- case "summary":
129
- Launcher.launchSummary();
130
- break;
131
- case "authorized":
132
- // authorized but not yet 'signed in'
133
- YMDP.signInUser();
134
- break;
135
- case "new_active":
136
- // no messages processed yet
137
- case "processing":
138
- // activated but we have synced fewer than 80% of their messages
139
- case "active":
140
- // active, launch the view this method was intended for
141
- launch_view();
142
- break;
143
- default:
144
- // other
145
- Launcher.launchAuthorize();
146
- }
147
- });
148
- });
149
- };
150
-
151
- Launcher.launchMain = function() {
152
- Launcher.launchView(Launcher.launchFolders);
153
- };