ymdp 0.4.5 → 0.4.6

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.5
1
+ 0.4.6
@@ -0,0 +1,140 @@
1
+ /*
2
+ AUTHORIZE USER
3
+
4
+ Authorize and sign in the user.
5
+ */
6
+
7
+ View.authorized = function() {
8
+ return true;
9
+ };
10
+
11
+ var Authorize;
12
+
13
+ Authorize = {
14
+ init: function(guid, default_state, params) {
15
+ Debug.log("Authorize.init");
16
+ params = params || {};
17
+ if (Params.get("invitation")) {
18
+ params["invitation"] = Params.get("invitation");
19
+ }
20
+ params["application"] = View.application;
21
+ Authorize.url = YAHOO.constants.controller_url + "/authorize/" + guid;
22
+ Authorize.locale = params.locale;
23
+ Authorize.default_state = default_state;
24
+
25
+ Authorize.params = params;
26
+ },
27
+
28
+ assignUrl: function(url) {
29
+ url = url || Authorize.url;
30
+ url = url + "?" + Object.toQueryString(Authorize.params);
31
+ if ($('get_started_1')) {
32
+ $('get_started_1').href = url;
33
+ $('get_started_1').setAttribute("target", "_blank");
34
+ }
35
+ if ($('get_started_2')) {
36
+ $('get_started_2').href = url;
37
+ $('get_started_2').setAttribute("target", "_blank");
38
+ }
39
+ $$('a.get_started').each(function(element) {
40
+ element = $(element);
41
+ element.href = url;
42
+ element.setAttribute("target", "_blank");
43
+ });
44
+ },
45
+
46
+ authorize: function() {
47
+ Debug.log("Authorize.authorize");
48
+ YAHOO.oib.getUserState(function(response) {
49
+ if (Authorize.authorized(response)) {
50
+ Authorize.confirm();
51
+ } else {
52
+ Debug.log("About to startScanning");
53
+ Authorize.startScanning();
54
+ }
55
+ });
56
+ },
57
+
58
+ startScanning: function() {
59
+ Debug.log("Authorize.startScanning", Authorize.scanner);
60
+ if (!Authorize.scanner) {
61
+ Debug.log("Authorize.scanner doesnt exist", Authorize.scanner);
62
+ Authorize.scanner = new PeriodicalExecuter(Authorize.scan, 5);
63
+ } else {
64
+ Debug.log("Authorize.scanner does exist", Authorize.scanner);
65
+ }
66
+ },
67
+
68
+ authorized: function(response) {
69
+ Debug.log("Authorize.authorized", response);
70
+ return !!(response.state !== Authorize.default_state && View.authorized(response));
71
+ },
72
+
73
+ confirm: YAHOO.oib.confirm,
74
+
75
+ scan: function(pe) {
76
+ Debug.log("Authorize.scan", pe);
77
+ if (Authorize.stop_scanning) {
78
+ Debug.log("Authorize.stop_scanning is true", Authorize.stop_scanning);
79
+ pe.stop();
80
+ } else {
81
+ Debug.log("Authorize.stop_scanning is not true", Authorize.stop_scanning);
82
+ }
83
+
84
+ Debug.log("About to getUserState");
85
+
86
+ YAHOO.oib.getUserState(function(response) {
87
+ Debug.log("inside Authorize.scan's getUserState callback", response);
88
+ if (response.state !== Authorize.default_state) {
89
+ Debug.log("not default state, about to Authorize.confirm()");
90
+
91
+ Authorize.confirm();
92
+ if (pe) {
93
+ Debug.log("pe", pe);
94
+ pe.stop();
95
+ }
96
+ Authorize.scanner = undefined;
97
+ Debug.log("just set Authorize.scanner to undefined");
98
+ }
99
+ }, function(response) {
100
+ // error function
101
+ Debug.error("Error in Authorize.scan's getUserState", response);
102
+
103
+ if (pe) {
104
+ pe.stop();
105
+ }
106
+ });
107
+ },
108
+
109
+ addBehaviors: function() {
110
+ Debug.log("Authorize.addBehaviors");
111
+ if ($("get_started_1")) {
112
+ Debug.log("get_started_1");
113
+ $("get_started_1").observe("click", Authorize.authorize);
114
+ }
115
+ if ($("get_started_2")) {
116
+ Debug.log("get_started_2");
117
+ $("get_started_2").observe("click", Authorize.authorize);
118
+ }
119
+ $$(".get_started").each(function(element) {
120
+ element.observe("click", Authorize.authorize);
121
+ });
122
+ },
123
+
124
+ verify: function() {
125
+ // call /ymdp/verify and return data about the user
126
+ YAHOO.oib.verifyUser(function(user) {
127
+ Debug.log("inside YAHOO.oib.verifyUser callback", user);
128
+
129
+ YAHOO.oib.login = user.login;
130
+ YAHOO.init.switchOnState(user);
131
+ }, function(response) {
132
+ // call to ymdp/verify was not a 200 response, show error
133
+ YAHOO.oib.showError({
134
+ "method_name": "YAHOO.oib.verifyUser",
135
+ "description": "error response"
136
+ });
137
+ });
138
+ }
139
+ };
140
+
@@ -251,7 +251,7 @@ module YMDP
251
251
  end
252
252
 
253
253
  def render_default_javascripts(options={})
254
- default_javascripts = ['application', 'params', 'browser', 'data', 'ajax', 'user', 'init', 'reporter', 'debug', 'tag_helper', 'launcher', 'logger', 'i18n', 'flash', 'ab_testing', 'education']
254
+ default_javascripts = ['application', 'authorization', 'params', 'browser', 'data', 'ajax', 'user', 'init', 'reporter', 'debug', 'tag_helper', 'launcher', 'logger', 'i18n', 'flash', 'ab_testing', 'education']
255
255
 
256
256
  filenames = default_javascripts.map do |filename|
257
257
  File.join(File.dirname(__FILE__), "..", "javascripts", "#{filename}.js")
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.4.5"
8
+ s.version = "0.4.6"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jeff Coleman"]
12
- s.date = %q{2011-04-04}
12
+ s.date = %q{2011-04-06}
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 = [
@@ -57,6 +57,7 @@ Gem::Specification.new do |s|
57
57
  "lib/ymdp/javascripts/ab_testing.js",
58
58
  "lib/ymdp/javascripts/ajax.js",
59
59
  "lib/ymdp/javascripts/application.js",
60
+ "lib/ymdp/javascripts/authorization.js",
60
61
  "lib/ymdp/javascripts/browser.js",
61
62
  "lib/ymdp/javascripts/data.js",
62
63
  "lib/ymdp/javascripts/debug.js",
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: 5
4
+ hash: 3
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
- - 5
10
- version: 0.4.5
9
+ - 6
10
+ version: 0.4.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jeff Coleman
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-04-04 00:00:00 -05:00
18
+ date: 2011-04-06 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -588,6 +588,7 @@ files:
588
588
  - lib/ymdp/javascripts/ab_testing.js
589
589
  - lib/ymdp/javascripts/ajax.js
590
590
  - lib/ymdp/javascripts/application.js
591
+ - lib/ymdp/javascripts/authorization.js
591
592
  - lib/ymdp/javascripts/browser.js
592
593
  - lib/ymdp/javascripts/data.js
593
594
  - lib/ymdp/javascripts/debug.js