Add ENABLE_MEDIA_ROUTER define to builds other than Android and iOS.
[chromium-blink-merge.git] / chrome / browser / resources / pdf / elements / viewer-password-screen / viewer-password-screen.js
blob83e8a23d075bf16379699af8d82c4a711e169d67
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.
5 Polymer('viewer-password-screen', {
6 text: 'This document is password protected. Please enter a password.',
7 active: false,
8 timerId: undefined,
9 ready: function() {
10 this.activeChanged();
12 accept: function() {
13 this.active = false;
15 deny: function() {
16 this.$.password.disabled = false;
17 this.$.submit.disabled = false;
18 this.$.password.focus();
19 this.$.password.select();
21 submit: function(e) {
22 // Prevent the default form submission behavior.
23 e.preventDefault();
24 if (this.$.password.value.length == 0)
25 return;
26 this.$.password.disabled = true;
27 this.$.submit.disabled = true;
28 this.fire('password-submitted', {password: this.$.password.value});
30 activeChanged: function() {
31 clearTimeout(this.timerId);
32 this.timerId = undefined;
33 if (this.active) {
34 this.style.visibility = 'visible';
35 this.style.opacity = 1;
36 this.$.password.focus();
37 } else {
38 this.style.opacity = 0;
39 this.timerId = setTimeout(function() {
40 this.style.visibility = 'hidden';
41 }.bind(this), 400);
44 });