diff options
author | Armen Kesablyan | 2012-05-14 11:45:11 -0700 |
---|---|---|
committer | Armen Kesablyan | 2012-05-14 11:45:11 -0700 |
commit | 9e6c0a247bd2f14d92278bcd97fff40277b71667 (patch) | |
tree | 4194388c03814b9168922dbf2907edf426295874 /node_modules/montage-google/feed-reader/feed-reader.reel | |
parent | 9fc3b70bf57e10846e71808c6041fbc339a435d1 (diff) | |
parent | 27f4cacb39de1c2e3910748dadc9fc16d0655480 (diff) | |
download | ninja-9e6c0a247bd2f14d92278bcd97fff40277b71667.tar.gz |
Merge branch 'refs/heads/masterDomArc' into binding
Diffstat (limited to 'node_modules/montage-google/feed-reader/feed-reader.reel')
-rw-r--r-- | node_modules/montage-google/feed-reader/feed-reader.reel/feed-reader.html | 79 | ||||
-rw-r--r-- | node_modules/montage-google/feed-reader/feed-reader.reel/feed-reader.js | 179 |
2 files changed, 258 insertions, 0 deletions
diff --git a/node_modules/montage-google/feed-reader/feed-reader.reel/feed-reader.html b/node_modules/montage-google/feed-reader/feed-reader.reel/feed-reader.html new file mode 100644 index 00000000..28c0ed1f --- /dev/null +++ b/node_modules/montage-google/feed-reader/feed-reader.reel/feed-reader.html | |||
@@ -0,0 +1,79 @@ | |||
1 | <!DOCTYPE html> | ||
2 | <html> | ||
3 | <head> | ||
4 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | ||
5 | <title>Feed Reader</title> | ||
6 | |||
7 | <script type="text/javascript" src="https://www.google.com/jsapi?callback=initGoogleAPI"></script> | ||
8 | |||
9 | <script type="text/montage-serialization"> | ||
10 | { | ||
11 | "entriesController": { | ||
12 | "name": "ArrayController", | ||
13 | "module": "montage/ui/controller/array-controller", | ||
14 | "properties": { | ||
15 | "selectObjectsOnAddition": true, | ||
16 | "automaticallyOrganizeObjects": true | ||
17 | }, | ||
18 | "bindings": { | ||
19 | "content": { | ||
20 | "boundObject": {"@": "owner"}, | ||
21 | "boundObjectPropertyPath": "entries", | ||
22 | "oneway": true | ||
23 | } | ||
24 | } | ||
25 | }, | ||
26 | |||
27 | "feedEntry": { | ||
28 | "module": "montage-google/feed-reader/feed-entry.reel", | ||
29 | "name": "FeedEntry", | ||
30 | "properties": { | ||
31 | "element": {"#": "feed-entry"} | ||
32 | }, | ||
33 | "bindings": { | ||
34 | "entry": { | ||
35 | "boundObject": {"@": "owner"}, | ||
36 | "boundObjectPropertyPath": "activeFeedEntry", | ||
37 | "oneway": true | ||
38 | } | ||
39 | } | ||
40 | }, | ||
41 | |||
42 | "owner": { | ||
43 | "module": "montage-google/feed-reader/feed-reader.reel", | ||
44 | "name": "FeedReader", | ||
45 | "properties": { | ||
46 | "element": {"#": "feed-reader"} | ||
47 | } | ||
48 | } | ||
49 | |||
50 | } | ||
51 | </script> | ||
52 | |||
53 | <style> | ||
54 | div.feed-reader { | ||
55 | /*padding: 2px;*/ | ||
56 | height: 120px; | ||
57 | width: 380px; | ||
58 | } | ||
59 | |||
60 | .feed-entry { | ||
61 | } | ||
62 | |||
63 | |||
64 | </style> | ||
65 | |||
66 | |||
67 | </head> | ||
68 | <body> | ||
69 | <div class="feed-reader" id="feed-reader"> | ||
70 | |||
71 | <div id="entries"> | ||
72 | <div class="feed-entry" id="feed-entry"></div> | ||
73 | </div> | ||
74 | |||
75 | |||
76 | </div> | ||
77 | |||
78 | </body> | ||
79 | </html> | ||
diff --git a/node_modules/montage-google/feed-reader/feed-reader.reel/feed-reader.js b/node_modules/montage-google/feed-reader/feed-reader.reel/feed-reader.js new file mode 100644 index 00000000..47a831eb --- /dev/null +++ b/node_modules/montage-google/feed-reader/feed-reader.reel/feed-reader.js | |||
@@ -0,0 +1,179 @@ | |||
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("montage/ui/component").Component; | ||
8 | |||
9 | exports.FeedReader = Montage.create(Component, { | ||
10 | |||
11 | didCreate: { | ||
12 | value: function() { | ||
13 | var self = this; | ||
14 | var apiInit = function() { | ||
15 | console.log('google api initialized'); | ||
16 | |||
17 | google.load("feeds", "1", { | ||
18 | callback: function() { | ||
19 | console.log('google feeds api loaded'); | ||
20 | self.needsDraw = true; | ||
21 | window.initGoogleAPI = null; | ||
22 | } | ||
23 | }); | ||
24 | }; | ||
25 | |||
26 | // set up a global function | ||
27 | window.initGoogleAPI = apiInit; | ||
28 | } | ||
29 | }, | ||
30 | |||
31 | _feedURL: {value: null}, | ||
32 | feedURL: { | ||
33 | get: function() { | ||
34 | return this._feedURL; | ||
35 | }, | ||
36 | set: function(value) { | ||
37 | this._feedURL = value; | ||
38 | // execute the search and get the entries | ||
39 | this._fetchFeed(); | ||
40 | } | ||
41 | }, | ||
42 | |||
43 | // time in ms between slides | ||
44 | interval: {value: 3, distinct: true}, | ||
45 | |||
46 | maxEntries: {value: 10, distinct: true}, | ||
47 | |||
48 | entries: {value: null}, | ||
49 | |||
50 | _feedDisplayMode: {value: null}, | ||
51 | feedDisplayMode: { | ||
52 | get: function() { | ||
53 | return this._feedDisplayMode; | ||
54 | }, | ||
55 | set: function(value) { | ||
56 | |||
57 | this.removeEntryAnimation(); | ||
58 | this._feedDisplayMode = value; | ||
59 | |||
60 | this.addEntryAnimation(); | ||
61 | } | ||
62 | }, | ||
63 | |||
64 | |||
65 | feedEntryTimer: {enumerable: false, value: null}, | ||
66 | |||
67 | |||
68 | activeFeedEntry: {value: null}, | ||
69 | _activeIndex: {value: null}, | ||
70 | activeIndex: { | ||
71 | get: function() { | ||
72 | return this._activeIndex || 0; | ||
73 | }, | ||
74 | set: function(index) { | ||
75 | if(this.entries) { | ||
76 | var max = this.entries.length-1; | ||
77 | if(index > max) { | ||
78 | index = 0; | ||
79 | } | ||
80 | if(index < 0) { | ||
81 | index = 0; | ||
82 | } | ||
83 | this._activeIndex = index; | ||
84 | this.activeFeedEntry = this.entries[this._activeIndex]; | ||
85 | } else { | ||
86 | this._activeIndex = 0; | ||
87 | } | ||
88 | } | ||
89 | }, | ||
90 | |||
91 | _fetchFeed: { | ||
92 | value: function() { | ||
93 | |||
94 | var url = this.feedURL; | ||
95 | var feed = new google.feeds.Feed(url); | ||
96 | feed.setNumEntries(10); | ||
97 | |||
98 | var self = this; | ||
99 | self.entries = []; | ||
100 | |||
101 | feed.load(function(result) { | ||
102 | self.removeEntryAnimation(); | ||
103 | if(result.error) { | ||
104 | self.entries = []; | ||
105 | } else { | ||
106 | //console.log('entries: ', result.feed.entries); | ||
107 | self.addEntryAnimation(); | ||
108 | self.entries = result.feed.entries; | ||
109 | self.activeIndex = 0; | ||
110 | |||
111 | } | ||
112 | |||
113 | |||
114 | }); | ||
115 | } | ||
116 | }, | ||
117 | |||
118 | addEntryAnimation: { | ||
119 | value: function() { | ||