OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 Polymer({ | 5 Polymer({ |
6 is: 'bookmarks-folder-node', | 6 is: 'bookmarks-folder-node', |
7 | 7 |
8 behaviors: [ | 8 behaviors: [ |
9 bookmarks.StoreClient, | 9 bookmarks.StoreClient, |
10 ], | 10 ], |
11 | 11 |
12 properties: { | 12 properties: { |
13 itemId: { | 13 itemId: { |
14 type: String, | 14 type: String, |
15 observer: 'updateFromStore', | 15 observer: 'updateFromStore', |
16 }, | 16 }, |
17 | 17 |
| 18 depth: { |
| 19 type: Number, |
| 20 observer: 'depthChanged_', |
| 21 }, |
| 22 |
18 /** @type {BookmarkNode} */ | 23 /** @type {BookmarkNode} */ |
19 item_: Object, | 24 item_: Object, |
20 | 25 |
21 /** @private */ | 26 /** @private */ |
22 isClosed_: Boolean, | 27 isClosed_: Boolean, |
23 | 28 |
24 /** @private */ | 29 /** @private */ |
25 selectedFolder_: String, | 30 selectedFolder_: String, |
26 | 31 |
27 /** @private */ | 32 /** @private */ |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 /** | 76 /** |
72 * Occurs when the drop down arrow is tapped. | 77 * Occurs when the drop down arrow is tapped. |
73 * @private | 78 * @private |
74 */ | 79 */ |
75 toggleFolder_: function() { | 80 toggleFolder_: function() { |
76 this.dispatch( | 81 this.dispatch( |
77 bookmarks.actions.changeFolderOpen(this.item_.id, this.isClosed_)); | 82 bookmarks.actions.changeFolderOpen(this.item_.id, this.isClosed_)); |
78 }, | 83 }, |
79 | 84 |
80 /** | 85 /** |
| 86 * @private |
81 * @param {string} itemId | 87 * @param {string} itemId |
82 * @param {string} selectedFolder | 88 * @param {string} selectedFolder |
83 * @return {boolean} | 89 * @return {boolean} |
84 * @private | |
85 */ | 90 */ |
86 computeIsSelected_: function(itemId, selectedFolder) { | 91 computeIsSelected_: function(itemId, selectedFolder) { |
87 return itemId == selectedFolder; | 92 return itemId == selectedFolder; |
88 }, | 93 }, |
89 | 94 |
90 /** | 95 /** |
91 * @private | 96 * @private |
92 * @return {boolean} | 97 * @return {boolean} |
93 */ | 98 */ |
94 hasChildFolder_: function() { | 99 hasChildFolder_: function() { |
95 for (var i = 0; i < this.item_.children.length; i++) { | 100 for (var i = 0; i < this.item_.children.length; i++) { |
96 if (this.isFolder_(this.item_.children[i])) | 101 if (this.isFolder_(this.item_.children[i])) |
97 return true; | 102 return true; |
98 } | 103 } |
99 return false; | 104 return false; |
100 }, | 105 }, |
101 | 106 |
| 107 /** @private */ |
| 108 depthChanged_: function() { |
| 109 this.style.setProperty('--node-depth', this.depth.toString()); |
| 110 }, |
| 111 |
| 112 /** |
| 113 * @private |
| 114 * @return {number} |
| 115 */ |
| 116 getChildDepth_: function() { |
| 117 return this.depth + 1; |
| 118 }, |
| 119 |
102 /** | 120 /** |
103 * @param {string} itemId | 121 * @param {string} itemId |
104 * @private | 122 * @private |
105 * @return {boolean} | 123 * @return {boolean} |
106 */ | 124 */ |
107 isFolder_: function(itemId) { | 125 isFolder_: function(itemId) { |
108 return !this.getState().nodes[itemId].url; | 126 return !this.getState().nodes[itemId].url; |
109 } | 127 } |
110 }); | 128 }); |
OLD | NEW |