Chromium Code Reviews| 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 | |
|
Alexander Alekseev
2016/10/28 10:49:11
Document this file, please.
Roman Sorokin (ftl)
2016/10/28 12:35:28
Hmm, our polymer elements have documentation in th
Alexander Alekseev
2016/10/28 13:00:59
Chromium coding style (https://chromium.googlesour
| |
| 5 Polymer((function() { | |
| 6 return { | |
| 7 is: 'offline-ad-login', | |
| 8 | |
| 9 properties: { | |
| 10 disabled: { | |
| 11 type: Boolean, | |
| 12 value: false, | |
| 13 observer: '_disabledChanged' | |
| 14 }, | |
| 15 showMachineInput: { | |
| 16 type: Boolean, | |
| 17 value: false | |
| 18 }, | |
| 19 realm: { | |
| 20 type: String, | |
| 21 observer: 'onRealmChanged_' | |
| 22 }, | |
| 23 userRealm: String, | |
| 24 adWelcomeMessage: String | |
| 25 }, | |
| 26 | |
| 27 focus: function() { | |
| 28 if (this.showMachineInput && this.$.machineNameInput.value == '') { | |
| 29 this.$.machineNameInput.focus(); | |
| 30 } else if (this.$.userInput.value == '') { | |
| 31 this.$.userInput.focus(); | |
| 32 } else { | |
| 33 this.$.passwordInput.focus(); | |
| 34 } | |
| 35 }, | |
| 36 | |
| 37 onRealmChanged_: function() { | |
| 38 this.$.welcomeMsg.textContent = | |
| 39 loadTimeData.getStringF('ADAuthWelcomeMessage', this.realm); | |
| 40 }, | |
| 41 | |
| 42 setUser: function(user, machineName) { | |
| 43 if (user) { | |
| 44 this.$.userInput.value = user; | |
| 45 this.$.passwordInput.isInvalid = true; | |
| 46 } else { | |
| 47 this.$.userInput.value = ''; | |
| 48 this.$.passwordInput.isInvalid = false; | |
| 49 } | |
| 50 this.$.machineNameInput.value = machineName || ''; | |
| 51 this.$.passwordInput.value = ''; | |
| 52 this.focus(); | |
| 53 }, | |
| 54 | |
| 55 isRTL_: function() { | |
| 56 return !!document.querySelector('html[dir=rtl]'); | |
| 57 }, | |
| 58 | |
| 59 onSubmit_: function() { | |
| 60 if (this.showMachineInput && !this.$.machineNameInput.checkValidity()) | |
| 61 return; | |
| 62 if (!this.$.passwordInput.checkValidity()) | |
| 63 return; | |
| 64 var user = this.$.userInput.value; | |
| 65 if (user.indexOf('@') === -1) { | |
| 66 if (this.userRealm) | |
| 67 user = user + this.userRealm; | |
| 68 } | |
| 69 var msg = { | |
| 70 'machinename': this.$.machineNameInput.value, | |
| 71 'username': user, | |
| 72 'password': this.$.passwordInput.value | |
| 73 }; | |
| 74 this.$.passwordInput.value = ''; | |
| 75 this.fire('authCompleted', msg); | |
| 76 }, | |
| 77 | |
| 78 _disabledChanged: function(newValue, oldValue) { | |
| 79 this.$.gaiaCard.classList.toggle('disabled', newValue); | |
| 80 } | |
| 81 }; | |
| 82 })()); | |
| OLD | NEW |