Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(487)

Side by Side Diff: chrome/browser/resources/options/chromeos/change_picture_options.js

Issue 8636015: [cros] Double-click fixes on Change Picture prefs page. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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('options', function() { 5 cr.define('options', function() {
6 6
7 var OptionsPage = options.OptionsPage; 7 var OptionsPage = options.OptionsPage;
8 var UserImagesGrid = options.UserImagesGrid; 8 var UserImagesGrid = options.UserImagesGrid;
9 var ButtonImages = UserImagesGrid.ButtonImages; 9 var ButtonImages = UserImagesGrid.ButtonImages;
10 10
11 /**
12 * Array of button URLs used on this page.
13 * @type {Array.<string>}
14 */
15 const ButtonImageUrls = [
16 ButtonImages.TAKE_PHOTO,
17 ButtonImages.CHOOSE_FILE
18 ];
19
11 ///////////////////////////////////////////////////////////////////////////// 20 /////////////////////////////////////////////////////////////////////////////
12 // ChangePictureOptions class: 21 // ChangePictureOptions class:
13 22
14 /** 23 /**
15 * Encapsulated handling of ChromeOS change picture options page. 24 * Encapsulated handling of ChromeOS change picture options page.
16 * @constructor 25 * @constructor
17 */ 26 */
18 function ChangePictureOptions() { 27 function ChangePictureOptions() {
19 OptionsPage.call( 28 OptionsPage.call(
20 this, 29 this,
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 $('images-grid').removeItem(this.oldImage_); 90 $('images-grid').removeItem(this.oldImage_);
82 this.oldImage_ = null; 91 this.oldImage_ = null;
83 } 92 }
84 }, 93 },
85 94
86 /** 95 /**
87 * Closes current page, returning back to Personal Stuff page. 96 * Closes current page, returning back to Personal Stuff page.
88 * @private 97 * @private
89 */ 98 */
90 closePage_: function() { 99 closePage_: function() {
100 $('images-grid').blur(); // Make sure the image grid is not active.
91 OptionsPage.navigateToPage('personal'); 101 OptionsPage.navigateToPage('personal');
92 }, 102 },
93 103
94 /** 104 /**
95 * Handles "Take photo" button activation. 105 * Handles "Take photo" button activation.
96 * @private 106 * @private
97 */ 107 */
98 handleTakePhoto_: function() { 108 handleTakePhoto_: function() {
99 chrome.send('takePhoto'); 109 chrome.send('takePhoto');
100 this.closePage_(); 110 this.closePage_();
(...skipping 13 matching lines...) Expand all
114 * @private 124 * @private
115 */ 125 */
116 handleImageActivated_: function() { 126 handleImageActivated_: function() {
117 switch ($('images-grid').selectedItemUrl) { 127 switch ($('images-grid').selectedItemUrl) {
118 case ButtonImages.TAKE_PHOTO: 128 case ButtonImages.TAKE_PHOTO:
119 this.handleTakePhoto_(); 129 this.handleTakePhoto_();
120 break; 130 break;
121 case ButtonImages.CHOOSE_FILE: 131 case ButtonImages.CHOOSE_FILE:
122 this.handleChooseFile_(); 132 this.handleChooseFile_();
123 break; 133 break;
124 case ButtonImages.PROFILE_PICTURE:
125 break;
126 default: 134 default:
127 this.closePage_(); 135 this.closePage_();
128 break; 136 break;
129 } 137 }
130 }, 138 },
131 139
132 /** 140 /**
133 * Handles double click on the image grid. 141 * Handles double click on the image grid.
134 * @param {Event} e Double click Event. 142 * @param {Event} e Double click Event.
135 */ 143 */
136 handleImageDblClick_: function(e) { 144 handleImageDblClick_: function(e) {
137 // Close page unless the click target is the grid itself, 145 // Close page unless the click target is the grid itself or
138 // any of the buttons or the Profile image until it's not loaded. 146 // any of the buttons.
139 var url = e.target.src; 147 var url = e.target.src;
140 if (!url) 148 if (url && ButtonImageUrls.indexOf(url) == -1)
141 return; 149 this.closePage_();
142 for (var k in ButtonImages) {
143 if (url == ButtonImages[k])
144 return;
145 }
146 this.closePage_();
147 }, 150 },
148 151
149 /** 152 /**
150 * URL of the current user image. 153 * URL of the current user image.
151 * @type {string} 154 * @type {string}
152 */ 155 */
153 get currentUserImageUrl() { 156 get currentUserImageUrl() {
154 return 'chrome://userimage/' + PersonalOptions.getLoggedInUserEmail() + 157 return 'chrome://userimage/' + PersonalOptions.getLoggedInUserEmail() +
155 '?id=' + (new Date()).getTime(); 158 '?id=' + (new Date()).getTime();
156 }, 159 },
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 }; 244 };
242 }); 245 });
243 246
244 // Export 247 // Export
245 return { 248 return {
246 ChangePictureOptions: ChangePictureOptions 249 ChangePictureOptions: ChangePictureOptions
247 }; 250 };
248 251
249 }); 252 });
250 253
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698