diff options
author | Jose Antonio Marquez | 2012-03-18 16:14:34 -0700 |
---|---|---|
committer | Jose Antonio Marquez | 2012-03-18 16:14:34 -0700 |
commit | 06a790e0f830d01539dc9e80c90e2bcdabaa666b (patch) | |
tree | 474f3f1e0ea147b0400ff8528e1c33566179b211 /node_modules/montage/ui/feed-reader/feed-reader.reel/feed-reader.js | |
parent | fda7b595c96d99177fdd93de8da9030348a3f8fb (diff) | |
parent | 3056d540f32bb24927d06bfc516240cc6a0001f8 (diff) | |
download | ninja-06a790e0f830d01539dc9e80c90e2bcdabaa666b.tar.gz |
Merge branch 'refs/heads/francoisfrisch-Ninja-Internal' into FileIO-Montage-Components
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 | 82 |
1 files changed, 82 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..838a957d --- /dev/null +++ b/node_modules/montage/ui/feed-reader/feed-reader.reel/feed-reader.js | |||
@@ -0,0 +1,82 @@ | |||
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 | entries: {value: null}, | ||
45 | |||
46 | |||
47 | _startLoading: { | ||
48 | value: function() { | ||
49 | //Notifier.show('Loading ... please wait', null, {top: this.element.style.top, left: this.element.style.left + 20}); | ||
50 | } | ||
51 | }, | ||
52 | |||
53 | _stopLoading: { | ||
54 | value: function() { | ||
55 | //Notifier.hide(); | ||
56 | } | ||
57 | }, | ||
58 | |||
59 | _fetchFeed: { | ||
60 | value: function() { | ||
61 | var url = this.feedURL; | ||
62 | var feed = new google.feeds.Feed(url); | ||
63 | feed.setNumEntries(10); | ||
64 | |||
65 | var self = this; | ||
66 | |||
67 | this._startLoading(); | ||
68 | self.entries = []; | ||
69 | |||
70 | feed.load(function(result) { | ||
71 | self._stopLoading(); | ||
72 | if(result.error) { | ||
73 | self.entries = []; | ||
74 | } else { | ||
75 | //console.log('entries: ', result.feed.entries); | ||
76 | self.entries = result.feed.entries; | ||
77 | } | ||
78 | }); | ||
79 | } | ||
80 | } | ||
81 | |||
82 | }); | ||