Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(102)

Side by Side Diff: chrome/browser/resources/pdf/elements/viewer-bookmark/viewer-bookmark.js

Issue 2939273002: DO NOT SUBMIT: what chrome/browser/resources/ could eventually look like with clang-format (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 }
42 } 31 }
43 }, 32 }
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';
63 }, 48 },
64 49
65 onClick: function() { 50 onClick: function() {
66 if (this.bookmark.hasOwnProperty('page')) 51 if (this.bookmark.hasOwnProperty('page'))
67 this.fire('change-page', {page: this.bookmark.page}); 52 this.fire('change-page', {page: this.bookmark.page});
68 else if (this.bookmark.hasOwnProperty('uri')) 53 else if (this.bookmark.hasOwnProperty('uri'))
69 this.fire('navigate', {uri: this.bookmark.uri, newtab: true}); 54 this.fire('navigate', {uri: this.bookmark.uri, newtab: true});
70 }, 55 },
71 56
72 onEnter_: function(e) { 57 onEnter_: function(e) {
73 // Don't allow events which have propagated up from the expand button to 58 // Don't allow events which have propagated up from the expand button to
74 // trigger a click. 59 // trigger a click.
75 if (e.detail.keyboardEvent.target != this.$.expand) 60 if (e.detail.keyboardEvent.target != this.$.expand)
76 this.onClick(); 61 this.onClick();
77 }, 62 },
78 63
79 onSpace_: function(e) { 64 onSpace_: function(e) {
80 // paper-icon-button stops propagation of space events, so there's no need 65 // paper-icon-button stops propagation of space events, so there's no need
81 // to check the event source here. 66 // to check the event source here.
82 this.onClick(); 67 this.onClick();
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 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698