Commit 401f9d3d authored by hirono@chromium.org's avatar hirono@chromium.org

Fixed gear menu navigation using keyboard.

Removed CSS codes that hides gear menu items but is not handled cr.ui.Menu class.
New codes hides gear menu items by using the 'hidden' attribute.

BUG=175662
TEST=Followed the steps written in bug report that reproduce the problem

Review URL: https://chromiumcodereview.appspot.com/13779006

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@193363 0039d316-1c4b-4281-b951-d872f2087c98
parent 394bde71
...@@ -1687,14 +1687,6 @@ body[type='full-page'] [visibleif]:not([visibleif~='full-page']) { ...@@ -1687,14 +1687,6 @@ body[type='full-page'] [visibleif]:not([visibleif~='full-page']) {
display: none; display: none;
} }
body:not([ctrl-pressing]) [required_attr='ctrl-pressing'] {
display: none;
}
body:not([drive]) [required_drive] {
display: none;
}
#gear-button::before { #gear-button::before {
background-image: url('../images/files/ui/settings.svg'); background-image: url('../images/files/ui/settings.svg');
background-position: 20px center; background-position: 20px center;
......
...@@ -63,6 +63,7 @@ function FileManager(dialogDom) { ...@@ -63,6 +63,7 @@ function FileManager(dialogDom) {
DialogType.FULL_PAGE]); DialogType.FULL_PAGE]);
this.selectionHandler_ = null; this.selectionHandler_ = null;
this.ctrlKeyPressed_ = false;
this.metadataCache_ = MetadataCache.createFull(); this.metadataCache_ = MetadataCache.createFull();
this.volumeManager_ = VolumeManager.getInstance(); this.volumeManager_ = VolumeManager.getInstance();
...@@ -553,6 +554,9 @@ DialogType.isModal = function(type) { ...@@ -553,6 +554,9 @@ DialogType.isModal = function(type) {
false /* Without loading caption. */)); false /* Without loading caption. */));
cr.ui.decorate(this.gearButton_, cr.ui.MenuButton); cr.ui.decorate(this.gearButton_, cr.ui.MenuButton);
this.dialogDom_.querySelector('#gear-menu').menuItemSelector =
'menuitem, hr';
this.syncButton.checkable = true; this.syncButton.checkable = true;
this.hostedButton.checkable = true; this.hostedButton.checkable = true;
}; };
...@@ -1631,6 +1635,13 @@ DialogType.isModal = function(type) { ...@@ -1631,6 +1635,13 @@ DialogType.isModal = function(type) {
this.directoryModel_.getCurrentRootType() === RootType.DRIVE_OFFLINE; this.directoryModel_.getCurrentRootType() === RootType.DRIVE_OFFLINE;
}; };
/**
* @return {boolean} True if the ctrl key is pressed now.
*/
FileManager.prototype.isCtrlKeyPressed = function() {
return this.ctrlKeyPressed_;
};
/** /**
* @return {boolean} True if the "Available offline" column should be shown in * @return {boolean} True if the "Available offline" column should be shown in
* the table layout. * the table layout.
...@@ -2050,6 +2061,8 @@ DialogType.isModal = function(type) { ...@@ -2050,6 +2061,8 @@ DialogType.isModal = function(type) {
FileManager.prototype.updateGearMenu_ = function() { FileManager.prototype.updateGearMenu_ = function() {
this.syncButton.hidden = !this.isOnDrive(); this.syncButton.hidden = !this.isOnDrive();
this.hostedButton.hidden = !this.isOnDrive(); this.hostedButton.hidden = !this.isOnDrive();
this.document_.getElementById('drive-separator').hidden =
!this.isOnDrive();
// If volume has changed, then fetch remaining space data. // If volume has changed, then fetch remaining space data.
if (this.previousRootUrl_ != this.directoryModel_.getCurrentRootUrl()) if (this.previousRootUrl_ != this.directoryModel_.getCurrentRootUrl())
...@@ -2530,7 +2543,7 @@ DialogType.isModal = function(type) { ...@@ -2530,7 +2543,7 @@ DialogType.isModal = function(type) {
switch (util.getKeyModifiers(event) + event.keyCode) { switch (util.getKeyModifiers(event) + event.keyCode) {
case 'Ctrl-17': // Ctrl => Show hidden setting case 'Ctrl-17': // Ctrl => Show hidden setting
this.dialogDom_.setAttribute('ctrl-pressing', 'true'); this.setCtrlKeyPressed_(true);
return; return;
case 'Ctrl-190': // Ctrl-. => Toggle filter files. case 'Ctrl-190': // Ctrl-. => Toggle filter files.
...@@ -2575,7 +2588,7 @@ DialogType.isModal = function(type) { ...@@ -2575,7 +2588,7 @@ DialogType.isModal = function(type) {
switch (util.getKeyModifiers(event) + event.keyCode) { switch (util.getKeyModifiers(event) + event.keyCode) {
case '17': // Ctrl => Hide hidden setting case '17': // Ctrl => Hide hidden setting
this.dialogDom_.removeAttribute('ctrl-pressing'); this.setCtrlKeyPressed_(false);
return; return;
} }
}; };
...@@ -3450,4 +3463,15 @@ DialogType.isModal = function(type) { ...@@ -3450,4 +3463,15 @@ DialogType.isModal = function(type) {
callback(prefs); callback(prefs);
}.bind(this)); }.bind(this));
}; };
/**
* Set the flag expressing whether the ctrl key is pressed or not.
* @param {boolean} flag New value of the flag
* @private
*/
FileManager.prototype.setCtrlKeyPressed_ = function(flag) {
this.ctrlKeyPressed_ = flag;
this.document_.querySelector('#drive-clear-local-cache').canExecuteChange();
this.document_.querySelector('#drive-reload').canExecuteChange();
};
})(); })();
...@@ -52,6 +52,17 @@ CommandUtil.canExecuteVisibleOnDriveOnly = function(event, fileManager) { ...@@ -52,6 +52,17 @@ CommandUtil.canExecuteVisibleOnDriveOnly = function(event, fileManager) {
event.command.setHidden(!fileManager.isOnDrive()); event.command.setHidden(!fileManager.isOnDrive());
}; };
/**
* Checks if command should be visible on drive with pressing ctrl key.
* @param {Event} event Command event to mark.
* @param {FileManager} fileManager FileManager to use.
*/
CommandUtil.canExecuteVisibleOnDriveWithCtrlKeyOnly =
function(event, fileManager) {
event.canExecute = fileManager.isOnDrive() && fileManager.isCtrlKeyPressed();
event.command.setHidden(!event.canExecute);
};
/** /**
* Returns a single selected/passed entry or null. * Returns a single selected/passed entry or null.
* @param {Event} event Command event. * @param {Event} event Command event.
...@@ -330,7 +341,7 @@ Commands.driveClearCacheCommand = { ...@@ -330,7 +341,7 @@ Commands.driveClearCacheCommand = {
execute: function() { execute: function() {
chrome.fileBrowserPrivate.clearDriveCache(); chrome.fileBrowserPrivate.clearDriveCache();
}, },
canExecute: CommandUtil.canExecuteVisibleOnDriveOnly canExecute: CommandUtil.canExecuteVisibleOnDriveWithCtrlKeyOnly
}; };
/** /**
...@@ -340,7 +351,7 @@ Commands.driveReloadCommand = { ...@@ -340,7 +351,7 @@ Commands.driveReloadCommand = {
execute: function() { execute: function() {
chrome.fileBrowserPrivate.reloadDrive(); chrome.fileBrowserPrivate.reloadDrive();
}, },
canExecute: CommandUtil.canExecuteVisibleOnDriveOnly canExecute: CommandUtil.canExecuteVisibleOnDriveWithCtrlKeyOnly
}; };
/** /**
......
...@@ -185,17 +185,15 @@ ...@@ -185,17 +185,15 @@
<menuitem command="#newwindow"></menuitem> <menuitem command="#newwindow"></menuitem>
<menuitem command="#newfolder"></menuitem> <menuitem command="#newfolder"></menuitem>
<menuitem command="#change-default-app"></menuitem> <menuitem command="#change-default-app"></menuitem>
<hr> <hr id="drive-separator">
<menuitem id="drive-sync-settings" <menuitem id="drive-sync-settings"
i18n-content=DRIVE_MOBILE_CONNECTION_OPTION></menuitem> i18n-content=DRIVE_MOBILE_CONNECTION_OPTION></menuitem>
<menuitem id="drive-hosted-settings" <menuitem id="drive-hosted-settings"
i18n-content=DRIVE_SHOW_HOSTED_FILES_OPTION></menuitem> i18n-content=DRIVE_SHOW_HOSTED_FILES_OPTION></menuitem>
<hr required_attr="ctrl-pressing" required_drive> <hr command="#drive-clear-local-cache">
<menuitem required_attr="ctrl-pressing" required_drive <menuitem command="#drive-clear-local-cache"></menuitem>
command="#drive-clear-local-cache"></menuitem> <menuitem command="#drive-reload"></menuitem>
<menuitem required_attr="ctrl-pressing" required_drive <hr>
command="#drive-reload"></menuitem>
<hr required_drive>
<div id="volume-space-info" disabled> <div id="volume-space-info" disabled>
<span id="volume-space-info-label"></span> <span id="volume-space-info-label"></span>
<div><div id="volume-space-info-bar"></div></div> <div><div id="volume-space-info-bar"></div></div>
......
...@@ -185,17 +185,15 @@ ...@@ -185,17 +185,15 @@
<menuitem command="#newwindow"></menuitem> <menuitem command="#newwindow"></menuitem>
<menuitem command="#newfolder"></menuitem> <menuitem command="#newfolder"></menuitem>
<menuitem command="#change-default-app"></menuitem> <menuitem command="#change-default-app"></menuitem>
<hr> <hr id="drive-separator">
<menuitem id="drive-sync-settings" <menuitem id="drive-sync-settings"
i18n-content=DRIVE_MOBILE_CONNECTION_OPTION></menuitem> i18n-content=DRIVE_MOBILE_CONNECTION_OPTION></menuitem>
<menuitem id="drive-hosted-settings" <menuitem id="drive-hosted-settings"
i18n-content=DRIVE_SHOW_HOSTED_FILES_OPTION></menuitem> i18n-content=DRIVE_SHOW_HOSTED_FILES_OPTION></menuitem>
<hr required_attr="ctrl-pressing" required_drive> <hr command="#drive-clear-local-cache">
<menuitem required_attr="ctrl-pressing" required_drive <menuitem command="#drive-clear-local-cache"></menuitem>
command="#drive-clear-local-cache"></menuitem> <menuitem command="#drive-reload"></menuitem>
<menuitem required_attr="ctrl-pressing" required_drive <hr>
command="#drive-reload"></menuitem>
<hr required_drive>
<div id="volume-space-info" disabled> <div id="volume-space-info" disabled>
<span id="volume-space-info-label"></span> <span id="volume-space-info-label"></span>
<div><div id="volume-space-info-bar"></div></div> <div><div id="volume-space-info-bar"></div></div>
......
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