OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 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 (function() { | |
6 'use strict'; | |
7 | |
8 /** | |
9 * The max number of fingerprints this list can hold. | |
10 * @const {number} | |
11 */ | |
12 var MAX_NUMBER_FINGERPRINTS_ALLOWED = 5; | |
13 | |
14 Polymer({ | |
15 is: 'settings-fingerprint-list', | |
16 | |
17 behaviors: [ | |
18 I18nBehavior, | |
19 ], | |
20 | |
21 properties: { | |
22 /** | |
23 * The list of fingerprint objects. | |
24 * @private {!Array<string>} | |
25 */ | |
26 fingerprints_: { | |
27 type: Array, | |
28 value: function() { | |
29 return []; | |
30 } | |
31 } | |
32 }, | |
33 | |
34 /** | |
35 * Adds a fingerprint with a default name. | |
36 * @private | |
37 */ | |
38 onAddFingerprint_: function() { | |
Dan Beam
2017/01/10 23:23:45
onAddFingerprint_: function() {
var numPrints =
sammiequon
2017/01/11 00:29:09
This would give something slightly different than
| |
39 // Determines what the newly added fingerprint's name should be. | |
40 // TODO(sammiequon): Add fingerprint using private API once it is ready. | |
41 | |
42 var fingerprintName; | |
43 for (var i = 1; i <= MAX_NUMBER_FINGERPRINTS_ALLOWED; ++i) { | |
44 fingerprintName = this.i18n('lockScreenFingerprintNewName', i); | |
45 if (this.fingerprints_.includes(fingerprintName)) | |
46 continue; | |
47 break; | |
48 } | |
49 this.push('fingerprints_', fingerprintName); | |
50 this.$.fingerprintsList.notifyResize(); | |
Dan Beam
2017/01/10 23:23:46
why do you need notifyResize()?
sammiequon
2017/01/11 00:29:09
Done.
sammiequon
2017/01/17 19:59:09
Actually, without this, on options the list does n
| |
51 }, | |
52 | |
53 /** | |
54 * Deletes a fingerprint from |fingerprints_|. | |
55 * @private | |
56 */ | |
57 onFingerprintDelete_: function(e) { | |
58 // TODO(sammiequon): Remove fingerprint using private API once it is ready. | |
59 this.splice('fingerprints_', e.model.index, 1); | |
60 this.$.fingerprintsList.notifyResize(); | |
Dan Beam
2017/01/10 23:23:45
why do you need notifyResize()?
sammiequon
2017/01/11 00:29:09
Done.
| |
61 }, | |
62 | |
63 /** | |
64 * Returns the text to be displayed for the add fingerprint button. | |
65 * @param {number} numFingerprints | |
66 * @return {string} | |
67 * @private | |
68 */ | |
69 getFingerprintButtonText_: function(numFingerprints) { | |
70 if (this.canAddNewFingerprint_(numFingerprints)) | |
71 return this.i18n('lockScreenAddFingerprint'); | |
72 | |
73 return this.i18n('lockScreenCannotAddFingerprint', | |
74 MAX_NUMBER_FINGERPRINTS_ALLOWED); | |
75 }, | |
76 | |
77 /** | |
78 * Checks whether another fingerprint can be added. | |
79 * @param {number} numFingerprints | |
80 * @return {boolean} | |
81 * @private | |
82 */ | |
83 canAddNewFingerprint_: function(numFingerprints) { | |
84 return numFingerprints < MAX_NUMBER_FINGERPRINTS_ALLOWED; | |
Dan Beam
2017/01/10 23:23:45
you only ever pass this.fingerprints_.length for n
sammiequon
2017/01/11 00:29:09
That is correct. If I do it that way, canAddNewFin
| |
85 } | |
86 }); | |
87 })(); | |
OLD | NEW |