OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 (function() { | 5 (function() { |
6 /** Amount that each level of bookmarks is indented by (px). */ | 6 /** Amount that each level of bookmarks is indented by (px). */ |
7 var BOOKMARK_INDENT = 20; | 7 var BOOKMARK_INDENT = 20; |
8 | 8 |
9 Polymer({ | 9 Polymer({ |
10 is: 'viewer-bookmark', | 10 is: 'viewer-bookmark', |
(...skipping 10 matching lines...) Expand all Loading... |
21 observer: 'bookmarkChanged_' | 21 observer: 'bookmarkChanged_' |
22 }, | 22 }, |
23 | 23 |
24 depth: { | 24 depth: { |
25 type: Number, | 25 type: Number, |
26 observer: 'depthChanged' | 26 observer: 'depthChanged' |
27 }, | 27 }, |
28 | 28 |
29 childDepth: Number, | 29 childDepth: Number, |
30 | 30 |
31 childrenShown_: { | 31 childrenShown: { |
32 type: Boolean, | 32 type: Boolean, |
| 33 reflectToAttribute: true, |
33 value: false | 34 value: false |
34 } | 35 } |
35 }, | 36 }, |
36 | 37 |
37 bookmarkChanged_: function() { | 38 bookmarkChanged_: function() { |
38 this.$.expand.style.visibility = | 39 this.$.expand.style.visibility = |
39 this.bookmark.children.length > 0 ? 'visible' : 'hidden'; | 40 this.bookmark.children.length > 0 ? 'visible' : 'hidden'; |
40 }, | 41 }, |
41 | 42 |
42 depthChanged: function() { | 43 depthChanged: function() { |
43 this.childDepth = this.depth + 1; | 44 this.childDepth = this.depth + 1; |
44 this.$.item.style.paddingLeft = (this.depth * BOOKMARK_INDENT) + 'px'; | 45 this.$.item.style.paddingLeft = (this.depth * BOOKMARK_INDENT) + 'px'; |
45 }, | 46 }, |
46 | 47 |
47 onClick: function() { | 48 onClick: function() { |
48 if (this.bookmark.hasOwnProperty('page')) | 49 if (this.bookmark.hasOwnProperty('page')) |
49 this.fire('change-page', {page: this.bookmark.page}); | 50 this.fire('change-page', {page: this.bookmark.page}); |
50 }, | 51 }, |
51 | 52 |
52 toggleChildren: function(e) { | 53 toggleChildren: function(e) { |
53 this.childrenShown_ = !this.childrenShown_; | 54 this.childrenShown = !this.childrenShown; |
54 if (this.childrenShown_) | |
55 this.$.expand.classList.add('open'); | |
56 else | |
57 this.$.expand.classList.remove('open'); | |
58 e.stopPropagation(); // Prevent the above onClick handler from firing. | 55 e.stopPropagation(); // Prevent the above onClick handler from firing. |
59 } | 56 } |
60 }); | 57 }); |
61 })(); | 58 })(); |
OLD | NEW |