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

Side by Side Diff: ui/webui/resources/cr_elements/cr_shared_menu/cr_shared_menu.js

Issue 2142893005: MD Settings: Update passwords section for new cr-shared-menu features (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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
« no previous file with comments | « chrome/browser/resources/settings/passwords_and_forms_page/passwords_shared_css.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 /** Same as paper-menu-button's custom easing cubic-bezier param. */ 5 /** Same as paper-menu-button's custom easing cubic-bezier param. */
6 var SLIDE_CUBIC_BEZIER = 'cubic-bezier(0.3, 0.95, 0.5, 1)'; 6 var SLIDE_CUBIC_BEZIER = 'cubic-bezier(0.3, 0.95, 0.5, 1)';
7 7
8 Polymer({ 8 Polymer({
9 is: 'cr-shared-menu', 9 is: 'cr-shared-menu',
10 10
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 106
107 /** 107 /**
108 * The last focusable child in the menu's light DOM. 108 * The last focusable child in the menu's light DOM.
109 * @private {?Element} 109 * @private {?Element}
110 */ 110 */
111 lastFocus_: null, 111 lastFocus_: null,
112 112
113 /** @override */ 113 /** @override */
114 attached: function() { 114 attached: function() {
115 window.addEventListener('resize', this.closeMenu.bind(this)); 115 window.addEventListener('resize', this.closeMenu.bind(this));
116
117 var focusableChildren = Polymer.dom(this).querySelectorAll(
118 '[tabindex],button');
119 if (focusableChildren.length > 0) {
120 this.$.dropdown.focusTarget = focusableChildren[0];
121 this.firstFocus_ = focusableChildren[0];
122 this.lastFocus_ = focusableChildren[focusableChildren.length - 1];
123 }
124 }, 116 },
125 117
126 /** Closes the menu. */ 118 /** Closes the menu. */
127 closeMenu: function() { 119 closeMenu: function() {
128 if (this.root.activeElement == null) { 120 if (this.root.activeElement == null) {
129 // Something else has taken focus away from the menu. Do not attempt to 121 // Something else has taken focus away from the menu. Do not attempt to
130 // restore focus to the button which opened the menu. 122 // restore focus to the button which opened the menu.
131 this.$.dropdown.restoreFocusOnClose = false; 123 this.$.dropdown.restoreFocusOnClose = false;
132 } 124 }
133 this.menuOpen = false; 125 this.menuOpen = false;
134 this.$.dropdown.restoreFocusOnClose = true; 126 this.$.dropdown.restoreFocusOnClose = true;
135 }, 127 },
136 128
137 /** 129 /**
138 * Opens the menu at the anchor location. 130 * Opens the menu at the anchor location.
139 * @param {!Element} anchor The location to display the menu. 131 * @param {!Element} anchor The location to display the menu.
140 * @param {!Object} itemData The contextual item's data. 132 * @param {!Object} itemData The contextual item's data.
141 */ 133 */
142 openMenu: function(anchor, itemData) { 134 openMenu: function(anchor, itemData) {
143 this.itemData = itemData; 135 this.itemData = itemData;
144 this.lastAnchor_ = anchor; 136 this.lastAnchor_ = anchor;
145 137
138 var focusableChildren = Polymer.dom(this).querySelectorAll(
139 '[tabindex]:not([hidden]),button:not([hidden])');
Dan Beam 2016/07/14 17:09:20 and it starts growing
tsergeant 2016/07/15 01:17:48 https://www.youtube.com/watch?v=bWcASV2sey0 https
140 if (focusableChildren.length > 0) {
141 this.$.dropdown.focusTarget = focusableChildren[0];
142 this.firstFocus_ = focusableChildren[0];
143 this.lastFocus_ = focusableChildren[focusableChildren.length - 1];
144 }
145
146 // Move the menu to the anchor. 146 // Move the menu to the anchor.
147 this.$.dropdown.positionTarget = anchor; 147 this.$.dropdown.positionTarget = anchor;
148 this.menuOpen = true; 148 this.menuOpen = true;
149 }, 149 },
150 150
151 /** 151 /**
152 * Toggles the menu for the anchor that is passed in. 152 * Toggles the menu for the anchor that is passed in.
153 * @param {!Element} anchor The location to display the menu. 153 * @param {!Element} anchor The location to display the menu.
154 * @param {!Object} itemData The contextual item's data. 154 * @param {!Object} itemData The contextual item's data.
155 */ 155 */
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 /** 188 /**
189 * Ensure the menu is reset properly when it is closed by the dropdown (eg, 189 * Ensure the menu is reset properly when it is closed by the dropdown (eg,
190 * clicking outside). 190 * clicking outside).
191 * @private 191 * @private
192 */ 192 */
193 menuOpenChanged_: function() { 193 menuOpenChanged_: function() {
194 if (!this.menuOpen) 194 if (!this.menuOpen)
195 this.itemData = null; 195 this.itemData = null;
196 }, 196 },
197 }); 197 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/settings/passwords_and_forms_page/passwords_shared_css.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698