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 * This variable is checked in SelectFileDialogExtensionBrowserTest. | 8 * This variable is checked in SelectFileDialogExtensionBrowserTest. |
9 * @type {number} | 9 * @type {number} |
10 */ | 10 */ |
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
540 this.textContextMenu_ = | 540 this.textContextMenu_ = |
541 this.dialogDom_.querySelector('#text-context-menu'); | 541 this.dialogDom_.querySelector('#text-context-menu'); |
542 cr.ui.Menu.decorate(this.textContextMenu_); | 542 cr.ui.Menu.decorate(this.textContextMenu_); |
543 | 543 |
544 this.gearButton_ = this.dialogDom_.querySelector('#gear-button'); | 544 this.gearButton_ = this.dialogDom_.querySelector('#gear-button'); |
545 this.gearButton_.addEventListener('menushow', | 545 this.gearButton_.addEventListener('menushow', |
546 this.refreshRemainingSpace_.bind(this, | 546 this.refreshRemainingSpace_.bind(this, |
547 false /* Without loading caption. */)); | 547 false /* Without loading caption. */)); |
548 cr.ui.decorate(this.gearButton_, cr.ui.MenuButton); | 548 cr.ui.decorate(this.gearButton_, cr.ui.MenuButton); |
549 | 549 |
550 this.gearMenu_ = this.dialogDom_.querySelector('#gear-menu'); | |
551 this.gearMenu_.menuItemSelector = 'menuitem, hr'; | |
552 | |
550 this.syncButton.checkable = true; | 553 this.syncButton.checkable = true; |
551 this.hostedButton.checkable = true; | 554 this.hostedButton.checkable = true; |
552 }; | 555 }; |
553 | 556 |
554 /** | 557 /** |
555 * One-time initialization of commands. | 558 * One-time initialization of commands. |
556 * @private | 559 * @private |
557 */ | 560 */ |
558 FileManager.prototype.initCommands_ = function() { | 561 FileManager.prototype.initCommands_ = function() { |
559 var commandButtons = this.dialogDom_.querySelectorAll('button[command]'); | 562 var commandButtons = this.dialogDom_.querySelectorAll('button[command]'); |
(...skipping 1466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2026 */ | 2029 */ |
2027 FileManager.prototype.updateSearchBoxOnDirChange_ = function() { | 2030 FileManager.prototype.updateSearchBoxOnDirChange_ = function() { |
2028 if (!this.searchBox_.disabled) | 2031 if (!this.searchBox_.disabled) |
2029 this.searchBox_.value = ''; | 2032 this.searchBox_.value = ''; |
2030 }; | 2033 }; |
2031 | 2034 |
2032 /** | 2035 /** |
2033 * Update the gear menu. | 2036 * Update the gear menu. |
2034 * @private | 2037 * @private |
2035 */ | 2038 */ |
2036 FileManager.prototype.updateGearMenu_ = function() { | 2039 FileManager.prototype.updateGearMenu_ = function() { |
mtomasz
2013/04/08 09:59:39
This seems to be correct, but I think we can make
hirono
2013/04/09 04:05:48
I fixed the code so that the menu items are hidden
| |
2037 this.syncButton.hidden = !this.isOnDrive(); | 2040 // Show or hide optional items. |
2038 this.hostedButton.hidden = !this.isOnDrive(); | 2041 var ctrlMenuHidden = !this.dialogDom_.hasAttribute('ctrl-pressing'); |
2042 var menuItems = this.gearMenu_.menuItems; | |
2043 var length = menuItems.length; | |
2044 for (var i = 0; i < length; i++) { | |
2045 var hidden = null; | |
2046 var item = menuItems[i]; | |
2047 if (item.getAttribute('required_attr') == 'ctrl-pressing') { | |
2048 if (hidden !== true) { | |
2049 hidden = ctrlMenuHidden; | |
2050 } | |
2051 } | |
2052 if (item.hasAttribute('required_drive')) { | |
2053 if (hidden !== true) { | |
2054 hidden = !this.isOnDrive(); | |
2055 } | |
2056 } | |
2057 if (hidden !== null) { | |
2058 if (hidden) { | |
2059 item.setAttribute('hidden', ''); | |
2060 } else { | |
2061 item.removeAttribute('hidden'); | |
2062 } | |
2063 } | |
2064 } | |
2039 | 2065 |
2040 // If volume has changed, then fetch remaining space data. | 2066 // If volume has changed, then fetch remaining space data. |
2041 if (this.previousRootUrl_ != this.directoryModel_.getCurrentRootUrl()) | 2067 if (this.previousRootUrl_ != this.directoryModel_.getCurrentRootUrl()) |
2042 this.refreshRemainingSpace_(true); // Show loading caption. | 2068 this.refreshRemainingSpace_(true); // Show loading caption. |
2043 | 2069 |
2044 this.previousRootUrl_ = this.directoryModel_.getCurrentRootUrl(); | 2070 this.previousRootUrl_ = this.directoryModel_.getCurrentRootUrl(); |
2045 }; | 2071 }; |
2046 | 2072 |
2047 /** | 2073 /** |
2048 * Refreshes space info of the current volume. | 2074 * Refreshes space info of the current volume. |
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2510 */ | 2536 */ |
2511 FileManager.prototype.onKeyDown_ = function(event) { | 2537 FileManager.prototype.onKeyDown_ = function(event) { |
2512 if (event.srcElement === this.renameInput_) { | 2538 if (event.srcElement === this.renameInput_) { |
2513 // Ignore keydown handler in the rename input box. | 2539 // Ignore keydown handler in the rename input box. |
2514 return; | 2540 return; |
2515 } | 2541 } |
2516 | 2542 |
2517 switch (util.getKeyModifiers(event) + event.keyCode) { | 2543 switch (util.getKeyModifiers(event) + event.keyCode) { |
2518 case 'Ctrl-17': // Ctrl => Show hidden setting | 2544 case 'Ctrl-17': // Ctrl => Show hidden setting |
2519 this.dialogDom_.setAttribute('ctrl-pressing', 'true'); | 2545 this.dialogDom_.setAttribute('ctrl-pressing', 'true'); |
2546 this.updateGearMenu_(); | |
2520 return; | 2547 return; |
2521 | 2548 |
2522 case 'Ctrl-190': // Ctrl-. => Toggle filter files. | 2549 case 'Ctrl-190': // Ctrl-. => Toggle filter files. |
2523 this.fileFilter_.setFilterHidden( | 2550 this.fileFilter_.setFilterHidden( |
2524 !this.fileFilter_.isFilterHiddenOn()); | 2551 !this.fileFilter_.isFilterHiddenOn()); |
2525 event.preventDefault(); | 2552 event.preventDefault(); |
2526 return; | 2553 return; |
2527 | 2554 |
2528 case '27': // Escape => Cancel dialog. | 2555 case '27': // Escape => Cancel dialog. |
2529 if (this.copyManager_ && | 2556 if (this.copyManager_ && |
(...skipping 25 matching lines...) Expand all Loading... | |
2555 */ | 2582 */ |
2556 FileManager.prototype.onKeyUp_ = function(event) { | 2583 FileManager.prototype.onKeyUp_ = function(event) { |
2557 if (event.srcElement === this.renameInput_) { | 2584 if (event.srcElement === this.renameInput_) { |
2558 // Ignore keydown handler in the rename input box. | 2585 // Ignore keydown handler in the rename input box. |
2559 return; | 2586 return; |
2560 } | 2587 } |
2561 | 2588 |
2562 switch (util.getKeyModifiers(event) + event.keyCode) { | 2589 switch (util.getKeyModifiers(event) + event.keyCode) { |
2563 case '17': // Ctrl => Hide hidden setting | 2590 case '17': // Ctrl => Hide hidden setting |
2564 this.dialogDom_.removeAttribute('ctrl-pressing'); | 2591 this.dialogDom_.removeAttribute('ctrl-pressing'); |
2592 this.updateGearMenu_(); | |
2565 return; | 2593 return; |
2566 } | 2594 } |
2567 }; | 2595 }; |
2568 | 2596 |
2569 /** | 2597 /** |
2570 * KeyDown event handler for the div#list-container element. | 2598 * KeyDown event handler for the div#list-container element. |
2571 * @param {Event} event Key event. | 2599 * @param {Event} event Key event. |
2572 * @private | 2600 * @private |
2573 */ | 2601 */ |
2574 FileManager.prototype.onListKeyDown_ = function(event) { | 2602 FileManager.prototype.onListKeyDown_ = function(event) { |
(...skipping 828 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3403 callback(this.preferences_); | 3431 callback(this.preferences_); |
3404 return; | 3432 return; |
3405 } | 3433 } |
3406 | 3434 |
3407 chrome.fileBrowserPrivate.getPreferences(function(prefs) { | 3435 chrome.fileBrowserPrivate.getPreferences(function(prefs) { |
3408 this.preferences_ = prefs; | 3436 this.preferences_ = prefs; |
3409 callback(prefs); | 3437 callback(prefs); |
3410 }.bind(this)); | 3438 }.bind(this)); |
3411 }; | 3439 }; |
3412 })(); | 3440 })(); |
OLD | NEW |