| 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 * @interface | 5 * @interface |
| 6 */ | 6 */ |
| 7 UI.View = function() {}; | 7 UI.View = function() {}; |
| 8 | 8 |
| 9 UI.View.prototype = { | 9 UI.View.prototype = { |
| 10 /** | 10 /** |
| (...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 UI.ViewManager._ExpandableContainerWidget = class extends UI.VBox { | 457 UI.ViewManager._ExpandableContainerWidget = class extends UI.VBox { |
| 458 /** | 458 /** |
| 459 * @param {!UI.View} view | 459 * @param {!UI.View} view |
| 460 */ | 460 */ |
| 461 constructor(view) { | 461 constructor(view) { |
| 462 super(true); | 462 super(true); |
| 463 this.element.classList.add('flex-none'); | 463 this.element.classList.add('flex-none'); |
| 464 this.registerRequiredCSS('ui/viewContainers.css'); | 464 this.registerRequiredCSS('ui/viewContainers.css'); |
| 465 | 465 |
| 466 this._titleElement = createElementWithClass('div', 'expandable-view-title'); | 466 this._titleElement = createElementWithClass('div', 'expandable-view-title'); |
| 467 this._titleElement.textContent = view.title(); | 467 this._titleExpandIcon = UI.Icon.create('smallicon-triangle-right', 'title-ex
pand-icon'); |
| 468 this._titleElement.appendChild(this._titleExpandIcon); |
| 469 this._titleElement.createTextChild(view.title()); |
| 468 this._titleElement.tabIndex = 0; | 470 this._titleElement.tabIndex = 0; |
| 469 this._titleElement.addEventListener('click', this._toggleExpanded.bind(this)
, false); | 471 this._titleElement.addEventListener('click', this._toggleExpanded.bind(this)
, false); |
| 470 this._titleElement.addEventListener('keydown', this._onTitleKeyDown.bind(thi
s), false); | 472 this._titleElement.addEventListener('keydown', this._onTitleKeyDown.bind(thi
s), false); |
| 471 this.contentElement.insertBefore(this._titleElement, this.contentElement.fir
stChild); | 473 this.contentElement.insertBefore(this._titleElement, this.contentElement.fir
stChild); |
| 472 | 474 |
| 473 this.contentElement.createChild('content'); | 475 this.contentElement.createChild('content'); |
| 474 this._view = view; | 476 this._view = view; |
| 475 view[UI.ViewManager._ExpandableContainerWidget._symbol] = this; | 477 view[UI.ViewManager._ExpandableContainerWidget._symbol] = this; |
| 476 } | 478 } |
| 477 | 479 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 493 return this._materializePromise; | 495 return this._materializePromise; |
| 494 } | 496 } |
| 495 | 497 |
| 496 /** | 498 /** |
| 497 * @return {!Promise} | 499 * @return {!Promise} |
| 498 */ | 500 */ |
| 499 _expand() { | 501 _expand() { |
| 500 if (this._titleElement.classList.contains('expanded')) | 502 if (this._titleElement.classList.contains('expanded')) |
| 501 return this._materialize(); | 503 return this._materialize(); |
| 502 this._titleElement.classList.add('expanded'); | 504 this._titleElement.classList.add('expanded'); |
| 505 this._titleExpandIcon.setIconType('smallicon-triangle-down'); |
| 503 return this._materialize().then(() => this._widget.show(this.element)); | 506 return this._materialize().then(() => this._widget.show(this.element)); |
| 504 } | 507 } |
| 505 | 508 |
| 506 _collapse() { | 509 _collapse() { |
| 507 if (!this._titleElement.classList.contains('expanded')) | 510 if (!this._titleElement.classList.contains('expanded')) |
| 508 return; | 511 return; |
| 509 this._titleElement.classList.remove('expanded'); | 512 this._titleElement.classList.remove('expanded'); |
| 513 this._titleExpandIcon.setIconType('smallicon-triangle-right'); |
| 510 this._materialize().then(() => this._widget.detach()); | 514 this._materialize().then(() => this._widget.detach()); |
| 511 } | 515 } |
| 512 | 516 |
| 513 _toggleExpanded() { | 517 _toggleExpanded() { |
| 514 if (this._titleElement.classList.contains('expanded')) | 518 if (this._titleElement.classList.contains('expanded')) |
| 515 this._collapse(); | 519 this._collapse(); |
| 516 else | 520 else |
| 517 this._expand(); | 521 this._expand(); |
| 518 } | 522 } |
| 519 | 523 |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 857 appendApplicableItems(locationName) { | 861 appendApplicableItems(locationName) { |
| 858 for (var view of this._manager._viewsForLocation(locationName)) | 862 for (var view of this._manager._viewsForLocation(locationName)) |
| 859 this.appendView(view); | 863 this.appendView(view); |
| 860 } | 864 } |
| 861 }; | 865 }; |
| 862 | 866 |
| 863 /** | 867 /** |
| 864 * @type {!UI.ViewManager} | 868 * @type {!UI.ViewManager} |
| 865 */ | 869 */ |
| 866 UI.viewManager; | 870 UI.viewManager; |
| OLD | NEW |