From 09852e9b9b8e64f003bed5aa57630d8b42c8ac95 Mon Sep 17 00:00:00 2001 From: François Frisch Date: Sat, 17 Mar 2012 19:28:30 -0700 Subject: Integrating picasa carousel and youtube channel --- .../ui/picasa-carousel.reel/picasa-carousel.js | 124 +++++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100644 node_modules/montage/ui/picasa-carousel.reel/picasa-carousel.js (limited to 'node_modules/montage/ui/picasa-carousel.reel/picasa-carousel.js') diff --git a/node_modules/montage/ui/picasa-carousel.reel/picasa-carousel.js b/node_modules/montage/ui/picasa-carousel.reel/picasa-carousel.js new file mode 100644 index 00000000..25d363b0 --- /dev/null +++ b/node_modules/montage/ui/picasa-carousel.reel/picasa-carousel.js @@ -0,0 +1,124 @@ +/* + 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. +
*/ +/** + + @requires montage/core/core + @requires montage/ui/component +*/ +var Montage = require("montage").Montage, + Component = require("ui/component").Component; +/** + @class module:"montage/ui/google/map.reel".Map + @extends module:montage/ui/component.Component + */ +var PicasaCarousel = exports.PicasaCarousel = Montage.create(Component, /** @lends module:"montage/ui/toggle-switch.reel".ToggleSwitch# */ { + photoListController: { + enumerable: false, + value: null + }, + + queryParameter: { + enumerable: false, + value: null + }, + + resultCount: { + enumerable: false, + value: 20 + }, + + prepareForDraw: { + enumerable: false, + value: function() { + // this.searchForm.identifier = "searchForm"; + // this.searchForm.addEventListener("submit", this, false); + } + }, + + _isSearching: { + value: false, + enumerable: false + }, + + isSearching: { + enumerable: false, + get: function() { + return this._isSearching; + }, + set: function(value) { + if (value === this._isSearching) { + return; + } + + this._isSearching = value; + this.needsDraw = true; + } + }, + + handleSearchFormSubmit: { + value: function(evt) { + evt.preventDefault(); + this.performSearch(); + } + }, + + performSearch: { + value: function() { + if (this.isSearching) { + console.log("already searching!") + return; + } + + this.isSearching = true; + this.searchResults = null; + + var base = "http://picasaweb.google.com/data/feed/base/all?visibility=public&alt=json&max-results=" + this.resultCount + "&kind=photo&prettyprint=true&imgmax=720u&q=" + // var base = "http://picasaweb.google.com/data/feed/base/featured?visibility=public&alt=json&max-results=" + this.resultCount + "&kind=photo&prettyprint=true" + var url = base + this.queryParameter; + + var req = new XMLHttpRequest(); + req.identifier = "searchRequest"; + req.open("GET", url); + req.addEventListener("load", this, false); + req.addEventListener("error", this, false); + req.send(); + + } + }, + + handleSearchRequestLoad: { + value: function(evt) { + var response = JSON.parse(evt.target.responseText); + this.searchResults = response.feed.entry; + this.isSearching = false; + } + }, + + handleSearchRequestError: { + value: function(evt) { + console.error("handleSearchRequestError", evt); + this.isSearching = false; + } + }, + + searchResults: { + enumerable: false, + value: null + }, + + draw: { + value: function() { + + if (this.isSearching) { + this.element.classList.add("searching"); + } else { + this.element.classList.remove("searching"); + } + + } + } + +}); -- cgit v1.2.3 From cff7deb476f4095d7d3d76c92360617d3316a96f Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Sun, 18 Mar 2012 00:07:39 -0700 Subject: changing the picasa-carousel to use a getter and setter for the queryParameter Signed-off-by: Valerio Virgillito --- .../montage/ui/picasa-carousel.reel/picasa-carousel.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'node_modules/montage/ui/picasa-carousel.reel/picasa-carousel.js') diff --git a/node_modules/montage/ui/picasa-carousel.reel/picasa-carousel.js b/node_modules/montage/ui/picasa-carousel.reel/picasa-carousel.js index 25d363b0..1f5e7dd0 100644 --- a/node_modules/montage/ui/picasa-carousel.reel/picasa-carousel.js +++ b/node_modules/montage/ui/picasa-carousel.reel/picasa-carousel.js @@ -20,9 +20,19 @@ var PicasaCarousel = exports.PicasaCarousel = Montage.create(Component, /** @len value: null }, + _queryParameter: { + enumerable: false, + value: null + }, + queryParameter: { - enumerable: false, - value: null + get: function() { + return this._queryParameter; + }, + set: function(value) { + this._queryParameter = value; + this.performSearch(); + } }, resultCount: { -- cgit v1.2.3 From 31eee2972667d7553974f0857fdc458954219203 Mon Sep 17 00:00:00 2001 From: François Frisch Date: Tue, 20 Mar 2012 17:45:34 -0700 Subject: Initializing carousel in middle position --- .../montage/ui/picasa-carousel.reel/picasa-carousel.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'node_modules/montage/ui/picasa-carousel.reel/picasa-carousel.js') diff --git a/node_modules/montage/ui/picasa-carousel.reel/picasa-carousel.js b/node_modules/montage/ui/picasa-carousel.reel/picasa-carousel.js index 1f5e7dd0..b41df9a6 100644 --- a/node_modules/montage/ui/picasa-carousel.reel/picasa-carousel.js +++ b/node_modules/montage/ui/picasa-carousel.reel/picasa-carousel.js @@ -20,6 +20,16 @@ var PicasaCarousel = exports.PicasaCarousel = Montage.create(Component, /** @len value: null }, + flow: { + value: null + }, + + initialPosition: { + value: 2300 + }, + + + _queryParameter: { enumerable: false, value: null @@ -37,7 +47,7 @@ var PicasaCarousel = exports.PicasaCarousel = Montage.create(Component, /** @len resultCount: { enumerable: false, - value: 20 + value: 40 }, prepareForDraw: { @@ -103,6 +113,8 @@ var PicasaCarousel = exports.PicasaCarousel = Montage.create(Component, /** @len value: function(evt) { var response = JSON.parse(evt.target.responseText); this.searchResults = response.feed.entry; + this.flow.length = this.initialPosition; + this.flow.origin = this.initialPosition; this.isSearching = false; } }, -- cgit v1.2.3 From 6f995a7ea1f35632fa54ad007953377bdf119c3a Mon Sep 17 00:00:00 2001 From: François Frisch Date: Wed, 21 Mar 2012 11:48:30 -0700 Subject: Flow doesn't reset to origin 0 when changing the feed --- .../montage/ui/picasa-carousel.reel/picasa-carousel.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'node_modules/montage/ui/picasa-carousel.reel/picasa-carousel.js') diff --git a/node_modules/montage/ui/picasa-carousel.reel/picasa-carousel.js b/node_modules/montage/ui/picasa-carousel.reel/picasa-carousel.js index b41df9a6..bdc74c83 100644 --- a/node_modules/montage/ui/picasa-carousel.reel/picasa-carousel.js +++ b/node_modules/montage/ui/picasa-carousel.reel/picasa-carousel.js @@ -111,10 +111,17 @@ var PicasaCarousel = exports.PicasaCarousel = Montage.create(Component, /** @len handleSearchRequestLoad: { value: function(evt) { - var response = JSON.parse(evt.target.responseText); + var response = JSON.parse(evt.target.responseText), + previousOrigin = this.flow.origin; this.searchResults = response.feed.entry; - this.flow.length = this.initialPosition; - this.flow.origin = this.initialPosition; + if (this.flow.length === 0) { + this.flow.length = this.initialPosition; + } + if (previousOrigin === 0) { + this.flow.origin = this.initialPosition; + } else { + this.flow.origin = previousOrigin; + } this.isSearching = false; } }, -- cgit v1.2.3