| 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 }, | 53 }, |
| 54 | 54 |
| 55 /** | 55 /** |
| 56 * @private | 56 * @private |
| 57 * @return {string} | 57 * @return {string} |
| 58 */ | 58 */ |
| 59 getFolderIcon_: function() { | 59 getFolderIcon_: function() { |
| 60 return this.isSelectedFolder_ ? 'bookmarks:folder-open' : 'cr:folder'; | 60 return this.isSelectedFolder_ ? 'bookmarks:folder-open' : 'cr:folder'; |
| 61 }, | 61 }, |
| 62 | 62 |
| 63 /** | |
| 64 * @private | |
| 65 * @return {string} | |
| 66 */ | |
| 67 getArrowIcon_: function() { | |
| 68 return this.isClosed_ ? 'cr:arrow-drop-down' : 'cr:arrow-drop-up'; | |
| 69 }, | |
| 70 | |
| 71 /** @private */ | 63 /** @private */ |
| 72 selectFolder_: function() { | 64 selectFolder_: function() { |
| 73 this.dispatch(bookmarks.actions.selectFolder(this.item_.id)); | 65 this.dispatch(bookmarks.actions.selectFolder(this.item_.id)); |
| 74 }, | 66 }, |
| 75 | 67 |
| 76 /** | 68 /** |
| 77 * Occurs when the drop down arrow is tapped. | 69 * Occurs when the drop down arrow is tapped. |
| 78 * @private | 70 * @private |
| 71 * @param {!Event} e |
| 79 */ | 72 */ |
| 80 toggleFolder_: function() { | 73 toggleFolder_: function(e) { |
| 81 this.dispatch( | 74 this.dispatch( |
| 82 bookmarks.actions.changeFolderOpen(this.item_.id, this.isClosed_)); | 75 bookmarks.actions.changeFolderOpen(this.item_.id, this.isClosed_)); |
| 76 e.stopPropagation(); |
| 83 }, | 77 }, |
| 84 | 78 |
| 85 /** | 79 /** |
| 86 * @private | 80 * @private |
| 87 * @param {string} itemId | 81 * @param {string} itemId |
| 88 * @param {string} selectedFolder | 82 * @param {string} selectedFolder |
| 89 * @return {boolean} | 83 * @return {boolean} |
| 90 */ | 84 */ |
| 91 computeIsSelected_: function(itemId, selectedFolder) { | 85 computeIsSelected_: function(itemId, selectedFolder) { |
| 92 return itemId == selectedFolder; | 86 return itemId == selectedFolder; |
| 93 }, | 87 }, |
| 94 | 88 |
| 95 /** | 89 /** |
| 96 * @private | 90 * @private |
| 97 * @return {boolean} | 91 * @return {boolean} |
| 98 */ | 92 */ |
| 99 hasChildFolder_: function() { | 93 hasChildFolder_: function() { |
| 100 for (var i = 0; i < this.item_.children.length; i++) { | 94 for (var i = 0; i < this.item_.children.length; i++) { |
| 101 if (this.isFolder_(this.item_.children[i])) | 95 if (this.isFolder_(this.item_.children[i])) |
| 102 return true; | 96 return true; |
| 103 } | 97 } |
| 104 return false; | 98 return false; |
| 105 }, | 99 }, |
| 106 | 100 |
| 107 /** @private */ | 101 /** @private */ |
| 108 depthChanged_: function() { | 102 depthChanged_: function() { |
| 109 this.style.setProperty('--node-depth', this.depth.toString()); | 103 this.style.setProperty('--node-depth', String(this.depth)); |
| 110 }, | 104 }, |
| 111 | 105 |
| 112 /** | 106 /** |
| 113 * @private | 107 * @private |
| 114 * @return {number} | 108 * @return {number} |
| 115 */ | 109 */ |
| 116 getChildDepth_: function() { | 110 getChildDepth_: function() { |
| 117 return this.depth + 1; | 111 return this.depth + 1; |
| 118 }, | 112 }, |
| 119 | 113 |
| 120 /** | 114 /** |
| 121 * @param {string} itemId | 115 * @param {string} itemId |
| 122 * @private | 116 * @private |
| 123 * @return {boolean} | 117 * @return {boolean} |
| 124 */ | 118 */ |
| 125 isFolder_: function(itemId) { | 119 isFolder_: function(itemId) { |
| 126 return !this.getState().nodes[itemId].url; | 120 return !this.getState().nodes[itemId].url; |
| 127 } | 121 } |
| 128 }); | 122 }); |
| OLD | NEW |