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

Unified Diff: lib/src/iron-overlay-behavior/iron-overlay-behavior.html

Issue 1418513006: update elements and fix some bugs (Closed) Base URL: git@github.com:dart-lang/polymer_elements.git@master
Patch Set: code review updates Created 5 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: lib/src/iron-overlay-behavior/iron-overlay-behavior.html
diff --git a/lib/src/iron-overlay-behavior/iron-overlay-behavior.html b/lib/src/iron-overlay-behavior/iron-overlay-behavior.html
index 180b19cefac6d15794626ea3789483c5a97fe5db..837759f7e7f73007be88e53f3a36613a34751247 100644
--- a/lib/src/iron-overlay-behavior/iron-overlay-behavior.html
+++ b/lib/src/iron-overlay-behavior/iron-overlay-behavior.html
@@ -28,7 +28,8 @@ intent. Closing generally implies that the user acknowledged the content on the
it will cancel whenever the user taps outside it or presses the escape key. This behavior is
configurable with the `no-cancel-on-esc-key` and the `no-cancel-on-outside-click` properties.
`close()` should be called explicitly by the implementer when the user interacts with a control
-in the overlay element.
+in the overlay element. When the dialog is canceled, the overlay fires an 'iron-overlay-canceled'
+event. Call `preventDefault` on this event to prevent the overlay from closing.
### Positioning
@@ -139,7 +140,7 @@ context. You should place this element as a child of `<body>` whenever possible.
},
listeners: {
- 'click': '_onClick',
+ 'tap': '_onClick',
'iron-resize': '_onIronResize'
},
@@ -199,7 +200,12 @@ context. You should place this element as a child of `<body>` whenever possible.
* Cancels the overlay.
*/
cancel: function() {
- this.opened = false,
+ var cancelEvent = this.fire('iron-overlay-canceled', undefined, {cancelable: true});
+ if (cancelEvent.defaultPrevented) {
+ return;
+ }
+
+ this.opened = false;
this._setCanceled(true);
},
@@ -257,8 +263,16 @@ context. You should place this element as a child of `<body>` whenever possible.
_toggleListener: function(enable, node, event, boundListener, capture) {
if (enable) {
+ // enable document-wide tap recognizer
+ if (event === 'tap') {
+ Polymer.Gestures.add(document, 'tap', null);
+ }
node.addEventListener(event, boundListener, capture);
} else {
+ // disable document-wide tap recognizer
+ if (event === 'tap') {
+ Polymer.Gestures.remove(document, 'tap', null);
+ }
node.removeEventListener(event, boundListener, capture);
}
},
@@ -269,10 +283,10 @@ context. You should place this element as a child of `<body>` whenever possible.
}
// async so we don't auto-close immediately via a click.
this._toggleListenersAsync = this.async(function() {
- this._toggleListener(this.opened, document, 'click', this._boundOnCaptureClick, true);
+ this._toggleListener(this.opened, document, 'tap', this._boundOnCaptureClick, true);
this._toggleListener(this.opened, document, 'keydown', this._boundOnCaptureKeydown, true);
this._toggleListenersAsync = null;
- });
+ }, 1);
},
// tasks which must occur before opening; e.g. making the element visible
« no previous file with comments | « lib/src/iron-meta/test/iron-meta.html ('k') | lib/src/iron-overlay-behavior/test/iron-overlay-behavior.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698