Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 var OptionsPage = options.OptionsPage; | 6 var OptionsPage = options.OptionsPage; |
| 7 var ArrayDataModel = cr.ui.ArrayDataModel; | 7 var ArrayDataModel = cr.ui.ArrayDataModel; |
| 8 | 8 |
| 9 /** | 9 /** |
| 10 * ManageProfileOverlay class | 10 * ManageProfileOverlay class |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 66 $('manage-profile-ok').onclick = function(event) { | 66 $('manage-profile-ok').onclick = function(event) { |
| 67 OptionsPage.closeOverlay(); | 67 OptionsPage.closeOverlay(); |
| 68 self.submitManageChanges_(); | 68 self.submitManageChanges_(); |
| 69 }; | 69 }; |
| 70 $('delete-profile-ok').onclick = function(event) { | 70 $('delete-profile-ok').onclick = function(event) { |
| 71 OptionsPage.closeOverlay(); | 71 OptionsPage.closeOverlay(); |
| 72 chrome.send('deleteProfile', [self.profileInfo_.filePath]); | 72 chrome.send('deleteProfile', [self.profileInfo_.filePath]); |
| 73 }; | 73 }; |
| 74 $('create-profile-ok').onclick = function(event) { | 74 $('create-profile-ok').onclick = function(event) { |
| 75 OptionsPage.closeOverlay(); | 75 OptionsPage.closeOverlay(); |
| 76 // Get the user's chosen name and icon, or default if they do not | 76 self.submitCreateProfile_(); |
| 77 // wish to customize their profile. | 77 }; |
| 78 var name = $('create-profile-name').value; | 78 $('manage-profile-name').onkeydown = |
| 79 var icon_url = createIconGrid.selectedItem; | 79 $('manage-profile-icon-grid').onkeydown = function(event) { |
| 80 var create_checkbox = false; | 80 if (!$('manage-profile-ok').disabled && event.keyCode == 13) { // Enter |
| 81 if ($('create-shortcut')) | 81 OptionsPage.closeOverlay(); |
| 82 create_checkbox = $('create-shortcut').checked; | 82 self.submitManageChanges_(); |
| 83 chrome.send('createProfile', [name, icon_url, create_checkbox]); | 83 } |
| 84 }; | |
| 85 $('create-profile-name').onkeydown = | |
| 86 $('create-profile-icon-grid').onkeydown = function(event) { | |
| 87 if (!$('create-profile-ok').disabled && event.keyCode == 13) { // Enter | |
| 88 OptionsPage.closeOverlay(); | |
| 89 self.submitCreateProfile_(); | |
| 90 } | |
|
csilv
2012/12/15 01:05:12
These two methods are identical, so it would be ni
Rune Fevang
2012/12/18 02:47:02
Done.
| |
| 84 }; | 91 }; |
| 85 }, | 92 }, |
| 86 | 93 |
| 87 /** @override */ | 94 /** @override */ |
| 88 didShowPage: function() { | 95 didShowPage: function() { |
| 89 chrome.send('requestDefaultProfileIcons'); | 96 chrome.send('requestDefaultProfileIcons'); |
| 90 | 97 |
| 91 if ($('create-shortcut')) | 98 if ($('create-shortcut')) |
| 92 $('create-shortcut').checked = true; | 99 $('create-shortcut').checked = true; |
| 93 if ($('manage-shortcut')) | 100 if ($('manage-shortcut')) |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 206 this.showErrorBubble_('manageProfilesDuplicateNameError', mode); | 213 this.showErrorBubble_('manageProfilesDuplicateNameError', mode); |
| 207 } else { | 214 } else { |
| 208 this.hideErrorBubble_(mode); | 215 this.hideErrorBubble_(mode); |
| 209 | 216 |
| 210 var nameIsValid = $(mode + '-profile-name').validity.valid; | 217 var nameIsValid = $(mode + '-profile-name').validity.valid; |
| 211 $(mode + '-profile-ok').disabled = !nameIsValid; | 218 $(mode + '-profile-ok').disabled = !nameIsValid; |
| 212 } | 219 } |
| 213 }, | 220 }, |
| 214 | 221 |
| 215 /** | 222 /** |
| 216 * Called when the user clicks "OK". Saves the newly changed profile info. | 223 * Called when the user clicks "OK" or hits enter. Saves the newly changed |
| 224 * profile info. | |
| 217 * @private | 225 * @private |
| 218 */ | 226 */ |
| 219 submitManageChanges_: function() { | 227 submitManageChanges_: function() { |
| 220 var name = $('manage-profile-name').value; | 228 var name = $('manage-profile-name').value; |
| 221 var iconURL = $('manage-profile-icon-grid').selectedItem; | 229 var iconURL = $('manage-profile-icon-grid').selectedItem; |
| 222 var manage_checkbox = false; | 230 var manage_checkbox = false; |
| 223 if ($('manage-shortcut')) | 231 if ($('manage-shortcut')) |
| 224 manage_checkbox = $('manage-shortcut').checked; | 232 manage_checkbox = $('manage-shortcut').checked; |
| 225 chrome.send('setProfileNameAndIcon', | 233 chrome.send('setProfileNameAndIcon', |
| 226 [this.profileInfo_.filePath, name, iconURL, | 234 [this.profileInfo_.filePath, name, iconURL, |
| 227 manage_checkbox]); | 235 manage_checkbox]); |
| 228 }, | 236 }, |
| 229 | 237 |
| 230 /** | 238 /** |
| 239 * Called when the user clicks "OK" or hits enter. Creates the profile | |
| 240 * using the information in the dialog. | |
| 241 * @private | |
| 242 */ | |
| 243 submitCreateProfile_: function() { | |
| 244 // Get the user's chosen name and icon, or default if they do not | |
| 245 // wish to customize their profile. | |
| 246 var name = $('create-profile-name').value; | |
| 247 var icon_url = $('create-profile-icon-grid').selectedItem; | |
| 248 var create_checkbox = false; | |
| 249 if ($('create-shortcut')) | |
| 250 create_checkbox = $('create-shortcut').checked; | |
| 251 chrome.send('createProfile', [name, icon_url, create_checkbox]); | |
| 252 }, | |
| 253 | |
| 254 /** | |
| 231 * Called when the selected icon in the icon grid changes. | 255 * Called when the selected icon in the icon grid changes. |
| 232 * @param {String} mode A label that specifies the type of dialog | 256 * @param {String} mode A label that specifies the type of dialog |
| 233 * box which is currently being viewed (i.e. 'create' or | 257 * box which is currently being viewed (i.e. 'create' or |
| 234 * 'manage'). | 258 * 'manage'). |
| 235 * @private | 259 * @private |
| 236 */ | 260 */ |
| 237 onIconGridSelectionChanged_: function(mode) { | 261 onIconGridSelectionChanged_: function(mode) { |
| 238 var iconURL = $(mode + '-profile-icon-grid').selectedItem; | 262 var iconURL = $(mode + '-profile-icon-grid').selectedItem; |
| 239 if (!iconURL || iconURL == this.iconGridSelectedURL_) | 263 if (!iconURL || iconURL == this.iconGridSelectedURL_) |
| 240 return; | 264 return; |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 320 var instance = ManageProfileOverlay.getInstance(); | 344 var instance = ManageProfileOverlay.getInstance(); |
| 321 return instance[name + '_'].apply(instance, arguments); | 345 return instance[name + '_'].apply(instance, arguments); |
| 322 }; | 346 }; |
| 323 }); | 347 }); |
| 324 | 348 |
| 325 // Export | 349 // Export |
| 326 return { | 350 return { |
| 327 ManageProfileOverlay: ManageProfileOverlay | 351 ManageProfileOverlay: ManageProfileOverlay |
| 328 }; | 352 }; |
| 329 }); | 353 }); |
| OLD | NEW |