Allow only one bookmark to be added for multiple fast starring
[chromium-blink-merge.git] / chrome / browser / resources / pdf / elements / viewer-password-screen-legacy / viewer-password-screen-legacy.js
blob8d09e153e50ed3d6452f6f396b12fa43fc71487e
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({
6 is: 'viewer-password-screen-legacy',
8 properties: {
9 text: {
10 type: String,
11 value: 'This document is password protected. Please enter a password.',
14 active: {
15 type: Boolean,
16 value: false,
17 observer: 'activeChanged'
21 timerId: undefined,
23 ready: function() {
24 this.activeChanged();
27 accept: function() {
28 this.active = false;
31 deny: function() {
32 this.$.password.disabled = false;
33 this.$.submit.disabled = false;
34 this.$.password.focus();
35 this.$.password.select();
38 submit: function(e) {
39 // Prevent the default form submission behavior.
40 e.preventDefault();
41 if (this.$.password.value.length == 0)
42 return;
43 this.$.password.disabled = true;
44 this.$.submit.disabled = true;
45 this.fire('password-submitted', {password: this.$.password.value});
48 activeChanged: function() {
49 clearTimeout(this.timerId);
50 this.timerId = undefined;
51 if (this.active) {
52 this.style.visibility = 'visible';
53 this.style.opacity = 1;
54 this.$.password.focus();
55 } else {
56 this.style.opacity = 0;
57 this.timerId = setTimeout(function() {
58 this.style.visibility = 'hidden';
59 }.bind(this), 400);
62 });