Commit 1855c4ee authored by dpapad's avatar dpapad Committed by Commit Bot

PDF Viewer update: Display "on" state while more menu is open.

 - Emit 'open-changed' events from cr-action-menu and add test.
 - Update viewer-pdf-toolbar-new to leverage these.
 - Change viewer-download-controls to use same approach.
   Previously relied on manually updating a boolean when
   the menu was triggered and when it was closed.

Fixed: 1130107
Change-Id: I9303cd4a6cc4befd5aaf99e7eff9b0b95a8ec5d0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2421184Reviewed-by: default avatarJohn Lee <johntlee@chromium.org>
Commit-Queue: dpapad <dpapad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#808914}
parent 50b49941
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
on-click="onDownloadClick_" aria-label="$i18n{tooltipDownload}" on-click="onDownloadClick_" aria-label="$i18n{tooltipDownload}"
aria-haspopup$="[[downloadHasPopup_]]" aria-haspopup$="[[downloadHasPopup_]]"
title="$i18n{tooltipDownload}"></cr-icon-button> title="$i18n{tooltipDownload}"></cr-icon-button>
<cr-action-menu id="menu" on-close="onMenuClose_"> <cr-action-menu id="menu" on-open-changed="onOpenChanged_">
<button class="dropdown-item" on-click="onDownloadEditedClick_"> <button class="dropdown-item" on-click="onDownloadEditedClick_">
$i18n{downloadEdited} $i18n{downloadEdited}
</button> </button>
......
...@@ -83,9 +83,12 @@ export class ViewerDownloadControlsElement extends PolymerElement { ...@@ -83,9 +83,12 @@ export class ViewerDownloadControlsElement extends PolymerElement {
this.getDownloadMenu_().close(); this.getDownloadMenu_().close();
} }
/** @private */ /**
onMenuClose_() { * @param {!CustomEvent<!{value: boolean}>} e
this.menuOpen_ = false; * @private
*/
onOpenChanged_(e) {
this.menuOpen_ = e.detail.value;
} }
/** /**
...@@ -117,7 +120,6 @@ export class ViewerDownloadControlsElement extends PolymerElement { ...@@ -117,7 +120,6 @@ export class ViewerDownloadControlsElement extends PolymerElement {
/** @private */ /** @private */
showDownloadMenu_() { showDownloadMenu_() {
this.menuOpen_ = true;
this.getDownloadMenu_().showAt(this.$.download, { this.getDownloadMenu_().showAt(this.$.download, {
anchorAlignmentX: AnchorAlignment.CENTER, anchorAlignmentX: AnchorAlignment.CENTER,
}); });
......
...@@ -10,6 +10,11 @@ ...@@ -10,6 +10,11 @@
position: relative; position: relative;
} }
:host([more-menu-open_]) #more {
background-color: var(--active-button-bg);
border-radius: 50%;
}
#toolbar { #toolbar {
align-items: center; align-items: center;
background-color: var(--viewer-pdf-toolbar-background-color); background-color: var(--viewer-pdf-toolbar-background-color);
...@@ -234,7 +239,7 @@ ...@@ -234,7 +239,7 @@
<paper-progress id="progress" value="[[loadProgress]]" hidden="[[!loading_]]"> <paper-progress id="progress" value="[[loadProgress]]" hidden="[[!loading_]]">
</paper-progress> </paper-progress>
<cr-action-menu> <cr-action-menu on-open-changed="onMoreOpenChanged_">
<button id="two-page-view-button" <button id="two-page-view-button"
class="dropdown-item" on-click="toggleTwoPageViewClick_" role="checkbox" class="dropdown-item" on-click="toggleTwoPageViewClick_" role="checkbox"
<if expr="chromeos"> <if expr="chromeos">
......
...@@ -72,6 +72,11 @@ export class ViewerPdfToolbarNewElement extends PolymerElement { ...@@ -72,6 +72,11 @@ export class ViewerPdfToolbarNewElement extends PolymerElement {
observer: 'viewportZoomChanged_', observer: 'viewportZoomChanged_',
}, },
moreMenuOpen_: {
type: Boolean,
reflectToAttribute: true,
},
twoUpViewEnabled_: Boolean, twoUpViewEnabled_: Boolean,
fittingType_: Number, fittingType_: Number,
...@@ -105,6 +110,9 @@ export class ViewerPdfToolbarNewElement extends PolymerElement { ...@@ -105,6 +110,9 @@ export class ViewerPdfToolbarNewElement extends PolymerElement {
/** @private {boolean} */ /** @private {boolean} */
this.displayAnnotations_ = true; this.displayAnnotations_ = true;
/** @private {boolean} */
this.moreMenuOpen_ = false;
/** @private {boolean} */ /** @private {boolean} */
this.twoUpViewEnabled_ = false; this.twoUpViewEnabled_ = false;
...@@ -321,6 +329,14 @@ export class ViewerPdfToolbarNewElement extends PolymerElement { ...@@ -321,6 +329,14 @@ export class ViewerPdfToolbarNewElement extends PolymerElement {
}); });
} }
/**
* @param {!CustomEvent<!{value: boolean}>} e
* @private
*/
onMoreOpenChanged_(e) {
this.moreMenuOpen_ = e.detail.value;
}
// <if expr="chromeos"> // <if expr="chromeos">
toggleAnnotation() { toggleAnnotation() {
const newAnnotationMode = !this.annotationMode; const newAnnotationMode = !this.annotationMode;
......
...@@ -85,6 +85,18 @@ suite('CrActionMenu', function() { ...@@ -85,6 +85,18 @@ suite('CrActionMenu', function() {
MockInteractions.keyDownOn(menu, 0, [], 'Enter'); MockInteractions.keyDownOn(menu, 0, [], 'Enter');
} }
test('open-changed event fires', async function() {
let whenFired = test_util.eventToPromise('open-changed', menu);
menu.showAt(dots);
let event = await whenFired;
assertTrue(event.detail.value);
whenFired = test_util.eventToPromise('open-changed', menu);
menu.close();
event = await whenFired;
assertFalse(event.detail.value);
});
test('close event bubbles', function() { test('close event bubbles', function() {
menu.showAt(dots); menu.showAt(dots);
const whenFired = test_util.eventToPromise('close', menu); const whenFired = test_util.eventToPromise('close', menu);
......
...@@ -162,6 +162,7 @@ Polymer({ ...@@ -162,6 +162,7 @@ Polymer({
open: { open: {
type: Boolean, type: Boolean,
notify: true,
value: false, value: false,
}, },
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment