OLD | NEW |
---|---|
(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 bookmarks: null, | |
raymes
2015/01/27 09:10:54
Let's add documentation for all of the functions a
Alexandre Carlton
2015/01/28 00:22:46
Done.
| |
7 | |
8 bookmarksChanged: function() { | |
9 for (var i = 0; i < this.bookmarks.length; i++) { | |
10 var bookmark = this.makeBookmark_(this.bookmarks[i]); | |
11 this.$.pane.appendChild(bookmark); | |
12 } | |
13 }, | |
14 | |
15 makeBookmark_: function(bookmark) { | |
16 var node = document.createElement('paper-item'); | |
17 node.textContent = bookmark.title; | |
18 if (bookmark.hasOwnProperty('page')) { | |
19 node.addEventListener('click', function() { | |
20 this.fire('changePage', {page: bookmark.page}); | |
21 }); | |
22 } | |
23 if (bookmark.children.length === 0) { | |
24 return node; | |
25 } else { | |
26 var titleNode = document.createElement('div'); | |
raymes
2015/01/27 09:10:54
titleNode seems a bit confusing to me because I do
Alexandre Carlton
2015/01/28 00:22:46
Fixed; node is now titleNode, and titleNode has be
| |
27 titleNode.className += ' sub-bookmark'; | |
28 | |
29 for (var i = 0; i < bookmark.children.length; i++) { | |
30 var childNode = this.makeBookmark_(bookmark.children[i]); | |
31 titleNode.appendChild(childNode); | |
32 } | |
33 var wrapperNode = document.createElement('div'); | |
34 wrapperNode.appendChild(node); | |
35 wrapperNode.appendChild(titleNode); | |
36 return wrapperNode; | |
raymes
2015/01/27 09:10:54
I think the structure should be something like thi
Alexandre Carlton
2015/01/28 00:22:46
For reference, the structure currently is:
<div>
| |
37 } | |
38 }, | |
39 | |
40 toggle: function() { | |
41 this.$.pane.toggle(); | |
42 } | |
43 }); | |
OLD | NEW |