| 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', |
| 11 | 11 |
| 12 properties: { | 12 properties: { |
| 13 /** | 13 /** |
| 14 * A bookmark object, each containing a: | 14 * A bookmark object, each containing a: |
| 15 * - title | 15 * - title |
| 16 * - page (optional) | 16 * - page (optional) |
| 17 * - children (an array of bookmarks) | 17 * - children (an array of bookmarks) |
| 18 */ | 18 */ |
| 19 bookmark: { | 19 bookmark: {type: Object, observer: 'bookmarkChanged_'}, |
| 20 type: Object, | |
| 21 observer: 'bookmarkChanged_' | |
| 22 }, | |
| 23 | 20 |
| 24 depth: { | 21 depth: {type: Number, observer: 'depthChanged'}, |
| 25 type: Number, | |
| 26 observer: 'depthChanged' | |
| 27 }, | |
| 28 | 22 |
| 29 childDepth: Number, | 23 childDepth: Number, |
| 30 | 24 |
| 31 childrenShown: { | 25 childrenShown: {type: Boolean, reflectToAttribute: true, value: false}, |
| 32 type: Boolean, | |
| 33 reflectToAttribute: true, | |
| 34 value: false | |
| 35 }, | |
| 36 | 26 |
| 37 keyEventTarget: { | 27 keyEventTarget: { |
| 38 type: Object, | 28 type: Object, |
| 39 value: function() { | 29 value: function() { |
| 40 return this.$.item; | 30 return this.$.item; |
| 41 } | 31 } |
| 42 } | 32 } |
| 43 }, | 33 }, |
| 44 | 34 |
| 45 behaviors: [ | 35 behaviors: [Polymer.IronA11yKeysBehavior], |
| 46 Polymer.IronA11yKeysBehavior | |
| 47 ], | |
| 48 | 36 |
| 49 keyBindings: { | 37 keyBindings: {'enter': 'onEnter_', 'space': 'onSpace_'}, |
| 50 'enter': 'onEnter_', | |
| 51 'space': 'onSpace_' | |
| 52 }, | |
| 53 | 38 |
| 54 bookmarkChanged_: function() { | 39 bookmarkChanged_: function() { |
| 55 this.$.expand.style.visibility = | 40 this.$.expand.style.visibility = |
| 56 this.bookmark.children.length > 0 ? 'visible' : 'hidden'; | 41 this.bookmark.children.length > 0 ? 'visible' : 'hidden'; |
| 57 }, | 42 }, |
| 58 | 43 |
| 59 depthChanged: function() { | 44 depthChanged: function() { |
| 60 this.childDepth = this.depth + 1; | 45 this.childDepth = this.depth + 1; |
| 61 this.$.item.style.webkitPaddingStart = | 46 this.$.item.style.webkitPaddingStart = |
| 62 (this.depth * BOOKMARK_INDENT) + 'px'; | 47 (this.depth * BOOKMARK_INDENT) + 'px'; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 83 // Prevent default space scroll behavior. | 68 // Prevent default space scroll behavior. |
| 84 e.detail.keyboardEvent.preventDefault(); | 69 e.detail.keyboardEvent.preventDefault(); |
| 85 }, | 70 }, |
| 86 | 71 |
| 87 toggleChildren: function(e) { | 72 toggleChildren: function(e) { |
| 88 this.childrenShown = !this.childrenShown; | 73 this.childrenShown = !this.childrenShown; |
| 89 e.stopPropagation(); // Prevent the above onClick handler from firing. | 74 e.stopPropagation(); // Prevent the above onClick handler from firing. |
| 90 } | 75 } |
| 91 }); | 76 }); |
| 92 })(); | 77 })(); |
| OLD | NEW |