From 9b8a24a7360416d5750828c9580e33dd336ff882 Mon Sep 17 00:00:00 2001 From: François Frisch Date: Fri, 16 Mar 2012 17:57:18 -0700 Subject: Getting ownerComponent bindings --- .../templates/montage-html/main.reel/main.js | 43 +++++++++++----------- node_modules/components-data/textfield.json | 4 ++ node_modules/montage/ui/text-input.js | 22 +++++++++++ 3 files changed, 48 insertions(+), 21 deletions(-) diff --git a/js/document/templates/montage-html/main.reel/main.js b/js/document/templates/montage-html/main.reel/main.js index 567f481c..ee23e844 100644 --- a/js/document/templates/montage-html/main.reel/main.js +++ b/js/document/templates/montage-html/main.reel/main.js @@ -17,7 +17,25 @@ exports.Main = Montage.create(Component, { */ templateDidLoad: { value: function(){ - window.addComponent = this.addComponentToUserDocument; + var self = this; + window.addComponent = function(element, data, callback) { + var component; + + component = require.async(data.path) + .then(function(component) { + var componentRequire = component[data.name]; + var componentInstance = componentRequire.create(); + + componentInstance.element = element; + //componentInstance.deserializedFromTemplate(); + componentInstance.needsDraw = true; + componentInstance.ownerComponent = self; + + callback(componentInstance, element); + }) + .end(); + + }; // window.addBinding = this.addBindingToUserDocument; // Dispatch event when this template has loaded. @@ -29,26 +47,9 @@ exports.Main = Montage.create(Component, { } }, - // Adding components to the user document by using a async require. - addComponentToUserDocument:{ - value:function(element, data, callback){ - - var component; - - component = require.async(data.path) - .then(function(component) { - var componentRequire = component[data.name]; - var componentInstance = componentRequire.create(); - - componentInstance.element = element; - //componentInstance.deserializedFromTemplate(); - componentInstance.needsDraw = true; - - callback(componentInstance, element); - }) - .end(); - - } + location: { + value:null, + enumerable:false } }); \ No newline at end of file diff --git a/node_modules/components-data/textfield.json b/node_modules/components-data/textfield.json index 7164b8b3..39c65eab 100644 --- a/node_modules/components-data/textfield.json +++ b/node_modules/components-data/textfield.json @@ -7,6 +7,10 @@ "properties": [ { + "name": "valueBinding", + "type": "string", + "default": null + },{ "name": "accept", "type": "string", "default": null diff --git a/node_modules/montage/ui/text-input.js b/node_modules/montage/ui/text-input.js index cdd20c78..d707fa69 100644 --- a/node_modules/montage/ui/text-input.js +++ b/node_modules/montage/ui/text-input.js @@ -79,6 +79,28 @@ var TextInput = exports.TextInput = Montage.create(NativeControl, { } }, + _valueBinding: { + value: null + }, + + valueBinding: { + get: function() { + return this._valueBinding; + }, + set: function(value) { + if (this._valueBinding !== value) { + if (this._valueBinding !== null) { + Object.deleteBinding(this, "value"); + } + this._valueBinding = value; + if (String.isString(value)) { + Object.defineBinding(this, "value", {boundObject: this.ownerComponent, boundObjectPropertyPath: value}); + + } + } + } + }, + // set value from user input /** @private -- cgit v1.2.3 From 1d0efc758bc9404eebbc8b8d592de9dbb329899e Mon Sep 17 00:00:00 2001 From: François Frisch Date: Sat, 17 Mar 2012 11:21:22 -0700 Subject: Adding feed reader and map --- .../examples/feed-reader/images/07-map-marker.png | Bin 0 -> 3131 bytes .../examples/feed-reader/images/10-medical.png | Bin 0 -> 2915 bytes .../examples/feed-reader/images/100-coffee.png | Bin 0 -> 2958 bytes .../examples/feed-reader/images/107-widescreen.png | Bin 0 -> 2986 bytes .../examples/feed-reader/images/125-food.png | Bin 0 -> 3038 bytes .../feed-reader/images/142-wine-bottle.png | Bin 0 -> 187 bytes .../examples/feed-reader/images/34-coffee.png | Bin 0 -> 3052 bytes .../examples/feed-reader/images/35-shopping.png | Bin 0 -> 2970 bytes .../examples/feed-reader/images/38-airplane.png | Bin 0 -> 3004 bytes .../feed-reader/images/41-picture-frame.png | Bin 0 -> 2928 bytes .../feed-reader/images/48-fork-and-knife.png | Bin 0 -> 2882 bytes .../examples/feed-reader/images/87-wine-glass.png | Bin 0 -> 2983 bytes .../montage/examples/feed-reader/index.html | 81 ++++++ .../examples/feed-reader/main.reel/main.html | 184 ++++++++++++++ .../montage/examples/feed-reader/main.reel/main.js | 45 ++++ .../examples/feed-reader/map-example.reel/main.css | 2 + .../feed-reader/map-example.reel/main.html | 58 +++++ .../examples/feed-reader/map-example.reel/main.js | 24 ++ .../montage/examples/feed-reader/package.json | 10 + .../ui/feed-reader/feed-entry.reel/feed-entry.html | 90 +++++++ .../ui/feed-reader/feed-entry.reel/feed-entry.js | 13 + .../feed-reader/feed-reader.reel/feed-reader.html | 83 ++++++ .../ui/feed-reader/feed-reader.reel/feed-reader.js | 82 ++++++ node_modules/montage/ui/map.reel/map.css | 9 + node_modules/montage/ui/map.reel/map.html | 58 +++++ node_modules/montage/ui/map.reel/map.js | 283 +++++++++++++++++++++ node_modules/montage/ui/template.js | 6 +- 27 files changed, 1025 insertions(+), 3 deletions(-) create mode 100644 node_modules/montage/examples/feed-reader/images/07-map-marker.png create mode 100644 node_modules/montage/examples/feed-reader/images/10-medical.png create mode 100644 node_modules/montage/examples/feed-reader/images/100-coffee.png create mode 100644 node_modules/montage/examples/feed-reader/images/107-widescreen.png create mode 100644 node_modules/montage/examples/feed-reader/images/125-food.png create mode 100644 node_modules/montage/examples/feed-reader/images/142-wine-bottle.png create mode 100644 node_modules/montage/examples/feed-reader/images/34-coffee.png create mode 100644 node_modules/montage/examples/feed-reader/images/35-shopping.png create mode 100644 node_modules/montage/examples/feed-reader/images/38-airplane.png create mode 100644 node_modules/montage/examples/feed-reader/images/41-picture-frame.png create mode 100644 node_modules/montage/examples/feed-reader/images/48-fork-and-knife.png create mode 100644 node_modules/montage/examples/feed-reader/images/87-wine-glass.png create mode 100644 node_modules/montage/examples/feed-reader/index.html create mode 100644 node_modules/montage/examples/feed-reader/main.reel/main.html create mode 100644 node_modules/montage/examples/feed-reader/main.reel/main.js create mode 100644 node_modules/montage/examples/feed-reader/map-example.reel/main.css create mode 100644 node_modules/montage/examples/feed-reader/map-example.reel/main.html create mode 100644 node_modules/montage/examples/feed-reader/map-example.reel/main.js create mode 100644 node_modules/montage/examples/feed-reader/package.json create mode 100644 node_modules/montage/ui/feed-reader/feed-entry.reel/feed-entry.html create mode 100644 node_modules/montage/ui/feed-reader/feed-entry.reel/feed-entry.js create mode 100644 node_modules/montage/ui/feed-reader/feed-reader.reel/feed-reader.html create mode 100644 node_modules/montage/ui/feed-reader/feed-reader.reel/feed-reader.js create mode 100644 node_modules/montage/ui/map.reel/map.css create mode 100644 node_modules/montage/ui/map.reel/map.html create mode 100644 node_modules/montage/ui/map.reel/map.js diff --git a/node_modules/montage/examples/feed-reader/images/07-map-marker.png b/node_modules/montage/examples/feed-reader/images/07-map-marker.png new file mode 100644 index 00000000..a5d99d69 Binary files /dev/null and b/node_modules/montage/examples/feed-reader/images/07-map-marker.png differ diff --git a/node_modules/montage/examples/feed-reader/images/10-medical.png b/node_modules/montage/examples/feed-reader/images/10-medical.png new file mode 100644 index 00000000..ab78c783 Binary files /dev/null and b/node_modules/montage/examples/feed-reader/images/10-medical.png differ diff --git a/node_modules/montage/examples/feed-reader/images/100-coffee.png b/node_modules/montage/examples/feed-reader/images/100-coffee.png new file mode 100644 index 00000000..4e9c517a Binary files /dev/null and b/node_modules/montage/examples/feed-reader/images/100-coffee.png differ diff --git a/node_modules/montage/examples/feed-reader/images/107-widescreen.png b/node_modules/montage/examples/feed-reader/images/107-widescreen.png new file mode 100644 index 00000000..2e5f1ba7 Binary files /dev/null and b/node_modules/montage/examples/feed-reader/images/107-widescreen.png differ diff --git a/node_modules/montage/examples/feed-reader/images/125-food.png b/node_modules/montage/examples/feed-reader/images/125-food.png new file mode 100644 index 00000000..81afd74a Binary files /dev/null and b/node_modules/montage/examples/feed-reader/images/125-food.png differ diff --git a/node_modules/montage/examples/feed-reader/images/142-wine-bottle.png b/node_modules/montage/examples/feed-reader/images/142-wine-bottle.png new file mode 100644 index 00000000..a7df9e97 Binary files /dev/null and b/node_modules/montage/examples/feed-reader/images/142-wine-bottle.png differ diff --git a/node_modules/montage/examples/feed-reader/images/34-coffee.png b/node_modules/montage/examples/feed-reader/images/34-coffee.png new file mode 100644 index 00000000..4c4bedad Binary files /dev/null and b/node_modules/montage/examples/feed-reader/images/34-coffee.png differ diff --git a/node_modules/montage/examples/feed-reader/images/35-shopping.png b/node_modules/montage/examples/feed-reader/images/35-shopping.png new file mode 100644 index 00000000..03689f99 Binary files /dev/null and b/node_modules/montage/examples/feed-reader/images/35-shopping.png differ diff --git a/node_modules/montage/examples/feed-reader/images/38-airplane.png b/node_modules/montage/examples/feed-reader/images/38-airplane.png new file mode 100644 index 00000000..dfcbbc78 Binary files /dev/null and b/node_modules/montage/examples/feed-reader/images/38-airplane.png differ diff --git a/node_modules/montage/examples/feed-reader/images/41-picture-frame.png b/node_modules/montage/examples/feed-reader/images/41-picture-frame.png new file mode 100644 index 00000000..6deee997 Binary files /dev/null and b/node_modules/montage/examples/feed-reader/images/41-picture-frame.png differ diff --git a/node_modules/montage/examples/feed-reader/images/48-fork-and-knife.png b/node_modules/montage/examples/feed-reader/images/48-fork-and-knife.png new file mode 100644 index 00000000..06d91088 Binary files /dev/null and b/node_modules/montage/examples/feed-reader/images/48-fork-and-knife.png differ diff --git a/node_modules/montage/examples/feed-reader/images/87-wine-glass.png b/node_modules/montage/examples/feed-reader/images/87-wine-glass.png new file mode 100644 index 00000000..b4d34474 Binary files /dev/null and b/node_modules/montage/examples/feed-reader/images/87-wine-glass.png differ diff --git a/node_modules/montage/examples/feed-reader/index.html b/node_modules/montage/examples/feed-reader/index.html new file mode 100644 index 00000000..3b5529b9 --- /dev/null +++ b/node_modules/montage/examples/feed-reader/index.html @@ -0,0 +1,81 @@ + + + + + + Montage Feed Reader + + + + + + + + + + +

+

+ +
+

+ +
+

This is the bootstrapper content which will now be shown for at least 1500ms.

+
+
+

This is the loader content which will now be shown for at least 2000ms.

+
+ + + + diff --git a/node_modules/montage/examples/feed-reader/main.reel/main.html b/node_modules/montage/examples/feed-reader/main.reel/main.html new file mode 100644 index 00000000..8ea9a79b --- /dev/null +++ b/node_modules/montage/examples/feed-reader/main.reel/main.html @@ -0,0 +1,184 @@ + + + + + Feed Reader Example + + + + + + + + + + +
+ + + +
+
+
+

Top Stories Around you

+
+ Feed URL: + +
+
+
+
+ +
+
+

Find your way

+
+ Location: + +
+
+
Map
+
+ +
+ +
+ + +
+ + + diff --git a/node_modules/montage/examples/feed-reader/main.reel/main.js b/node_modules/montage/examples/feed-reader/main.reel/main.js new file mode 100644 index 00000000..bea5f91a --- /dev/null +++ b/node_modules/montage/examples/feed-reader/main.reel/main.js @@ -0,0 +1,45 @@ +/* + 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/core/core").Montage, + Component = require("montage/ui/component").Component; + +exports.Main = Montage.create(Component, { + + feedURL: { + value: 'http://rss.cnn.com/rss/cnn_mostpopular.rss', + distinct: true + }, + + feedReader: {value: null}, + + map: {value: null}, + + mapCenter: {value: null}, + + handleGoAction: { + value: function(event) { + event.preventDefault(); + this.feedReader.feedURL = this.feedURL; + + } + }, + + handleMapButtonAction: { + value: function(event) { + event.preventDefault(); + this.map.center = this.mapCenter; + } + }, + + draw: { + value: function() { + if(this.mapCenter != null) { + this.map.center = this.mapCenter; + } + } + } + +}); diff --git a/node_modules/montage/examples/feed-reader/map-example.reel/main.css b/node_modules/montage/examples/feed-reader/map-example.reel/main.css new file mode 100644 index 00000000..139597f9 --- /dev/null +++ b/node_modules/montage/examples/feed-reader/map-example.reel/main.css @@ -0,0 +1,2 @@ + + diff --git a/node_modules/montage/examples/feed-reader/map-example.reel/main.html b/node_modules/montage/examples/feed-reader/map-example.reel/main.html new file mode 100644 index 00000000..889ca8d6 --- /dev/null +++ b/node_modules/montage/examples/feed-reader/map-example.reel/main.html @@ -0,0 +1,58 @@ + + + + + + Main Component + + + + + + + + +
+

Main component of application

+
+
+
+ +
+ + + diff --git a/node_modules/montage/examples/feed-reader/map-example.reel/main.js b/node_modules/montage/examples/feed-reader/map-example.reel/main.js new file mode 100644 index 00000000..54b84425 --- /dev/null +++ b/node_modules/montage/examples/feed-reader/map-example.reel/main.js @@ -0,0 +1,24 @@ +/* + 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/core/core").Montage, + Component = require("montage/ui/component").Component; + + +exports.Main = Montage.create(Component, { + + templateDidLoad: { + value: function() { + //console.log("main templateDidLoad") + } + }, + + prepareForDraw: { + value: function() { + //console.log("main prepareForDraw") + } + } + +}); diff --git a/node_modules/montage/examples/feed-reader/package.json b/node_modules/montage/examples/feed-reader/package.json new file mode 100644 index 00000000..cbb9365f --- /dev/null +++ b/node_modules/montage/examples/feed-reader/package.json @@ -0,0 +1,10 @@ +{ + "name": "loader", + "version": "0.0.0", + "mappings": { + "montage": "../.." + }, + "directories": { + "lib": "" + } +} diff --git a/node_modules/montage/ui/feed-reader/feed-entry.reel/feed-entry.html b/node_modules/montage/ui/feed-reader/feed-entry.reel/feed-entry.html new file mode 100644 index 00000000..213b4602 --- /dev/null +++ b/node_modules/montage/ui/feed-reader/feed-entry.reel/feed-entry.html @@ -0,0 +1,90 @@ + + + + + Feed Entry + + + + + + + +
+ +

+

+
+ + + diff --git a/node_modules/montage/ui/feed-reader/feed-entry.reel/feed-entry.js b/node_modules/montage/ui/feed-reader/feed-entry.reel/feed-entry.js new file mode 100644 index 00000000..3d97eec7 --- /dev/null +++ b/node_modules/montage/ui/feed-reader/feed-entry.reel/feed-entry.js @@ -0,0 +1,13 @@ +/* + 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("ui/component").Component; + +exports.FeedEntry = Montage.create(Component, { + + entry: {value: null} + +}); diff --git a/node_modules/montage/ui/feed-reader/feed-reader.reel/feed-reader.html b/node_modules/montage/ui/feed-reader/feed-reader.reel/feed-reader.html new file mode 100644 index 00000000..a3523001 --- /dev/null +++ b/node_modules/montage/ui/feed-reader/feed-reader.reel/feed-reader.html @@ -0,0 +1,83 @@ + + + + + Feed Reader + + + + + + + + + + +
+ +
+
+
+ + +
+ + + 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 new file mode 100644 index 00000000..838a957d --- /dev/null +++ b/node_modules/montage/ui/feed-reader/feed-reader.reel/feed-reader.js @@ -0,0 +1,82 @@ +/* + 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("ui/component").Component; + //Notifier = require("ui/popup/notifier.reel").Notifier; + +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(); + } + }, + + entries: {value: null}, + + + _startLoading: { + value: function() { + //Notifier.show('Loading ... please wait', null, {top: this.element.style.top, left: this.element.style.left + 20}); + } + }, + + _stopLoading: { + value: function() { + //Notifier.hide(); + } + }, + + _fetchFeed: { + value: function() { + var url = this.feedURL; + var feed = new google.feeds.Feed(url); + feed.setNumEntries(10); + + var self = this; + + this._startLoading(); + self.entries = []; + + feed.load(function(result) { + self._stopLoading(); + if(result.error) { + self.entries = []; + } else { + //console.log('entries: ', result.feed.entries); + self.entries = result.feed.entries; + } + }); + } + } + +}); diff --git a/node_modules/montage/ui/map.reel/map.css b/node_modules/montage/ui/map.reel/map.css new file mode 100644 index 00000000..45307593 --- /dev/null +++ b/node_modules/montage/ui/map.reel/map.css @@ -0,0 +1,9 @@ +/* + 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. +
*/ +.montage-google-map { + width: 100%; + height: 100%; +} \ No newline at end of file diff --git a/node_modules/montage/ui/map.reel/map.html b/node_modules/montage/ui/map.reel/map.html new file mode 100644 index 00000000..a6ac5303 --- /dev/null +++ b/node_modules/montage/ui/map.reel/map.html @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + +
+
+ Show: + +
+
MAP
+ +
+ + + diff --git a/node_modules/montage/ui/map.reel/map.js b/node_modules/montage/ui/map.reel/map.js new file mode 100644 index 00000000..1e4f452c --- /dev/null +++ b/node_modules/montage/ui/map.reel/map.js @@ -0,0 +1,283 @@ +/* + 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 Map = exports.Map = Montage.create(Component, /** @lends module:"montage/ui/toggle-switch.reel".ToggleSwitch# */ { + + didCreate: { + value: function() { + var self = this; + window.initialize = function initialize() { + console.log('google maps api loaded'); + self._mapLoaded = true; + self._geoCoder = new google.maps.Geocoder(); + self.needsDraw = true; + }; + } + }, + + _geoCoder: {value: null}, + + // HTMLElement to load the Map into + mapEl: {value: null}, + + _mapLoaded: { + enumerable: false, + value: false + }, + _map: { + enumerable: false, + value: false + }, + _latitude: { + enumerable: false, + value: -34.397 + }, + latitude: { + enumerable: false, + set: function(value) { + this._latitude = value; + this.needsDraw = true; + }, + get: function() { + return this._latitude; + } + }, + _longitude: { + enumerable: false, + value: -34.397 + }, + longitude: { + enumerable: false, + set: function(value) { + this._longitude = value; + this.needsDraw = true; + }, + get: function() { + return this._longitude; + } + }, + + defaultLatLng: { + value: {lat: -34.397, lng: 150.644} + }, + + _latLng: { + value: this.defaultLatLng, + distinct: true + }, + latLng: { + get: function() { + return this._latLng; + }, + set: function(value) { + if(value) { + this._latLng = value; + // refresh the map + this.needsDraw = true; + } + } + }, + + // {lat, lon} Or a String representing the location (eg: Paris, France) + center: { + get: function() { + return this._center; + }, + set: function(value) { + if(value) { + var self = this, geocoder = this._geoCoder; + this._center = value; + if(this._mapLoaded) { + + if(String.isString(value)) { + // geocode + 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()}; + } else { + console.log('Geocode was not successful : ' + status); + } + }); + } else if(value.lat && value.lng) { + this.latLng = value; + } else { + // default location + this.latLng = this.defaultLatLng; + } + + } + + } + + } + }, + + category: { + get: function() { + return this._category; + }, + set: function(value) { + if(value) { + this._category = value; + this._getPlaces(this._category); + this.needsDraw = true; + } + } + }, + + zoom: { + value: 8 + }, + + __places: {value: null}, + _places: { + get: function() { + return this.__places; + }, + set: function(value) { + if(value) { + this.__places = value; + this.needsDraw = true; + } + } + }, + + _getPlaces: { + value: function(type, keyword) { + var self = this; + var request = { + location: new window.google.maps.LatLng(this.latLng.lat, this.latLng.lng), + radius: 5000, + types: [type] + }; + if(!this._infoWindow) { + this._infoWindow = new google.maps.InfoWindow(); + } + var service = new google.maps.places.PlacesService(this._map); + service.search(request, function(results, status) { + if (status == google.maps.places.PlacesServiceStatus.OK) { + self._places = results; + } else { + self._places = []; + } + }); + } + }, + + _infoWindow: {value: null}, + _markers: {value: null}, + _createMarker: { + value: function(place) { + var placeLoc = place.geometry.location, map = this._map; + var icon, image; + switch(this.category) { + case 'restaurant': + icon = '48-fork-and-knife.png'; + break; + case 'hospital': + icon = '10-medical.png'; + break; + case 'cafe': + icon = '34-coffee.png'; + break; + case 'museum': + icon = '41-picture-frame.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 = []; + } + this._markers.push(marker); + + var infoWindow = this._infoWindow; + google.maps.event.addListener(marker, 'click', function() { + infoWindow.setContent(place.name + '
' + place.vicinity); + infoWindow.open(map, this); + }); + } + }, + + _removeAllMarkers: { + value: function() { + if(this._markers && this._markers.length > 0) { + var i=0, len = this._markers.length; + for(i; i< len; i++) { + this._markers[i].setMap(null); + } + this._markers = []; + } + } + }, + + +/** + Description TODO + @function + */ + draw: { + enumerable: false, + value: function () { + + if(this._mapLoaded) { + var latLng = this.latLng || this.defaultLatLng; + if(!this._map) { + var map; + var myOptions = { + zoom: this.zoom, + center: new window.google.maps.LatLng(latLng.lat, latLng.lng), + mapTypeId: window.google.maps.MapTypeId.ROADMAP + }; + + this._map = new window.google.maps.Map(this.mapEl, myOptions); + } else { + var map = this._map; + map.setZoom(12); + 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) { + this._removeAllMarkers(); + for (var i = 0; i < places.length; i++) { + this._createMarker(places[i]); + } + } + } + + } + + //window.google.maps.event.addDomListener(window, 'load', initialize); + } + } +}); diff --git a/node_modules/montage/ui/template.js b/node_modules/montage/ui/template.js index c6589b35..210d8cb7 100755 --- a/node_modules/montage/ui/template.js +++ b/node_modules/montage/ui/template.js @@ -438,7 +438,7 @@ var Template = exports.Template = Montage.create(Montage, /** @lends module:mont for (var i = 0, cssTag; (cssTag = cssTags[i]); i++) { if ((url = cssTag.getAttribute("href"))) { - if (! /^http:\/\/|^\//.test(url)) { // TODO: look into base links... + if (! /^https?:\/\/|^\//.test(url)) { // TODO: look into base links... url = rootUrl + url; } @@ -547,7 +547,7 @@ var Template = exports.Template = Montage.create(Montage, /** @lends module:mont src = script.getAttribute("src"); scriptNode = doc.importNode(script, true); if (src) { - if (! /^http:\/\/|^\//.test(src)) { // TODO: look into base links... + if (! /^https?:\/\/|^\//.test(src)) { // TODO: look into base links... scriptNode.src = src = rootUrl + src; } if (src in externalScriptsLoaded) continue; @@ -688,7 +688,7 @@ var Template = exports.Template = Montage.create(Montage, /** @lends module:mont url = link.getAttribute("href"), rootUrl = this._rootUrl ? this._rootUrl[0] : ""; - if (! /^http:\/\/|^\//.test(url)) { + if (! /^https?:\/\/|^\//.test(url)) { url = rootUrl + url; } -- cgit v1.2.3 From 9b53d2dac464cb9217b217e6707dbb97c1d65490 Mon Sep 17 00:00:00 2001 From: François Frisch Date: Sat, 17 Mar 2012 11:25:52 -0700 Subject: Deleting unecessary property --- js/document/templates/montage-html/main.reel/main.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/js/document/templates/montage-html/main.reel/main.js b/js/document/templates/montage-html/main.reel/main.js index ee23e844..6c141108 100644 --- a/js/document/templates/montage-html/main.reel/main.js +++ b/js/document/templates/montage-html/main.reel/main.js @@ -45,11 +45,5 @@ exports.Main = Montage.create(Component, { document.body.dispatchEvent( newEvent ); } - }, - - location: { - value:null, - enumerable:false } - }); \ No newline at end of file -- cgit v1.2.3 From 14f28d0031dc9d522b4ae7d1dbff192b8d8a670e Mon Sep 17 00:00:00 2001 From: François Frisch Date: Sat, 17 Mar 2012 11:58:58 -0700 Subject: Adding components to PI --- .../ComponentsPanelBase.js | 22 +++++++++++++++++++++- node_modules/components-data/feed-reader.json | 15 +++++++++++++++ node_modules/components-data/map.json | 22 ++++++++++++++++++++++ node_modules/components-data/searchfield.json | 20 ++++++++++++++++++++ 4 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 node_modules/components-data/feed-reader.json create mode 100644 node_modules/components-data/map.json create mode 100644 node_modules/components-data/searchfield.json diff --git a/js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.js b/js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.js index b4eec771..981e666f 100755 --- a/js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.js +++ b/js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.js @@ -22,6 +22,26 @@ var ComponentsPanelBase = exports.ComponentsPanelBase = Montage.create(Component value: { "text": "styles", "children": [ + { + "text": "Widgets", + "children": [ + { + "text": "Map", + "dataFile" : "node_modules/components-data/map.json", + "component": "map" + }, + { + "text": "Feed Reader", + "dataFile" : "node_modules/components-data/feed-reader.json", + "component": "feedreader" + }, + { + "text": "Search Bar", + "dataFile" : "node_modules/components-data/searchfield.json", + "component": "searchfield" + } + ] + }, { "text": "Montage Components", "children": [ @@ -50,7 +70,7 @@ var ComponentsPanelBase = exports.ComponentsPanelBase = Montage.create(Component "dataFile" : "node_modules/components-data/number-input.json", "component": "numberInput" }, - { + { "text": "Select Input", "dataFile" : "node_modules/components-data/select.json", "component": "select" diff --git a/node_modules/components-data/feed-reader.json b/node_modules/components-data/feed-reader.json new file mode 100644 index 00000000..6caf768d --- /dev/null +++ b/node_modules/components-data/feed-reader.json @@ -0,0 +1,15 @@ +{ + "component": "feedreader", + + "module": "montage/ui/feed-reader/feed-reader.reel", + + "name": "FeedReader", + + "properties": [ + { + "name": "feedURL", + "type": "string", + "default": null + } + ] +} \ No newline at end of file diff --git a/node_modules/components-data/map.json b/node_modules/components-data/map.json new file mode 100644 index 00000000..071fa73a --- /dev/null +++ b/node_modules/components-data/map.json @@ -0,0 +1,22 @@ +{ + "component": "map", + + "module": "montage/ui/map.reel", + + "name": "Map", + + "properties": [ + { + "name": "category", + "type": "string", + "default": null, + "possibleValues": ["restaurant", "hospital", "cafe", "museum"] + }, + { + "name": "center", + "type": "string", + "default": null + } + + ] +} \ No newline at end of file diff --git a/node_modules/components-data/searchfield.json b/node_modules/components-data/searchfield.json new file mode 100644 index 00000000..94c570d9 --- /dev/null +++ b/node_modules/components-data/searchfield.json @@ -0,0 +1,20 @@ +{ + "component": "searchfield", + + "module": "montage/ui/textfield.reel", + + "name": "Textfield", + + "properties": [ + { + "name": "valueBinding", + "type": "string", + "default": null + }, + { + "name": "value", + "type": "string", + "default": "" + } + ] +} \ No newline at end of file -- cgit v1.2.3 From 9c7f7c69495175a4a5a093aeb78f078d0cb7835d Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Fri, 16 Mar 2012 17:14:54 -0700 Subject: Fixed snap-manager to stop snapping after first level children. Signed-off-by: Nivesh Rajbhandari --- js/helper-classes/3D/snap-manager.js | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/js/helper-classes/3D/snap-manager.js b/js/helper-classes/3D/snap-manager.js index 1caacd00..a755e9e2 100755 --- a/js/helper-classes/3D/snap-manager.js +++ b/js/helper-classes/3D/snap-manager.js @@ -471,7 +471,8 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { value: function( plane ) { this._elementCache = new Array; - var stage = this.getStage(); +// var stage = this.getStage(); + var stage = this.application.ninja.currentSelectedContainer || this.getStage(); this.hLoadElementCache( stage, plane, 0 ); this._isCacheInvalid = false; @@ -570,6 +571,11 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { hLoadElementCache : { value: function( elt, plane, depth ) { + if(depth > 1) + { + return; + } + if (depth > 0) { // check if the element is on the specified plane @@ -590,8 +596,7 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { elt.elementModel.isIn2DSnapCache = false; } - // TODO - Don't traverse components' children -// if(elt.elementModel && elt.elementModel.isComponent) + // TODO - Don't traverse svg and components' children if(elt.nodeName.toLowerCase() === "svg" || (elt.elementModel && (elt.elementModel.isComponent || (elt.elementModel.selection === "SVG")))) { return; @@ -964,7 +969,8 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { snapToElements : { value: function( screenPt, hitRecs ) { // start at the stage. - var stage = this.getStage(); +// var stage = this.getStage(); + var stage = this.application.ninja.currentSelectedContainer || this.getStage(); // the root should be the 'view' canvas, so the first matrix is the camera viewUtils.setViewportObj( stage ); @@ -980,6 +986,10 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { { value: function( elt, hitRecs, depth, globalScrPt ) { + if(depth > 1) + { + return; + } // hit test the current object var hit; if (depth > 0) // don't snap to the root @@ -1001,8 +1011,7 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { } } - // TODO - Don't traverse components' children -// if(elt.elementModel && elt.elementModel.isComponent) + // TODO - Don't traverse svg and components' children if(elt.nodeName.toLowerCase() === "svg" || (elt.elementModel && (elt.elementModel.isComponent || (elt.elementModel.selection === "SVG")))) { return; -- cgit v1.2.3 From 11afad994a9ff5e3c8c43d8ad9cd2cf7d0147797 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Sat, 17 Mar 2012 15:38:29 -0700 Subject: adding element creation for the map and feedreader components. Signed-off-by: Valerio Virgillito --- .../ComponentsPanelBase.reel/ComponentsPanelBase.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.js b/js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.js index 981e666f..92d21bc3 100755 --- a/js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.js +++ b/js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.js @@ -333,6 +333,7 @@ var ComponentsPanelBase = exports.ComponentsPanelBase = Montage.create(Component el.setAttribute("type", "range"); break; case "textfield": + case "searchfield": el = NJUtils.makeNJElement("input", "Textfield", "component"); el.elementModel.pi = "TextfieldPi"; el.setAttribute("type", "text"); @@ -346,6 +347,16 @@ var ComponentsPanelBase = exports.ComponentsPanelBase = Montage.create(Component el.elementModel.pi = "ToggleButtonPi"; el.innerHTML = "Off"; break; + case "map": + el = NJUtils.makeNJElement("div", "Map", "component"); + el.elementModel.pi = "MapPi"; + el.elementModel.isComponent = true; + break; + case "feedreader": + el = NJUtils.makeNJElement("div", "Feed Reader", "component"); + el.elementModel.pi = "FeedReaderPi"; + el.elementModel.isComponent = true; + } return el; -- cgit v1.2.3 From bcddcf118d4ce93e8a2519ed455c6e25a701ce74 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Sat, 17 Mar 2012 16:42:13 -0700 Subject: fixing the map styles and temporary disabling the 3d styles for elements. Signed-off-by: Valerio Virgillito --- js/controllers/elements/element-controller.js | 8 ++++---- node_modules/montage/ui/map.reel/map.html | 11 +++++++++++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/js/controllers/elements/element-controller.js b/js/controllers/elements/element-controller.js index 70aba54e..efaa00ee 100755 --- a/js/controllers/elements/element-controller.js +++ b/js/controllers/elements/element-controller.js @@ -290,10 +290,10 @@ var ElementController = exports.ElementController = Montage.create(NJComponent, value: function(el, props, index, update3DModel) { var dist = props[index]["dist"], mat = props[index]["mat"]; - this.application.ninja.stylesController.setElementStyle(el, - "-webkit-transform", - "perspective(" + dist + ") " + - "matrix3d(" + MathUtils.scientificToDecimal(mat, 5) + ")"); +// this.application.ninja.stylesController.setElementStyle(el, +// "-webkit-transform", +// "perspective(" + dist + ") " + +// "matrix3d(" + MathUtils.scientificToDecimal(mat, 5) + ")"); el.elementModel.props3D.matrix3d = mat; el.elementModel.props3D.perspectiveDist = dist; diff --git a/node_modules/montage/ui/map.reel/map.html b/node_modules/montage/ui/map.reel/map.html index a6ac5303..5cd3a5b5 100644 --- a/node_modules/montage/ui/map.reel/map.html +++ b/node_modules/montage/ui/map.reel/map.html @@ -35,6 +35,17 @@ } + + -- cgit v1.2.3 From 28a7a71d2962158cab34f50627f2d22540c29eab Mon Sep 17 00:00:00 2001 From: Benoit Marchant Date: Sat, 17 Mar 2012 17:41:47 -0700 Subject: Added a new picasa-carousel component as well as an example using it --- .../lab/sandbox/ui/picasa-carousel-test/index.html | 77 +++++++++ .../ui/picasa-carousel-test/main.reel/main.css | 8 + .../ui/picasa-carousel-test/main.reel/main.html | 75 +++++++++ .../ui/picasa-carousel-test/main.reel/main.js | 35 ++++ .../sandbox/ui/picasa-carousel-test/package.json | 10 ++ .../picasa-carousel.reel/image.reel/image.html | 37 +++++ .../picasa-carousel.reel/image.reel/image.js | 20 +++ .../picasa-carousel.reel/picasa-carousel.css | 44 +++++ .../picasa-carousel.reel/picasa-carousel.html | 181 +++++++++++++++++++++ .../google/picasa-carousel.reel/picasa-carousel.js | 124 ++++++++++++++ 10 files changed, 611 insertions(+) create mode 100755 node_modules/montage/lab/sandbox/ui/picasa-carousel-test/index.html create mode 100755 node_modules/montage/lab/sandbox/ui/picasa-carousel-test/main.reel/main.css create mode 100755 node_modules/montage/lab/sandbox/ui/picasa-carousel-test/main.reel/main.html create mode 100755 node_modules/montage/lab/sandbox/ui/picasa-carousel-test/main.reel/main.js create mode 100755 node_modules/montage/lab/sandbox/ui/picasa-carousel-test/package.json create mode 100644 node_modules/montage/ui/google/picasa-carousel.reel/image.reel/image.html create mode 100644 node_modules/montage/ui/google/picasa-carousel.reel/image.reel/image.js create mode 100755 node_modules/montage/ui/google/picasa-carousel.reel/picasa-carousel.css create mode 100755 node_modules/montage/ui/google/picasa-carousel.reel/picasa-carousel.html create mode 100644 node_modules/montage/ui/google/picasa-carousel.reel/picasa-carousel.js diff --git a/node_modules/montage/lab/sandbox/ui/picasa-carousel-test/index.html b/node_modules/montage/lab/sandbox/ui/picasa-carousel-test/index.html new file mode 100755 index 00000000..ec34286f --- /dev/null +++ b/node_modules/montage/lab/sandbox/ui/picasa-carousel-test/index.html @@ -0,0 +1,77 @@ + + + + + + + Flow Example + + + + + + + + + +
+

Bootstrapper

+

This is the bootstrapper content which will now be shown for at least 1500ms.

+
+
+

Loader

+

This is the loader content which will now be shown for at least 2000ms.

+
+ + diff --git a/node_modules/montage/lab/sandbox/ui/picasa-carousel-test/main.reel/main.css b/node_modules/montage/lab/sandbox/ui/picasa-carousel-test/main.reel/main.css new file mode 100755 index 00000000..82b04cf9 --- /dev/null +++ b/node_modules/montage/lab/sandbox/ui/picasa-carousel-test/main.reel/main.css @@ -0,0 +1,8 @@ +.montage-google-picasa-carousel, [data-montage-id="montage-google-picasa-carousel"] { + width: 800px; + height: 400px; + -webkit-perspective: 800px; + background: -webkit-gradient(linear, left top, left bottom, from(#666), to(#bbb)); +} + + diff --git a/node_modules/montage/lab/sandbox/ui/picasa-carousel-test/main.reel/main.html b/node_modules/montage/lab/sandbox/ui/picasa-carousel-test/main.reel/main.html new file mode 100755 index 00000000..177eb068 --- /dev/null +++ b/node_modules/montage/lab/sandbox/ui/picasa-carousel-test/main.reel/main.html @@ -0,0 +1,75 @@ + + + + + + Main Component + + + +