Chromium Code Reviews| 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 isClosed: Boolean, | 26 isClosed: Boolean, |
| 22 | 27 |
| 23 selectedFolder: String, | 28 selectedFolder: String, |
| 24 | 29 |
| 25 isSelectedFolder: { | 30 isSelectedFolder: { |
| 26 type: Boolean, | 31 type: Boolean, |
| 27 value: false, | 32 value: false, |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 67 | 72 |
| 68 /** | 73 /** |
| 69 * Occurs when the drop down arrow is tapped. | 74 * Occurs when the drop down arrow is tapped. |
| 70 * @private | 75 * @private |
| 71 */ | 76 */ |
| 72 toggleFolder_: function() { | 77 toggleFolder_: function() { |
| 73 this.dispatch( | 78 this.dispatch( |
| 74 bookmarks.actions.changeFolderOpen(this.item.id, this.isClosed)); | 79 bookmarks.actions.changeFolderOpen(this.item.id, this.isClosed)); |
| 75 }, | 80 }, |
| 76 | 81 |
| 82 /** | |
| 83 * @private | |
| 84 * @param {string} itemId | |
| 85 * @param {string} selectedFolder | |
| 86 * @return {boolean} | |
| 87 */ | |
| 77 computeIsSelected_: function(itemId, selectedFolder) { | 88 computeIsSelected_: function(itemId, selectedFolder) { |
| 78 return itemId == selectedFolder; | 89 return itemId == selectedFolder; |
| 79 }, | 90 }, |
| 80 | 91 |
| 81 /** | 92 /** |
| 82 * @private | 93 * @private |
| 83 * @return {boolean} | 94 * @return {boolean} |
| 84 */ | 95 */ |
| 85 hasChildFolder_: function() { | 96 hasChildFolder_: function() { |
| 86 for (var i = 0; i < this.item.children.length; i++) { | 97 for (var i = 0; i < this.item.children.length; i++) { |
| 87 var child = this.getState().nodes[this.item.children[i]]; | 98 var child = this.getState().nodes[this.item.children[i]]; |
| 88 if (!child.url) | 99 if (!child.url) |
| 89 return true; | 100 return true; |
| 90 } | 101 } |
| 91 return false; | 102 return false; |
| 92 }, | 103 }, |
| 93 | 104 |
| 105 /** @private */ | |
| 106 depthChanged_: function() { | |
| 107 this.$['folder-label'].style.paddingLeft = | |
|
tsergeant
2017/03/07 23:32:50
I wonder if there's any way we can do this with cu
calamity
2017/03/08 06:52:45
Magic installed.
| |
| 108 `calc(${this.depth} * var(--padding-left-per-depth))`; | |
| 109 }, | |
| 110 | |
| 111 /** | |
| 112 * @private | |
| 113 * @return {number} | |
| 114 */ | |
| 115 getChildDepth_: function() { | |
| 116 return this.depth + 1; | |
| 117 }, | |
| 118 | |
| 94 /** | 119 /** |
| 95 * @param {string} itemId | 120 * @param {string} itemId |
| 96 * @private | 121 * @private |
| 97 * @return {boolean} | 122 * @return {boolean} |
| 98 */ | 123 */ |
| 99 isFolder_: function(itemId) { | 124 isFolder_: function(itemId) { |
| 100 return !this.getState().nodes[itemId].url; | 125 return !this.getState().nodes[itemId].url; |
| 101 } | 126 } |
| 102 }); | 127 }); |
| OLD | NEW |