diff options
author | Nivesh Rajbhandari | 2012-03-27 09:32:53 -0700 |
---|---|---|
committer | Nivesh Rajbhandari | 2012-03-27 09:32:53 -0700 |
commit | 406bbfc63f8ed42d7da105dbd068a49ff8fb5f09 (patch) | |
tree | 3a8b45f4802f002269ff1bcf596f94cee4679a07 /node_modules/montage/ui/feed-reader/feed-reader.reel/feed-reader.js | |
parent | bda9f8f5829c943486f8850e68c991e83f8fb8c8 (diff) | |
parent | 309dde5a8c4599cef6a1052c1ff9ee1ad8ec5858 (diff) | |
download | ninja-406bbfc63f8ed42d7da105dbd068a49ff8fb5f09.tar.gz |
Merge branch 'refs/heads/ninja-internal' into WebGLMaterials
Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com>
Diffstat (limited to 'node_modules/montage/ui/feed-reader/feed-reader.reel/feed-reader.js')
-rw-r--r-- | node_modules/montage/ui/feed-reader/feed-reader.reel/feed-reader.js | 180 |
1 files changed, 180 insertions, 0 deletions
diff --git a/node_modules/montage/ui/feed-reader/feed-reader.reel/feed-reader.js b/node_modules/montage/ui/feed-reader/feed-reader.reel/feed-reader.js new file mode 100644 index 00000000..cc652417 --- /dev/null +++ b/node_modules/montage/ui/feed-reader/feed-reader.reel/feed-reader.js | |||
@@ -0,0 +1,180 @@ | |||
1 | /* <copyright> | ||
2 | This file contains proprietary software owned by Motorola Mobility, Inc.<br/> | ||
3 | No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/> | ||
4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. | ||
5 | </copyright> */ | ||
6 | var Montage = require("montage").Montage, | ||
7 | Component = require("ui/component").Component; | ||
8 | //Notifier = require("ui/popup/notifier.reel").Notifier; | ||
9 | |||
10 | exports.FeedReader = Montage.create(Component, { | ||
11 | |||
12 | didCreate: { | ||
13 | value: function() { | ||
14 | var self = this; | ||
15 | var apiInit = function() { | ||
16 | console.log('google api initialized'); | ||
17 | |||
18 | google.load("feeds", "1", { | ||
19 | callback: function() { | ||
20 | console.log('google feeds api loaded'); | ||
21 | self.needsDraw = true; | ||
22 | window.initGoogleAPI = null; | ||
23 | } | ||
24 | }); | ||
25 | }; | ||
26 | |||
27 | // set up a global function | ||
28 | window.initGoogleAPI = apiInit; | ||
29 | } | ||
30 | }, | ||
31 | |||
32 | _feedURL: {value: null}, | ||
33 | feedURL: { | ||
34 | get: function() { | ||
35 | return this._feedURL; | ||
36 | }, | ||
37 | set: function(value) { | ||
38 | this._feedURL = value; | ||
39 | // execute the search and get the entries | ||
40 | this._fetchFeed(); | ||
41 | } | ||
42 | }, | ||
43 | |||
44 | // time in ms between slides | ||
45 | interval: {value: 3, distinct: true}, | ||
46 | |||
47 | maxEntries: {value: 10, distinct: true}, | ||
48 | |||
49 | entries: {value: null}, | ||
50 | |||
51 | _feedDisplayMode: {value: null}, | ||
52 | feedDisplayMode: { | ||
53 | get: function() { | ||
54 | return this._feedDisplayMode; | ||
55 | }, | ||
56 | set: function(value) { | ||
57 | |||
58 | this.removeEntryAnimation(); | ||
59 | this._feedDisplayMode = value; | ||
60 | |||
61 | this.addEntryAnimation(); | ||
62 | } | ||
63 | }, | ||
64 | |||
65 | |||
66 | feedEntryTimer: {enumerable: false, value: null}, | ||
67 | |||
68 | |||
69 | activeFeedEntry: {value: null}, | ||
70 | _activeIndex: {value: null}, | ||
71 | activeIndex: { | ||
72 | get: function() { | ||
73 | return this._activeIndex || 0; | ||
74 | }, | ||
75 | set: function(index) { | ||
76 | if(this.entries) { | ||
77 | var max = this.entries.length-1; | ||
78 | if(index > max) { | ||
79 | index = 0; | ||
80 | } | ||
81 | if(index < 0) { | ||
82 | index = 0; | ||
83 | } | ||
84 | this._activeIndex = index; | ||
85 | this.activeFeedEntry = this.entries[this._activeIndex]; | ||
86 | } else { | ||
87 | this._activeIndex = 0; | ||
88 | } | ||
89 | } | ||
90 | }, | ||
91 | |||
92 | _fetchFeed: { | ||
93 | value: function() { | ||
94 | |||
95 | var url = this.feedURL; | ||
96 | var feed = new google.feeds.Feed(url); | ||
97 | feed.setNumEntries(10); | ||
98 | |||
99 | var self = this; | ||
100 | self.entries = []; | ||
101 | |||
102 | feed.load(function(result) { | ||
103 | self.removeEntryAnimation(); | ||
104 | if(result.error) { | ||
105 | self.entries = []; | ||
106 | } else { | ||
107 | //console.log('entries: ', result.feed.entries); | ||
108 | self.addEntryAnimation(); | ||
109 | self.entries = result.feed.entries; | ||
110 | self.activeIndex = 0; | ||
111 | |||
112 | } | ||
113 | |||
114 | |||
115 | }); | ||
116 | } | ||
117 | }, | ||
118 | |||
119 | addEntryAnimation: { | ||
120 | value: function() { | ||
121 | var self = this; | ||
122 | if("animation" == this.feedDisplayMode) { | ||
123 | this.element.addEventListener('webkitAnimationStart', this); | ||
124 | this.element.addEventListener('webkitAnimationIteration', this); | ||
125 | this.element.addEventListener('webkitAnimationEnd', this); | ||
126 | } else { | ||
127 | // timer | ||
128 | this.feedEntryTimer = setInterval(function() { | ||
129 | self.activeIndex = self.activeIndex + 1; | ||
130 | }, (this.interval * 1000)); | ||
131 | } | ||
132 | } | ||
133 | }, | ||
134 | |||
135 | removeEntryAnimation: { | ||
136 | value: function() { | ||
137 | if("animation" == this.feedDisplayMode) { | ||
138 | this.element.removeEventListener('webkitAnimationStart', this); | ||
139 | this.element.removeEventListener('webkitAnimationIteration', this); | ||
140 | this.element.removeEventListener('webkitAnimationEnd', this); | ||
141 | |||
142 | } else { | ||
143 | if(this.feedEntryTimer) { | ||
144 | window.clearInterval(this.feedEntryTimer); | ||
145 | } | ||
146 | } | ||
147 | } | ||
148 | }, | ||
149 | |||
150 | handleWebkitAnimationStart: { | ||
151 | value: function() { | ||
152 | console.log('animation start'); | ||
153 | } | ||
154 | }, | ||
155 | |||
156 | handleWebkitAnimationIteration: { | ||
157 | value: function() { | ||
158 | console.log('animation iteration'); | ||
159 | this.activeIndex = this.activeIndex + 1; | ||
160 | } | ||
161 | }, | ||
162 | |||
163 | handleWebkitAnimationEnd: { | ||
164 | value: function() { | ||
165 | console.log('animation end'); | ||
166 | } | ||
167 | }, | ||
168 | |||
169 | prepareForDraw: { | ||
170 | value: function() { | ||
171 | } | ||
172 | }, | ||
173 | |||
174 | draw: { | ||
175 | value: function() { | ||
176 | |||
177 | } | ||
178 | } | ||
179 | |||
180 | }); | ||