OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 cr.define('settings_test', function() { | 5 cr.define('settings_test', function() { |
6 var changePictureOptions = settings_test.changePictureOptions || { | 6 var changePictureOptions = settings_test.changePictureOptions || { |
7 /** | 7 /** |
8 * True if property changes should fire events for testing purposes. | 8 * True if property changes should fire events for testing purposes. |
9 * @type {boolean} | 9 * @type {boolean} |
10 */ | 10 */ |
(...skipping 21 matching lines...) Expand all Loading... | |
32 /** | 32 /** |
33 * The currently selected profile image URL. May be a data URL. | 33 * The currently selected profile image URL. May be a data URL. |
34 * @private {string} | 34 * @private {string} |
35 */ | 35 */ |
36 selectedImageUrl_: { | 36 selectedImageUrl_: { |
37 type: String, | 37 type: String, |
38 notify: settings_test.changePictureOptions.notifyPropertyChangesForTest, | 38 notify: settings_test.changePictureOptions.notifyPropertyChangesForTest, |
39 }, | 39 }, |
40 | 40 |
41 /** | 41 /** |
42 * True only if the user has selected the camera icon. Old photos captured | |
43 * from the camera are represented as the 'old' image. | |
44 * @type {boolean} | |
45 */ | |
46 cameraActive: { | |
47 type: Boolean, | |
48 value: false, | |
49 }, | |
50 | |
51 /** | |
52 * This differs from its default value only if the user has just captured | |
53 * a new photo from the camera. | |
54 * @type {string} | |
55 */ | |
56 cameraImageUrl: { | |
dpapad
2016/01/21 18:11:40
Does this URL need to be public (all other URLs in
tommycli
2016/01/21 18:47:05
Done. Actually I think not.
The eventual goal is
| |
57 type: String, | |
58 value: settings.ChangePicturePrivateApi.ButtonImages.TAKE_PHOTO, | |
59 }, | |
60 | |
61 /** | |
62 * This differs from its default value only if the user has just captured | |
63 * a new photo from the camera. | |
64 * @type {string} | |
dpapad
2016/01/21 18:11:40
@private or remove the underscore from the name.
tommycli
2016/01/21 18:47:05
Done.
| |
65 */ | |
66 cameraImageTitle_: { | |
67 type: String, | |
68 value: function() { return loadTimeData.getString('takePhoto'); }, | |
69 }, | |
70 | |
71 /** | |
42 * The url of the 'old' image, which is the existing image sourced from | 72 * The url of the 'old' image, which is the existing image sourced from |
43 * the camera, a file, or a deprecated default image. | 73 * the camera, a file, or a deprecated default image. |
44 * @private {string} | 74 * @private {string} |
45 */ | 75 */ |
46 oldImageUrl_: String, | 76 oldImageUrl_: String, |
47 | 77 |
48 /** | 78 /** |
49 * The url of the profile image. | 79 * The url of the profile image. |
50 * @private {string} | 80 * @private {string} |
51 */ | 81 */ |
(...skipping 22 matching lines...) Expand all Loading... | |
74 */ | 104 */ |
75 receiveDefaultImages: function(images) { | 105 receiveDefaultImages: function(images) { |
76 this.defaultImages_ = images; | 106 this.defaultImages_ = images; |
77 }.bind(this), | 107 }.bind(this), |
78 | 108 |
79 /** | 109 /** |
80 * Called from C++ to provide the URL of the selected image. | 110 * Called from C++ to provide the URL of the selected image. |
81 * @param {string} imageUrl | 111 * @param {string} imageUrl |
82 */ | 112 */ |
83 receiveSelectedImage: function(imageUrl) { | 113 receiveSelectedImage: function(imageUrl) { |
114 this.cameraActive = false; | |
dpapad
2016/01/21 18:11:40
Would it make sense to set the value of this boole
tommycli
2016/01/21 18:47:05
Hmm.. I'm not sure yet.
Basically I'm still not s
dpapad
2016/01/21 18:55:47
SG.
| |
84 this.selectedImageUrl_ = imageUrl; | 115 this.selectedImageUrl_ = imageUrl; |
85 }.bind(this), | 116 }.bind(this), |
86 | 117 |
87 /** | 118 /** |
88 * Called from C++ to provide the URL of the 'old' image. The 'old' | 119 * Called from C++ to provide the URL of the 'old' image. The 'old' |
89 * image is any selected non-profile and non-default image. It can be | 120 * image is any selected non-profile and non-default image. It can be |
90 * from the camera, a file, or a deprecated default image. When this | 121 * from the camera, a file, or a deprecated default image. When this |
91 * method is called, it's implied that the old image is selected. | 122 * method is called, it's implied that the old image is selected. |
92 * @param {string} imageUrl | 123 * @param {string} imageUrl |
93 */ | 124 */ |
94 receiveOldImage: function(imageUrl) { | 125 receiveOldImage: function(imageUrl) { |
126 this.cameraActive = false; | |
95 this.oldImageUrl_ = imageUrl; | 127 this.oldImageUrl_ = imageUrl; |
96 this.selectedImageUrl_ = imageUrl; | 128 this.selectedImageUrl_ = imageUrl; |
97 }.bind(this), | 129 }.bind(this), |
98 | 130 |
99 /** | 131 /** |
100 * Called from C++ to provide the URL of the profile image. | 132 * Called from C++ to provide the URL of the profile image. |
101 * @param {string} imageUrl | 133 * @param {string} imageUrl |
102 * @param {boolean} selected | 134 * @param {boolean} selected |
103 */ | 135 */ |
104 receiveProfileImage: function(imageUrl, selected) { | 136 receiveProfileImage: function(imageUrl, selected) { |
105 this.profileImageUrl_ = imageUrl; | 137 this.profileImageUrl_ = imageUrl; |
106 if (selected) | 138 if (selected) { |
139 this.cameraActive = false; | |
107 this.selectedImageUrl_ = imageUrl; | 140 this.selectedImageUrl_ = imageUrl; |
141 } | |
108 }.bind(this), | 142 }.bind(this), |
109 | 143 |
110 /** | 144 /** |
111 * Called from the C++ to notify page about camera presence. | 145 * Called from the C++ to notify page about camera presence. |
112 * @param {boolean} cameraPresent | 146 * @param {boolean} cameraPresent |
113 */ | 147 */ |
114 receiveCameraPresence: function(cameraPresent) { | 148 receiveCameraPresence: function(cameraPresent) { |
115 // TODO(tommycli): Implement camera functionality. | 149 // TODO(tommycli): Implement camera functionality. |
116 }.bind(this), | 150 }.bind(this), |
117 }; | 151 }; |
118 | 152 |
119 cr.define('settings', function() { | 153 cr.define('settings', function() { |
120 var ChangePicturePage = nativeInterface; | 154 var ChangePicturePage = nativeInterface; |
121 return { | 155 return { |
122 ChangePicturePage: ChangePicturePage, | 156 ChangePicturePage: ChangePicturePage, |
123 }; | 157 }; |
124 }); | 158 }); |
125 | 159 |
126 settings.ChangePicturePrivateApi.initialize(); | 160 settings.ChangePicturePrivateApi.initialize(); |
127 }, | 161 }, |
128 | 162 |
129 /** | 163 /** |
164 * Handler for when the user clicks the camera image. | |
165 * @private | |
166 * @param {!Event} event | |
dpapad
2016/01/21 18:55:47
We are not using the event parameter. Can it be re
tommycli
2016/01/21 19:08:03
Done.
| |
167 */ | |
168 onCameraImageTap_: function(event) { | |
169 this.cameraActive = true; | |
170 }, | |
171 | |
172 /** | |
130 * Handler for when the user clicks a new profile image. | 173 * Handler for when the user clicks a new profile image. |
131 * @private | 174 * @private |
132 * @param {!Event} event | 175 * @param {!Event} event |
133 */ | 176 */ |
134 onDefaultImageTap_: function(event) { | 177 onDefaultImageTap_: function(event) { |
135 var element = Polymer.dom(event).rootTarget; | 178 var element = Polymer.dom(event).rootTarget; |
136 | 179 |
137 var imageUrl = null; | 180 var imageUrl = null; |
138 if (element.nodeName == 'IMG') | 181 if (element.nodeName == 'IMG') |
139 imageUrl = element.src; | 182 imageUrl = element.src; |
(...skipping 29 matching lines...) Expand all Loading... | |
169 event.preventDefault(); | 212 event.preventDefault(); |
170 }, | 213 }, |
171 | 214 |
172 /** | 215 /** |
173 * Computed binding determining which profile image button is toggled on. | 216 * Computed binding determining which profile image button is toggled on. |
174 * @private | 217 * @private |
175 * @param {string} imageUrl | 218 * @param {string} imageUrl |
176 * @param {string} selectedImageUrl | 219 * @param {string} selectedImageUrl |
177 * @return {boolean} | 220 * @return {boolean} |
178 */ | 221 */ |
179 isActiveImage_: function(imageUrl, selectedImageUrl) { | 222 isActiveImage_: function(cameraActive, imageUrl, selectedImageUrl) { |
180 return imageUrl == selectedImageUrl; | 223 return !cameraActive && (imageUrl == selectedImageUrl); |
181 }, | 224 }, |
182 }); | 225 }); |
OLD | NEW |