| 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 ], |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 | 31 |
| 32 /** @private */ | 32 /** @private */ |
| 33 isSelectedFolder_: { | 33 isSelectedFolder_: { |
| 34 type: Boolean, | 34 type: Boolean, |
| 35 value: false, | 35 value: false, |
| 36 reflectToAttribute: true, | 36 reflectToAttribute: true, |
| 37 computed: 'computeIsSelected_(itemId, selectedFolder_)' | 37 computed: 'computeIsSelected_(itemId, selectedFolder_)' |
| 38 }, | 38 }, |
| 39 }, | 39 }, |
| 40 | 40 |
| 41 /** @override */ |
| 41 attached: function() { | 42 attached: function() { |
| 42 this.watch('item_', function(state) { | 43 this.watch('item_', function(state) { |
| 43 return state.nodes[this.itemId]; | 44 return state.nodes[this.itemId]; |
| 44 }.bind(this)); | 45 }.bind(this)); |
| 45 this.watch('isClosed_', function(state) { | 46 this.watch('isClosed_', function(state) { |
| 46 return !!state.closedFolders[this.itemId]; | 47 return !!state.closedFolders[this.itemId]; |
| 47 }.bind(this)); | 48 }.bind(this)); |
| 48 this.watch('selectedFolder_', function(state) { | 49 this.watch('selectedFolder_', function(state) { |
| 49 return state.selectedFolder; | 50 return state.selectedFolder; |
| 50 }); | 51 }); |
| 51 | 52 |
| 52 this.updateFromStore(); | 53 this.updateFromStore(); |
| 53 }, | 54 }, |
| 54 | 55 |
| 56 /** @return {HTMLElement} */ |
| 57 getDropTarget: function() { |
| 58 return this.$.container; |
| 59 }, |
| 60 |
| 55 /** | 61 /** |
| 56 * @private | 62 * @private |
| 57 * @return {string} | 63 * @return {string} |
| 58 */ | 64 */ |
| 59 getFolderIcon_: function() { | 65 getFolderIcon_: function() { |
| 60 return this.isSelectedFolder_ ? 'bookmarks:folder-open' : 'cr:folder'; | 66 return this.isSelectedFolder_ ? 'bookmarks:folder-open' : 'cr:folder'; |
| 61 }, | 67 }, |
| 62 | 68 |
| 63 /** @private */ | 69 /** @private */ |
| 64 selectFolder_: function() { | 70 selectFolder_: function() { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 84 */ | 90 */ |
| 85 computeIsSelected_: function(itemId, selectedFolder) { | 91 computeIsSelected_: function(itemId, selectedFolder) { |
| 86 return itemId == selectedFolder; | 92 return itemId == selectedFolder; |
| 87 }, | 93 }, |
| 88 | 94 |
| 89 /** | 95 /** |
| 90 * @private | 96 * @private |
| 91 * @return {boolean} | 97 * @return {boolean} |
| 92 */ | 98 */ |
| 93 hasChildFolder_: function() { | 99 hasChildFolder_: function() { |
| 94 for (var i = 0; i < this.item_.children.length; i++) { | 100 return bookmarks.util.hasChildFolders(this.itemId, this.getState().nodes); |
| 95 if (this.isFolder_(this.item_.children[i])) | |
| 96 return true; | |
| 97 } | |
| 98 return false; | |
| 99 }, | 101 }, |
| 100 | 102 |
| 101 /** @private */ | 103 /** @private */ |
| 102 depthChanged_: function() { | 104 depthChanged_: function() { |
| 103 this.style.setProperty('--node-depth', String(this.depth)); | 105 this.style.setProperty('--node-depth', String(this.depth)); |
| 104 }, | 106 }, |
| 105 | 107 |
| 106 /** | 108 /** |
| 107 * @private | 109 * @private |
| 108 * @return {number} | 110 * @return {number} |
| 109 */ | 111 */ |
| 110 getChildDepth_: function() { | 112 getChildDepth_: function() { |
| 111 return this.depth + 1; | 113 return this.depth + 1; |
| 112 }, | 114 }, |
| 113 | 115 |
| 114 /** | 116 /** |
| 115 * @param {string} itemId | 117 * @param {string} itemId |
| 116 * @private | 118 * @private |
| 117 * @return {boolean} | 119 * @return {boolean} |
| 118 */ | 120 */ |
| 119 isFolder_: function(itemId) { | 121 isFolder_: function(itemId) { |
| 120 return !this.getState().nodes[itemId].url; | 122 return !this.getState().nodes[itemId].url; |
| 121 } | 123 }, |
| 124 |
| 125 /** |
| 126 * @private |
| 127 * @return {boolean} |
| 128 */ |
| 129 isRootFolder_: function() { |
| 130 return this.depth == 0; |
| 131 }, |
| 122 }); | 132 }); |
| OLD | NEW |