diff options
author | François Frisch | 2012-03-17 19:28:30 -0700 |
---|---|---|
committer | François Frisch | 2012-03-17 19:28:30 -0700 |
commit | 09852e9b9b8e64f003bed5aa57630d8b42c8ac95 (patch) | |
tree | de6f15ae7557a17f105386729952f35783f67647 /node_modules/montage/ui/picasa-carousel.reel/picasa-carousel.js | |
parent | a086ca62423a09807e2f3a79107249bc31d5e908 (diff) | |
download | ninja-09852e9b9b8e64f003bed5aa57630d8b42c8ac95.tar.gz |
Integrating picasa carousel and youtube channel
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 | 124 |
1 files changed, 124 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..25d363b0 --- /dev/null +++ b/node_modules/montage/ui/picasa-carousel.reel/picasa-carousel.js | |||
@@ -0,0 +1,124 @@ | |||
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 | queryParameter: { | ||
24 | enumerable: false, | ||
25 | value: null | ||
26 | }, | ||
27 | |||
28 | resultCount: { | ||
29 | enumerable: false, | ||
30 | value: 20 | ||
31 | }, | ||
32 | |||
33 | prepareForDraw: { | ||
34 | enumerable: false, | ||
35 | value: function() { | ||
36 | // this.searchForm.identifier = "searchForm"; | ||
37 | // this.searchForm.addEventListener("submit", this, false); | ||
38 | } | ||
39 | }, | ||
40 | |||
41 | _isSearching: { | ||
42 | value: false, | ||
43 | enumerable: false | ||
44 | }, | ||
45 | |||
46 | isSearching: { | ||
47 | enumerable: false, | ||
48 | get: function() { | ||
49 | return this._isSearching; | ||
50 | }, | ||
51 | set: function(value) { | ||
52 | if (value === this._isSearching) { | ||
53 | return; | ||
54 | } | ||
55 | |||
56 | this._isSearching = value; | ||
57 | this.needsDraw = true; | ||
58 | } | ||
59 | }, | ||
60 | |||
61 | handleSearchFormSubmit: { | ||
62 | value: function(evt) { | ||
63 | evt.preventDefault(); | ||
64 | this.performSearch(); | ||
65 | } | ||
66 | }, | ||
67 | |||
68 | performSearch: { | ||
69 | value: function() { | ||
70 | if (this.isSearching) { | ||
71 | console.log("already searching!") | ||
72 | return; | ||
73 | } | ||
74 | |||
75 | this.isSearching = true; | ||
76 | this.searchResults = null; | ||
77 | |||
78 | 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=" | ||
79 | // var base = "http://picasaweb.google.com/data/feed/base/featured?visibility=public&alt=json&max-results=" + this.resultCount + "&kind=photo&prettyprint=true" | ||
80 | var url = base + this.queryParameter; | ||
81 | |||
82 | var req = new XMLHttpRequest(); | ||
83 | req.identifier = "searchRequest"; | ||
84 | req.open("GET", url); | ||
85 | req.addEventListener("load", this, false); | ||
86 | req.addEventListener("error", this, false); | ||
87 | req.send(); | ||
88 | |||
89 | } | ||
90 | }, | ||
91 | |||
92 | handleSearchRequestLoad: { | ||
93 | value: function(evt) { | ||
94 | var response = JSON.parse(evt.target.responseText); | ||
95 | this.searchResults = response.feed.entry; | ||
96 | this.isSearching = false; | ||
97 | } | ||
98 | }, | ||
99 | |||
100 | handleSearchRequestError: { | ||
101 | value: function(evt) { | ||
102 | console.error("handleSearchRequestError", evt); | ||
103 | this.isSearching = false; | ||
104 | } | ||
105 | }, | ||
106 | |||
107 | searchResults: { | ||
108 | enumerable: false, | ||
109 | value: null | ||
110 | }, | ||
111 | |||
112 | draw: { | ||
113 | value: function() { | ||
114 | |||
115 | if (this.isSearching) { | ||
116 | this.element.classList.add("searching"); | ||
117 | } else { | ||
118 | this.element.classList.remove("searching"); | ||
119 | } | ||
120 | |||
121 | } | ||
122 | } | ||
123 | |||
124 | }); | ||