From 2ea84629a355a02d7eaa33464a0298ec4999073c Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Thu, 31 May 2012 10:14:22 -0700 Subject: updating the google components serialization to enable saving Signed-off-by: Valerio Virgillito --- node_modules/montage-google/map.reel/map.js | 70 ++++++++++++---------- .../picasa-carousel.reel/picasa-carousel.js | 11 +++- .../youtube-channel.reel/youtube-channel.js | 19 ++++-- 3 files changed, 61 insertions(+), 39 deletions(-) (limited to 'node_modules/montage-google') diff --git a/node_modules/montage-google/map.reel/map.js b/node_modules/montage-google/map.reel/map.js index 3ba7fff7..fc104df5 100644 --- a/node_modules/montage-google/map.reel/map.js +++ b/node_modules/montage-google/map.reel/map.js @@ -28,12 +28,12 @@ var Map = exports.Map = Montage.create(Component, /** @lends module:"montage/ui/ }; } }, - - _geoCoder: {value: null}, - + + _geoCoder: {value: null}, + // HTMLElement to load the Map into mapEl: {value: null}, - + _mapLoaded: { enumerable: false, value: false @@ -42,14 +42,14 @@ var Map = exports.Map = Montage.create(Component, /** @lends module:"montage/ui/ enumerable: false, value: false }, - + // Sunnyvale, CA defaultLatLng: { value: {lat: 37.37, lng: -122.03} }, _latLng: { - value: this.defaultLatLng, + value: this.defaultLatLng, distinct: true }, latLng: { @@ -75,7 +75,7 @@ var Map = exports.Map = Montage.create(Component, /** @lends module:"montage/ui/ var self = this, geocoder = this._geoCoder; this._center = value; if(this._mapLoaded) { - + if(String.isString(value)) { // geocode geocoder.geocode( { 'address': value}, function(results, status) { @@ -92,9 +92,9 @@ var Map = exports.Map = Montage.create(Component, /** @lends module:"montage/ui/ // default location this.latLng = this.defaultLatLng; } - + } - + } } @@ -113,7 +113,7 @@ var Map = exports.Map = Montage.create(Component, /** @lends module:"montage/ui/ } } }, - + trafficLayer: {value: null}, _traffic: {value: null}, traffic: { @@ -127,12 +127,12 @@ var Map = exports.Map = Montage.create(Component, /** @lends module:"montage/ui/ } } }, - - + + zoomValue: { value: 8 }, - + __places: {value: null}, _places: { get: function() { @@ -145,11 +145,11 @@ var Map = exports.Map = Montage.create(Component, /** @lends module:"montage/ui/ } } }, - + _getPlaces: { value: function(type, keyword) { var self = this; - var request = { + var request = { location: new window.google.maps.LatLng(this.latLng.lat, this.latLng.lng), radius: 5000, types: [type] @@ -168,7 +168,7 @@ var Map = exports.Map = Montage.create(Component, /** @lends module:"montage/ui/ }); } }, - + _infoWindow: {value: null}, _markers: {value: null}, _createMarker: { @@ -192,20 +192,20 @@ var Map = exports.Map = Montage.create(Component, /** @lends module:"montage/ui/ icon = '41-picture-frame.png'; break; case 'gas_station': - icon = '47-fuel.png'; + icon = '47-fuel.png'; break; }; if(icon) { image = new google.maps.MarkerImage('images/' + icon); - } + } var options = { map: map, position: place.geometry.location }; if(image) { options.icon = image; - } - + } + var marker = new google.maps.Marker(options); if(!this._markers) { this._markers = []; @@ -219,7 +219,7 @@ var Map = exports.Map = Montage.create(Component, /** @lends module:"montage/ui/ }); } }, - + _removeAllMarkers: { value: function() { if(this._markers && this._markers.length > 0) { @@ -231,7 +231,7 @@ var Map = exports.Map = Montage.create(Component, /** @lends module:"montage/ui/ } } }, - + /** Description TODO @@ -240,11 +240,11 @@ var Map = exports.Map = Montage.create(Component, /** @lends module:"montage/ui/ draw: { enumerable: false, value: function () { - + if(this._mapLoaded) { var latLng = this.latLng || this.defaultLatLng; if(!this._map) { - var map; + var map; var myOptions = { zoom: this.zoomValue, center: new window.google.maps.LatLng(latLng.lat, latLng.lng), @@ -258,9 +258,9 @@ var Map = exports.Map = Montage.create(Component, /** @lends module:"montage/ui/ var latLng = new window.google.maps.LatLng(latLng.lat, latLng.lng); map.setCenter(latLng); var marker = new google.maps.Marker({ - map: map, + map: map, position: latLng - }); + }); var places = this._places; if(places && places.length > 0) { @@ -269,8 +269,8 @@ var Map = exports.Map = Montage.create(Component, /** @lends module:"montage/ui/ for (var i = 0; i < places.length; i++) { this._createMarker(places[i]); } - } - + } + if(this.traffic === true) { this.trafficLayer = new google.maps.TrafficLayer(); this.trafficLayer.setMap(map); @@ -278,12 +278,20 @@ var Map = exports.Map = Montage.create(Component, /** @lends module:"montage/ui/ if(this.trafficLayer) { this.trafficLayer.setMap(null); } - } + } } - - } + + } //window.google.maps.event.addDomListener(window, 'load', initialize); } + }, + + serializeProperties: { + value: function(serializer) { + serializer.set("element", this.element); + serializer.set("category", this.category); + serializer.set("center", this.center); + } } }); diff --git a/node_modules/montage-google/picasa-carousel.reel/picasa-carousel.js b/node_modules/montage-google/picasa-carousel.reel/picasa-carousel.js index 800e073c..0b669b80 100644 --- a/node_modules/montage-google/picasa-carousel.reel/picasa-carousel.js +++ b/node_modules/montage-google/picasa-carousel.reel/picasa-carousel.js @@ -138,13 +138,20 @@ var PicasaCarousel = exports.PicasaCarousel = Montage.create(Component, /** @len draw: { value: function() { - + if (this.isSearching) { this.element.classList.add("searching"); } else { this.element.classList.remove("searching"); } - + + } + }, + + serializeProperties: { + value: function(serializer) { + serializer.set("element", this.element); + serializer.set("queryParameter", this.queryParameter); } } diff --git a/node_modules/montage-google/youtube-channel.reel/youtube-channel.js b/node_modules/montage-google/youtube-channel.reel/youtube-channel.js index 88f87f3c..18ea7923 100644 --- a/node_modules/montage-google/youtube-channel.reel/youtube-channel.js +++ b/node_modules/montage-google/youtube-channel.reel/youtube-channel.js @@ -6,38 +6,38 @@ /*global require,exports*/ var Montage = require("montage").Montage, Component = require("montage/ui/component").Component, - Uuid = require("montage/core/Uuid"); + Uuid = require("montage/core/uuid"); var YoutubeChannel = exports.YoutubeChannel = Montage.create(Component, { _userRe: { - enumerable: false, value: /youtube.com\/(user\/)?([a-z0-9]+)/i }, imageA: { value: null }, + imageB: { value: null }, + imageC: { value: null }, + _popupElement: { - enumerable: false, value: null }, _shouldShowPopup: { - enumerable: false, value: false }, _channelUrl: { - enumerable: false, value: null }, + channelUrl: { depends: ["channel"], get: function() { @@ -237,6 +237,13 @@ var YoutubeChannel = exports.YoutubeChannel = Montage.create(Component, { this._entries = data.feed.entry || []; this.needsDraw = true; } - } + }, + serializeProperties: { + value: function(serializer) { + serializer.set("element", this.element); + serializer.set("channelUrl", this.channelUrl); + serializer.set("channel", this.channel); + } + } }); \ No newline at end of file -- cgit v1.2.3 From 8bbabd61e600e0a4aee72377c962d9147db1d8e1 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Thu, 31 May 2012 22:04:11 -0700 Subject: updating the feed reader to enable serialization Signed-off-by: Valerio Virgillito --- .../feed-reader/feed-entry.reel/feed-entry.html | 22 +++++------ .../feed-reader/feed-reader.reel/feed-reader.html | 43 ++++++++++------------ .../feed-reader/feed-reader.reel/feed-reader.js | 14 ++++++- 3 files changed, 41 insertions(+), 38 deletions(-) (limited to 'node_modules/montage-google') 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 index 6b2e51e2..8e9b3371 100644 --- 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 @@ -6,8 +6,7 @@ - + @@ -56,23 +53,23 @@ height: 120px; width: 380px; } - + .feed-entry { } - - + + -
- -
-
+
+ +
+
- - + +
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 index 47a831eb..c066220e 100644 --- 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 @@ -8,6 +8,10 @@ var Montage = require("montage").Montage, exports.FeedReader = Montage.create(Component, { + _apiLoaded: { + value: false + }, + didCreate: { value: function() { var self = this; @@ -17,6 +21,8 @@ exports.FeedReader = Montage.create(Component, { google.load("feeds", "1", { callback: function() { console.log('google feeds api loaded'); + self._apiLoaded = true; + self.feedURL = self._feedURL; self.needsDraw = true; window.initGoogleAPI = null; } @@ -30,13 +36,16 @@ exports.FeedReader = Montage.create(Component, { _feedURL: {value: null}, feedURL: { + serializable: true, get: function() { return this._feedURL; }, set: function(value) { this._feedURL = value; // execute the search and get the entries - this._fetchFeed(); + if (this._apiLoaded) { + this._fetchFeed(); + } } }, @@ -49,6 +58,7 @@ exports.FeedReader = Montage.create(Component, { _feedDisplayMode: {value: null}, feedDisplayMode: { + serializable: true, get: function() { return this._feedDisplayMode; }, @@ -107,7 +117,7 @@ exports.FeedReader = Montage.create(Component, { self.addEntryAnimation(); self.entries = result.feed.entries; self.activeIndex = 0; - + } -- cgit v1.2.3 From e09e4a8e24e5daf899d24314d0ffc218bbb2a97d Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Fri, 1 Jun 2012 11:51:16 -0700 Subject: Fixing Google Map component Pulled in from components branch. --- node_modules/montage-google/map.reel/map.js | 82 ++++++++++++++++------------- 1 file changed, 46 insertions(+), 36 deletions(-) (limited to 'node_modules/montage-google') diff --git a/node_modules/montage-google/map.reel/map.js b/node_modules/montage-google/map.reel/map.js index fc104df5..879a80d4 100644 --- a/node_modules/montage-google/map.reel/map.js +++ b/node_modules/montage-google/map.reel/map.js @@ -20,8 +20,9 @@ var Map = exports.Map = Montage.create(Component, /** @lends module:"montage/ui/ didCreate: { value: function() { var self = this; + + this._latLng = this.defaultLatLng; window.initialize = function initialize() { - console.log('google maps api loaded'); self._mapLoaded = true; self._geoCoder = new google.maps.Geocoder(); self.needsDraw = true; @@ -32,7 +33,10 @@ var Map = exports.Map = Montage.create(Component, /** @lends module:"montage/ui/ _geoCoder: {value: null}, // HTMLElement to load the Map into - mapEl: {value: null}, + mapEl: { + serializable: true, + value: null + }, _mapLoaded: { enumerable: false, @@ -49,9 +53,9 @@ var Map = exports.Map = Montage.create(Component, /** @lends module:"montage/ui/ }, _latLng: { - value: this.defaultLatLng, - distinct: true + value: null }, + latLng: { get: function() { return this._latLng; @@ -67,6 +71,7 @@ var Map = exports.Map = Montage.create(Component, /** @lends module:"montage/ui/ // {lat, lon} Or a String representing the location (eg: Paris, France) center: { + serializable: true, get: function() { return this._center; }, @@ -78,10 +83,12 @@ var Map = exports.Map = Montage.create(Component, /** @lends module:"montage/ui/ if(String.isString(value)) { // geocode + self.LatLng = null; geocoder.geocode( { 'address': value}, function(results, status) { if (status == google.maps.GeocoderStatus.OK) { var loc = results[0].geometry.location; self.latLng = {lat: loc.lat(), lng: loc.lng()}; + self.category = self._category; } else { console.log('Geocode was not successful : ' + status); } @@ -101,15 +108,17 @@ var Map = exports.Map = Montage.create(Component, /** @lends module:"montage/ui/ }, category: { + serializable: true, get: function() { return this._category; }, set: function(value) { - console.log('category set: ' + value); if(value) { this._category = value; - this._getPlaces(this._category); - this.needsDraw = true; + if (this._mapLoaded && this.latLng) { + this._getPlaces(this._category); + this.needsDraw = true; + } } } }, @@ -159,12 +168,12 @@ var Map = exports.Map = Montage.create(Component, /** @lends module:"montage/ui/ } var service = new google.maps.places.PlacesService(this._map); service.search(request, function(results, status) { - console.log('got places for ', self.category, status, results); if (status == google.maps.places.PlacesServiceStatus.OK) { self._places = results; } else { self._places = []; } + self.needsDraw = true; }); } }, @@ -252,35 +261,36 @@ var Map = exports.Map = Montage.create(Component, /** @lends module:"montage/ui/ }; this._map = new window.google.maps.Map(this.mapEl, myOptions); - } else { - var map = this._map; - map.setZoom(10); - var latLng = new window.google.maps.LatLng(latLng.lat, latLng.lng); - map.setCenter(latLng); - var marker = new google.maps.Marker({ - map: map, - position: latLng - }); - - var places = this._places; - if(places && places.length > 0) { - map.setZoom(13); - this._removeAllMarkers(); - for (var i = 0; i < places.length; i++) { - this._createMarker(places[i]); - } - } - - if(this.traffic === true) { - this.trafficLayer = new google.maps.TrafficLayer(); - this.trafficLayer.setMap(map); - } else { - if(this.trafficLayer) { - this.trafficLayer.setMap(null); - } - } + this.center = this._center; + this.category = this._category; + } + + var map = this._map; + map.setZoom(10); + var latLng = new window.google.maps.LatLng(latLng.lat, latLng.lng); + map.setCenter(latLng); + var marker = new google.maps.Marker({ + map: map, + position: latLng + }); + + var places = this._places; + if(places && places.length > 0) { + map.setZoom(13); + this._removeAllMarkers(); + for (var i = 0; i < places.length; i++) { + this._createMarker(places[i]); + } } + if(this.traffic === true) { + this.trafficLayer = new google.maps.TrafficLayer(); + this.trafficLayer.setMap(map); + } else { + if(this.trafficLayer) { + this.trafficLayer.setMap(null); + } + } } //window.google.maps.event.addDomListener(window, 'load', initialize); @@ -294,4 +304,4 @@ var Map = exports.Map = Montage.create(Component, /** @lends module:"montage/ui/ serializer.set("center", this.center); } } -}); +}); \ No newline at end of file -- cgit v1.2.3 From f34752a034c7bf9060c7a286975df51f4e1a1e04 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Fri, 1 Jun 2012 13:48:20 -0700 Subject: Map fixes --- node_modules/montage-google/map.reel/map.js | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'node_modules/montage-google') diff --git a/node_modules/montage-google/map.reel/map.js b/node_modules/montage-google/map.reel/map.js index 879a80d4..4e3a6d70 100644 --- a/node_modules/montage-google/map.reel/map.js +++ b/node_modules/montage-google/map.reel/map.js @@ -21,10 +21,10 @@ var Map = exports.Map = Montage.create(Component, /** @lends module:"montage/ui/ value: function() { var self = this; - this._latLng = this.defaultLatLng; window.initialize = function initialize() { self._mapLoaded = true; self._geoCoder = new google.maps.Geocoder(); + self.center = self._center; self.needsDraw = true; }; } @@ -115,7 +115,7 @@ var Map = exports.Map = Montage.create(Component, /** @lends module:"montage/ui/ set: function(value) { if(value) { this._category = value; - if (this._mapLoaded && this.latLng) { + if (this._map && this.latLng) { this._getPlaces(this._category); this.needsDraw = true; } @@ -139,7 +139,7 @@ var Map = exports.Map = Montage.create(Component, /** @lends module:"montage/ui/ zoomValue: { - value: 8 + value: 13 }, __places: {value: null}, @@ -249,9 +249,17 @@ var Map = exports.Map = Montage.create(Component, /** @lends module:"montage/ui/ draw: { enumerable: false, value: function () { - if(this._mapLoaded) { - var latLng = this.latLng || this.defaultLatLng; + var latLng = this.latLng; + + if (!latLng) { + if (this._center) { + return; + } else { + latLng = this.defaultLatLng; + } + } + if(!this._map) { var map; var myOptions = { @@ -266,7 +274,7 @@ var Map = exports.Map = Montage.create(Component, /** @lends module:"montage/ui/ } var map = this._map; - map.setZoom(10); + //map.setZoom(10); var latLng = new window.google.maps.LatLng(latLng.lat, latLng.lng); map.setCenter(latLng); var marker = new google.maps.Marker({ @@ -276,7 +284,7 @@ var Map = exports.Map = Montage.create(Component, /** @lends module:"montage/ui/ var places = this._places; if(places && places.length > 0) { - map.setZoom(13); + //map.setZoom(13); this._removeAllMarkers(); for (var i = 0; i < places.length; i++) { this._createMarker(places[i]); -- cgit v1.2.3 From 745c39fb9460e882f5c6c5cfeedc0b3edf85f8eb Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Fri, 1 Jun 2012 15:28:05 -0700 Subject: Fixing feedread component --- .../montage-google/feed-reader/feed-entry.reel/feed-entry.html | 3 +-- .../montage-google/feed-reader/feed-reader.reel/feed-reader.js | 8 ++++++++ 2 files changed, 9 insertions(+), 2 deletions(-) (limited to 'node_modules/montage-google') 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 index 8e9b3371..b8b9f39a 100644 --- 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 @@ -76,8 +76,7 @@
- -

+

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 index c066220e..34533d6d 100644 --- 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 @@ -184,6 +184,14 @@ exports.FeedReader = Montage.create(Component, { value: function() { } + }, + + serializeProperties: { + value: function(serializer) { + serializer.set("element", this.element); + serializer.set("feedURL", this.feedURL); + serializer.set("feedDisplayMode", this.feedDisplayMode); + } } }); -- cgit v1.2.3