aboutsummaryrefslogtreecommitdiff
path: root/node_modules/montage-google/picasa-carousel.reel/picasa-carousel.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/montage-google/picasa-carousel.reel/picasa-carousel.js')
-rw-r--r--node_modules/montage-google/picasa-carousel.reel/picasa-carousel.js151
1 files changed, 151 insertions, 0 deletions
diff --git a/node_modules/montage-google/picasa-carousel.reel/picasa-carousel.js b/node_modules/montage-google/picasa-carousel.reel/picasa-carousel.js
new file mode 100644
index 00000000..800e073c
--- /dev/null
+++ b/node_modules/montage-google/picasa-carousel.reel/picasa-carousel.js
@@ -0,0 +1,151 @@
1/* <copyright>
2 This file contains proprietary software owned by Motorola Mobility, Inc.<br/>
3 No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/>
4 (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
5 </copyright> */
6/**
7
8 @requires montage/core/core
9 @requires montage/ui/component
10*/
11var Montage = require("montage").Montage,
12 Component = require("montage/ui/component").Component;
13/**
14 @class module:"montage/ui/google/map.reel".Map
15 @extends module:montage/ui/component.Component
16 */
17var PicasaCarousel = exports.PicasaCarousel = Montage.create(Component, /** @lends module:"montage/ui/toggle-switch.reel".ToggleSwitch# */ {
18 photoListController: {
19 enumerable: false,
20 value: null
21 },
22
23 flow: {
24 value: null
25 },
26
27 initialPosition: {
28 value: 2300
29 },
30
31 _queryParameter: {
32 enumerable: false,
33 value: null
34 },
35
36 queryParameter: {
37 get: function() {
38 return this._queryParameter;
39 },
40 set: function(value) {
41 this._queryParameter = value;
42 this.performSearch();
43 }
44 },
45
46 resultCount: {
47 enumerable: false,
48 value: 1000
49 },
50
51 prepareForDraw: {
52 enumerable: false,
53 value: function() {
54 // this.searchForm.identifier = "searchForm";
55 // this.searchForm.addEventListener("submit", this, false);
56 }
57 },
58
59 _isSearching: {
60 value: false,
61 enumerable: false
62 },
63
64 isSearching: {
65 enumerable: false,
66 get: function() {
67 return this._isSearching;
68 },
69 set: function(value) {
70 if (value === this._isSearching) {
71 return;
72 }
73
74 this._isSearching = value;
75 this.needsDraw = true;
76 }
77 },
78
79 handleSearchFormSubmit: {
80 value: function(evt) {
81 evt.preventDefault();
82 this.performSearch();
83 }
84 },
85
86 performSearch: {
87 value: function() {
88 if (this.isSearching) {
89 console.log("already searching!")
90 return;
91 }
92
93 this.isSearching = true;
94 this.searchResults = null;
95
96 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="
97 // var base = "http://picasaweb.google.com/data/feed/base/featured?visibility=public&alt=json&max-results=" + this.resultCount + "&kind=photo&prettyprint=true"
98 var url = base + this.queryParameter;
99
100 var req = new XMLHttpRequest();
101 req.identifier = "searchRequest";
102 req.open("GET", url);
103 req.addEventListener("load", this, false);
104 req.addEventListener("error", this, false);
105 req.send();
106
107 }
108 },
109
110 handleSearchRequestLoad: {
111 value: function(evt) {
112 var response = JSON.parse(evt.target.responseText);
113
114 this.searchResults = response.feed.entry;
115 /*if (this.flow.length === 0) {
116 this.flow.length = this.initialPosition;
117 }
118 if (previousOrigin === 0) {
119 this.flow.origin = this.initialPosition;
120 } else {
121 this.flow.origin = previousOrigin;
122 }*/
123 this.isSearching = false;
124 }
125 },
126
127 handleSearchRequestError: {
128 value: function(evt) {
129 console.error("handleSearchRequestError", evt);
130 this.isSearching = false;
131 }
132 },
133
134 searchResults: {
135 enumerable: false,
136 value: null
137 },
138
139 draw: {
140 value: function() {
141
142 if (this.isSearching) {
143 this.element.classList.add("searching");
144 } else {
145 this.element.classList.remove("searching");
146 }
147
148 }
149 }
150
151});