diff options
author | Eric Guzman | 2012-03-27 10:22:42 -0700 |
---|---|---|
committer | Eric Guzman | 2012-03-27 10:22:42 -0700 |
commit | 309b201017da2a4094df4f06adeeff9d396b193a (patch) | |
tree | 92257b32855bcd31dd74967b085a6632fd7dbe9b /node_modules/montage/ui/picasa-carousel.reel/picasa-carousel.js | |
parent | da03585a0b03220281f6d54d9acf0ae0fafaef16 (diff) | |
parent | 309dde5a8c4599cef6a1052c1ff9ee1ad8ec5858 (diff) | |
download | ninja-309b201017da2a4094df4f06adeeff9d396b193a.tar.gz |
Merge branch 'refs/heads/master' into PresetsPI
Diffstat (limited to 'node_modules/montage/ui/picasa-carousel.reel/picasa-carousel.js')
-rw-r--r-- | node_modules/montage/ui/picasa-carousel.reel/picasa-carousel.js | 153 |
1 files changed, 153 insertions, 0 deletions
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..bdc74c83 --- /dev/null +++ b/node_modules/montage/ui/picasa-carousel.reel/picasa-carousel.js | |||
@@ -0,0 +1,153 @@ | |||
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 | */ | ||
11 | var Montage = require("montage").Montage, | ||
12 | Component = require("ui/component").Component; | ||
13 | /** | ||
14 | @class module:"montage/ui/google/map.reel".Map | ||
15 | @extends module:montage/ui/component.Component | ||
16 | */ | ||
17 | var 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 | |||
32 | |||
33 | _queryParameter: { | ||
34 | enumerable: false, | ||
35 | value: null | ||
36 | }, | ||
37 | |||
38 | queryParameter: { | ||
39 | get: function() { | ||
40 | return this._queryParameter; | ||
41 | }, | ||
42 | set: function(value) { | ||
43 | this._queryParameter = value; | ||
44 | this.performSearch(); | ||
45 | } | ||
46 | }, | ||
47 | |||
48 | resultCount: { | ||
49 | enumerable: false, | ||
50 | value: 40 | ||
51 | }, | ||
52 | |||
53 | prepareForDraw: { | ||
54 | enumerable: false, | ||
55 | value: function() { | ||
56 | // this.searchForm.identifier = "searchForm"; | ||
57 | // this.searchForm.addEventListener("submit", this, false); | ||
58 | } | ||
59 | }, | ||
60 | |||
61 | _isSearching: { | ||
62 | value: false, | ||
63 | enumerable: false | ||
64 | }, | ||
65 | |||
66 | isSearching: { | ||
67 | enumerable: false, | ||
68 | get: function() { | ||
69 | return this._isSearching; | ||
70 | }, | ||
71 | set: function(value) { | ||
72 | if (value === this._isSearching) { | ||
73 | return; | ||
74 | } | ||
75 | |||
76 | this._isSearching = value; | ||
77 | this.needsDraw = true; | ||
78 | } | ||
79 | }, | ||
80 | |||
81 | handleSearchFormSubmit: { | ||
82 | value: function(evt) { | ||
83 | evt.preventDefault(); | ||
84 | this.performSearch(); | ||
85 | } | ||
86 | }, | ||
87 | |||
88 | performSearch: { | ||
89 | value: function() { | ||
90 | if (this.isSearching) { | ||
91 | console.log("already searching!") | ||
92 | return; | ||
93 | } | ||
94 | |||
95 | this.isSearching = true; | ||
96 | this.searchResults = null; | ||
97 | |||
98 | 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=" | ||
99 | // var base = "http://picasaweb.google.com/data/feed/base/featured?visibility=public&alt=json&max-results=" + this.resultCount + "&kind=photo&prettyprint=true" | ||
100 | var url = base + this.queryParameter; | ||
101 | |||
102 | var req = new XMLHttpRequest(); | ||
103 | req.identifier = "searchRequest"; | ||
104 | req.open("GET", url); | ||
105 | req.addEventListener("load", this, false); | ||
106 | req.addEventListener("error", this, false); | ||
107 | req.send(); | ||
108 | |||
109 | } | ||
110 | }, | ||
111 | |||
112 | handleSearchRequestLoad: { | ||
113 | value: function(evt) { | ||
114 | var response = JSON.parse(evt.target.responseText), | ||
115 | previousOrigin = this.flow.origin; | ||
116 | this.searchResults = response.feed.entry; | ||
117 | if (this.flow.length === 0) { | ||
118 | this.flow.length = this.initialPosition; | ||
119 | } | ||
120 | if (previousOrigin === 0) { | ||
121 | this.flow.origin = this.initialPosition; | ||
122 | } else { | ||
123 | this.flow.origin = previousOrigin; | ||
124 | } | ||
125 | this.isSearching = false; | ||
126 | } | ||
127 | }, | ||
128 | |||
129 | handleSearchRequestError: { | ||
130 | value: function(evt) { | ||
131 | console.error("handleSearchRequestError", evt); | ||
132 | this.isSearching = false; | ||
133 | } | ||
134 | }, | ||
135 | |||
136 | searchResults: { | ||
137 | enumerable: false, | ||
138 | value: null | ||
139 | }, | ||
140 | |||
141 | draw: { | ||
142 | value: function() { | ||
143 | |||
144 | if (this.isSearching) { | ||
145 | this.element.classList.add("searching"); | ||
146 | } else { | ||
147 | this.element.classList.remove("searching"); | ||
148 | } | ||
149 | |||
150 | } | ||
151 | } | ||
152 | |||
153 | }); | ||