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

Side by Side Diff: chrome/browser/resources/pdf/elements/bookmarks-pane/bookmarks-pane.js

Issue 865033002: Implement a slide-in pane for bookmarks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@pdf-pane
Patch Set: Document bookmarks.js Created 5 years, 10 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
(Empty)
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
3 // found in the LICENSE file.
4
5 Polymer('bookmarks-pane', {
6 // An array of top-level bookmarks, each containing a:
7 // - title
8 // - page (optional)
9 // - children (an array of bookmarks)
10 bookmarks: null,
11
12 // Inserts bookmark elements into the pane
raymes 2015/01/28 01:10:20 Take a look at the jsdoc in pdf.js and let's follo
Alexandre Carlton 2015/01/28 07:16:52 Done.
13 bookmarksChanged: function() {
14 for (var i = 0; i < this.bookmarks.length; i++) {
15 var bookmark = this.makeBookmark_(this.bookmarks[i]);
16 this.$.pane.appendChild(bookmark);
17 }
18 },
19
20 // Transforms bookmark object into an HTML element.
21 makeBookmark_: function(bookmark) {
Sam McNally 2015/01/28 03:04:30 It feels like a bookmark could be a custom element
22 var titleNode = document.createElement('paper-item');
23 titleNode.textContent = bookmark.title;
24 if (bookmark.hasOwnProperty('page')) {
25 titleNode.addEventListener('click', function() {
26 this.fire('changePage', {page: bookmark.page});
27 });
28 }
29 if (bookmark.children.length === 0) {
30 return titleNode;
31 } else {
32 var subNode = document.createElement('div');
raymes 2015/01/28 01:10:20 nit: can we call this childBookmarksNode
Alexandre Carlton 2015/01/28 07:16:52 Done.
Alexandre Carlton 2015/01/28 07:16:52 Done.
33 subNode.className += ' sub-bookmark';
34
35 for (var i = 0; i < bookmark.children.length; i++) {
36 var childNode = this.makeBookmark_(bookmark.children[i]);
37 subNode.appendChild(childNode);
38 }
39 var wrapperNode = document.createElement('div');
40 wrapperNode.appendChild(titleNode);
41 wrapperNode.appendChild(subNode);
42 return wrapperNode;
43 }
44 },
45
46 toggle: function() {
47 this.$.pane.toggle();
48 }
49 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698