diff options
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 | 127 |
1 files changed, 76 insertions, 51 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 index d5c9ca17..8fd9ae22 100644 --- 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 | |||
@@ -42,92 +42,117 @@ exports.FeedReader = Montage.create(Component, { | |||
42 | }, | 42 | }, |
43 | 43 | ||
44 | // time in ms between slides | 44 | // time in ms between slides |
45 | interval: {value: 3000, distinct: true}, | 45 | interval: {value: 3, distinct: true}, |
46 | |||
47 | repetition: {enumerable: false, value: null}, | ||
48 | 46 | ||
49 | maxEntries: {value: 10, distinct: true}, | 47 | maxEntries: {value: 10, distinct: true}, |
50 | entries: {value: null}, | ||
51 | |||
52 | |||
53 | _startLoading: { | ||
54 | value: function() { | ||
55 | //Notifier.show('Loading ... please wait', null, {top: this.element.style.top, left: this.element.style.left + 20}); | ||
56 | } | ||
57 | }, | ||
58 | |||
59 | _stopLoading: { | ||
60 | value: function() { | ||
61 | //Notifier.hide(); | ||
62 | } | ||
63 | }, | ||
64 | 48 | ||
49 | entries: {value: null}, | ||
65 | 50 | ||
66 | feedEntryTimer: {enumerable: false, value: null}, | 51 | _feedDisplayMode: {value: null}, |
67 | _items: { | 52 | feedDisplayMode: { |
68 | value: null | ||
69 | }, | ||
70 | items: { | ||
71 | get: function() { | 53 | get: function() { |
72 | return this._items; | 54 | return this._feedDisplayMode; |
73 | }, | 55 | }, |
74 | set: function(value) { | 56 | set: function(value) { |
75 | this._items = value; | 57 | this._feedDisplayMode = value; |
76 | // reset the counter | ||
77 | console.log('got items'); | ||
78 | this.activeIndex = 0; | ||
79 | |||
80 | if(this.feedEntryTimer) { | ||
81 | window.clearInterval(this.feedEntryTimer); | ||
82 | } | ||
83 | var self = this, maxEntries = self.maxEntries; | ||
84 | |||
85 | this.feedEntryTimer = setInterval(function() { | ||
86 | var index = self.activeIndex + 1; | ||
87 | if(index > maxEntries) { | ||
88 | index = 0; | ||
89 | } | ||
90 | if(index < 0) { | ||
91 | index = 0; | ||
92 | } | ||
93 | self.activeIndex = index; | ||
94 | |||
95 | }, this.interval); | ||
96 | } | 58 | } |
97 | }, | 59 | }, |
98 | 60 | ||
61 | |||
62 | feedEntryTimer: {enumerable: false, value: null}, | ||
63 | |||
64 | |||
65 | activeFeedEntry: {value: null}, | ||
99 | _activeIndex: {value: null}, | 66 | _activeIndex: {value: null}, |
100 | activeIndex: { | 67 | activeIndex: { |
101 | get: function() { | 68 | get: function() { |
102 | return this._activeIndex || 0; | 69 | return this._activeIndex || 0; |
103 | }, | 70 | }, |
104 | set: function(value) { | 71 | set: function(index) { |
105 | this._activeIndex = value; | 72 | if(this.entries) { |
106 | this.repetition.activeIndexes = [value]; | 73 | var max = this.entries.length-1; |
74 | if(index > max) { | ||
75 | index = 0; | ||
76 | } | ||
77 | if(index < 0) { | ||
78 | index = 0; | ||
79 | } | ||
80 | this._activeIndex = index; | ||
81 | this.activeFeedEntry = this.entries[this._activeIndex]; | ||
82 | } else { | ||
83 | this._activeIndex = 0; | ||
84 | } | ||
107 | } | 85 | } |
108 | }, | 86 | }, |
109 | 87 | ||
110 | _fetchFeed: { | 88 | _fetchFeed: { |
111 | value: function() { | 89 | value: function() { |
90 | |||
112 | var url = this.feedURL; | 91 | var url = this.feedURL; |
113 | var feed = new google.feeds.Feed(url); | 92 | var feed = new google.feeds.Feed(url); |
114 | feed.setNumEntries(10); | 93 | feed.setNumEntries(10); |
115 | 94 | ||
116 | var self = this; | 95 | var self = this; |
117 | |||
118 | this._startLoading(); | ||
119 | self.entries = []; | 96 | self.entries = []; |
120 | 97 | ||
121 | feed.load(function(result) { | 98 | feed.load(function(result) { |
122 | self._stopLoading(); | 99 | //self.removeEntryAnimation(); |
123 | if(result.error) { | 100 | if(result.error) { |
124 | self.entries = []; | 101 | self.entries = []; |
125 | } else { | 102 | } else { |
126 | //console.log('entries: ', result.feed.entries); | 103 | //console.log('entries: ', result.feed.entries); |
127 | self.entries = result.feed.entries; | 104 | self.entries = result.feed.entries; |
105 | this._activeIndex = 0; | ||
128 | } | 106 | } |
107 | |||
108 | |||
129 | }); | 109 | }); |
130 | } | 110 | } |
111 | }, | ||
112 | |||
113 | addEntryAnimation: { | ||
114 | value: function() { | ||
115 | var self = this; | ||
116 | if("animation" == this.feedDisplayMode) { | ||
117 | this.element.addEventListener('animationend', this); | ||
118 | } else { | ||
119 | // timer | ||
120 | this.feedEntryTimer = setInterval(function() { | ||
121 | self.activeIndex = self.activeIndex + 1; | ||
122 | }, (this.interval * 1000)); | ||
123 | } | ||
124 | } | ||
125 | }, | ||
126 | |||
127 | removeEntryAnimation: { | ||
128 | value: function() { | ||
129 | if("animation" == this.feedDisplayMode) { | ||
130 | this.element.removeEventListener('animationend', this); | ||
131 | } else { | ||
132 | if(this.feedEntryTimer) { | ||
133 | window.clearInterval(this.feedEntryTimer); | ||
134 | } | ||
135 | } | ||
136 | } | ||
137 | }, | ||
138 | |||
139 | handleAnimationend: { | ||
140 | value: function() { | ||
141 | console.log('animation end'); | ||
142 | this.activeIndex = this.activeIndex + 1; | ||
143 | } | ||
144 | }, | ||
145 | |||
146 | prepareForDraw: { | ||
147 | value: function() { | ||
148 | this.addEntryAnimation(); | ||
149 | } | ||
150 | }, | ||
151 | |||
152 | draw: { | ||
153 | value: function() { | ||
154 | |||
155 | } | ||
131 | } | 156 | } |
132 | 157 | ||
133 | }); | 158 | }); |