Commit 5938395e authored by yawano's avatar yawano Committed by Commit bot

Disable edit and print button when there is no selection.

BUG=421767
TEST=Open Gallery.app; In slide mode, delete all images by clicking bottom-right delete button.

Review URL: https://codereview.chromium.org/638383002

Cr-Commit-Position: refs/heads/master@{#299057}
parent 4e342594
...@@ -197,12 +197,12 @@ SlideMode.prototype.initDom_ = function() { ...@@ -197,12 +197,12 @@ SlideMode.prototype.initDom_ = function() {
this.editButton_ = this.toolbar_.querySelector('button.edit'); this.editButton_ = this.toolbar_.querySelector('button.edit');
this.editButton_.title = this.displayStringFunction_('GALLERY_EDIT'); this.editButton_.title = this.displayStringFunction_('GALLERY_EDIT');
this.editButton_.setAttribute('disabled', ''); // Disabled by default. this.editButton_.disabled = true; // Disabled by default.
this.editButton_.addEventListener('click', this.toggleEditor.bind(this)); this.editButton_.addEventListener('click', this.toggleEditor.bind(this));
this.printButton_ = this.toolbar_.querySelector('button.print'); this.printButton_ = this.toolbar_.querySelector('button.print');
this.printButton_.title = this.displayStringFunction_('GALLERY_PRINT'); this.printButton_.title = this.displayStringFunction_('GALLERY_PRINT');
this.printButton_.setAttribute('disabled', ''); // Disabled by default. this.printButton_.disabled = true; // Disabled by default.
this.printButton_.addEventListener('click', this.print_.bind(this)); this.printButton_.addEventListener('click', this.print_.bind(this));
this.editBarSpacer_ = this.toolbar_.querySelector('.edit-bar-spacer'); this.editBarSpacer_ = this.toolbar_.querySelector('.edit-bar-spacer');
...@@ -354,8 +354,8 @@ SlideMode.prototype.leave = function(zoomToRect, callback) { ...@@ -354,8 +354,8 @@ SlideMode.prototype.leave = function(zoomToRect, callback) {
} }
// Disable the slide-mode only buttons when leaving. // Disable the slide-mode only buttons when leaving.
this.editButton_.setAttribute('disabled', ''); this.editButton_.disabled = true;
this.printButton_.setAttribute('disabled', ''); this.printButton_.disabled = true;
// Disable touch operation. // Disable touch operation.
this.touchHandlers_.enabled = false; this.touchHandlers_.enabled = false;
...@@ -435,7 +435,7 @@ SlideMode.prototype.toggleFullScreen_ = function() { ...@@ -435,7 +435,7 @@ SlideMode.prototype.toggleFullScreen_ = function() {
*/ */
SlideMode.prototype.onSelection_ = function() { SlideMode.prototype.onSelection_ = function() {
if (this.selectionModel_.selectedIndexes.length === 0) if (this.selectionModel_.selectedIndexes.length === 0)
return; // Temporary empty selection. return; // Ignore temporary empty selection.
// Forget the saved selection if the user changed the selection manually. // Forget the saved selection if the user changed the selection manually.
if (!this.isSlideshowOn_()) if (!this.isSlideshowOn_())
...@@ -581,9 +581,12 @@ SlideMode.prototype.onSplice_ = function(event) { ...@@ -581,9 +581,12 @@ SlideMode.prototype.onSplice_ = function(event) {
// Removed item is the rightmost, but there are more items. // Removed item is the rightmost, but there are more items.
this.select(event.index - 1); // Select the new last index. this.select(event.index - 1); // Select the new last index.
} else { } else {
// No items left. Unload the image and show the banner. // No items left. Unload the image, disable edit and print button, and
// show the banner.
this.commitItem_(function() { this.commitItem_(function() {
this.unloadImage_(); this.unloadImage_();
this.printButton_.disabled = true;
this.editButton_.disabled = true;
this.errorBanner_.show('GALLERY_NO_IMAGES'); this.errorBanner_.show('GALLERY_NO_IMAGES');
}.bind(this)); }.bind(this));
} }
...@@ -717,11 +720,11 @@ SlideMode.prototype.loadItem_ = function( ...@@ -717,11 +720,11 @@ SlideMode.prototype.loadItem_ = function(
// Enable or disable buttons for editing and printing. // Enable or disable buttons for editing and printing.
if (error) { if (error) {
this.editButton_.setAttribute('disabled', ''); this.editButton_.disabled = true;
this.printButton_.setAttribute('disabled', ''); this.printButton_.disabled = true;
} else { } else {
this.editButton_.removeAttribute('disabled'); this.editButton_.disabled = false;
this.printButton_.removeAttribute('disabled'); this.printButton_.disabled = false;
} }
// For once edited image, disallow the 'overwrite' setting change. // For once edited image, disallow the 'overwrite' setting change.
...@@ -856,12 +859,12 @@ SlideMode.prototype.onKeyDown = function(event) { ...@@ -856,12 +859,12 @@ SlideMode.prototype.onKeyDown = function(event) {
switch (keyID) { switch (keyID) {
case 'Ctrl-U+0050': // Ctrl+'p' prints the current image. case 'Ctrl-U+0050': // Ctrl+'p' prints the current image.
if (!this.printButton_.hasAttribute('disabled')) if (!this.printButton_.disabled)
this.print_(); this.print_();
break; break;
case 'U+0045': // 'e' toggles the editor. case 'U+0045': // 'e' toggles the editor.
if (!this.editButton_.hasAttribute('disabled')) if (!this.editButton_.disabled)
this.toggleEditor(event); this.toggleEditor(event);
break; break;
......
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