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

Side by Side Diff: chrome/browser/resources/settings/passwords_and_forms_page/autofill_section.js

Issue 2789783002: MD Settings: Restore focus after closing dialogs, for passwords page. (Closed)
Patch Set: fix compilation Created 3 years, 8 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 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 /** 5 /**
6 * @fileoverview 'settings-autofill-section' is the section containing saved 6 * @fileoverview 'settings-autofill-section' is the section containing saved
7 * addresses and credit cards for use in autofill. 7 * addresses and credit cards for use in autofill.
8 */ 8 */
9 9
10 /** 10 /**
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 /** @private */ 184 /** @private */
185 showCreditCardDialog_: Boolean, 185 showCreditCardDialog_: Boolean,
186 }, 186 },
187 187
188 listeners: { 188 listeners: {
189 'save-address': 'saveAddress_', 189 'save-address': 'saveAddress_',
190 'save-credit-card': 'saveCreditCard_', 190 'save-credit-card': 'saveCreditCard_',
191 }, 191 },
192 192
193 /** 193 /**
194 * The element to return focus to, when the currently active dialog is
195 * closed.
196 * @private {?HTMLElement}
197 */
198 activeDialogAnchor_: null,
199
200 /**
194 * @type {AutofillManager} 201 * @type {AutofillManager}
195 * @private 202 * @private
196 */ 203 */
197 autofillManager_: null, 204 autofillManager_: null,
198 205
199 /** 206 /**
200 * @type {?function(!Array<!AutofillManager.AddressEntry>)} 207 * @type {?function(!Array<!AutofillManager.AddressEntry>)}
201 * @private 208 * @private
202 */ 209 */
203 setAddressesListener_: null, 210 setAddressesListener_: null,
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 https://github.com/Polymer/polymer/issues/2574 */ 277 https://github.com/Polymer/polymer/issues/2574 */
271 var item = menuEvent.model['dataHost']['dataHost'].item; 278 var item = menuEvent.model['dataHost']['dataHost'].item;
272 279
273 // Copy item so dialog won't update model on cancel. 280 // Copy item so dialog won't update model on cancel.
274 this.activeAddress = /** @type {!chrome.autofillPrivate.AddressEntry} */( 281 this.activeAddress = /** @type {!chrome.autofillPrivate.AddressEntry} */(
275 Object.assign({}, item)); 282 Object.assign({}, item));
276 283
277 var dotsButton = /** @type {!HTMLElement} */ (Polymer.dom(e).localTarget); 284 var dotsButton = /** @type {!HTMLElement} */ (Polymer.dom(e).localTarget);
278 /** @type {!CrActionMenuElement} */ ( 285 /** @type {!CrActionMenuElement} */ (
279 this.$.addressSharedMenu).showAt(dotsButton); 286 this.$.addressSharedMenu).showAt(dotsButton);
287 this.activeDialogAnchor_ = dotsButton;
280 }, 288 },
281 289
282 /** 290 /**
283 * Handles tapping on the "Add address" button. 291 * Handles tapping on the "Add address" button.
284 * @param {!Event} e The polymer event. 292 * @param {!Event} e The polymer event.
285 * @private 293 * @private
286 */ 294 */
287 onAddAddressTap_: function(e) { 295 onAddAddressTap_: function(e) {
288 e.preventDefault(); 296 e.preventDefault();
289 this.activeAddress = {}; 297 this.activeAddress = {};
290 this.showAddressDialog_ = true; 298 this.showAddressDialog_ = true;
299 this.activeDialogAnchor_ = this.$.addAddress;
291 }, 300 },
292 301
293 /** @private */ 302 /** @private */
294 onAddressDialogClosed_: function() { 303 onAddressDialogClosed_: function() {
295 this.showAddressDialog_ = false; 304 this.showAddressDialog_ = false;
305 this.activeDialogAnchor_.focus();
306 this.activeDialogAnchor_ = null;
296 }, 307 },
297 308
298 /** 309 /**
299 * Handles tapping on the "Edit" address button. 310 * Handles tapping on the "Edit" address button.
300 * @param {!Event} e The polymer event. 311 * @param {!Event} e The polymer event.
301 * @private 312 * @private
302 */ 313 */
303 onMenuEditAddressTap_: function(e) { 314 onMenuEditAddressTap_: function(e) {
304 e.preventDefault(); 315 e.preventDefault();
305 this.showAddressDialog_ = true; 316 this.showAddressDialog_ = true;
(...skipping 28 matching lines...) Expand all
334 var item = menuEvent.model['dataHost']['dataHost'].item; 345 var item = menuEvent.model['dataHost']['dataHost'].item;
335 346
336 // Copy item so dialog won't update model on cancel. 347 // Copy item so dialog won't update model on cancel.
337 this.activeCreditCard = 348 this.activeCreditCard =
338 /** @type {!chrome.autofillPrivate.CreditCardEntry} */( 349 /** @type {!chrome.autofillPrivate.CreditCardEntry} */(
339 Object.assign({}, item)); 350 Object.assign({}, item));
340 351
341 var dotsButton = /** @type {!HTMLElement} */ (Polymer.dom(e).localTarget); 352 var dotsButton = /** @type {!HTMLElement} */ (Polymer.dom(e).localTarget);
342 /** @type {!CrActionMenuElement} */ ( 353 /** @type {!CrActionMenuElement} */ (
343 this.$.creditCardSharedMenu).showAt(dotsButton); 354 this.$.creditCardSharedMenu).showAt(dotsButton);
355 this.activeDialogAnchor_ = dotsButton;
344 }, 356 },
345 357
346 /** 358 /**
347 * Handles tapping on the "Add credit card" button. 359 * Handles tapping on the "Add credit card" button.
348 * @param {!Event} e 360 * @param {!Event} e
349 * @private 361 * @private
350 */ 362 */
351 onAddCreditCardTap_: function(e) { 363 onAddCreditCardTap_: function(e) {
352 e.preventDefault(); 364 e.preventDefault();
353 var date = new Date(); // Default to current month/year. 365 var date = new Date(); // Default to current month/year.
354 var expirationMonth = date.getMonth() + 1; // Months are 0 based. 366 var expirationMonth = date.getMonth() + 1; // Months are 0 based.
355 this.activeCreditCard = { 367 this.activeCreditCard = {
356 expirationMonth: expirationMonth.toString(), 368 expirationMonth: expirationMonth.toString(),
357 expirationYear: date.getFullYear().toString(), 369 expirationYear: date.getFullYear().toString(),
358 }; 370 };
359 this.showCreditCardDialog_ = true; 371 this.showCreditCardDialog_ = true;
372 this.activeDialogAnchor_ = this.$.addCreditCard;
360 }, 373 },
361 374
362 /** @private */ 375 /** @private */
363 onCreditCardDialogClosed_: function() { 376 onCreditCardDialogClosed_: function() {
364 this.showCreditCardDialog_ = false; 377 this.showCreditCardDialog_ = false;
378 this.activeDialogAnchor_.focus();
379 this.activeDialogAnchor_ = null;
365 }, 380 },
366 381
367 /** 382 /**
368 * Handles tapping on the "Edit" credit card button. 383 * Handles tapping on the "Edit" credit card button.
369 * @param {!Event} e The polymer event. 384 * @param {!Event} e The polymer event.
370 * @private 385 * @private
371 */ 386 */
372 onMenuEditCreditCardTap_: function(e) { 387 onMenuEditCreditCardTap_: function(e) {
373 e.preventDefault(); 388 e.preventDefault();
374 this.showCreditCardDialog_ = true; 389 this.showCreditCardDialog_ = true;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 /** 446 /**
432 * @private 447 * @private
433 * @param {boolean} toggleValue 448 * @param {boolean} toggleValue
434 * @return {string} 449 * @return {string}
435 */ 450 */
436 getOnOffLabel_: function(toggleValue) { 451 getOnOffLabel_: function(toggleValue) {
437 return toggleValue ? this.i18n('toggleOn') : this.i18n('toggleOff'); 452 return toggleValue ? this.i18n('toggleOn') : this.i18n('toggleOff');
438 } 453 }
439 }); 454 });
440 })(); 455 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698