From f9f8fdc3000042ba5b4504d91870dc9a32ef25eb Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Wed, 16 May 2012 01:00:22 -0700 Subject: Squashed master into dom-architecture Signed-off-by: Valerio Virgillito --- .../feed-reader/feed-entry.reel/feed-entry.html | 89 ++++++++++ .../feed-reader/feed-entry.reel/feed-entry.js | 21 +++ .../feed-reader/feed-reader.reel/feed-reader.html | 79 +++++++++ .../feed-reader/feed-reader.reel/feed-reader.js | 179 +++++++++++++++++++++ 4 files changed, 368 insertions(+) create mode 100644 node_modules/montage-google/feed-reader/feed-entry.reel/feed-entry.html create mode 100644 node_modules/montage-google/feed-reader/feed-entry.reel/feed-entry.js create mode 100644 node_modules/montage-google/feed-reader/feed-reader.reel/feed-reader.html create mode 100644 node_modules/montage-google/feed-reader/feed-reader.reel/feed-reader.js (limited to 'node_modules/montage-google/feed-reader') diff --git a/node_modules/montage-google/feed-reader/feed-entry.reel/feed-entry.html b/node_modules/montage-google/feed-reader/feed-entry.reel/feed-entry.html new file mode 100644 index 00000000..6b2e51e2 --- /dev/null +++ b/node_modules/montage-google/feed-reader/feed-entry.reel/feed-entry.html @@ -0,0 +1,89 @@ + + + + + Feed Entry + + + + + + + +
+ +

+

+
+ + + diff --git a/node_modules/montage-google/feed-reader/feed-entry.reel/feed-entry.js b/node_modules/montage-google/feed-reader/feed-entry.reel/feed-entry.js new file mode 100644 index 00000000..8fdb3860 --- /dev/null +++ b/node_modules/montage-google/feed-reader/feed-entry.reel/feed-entry.js @@ -0,0 +1,21 @@ +/* + This file contains proprietary software owned by Motorola Mobility, Inc.
+ No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
+ (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. +
*/ +var Montage = require("montage").Montage, + Component = require("montage/ui/component").Component; + +exports.FeedEntry = Montage.create(Component, { + + _entry: {value: null}, + entry: { + get: function() { + return this._entry; + }, + set: function(value) { + this._entry = value; + } + } + +}); 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 @@ + + + + + Feed Reader + + + + + + + + + + +
+ +
+
+
+ + +
+ + + 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 @@ +/* + This file contains proprietary software owned by Motorola Mobility, Inc.
+ No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
+ (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. +
*/ +var Montage = require("montage").Montage, + Component = require("montage/ui/component").Component; + +exports.FeedReader = Montage.create(Component, { + + didCreate: { + value: function() { + var self = this; + var apiInit = function() { + console.log('google api initialized'); + + google.load("feeds", "1", { + callback: function() { + console.log('google feeds api loaded'); + self.needsDraw = true; + window.initGoogleAPI = null; + } + }); + }; + + // set up a global function + window.initGoogleAPI = apiInit; + } + }, + + _feedURL: {value: null}, + feedURL: { + get: function() { + return this._feedURL; + }, + set: function(value) { + this._feedURL = value; + // execute the search and get the entries + this._fetchFeed(); + } + }, + + // time in ms between slides + interval: {value: 3, distinct: true}, + + maxEntries: {value: 10, distinct: true}, + + entries: {value: null}, + + _feedDisplayMode: {value: null}, + feedDisplayMode: { + get: function() { + return this._feedDisplayMode; + }, + set: function(value) { + + this.removeEntryAnimation(); + this._feedDisplayMode = value; + + this.addEntryAnimation(); + } + }, + + + feedEntryTimer: {enumerable: false, value: null}, + + + activeFeedEntry: {value: null}, + _activeIndex: {value: null}, + activeIndex: { + get: function() { + return this._activeIndex || 0; + }, + set: function(index) { + if(this.entries) { + var max = this.entries.length-1; + if(index > max) { + index = 0; + } + if(index < 0) { + index = 0; + } + this._activeIndex = index; + this.activeFeedEntry = this.entries[this._activeIndex]; + } else { + this._activeIndex = 0; + } + } + }, + + _fetchFeed: { + value: function() { + + var url = this.feedURL; + var feed = new google.feeds.Feed(url); + feed.setNumEntries(10); + + var self = this; + self.entries = []; + + feed.load(function(result) { + self.removeEntryAnimation(); + if(result.error) { + self.entries = []; + } else { + //console.log('entries: ', result.feed.entries); + self.addEntryAnimation(); + self.entries = result.feed.entries; + self.activeIndex = 0; + + } + + + }); + } + }, + + addEntryAnimation: { + value: function() { + var self = this; + if("animation" == this.feedDisplayMode) { + this.element.addEventListener('webkitAnimationStart', this); + this.element.addEventListener('webkitAnimationIteration', this); + this.element.addEventListener('webkitAnimationEnd', this); + } else { + // timer + this.feedEntryTimer = setInterval(function() { + self.activeIndex = self.activeIndex + 1; + }, (this.interval * 1000)); + } + } + }, + + removeEntryAnimation: { + value: function() { + if("animation" == this.feedDisplayMode) { + this.element.removeEventListener('webkitAnimationStart', this); + this.element.removeEventListener('webkitAnimationIteration', this); + this.element.removeEventListener('webkitAnimationEnd', this); + + } else { + if(this.feedEntryTimer) { + window.clearInterval(this.feedEntryTimer); + } + } + } + }, + + handleWebkitAnimationStart: { + value: function() { + console.log('animation start'); + } + }, + + handleWebkitAnimationIteration: { + value: function() { + console.log('animation iteration'); + this.activeIndex = this.activeIndex + 1; + } + }, + + handleWebkitAnimationEnd: { + value: function() { + console.log('animation end'); + } + }, + + prepareForDraw: { + value: function() { + } + }, + + draw: { + value: function() { + + } + } + +}); -- cgit v1.2.3