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

Side by Side Diff: chrome/browser/resources/settings/people_page/manage_profile.js

Issue 1568963003: Revert of Settings People Revamp: Implement Chrome Profile name/icon selection. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 /**
6 * @fileoverview
7 * 'settings-manage-profile' is the settings subpage containing controls to
8 * edit a profile's name, icon, and desktop shortcut.
9 *
10 * @group Chrome Settings Elements
11 * @element settings-manage-profile
12 */
13 Polymer({
14 is: 'settings-manage-profile',
15
16 properties: {
17 /**
18 * The currently selected profile icon URL. May be a data URL.
19 */
20 profileIconUrl: String,
21
22 /**
23 * The current profile name.
24 */
25 profileName: String,
26
27 /**
28 * The available icons for selection. Populated by SyncPrivateApi.
29 * @type {!Array<!string>}
30 */
31 availableIconUrls: {
32 type: Array,
33 value: function() { return []; },
34 },
35 },
36
37 /** @override */
38 created: function() {
39 settings.SyncPrivateApi.getAvailableIcons(
40 this.handleAvailableIcons_.bind(this));
41 },
42
43 /**
44 * Handler for when the available icons are pushed from SyncPrivateApi.
45 * @private
46 * @param {!Array<!string>} iconUrls
47 */
48 handleAvailableIcons_: function(iconUrls) {
49 this.availableIconUrls = iconUrls;
50 },
51
52 /**
53 * Handler for when the profile name field is changed, then blurred.
54 * @private
55 * @param {!Event} event
56 */
57 onProfileNameChanged_: function(event) {
58 settings.SyncPrivateApi.setProfileIconAndName(this.profileIconUrl,
59 event.target.value);
60 },
61
62 /**
63 * Handler for when the user clicks a new profile icon.
64 * @private
65 * @param {!Event} event
66 */
67 onIconTap_: function(event) {
68 var element = Polymer.dom(event).rootTarget;
69
70 var iconUrl;
71 if (element.nodeName == 'IMG')
72 iconUrl = element.src;
73 else if (element.dataset && element.dataset.iconUrl)
74 iconUrl = element.dataset.iconUrl;
75
76 if (!iconUrl)
77 return;
78
79 settings.SyncPrivateApi.setProfileIconAndName(iconUrl, this.profileName);
80
81 // Button toggle state is controlled by the selected icon URL. Prevent
82 // tap events from changing the toggle state.
83 event.preventDefault();
84 },
85
86 /**
87 * Computed binding determining which profile icon button is toggled on.
88 * @private
89 * @param {!string} iconUrl
90 * @param {!string} paramIconUrl
91 * @return {boolean}
92 */
93 isActiveIcon_: function(iconUrl, profileIconUrl) {
94 return iconUrl == profileIconUrl;
95 },
96 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698