1 // Copyright 2014 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.
6 /** @const */ var ICON_COLORS
= ['#F0B9CB', '#F0ACC3', '#F098B6', '#F084A9',
7 '#F06D99', '#F05287', '#F0467F', '#F03473',
10 is
: 'pairing-device-list',
22 reflectToAttribute
: true
26 getStyleForDeviceIcon_: function(deviceName
) {
27 return 'color: ' + this.colorByName_(deviceName
);
30 /* Returns pseudo-random color depending of hash of the |name|. */
31 colorByName_: function(name
) {
33 for (var i
= 0; i
< name
.length
; ++i
)
34 hash
= (name
.charCodeAt(i
) + 31 * hash
) | 0;
35 return ICON_COLORS
[hash
% ICON_COLORS
.length
];
41 is
: 'controller-pairing-page',
44 Polymer
.NeonSharedElementAnimatableBehavior
51 'top-hero': this.$.top
,
52 'bottom-hero': this.$.bottom
61 name
: 'hero-animation',
65 name
: 'hero-animation',
69 name
: 'fade-in-animation',
74 name
: 'hero-animation',
78 name
: 'hero-animation',
82 name
: 'fade-out-animation',
94 // Keep these constants synced with corresponding constants defined in
95 // controller_pairing_screen_actor.{h,cc}.
96 /** @const */ var CONTEXT_KEY_CONTROLS_DISABLED
= 'controlsDisabled';
97 /** @const */ var CONTEXT_KEY_SELECTED_DEVICE
= 'selectedDevice';
98 /** @const */ var CONTEXT_KEY_ACCOUNT_ID
= 'accountId';
100 /** @const */ var ACTION_ENROLL
= 'enroll';
102 /** @const */ var PAGE_AUTHENTICATION
= 'authentication';
105 is
: 'controller-pairing-screen',
108 login
.OobeScreenBehavior
114 observer
: 'selectedDeviceChanged_'
119 'deviceListChanged_(C.devices)'
125 * https://github.com/PolymerElements/neon-animation/issues/32
126 * TODO(dzhioev): Remove when fixed in Polymer.
128 var pages
= this.$.pages
;
129 delete pages
._squelchNextFinishEvent
;
130 Object
.defineProperty(pages
, '_squelchNextFinishEvent',
131 { get: function() { return false; } });
135 initialize: function() {
140 'page'].forEach(this.registerBoundContextField
, this);
141 this.context
.set(CONTEXT_KEY_CONTROLS_DISABLED
, true);
142 this.commitContextChanges();
145 deviceListChanged_: function() {
146 this.selectedDevice
= this.context
.get(CONTEXT_KEY_SELECTED_DEVICE
, null);
149 selectedDeviceChanged_: function(selectedDevice
) {
150 this.context
.set(CONTEXT_KEY_SELECTED_DEVICE
,
151 selectedDevice
? selectedDevice
: '');
152 this.commitContextChanges();
155 helpButtonClicked_: function() {
156 console
.error('Help is not implemented yet.');
159 getHostEnrollmentStepTitle_: function(domain
) {
160 return this.i18n(['enrollmentInProgress', domain
]);
163 getSuccessMessage_: function(selectedDevice
) {
164 return this.i18n(['successText', selectedDevice
]);