OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 'use strict'; | 5 'use strict'; |
6 | 6 |
7 /** | 7 /** |
8 * A navigation list model. This model combines the 2 lists. | 8 * A navigation list model. This model combines the 2 lists. |
9 * @param {cr.ui.ArrayDataModel} volumesList The first list of the model. | 9 * @param {cr.ui.ArrayDataModel} volumesList The first list of the model. |
10 * @param {cr.ui.ArrayDataModel} pinnedList The second list of the model. | 10 * @param {cr.ui.ArrayDataModel} pinnedList The second list of the model. |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 // role for better accessibility on ChromeOS. | 276 // role for better accessibility on ChromeOS. |
277 this.setAttribute('role', 'listbox'); | 277 this.setAttribute('role', 'listbox'); |
278 | 278 |
279 var self = this; | 279 var self = this; |
280 this.itemConstructor = function(path) { | 280 this.itemConstructor = function(path) { |
281 return self.renderRoot_(path); | 281 return self.renderRoot_(path); |
282 }; | 282 }; |
283 }; | 283 }; |
284 | 284 |
285 /** | 285 /** |
| 286 * This overrides Node.removeChild(). |
| 287 * Instead of just removing the given child, this method adds a fade-out |
| 288 * animation and removes the child after animation completes. |
| 289 * |
| 290 * @param {NavigationListItem} item List item to be removed. |
| 291 * @override |
| 292 */ |
| 293 NavigationList.prototype.removeChild = function(item) { |
| 294 var removeElement = function(e) { |
| 295 // Must keep the animation name 'fadeOut' in sync with the css. |
| 296 if (e.animationName == 'fadeOut') |
| 297 // Checks if the element is still alive on the DOM tree. |
| 298 if (item.parentElement && item.parentElement == this) |
| 299 Node.prototype.removeChild.call(this, item); |
| 300 }.bind(this); |
| 301 |
| 302 item.addEventListener('webkitAnimationEnd', removeElement, false); |
| 303 // Must keep the class name 'fadeout' in sync with the css. |
| 304 item.classList.add('fadeout'); |
| 305 }; |
| 306 |
| 307 /** |
286 * Creates an element of a navigation list. This method is called from | 308 * Creates an element of a navigation list. This method is called from |
287 * cr.ui.List internally. | 309 * cr.ui.List internally. |
288 * @param {string} path Path of the directory to be rendered. | 310 * @param {string} path Path of the directory to be rendered. |
289 * @return {NavigationListItem} Rendered element. | 311 * @return {NavigationListItem} Rendered element. |
290 * @private | 312 * @private |
291 */ | 313 */ |
292 NavigationList.prototype.renderRoot_ = function(path) { | 314 NavigationList.prototype.renderRoot_ = function(path) { |
293 var item = new NavigationListItem(); | 315 var item = new NavigationListItem(); |
294 item.setPath(path); | 316 item.setPath(path); |
295 | 317 |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 var itemPath = this.dataModel.item(i); | 469 var itemPath = this.dataModel.item(i); |
448 if (PathUtil.getRootPath(itemPath) == newRootPath) { | 470 if (PathUtil.getRootPath(itemPath) == newRootPath) { |
449 // Not to invoke the handler of this instance, sets the guard. | 471 // Not to invoke the handler of this instance, sets the guard. |
450 this.dontHandleSelectionEvent_ = true; | 472 this.dontHandleSelectionEvent_ = true; |
451 this.selectionModel.selectedIndex = i; | 473 this.selectionModel.selectedIndex = i; |
452 this.dontHandleSelectionEvent_ = false; | 474 this.dontHandleSelectionEvent_ = false; |
453 return; | 475 return; |
454 } | 476 } |
455 } | 477 } |
456 }; | 478 }; |
OLD | NEW |