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

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

Issue 2445713004: MD Settings: Don't auto-close navigable dialogs on popstate. (Closed)
Patch Set: rename attribute Created 4 years, 1 month 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/reset_page/reset_profile_dialog.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 /** 5 /**
6 * @fileoverview 'cr-dialog' is a component for showing a modal dialog. If the 6 * @fileoverview 'cr-dialog' is a component for showing a modal dialog. If the
7 * dialog is closed via close(), a 'close' event is fired. If the dialog is 7 * dialog is closed via close(), a 'close' event is fired. If the dialog is
8 * canceled via cancel(), a 'cancel' event is fired followed by a 'close' event. 8 * canceled via cancel(), a 'cancel' event is fired followed by a 'close' event.
9 * Additionally clients can inspect the dialog's |returnValue| property inside 9 * Additionally clients can inspect the dialog's |returnValue| property inside
10 * the 'close' event listener to determine whether it was canceled or just 10 * the 'close' event listener to determine whether it was canceled or just
11 * closed, where a truthy value means success, and a falsy value means it was 11 * closed, where a truthy value means success, and a falsy value means it was
12 * canceled. 12 * canceled.
13 */ 13 */
14 Polymer({ 14 Polymer({
15 is: 'cr-dialog', 15 is: 'cr-dialog',
16 extends: 'dialog', 16 extends: 'dialog',
17 17
18 properties: {
19 /**
20 * True if the dialog should remain open on 'popstate' events. This is used
21 * for navigable dialogs that have their separate navigation handling code.
22 */
23 ignorePopstate: {
24 type: Boolean,
25 value: false,
26 },
27 },
28
18 /** @override */ 29 /** @override */
19 created: function() { 30 ready: function() {
20 // If the active history entry changes (i.e. user clicks back button), 31 // If the active history entry changes (i.e. user clicks back button),
21 // all open dialogs should be cancelled. 32 // all open dialogs should be cancelled.
22 window.addEventListener('popstate', function() { 33 window.addEventListener('popstate', function() {
23 if (this.open) 34 if (!this.ignorePopstate && this.open)
24 this.cancel(); 35 this.cancel();
25 }.bind(this)); 36 }.bind(this));
26 }, 37 },
27 38
28 cancel: function() { 39 cancel: function() {
29 this.fire('cancel'); 40 this.fire('cancel');
30 HTMLDialogElement.prototype.close.call(this, ''); 41 HTMLDialogElement.prototype.close.call(this, '');
31 }, 42 },
32 43
33 /** 44 /**
34 * @param {string=} opt_returnValue 45 * @param {string=} opt_returnValue
35 * @override 46 * @override
36 */ 47 */
37 close: function(opt_returnValue) { 48 close: function(opt_returnValue) {
38 HTMLDialogElement.prototype.close.call(this, 'success'); 49 HTMLDialogElement.prototype.close.call(this, 'success');
39 }, 50 },
40 51
41 /** @return {!PaperIconButtonElement} */ 52 /** @return {!PaperIconButtonElement} */
42 getCloseButton: function() { 53 getCloseButton: function() {
43 return this.$.close; 54 return this.$.close;
44 }, 55 },
45 }); 56 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/settings/reset_page/reset_profile_dialog.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698