Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(632)

Side by Side Diff: ui/file_manager/file_manager/foreground/js/gear_menu_controller.js

Issue 1170913006: Add material design toggle ripple element. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove changes to menu_button.js. Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 /** 5 /**
6 * @param {!cr.ui.MenuButton} gearButton 6 * @param {!cr.ui.MenuButton} gearButton
7 * @param {!FilesToggleRipple} toggleRipple
7 * @param {!GearMenu} gearMenu 8 * @param {!GearMenu} gearMenu
8 * @param {!DirectoryModel} directoryModel 9 * @param {!DirectoryModel} directoryModel
9 * @param {!CommandHandler} commandHandler 10 * @param {!CommandHandler} commandHandler
10 * @constructor 11 * @constructor
11 * @struct 12 * @struct
12 */ 13 */
13 function GearMenuController( 14 function GearMenuController(
14 gearButton, gearMenu, directoryModel, commandHandler) { 15 gearButton, toggleRipple, gearMenu, directoryModel, commandHandler) {
16 /**
17 * @type {!FilesToggleRipple}
18 * @const
19 * @private
20 */
21 this.toggleRipple_ = toggleRipple;
22
15 /** 23 /**
16 * @type {!GearMenu} 24 * @type {!GearMenu}
17 * @const 25 * @const
18 * @private 26 * @private
19 */ 27 */
20 this.gearMenu_ = gearMenu; 28 this.gearMenu_ = gearMenu;
21 29
22 /** 30 /**
23 * @type {!DirectoryModel} 31 * @type {!DirectoryModel}
24 * @const 32 * @const
25 * @private 33 * @private
26 */ 34 */
27 this.directoryModel_ = directoryModel; 35 this.directoryModel_ = directoryModel;
28 36
29 /** 37 /**
30 * @type {!CommandHandler} 38 * @type {!CommandHandler}
31 * @const 39 * @const
32 * @private 40 * @private
33 */ 41 */
34 this.commandHandler_ = commandHandler; 42 this.commandHandler_ = commandHandler;
35 43
36 gearButton.addEventListener('menushow', this.onShowGearMenu_.bind(this)); 44 gearButton.addEventListener('menushow', this.onShowGearMenu_.bind(this));
45 gearButton.addEventListener('menuhide', this.onHideGearMenu_.bind(this));
37 directoryModel.addEventListener( 46 directoryModel.addEventListener(
38 'directory-changed', this.onDirectoryChanged_.bind(this)); 47 'directory-changed', this.onDirectoryChanged_.bind(this));
39 chrome.fileManagerPrivate.onPreferencesChanged.addListener( 48 chrome.fileManagerPrivate.onPreferencesChanged.addListener(
40 this.onPreferencesChanged_.bind(this)); 49 this.onPreferencesChanged_.bind(this));
41 this.onPreferencesChanged_(); 50 this.onPreferencesChanged_();
42 } 51 }
43 52
44 /** 53 /**
45 * @private 54 * @private
46 */ 55 */
47 GearMenuController.prototype.onShowGearMenu_ = function() { 56 GearMenuController.prototype.onShowGearMenu_ = function() {
57 this.toggleRipple_.activated = true;
48 this.refreshRemainingSpace_(false); /* Without loading caption. */ 58 this.refreshRemainingSpace_(false); /* Without loading caption. */
49 59
50 // Update view of drive-related settings. 60 // Update view of drive-related settings.
51 this.commandHandler_.updateAvailability(); 61 this.commandHandler_.updateAvailability();
52 }; 62 };
53 63
54 /** 64 /**
65 * @private
66 */
67 GearMenuController.prototype.onHideGearMenu_ = function() {
68 this.toggleRipple_.activated = false;
69 };
70
71 /**
55 * @param {Event} event 72 * @param {Event} event
56 * @private 73 * @private
57 */ 74 */
58 GearMenuController.prototype.onDirectoryChanged_ = function(event) { 75 GearMenuController.prototype.onDirectoryChanged_ = function(event) {
59 event = /** @type {DirectoryChangeEvent} */ (event); 76 event = /** @type {DirectoryChangeEvent} */ (event);
60 if (event.volumeChanged) 77 if (event.volumeChanged)
61 this.refreshRemainingSpace_(true); // Show loading caption. 78 this.refreshRemainingSpace_(true); // Show loading caption.
62 }; 79 };
63 80
64 /** 81 /**
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 this.gearMenu_.syncButton.setAttribute('checked', ''); 114 this.gearMenu_.syncButton.setAttribute('checked', '');
98 else 115 else
99 this.gearMenu_.syncButton.removeAttribute('checked'); 116 this.gearMenu_.syncButton.removeAttribute('checked');
100 117
101 if (!prefs.hostedFilesDisabled) 118 if (!prefs.hostedFilesDisabled)
102 this.gearMenu_.hostedButton.setAttribute('checked', ''); 119 this.gearMenu_.hostedButton.setAttribute('checked', '');
103 else 120 else
104 this.gearMenu_.hostedButton.removeAttribute('checked'); 121 this.gearMenu_.hostedButton.removeAttribute('checked');
105 }.bind(this)); 122 }.bind(this));
106 }; 123 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698