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

Unified Diff: third_party/polymer/v1_0/components-chromium/paper-dialog-behavior/paper-dialog-behavior-extracted.js

Issue 2969003002: Revert of Polymer: Remove unused paper-dialog and paper-dialog-behavior. (Closed)
Patch Set: Created 3 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 side-by-side diff with in-line comments
Download patch
Index: third_party/polymer/v1_0/components-chromium/paper-dialog-behavior/paper-dialog-behavior-extracted.js
diff --git a/third_party/polymer/v1_0/components-chromium/paper-dialog-behavior/paper-dialog-behavior-extracted.js b/third_party/polymer/v1_0/components-chromium/paper-dialog-behavior/paper-dialog-behavior-extracted.js
new file mode 100644
index 0000000000000000000000000000000000000000..0dd39eef79ae7701573d9f0a1d539526ef9be1ac
--- /dev/null
+++ b/third_party/polymer/v1_0/components-chromium/paper-dialog-behavior/paper-dialog-behavior-extracted.js
@@ -0,0 +1,123 @@
+/**
+Use `Polymer.PaperDialogBehavior` and `paper-dialog-shared-styles.html` to implement a Material Design
+dialog.
+
+For example, if `<paper-dialog-impl>` implements this behavior:
+
+ <paper-dialog-impl>
+ <h2>Header</h2>
+ <div>Dialog body</div>
+ <div class="buttons">
+ <paper-button dialog-dismiss>Cancel</paper-button>
+ <paper-button dialog-confirm>Accept</paper-button>
+ </div>
+ </paper-dialog-impl>
+
+`paper-dialog-shared-styles.html` provide styles for a header, content area, and an action area for buttons.
+Use the `<h2>` tag for the header and the `buttons` class for the action area. You can use the
+`paper-dialog-scrollable` element (in its own repository) if you need a scrolling content area.
+
+Use the `dialog-dismiss` and `dialog-confirm` attributes on interactive controls to close the
+dialog. If the user dismisses the dialog with `dialog-confirm`, the `closingReason` will update
+to include `confirmed: true`.
+
+### Accessibility
+
+This element has `role="dialog"` by default. Depending on the context, it may be more appropriate
+to override this attribute with `role="alertdialog"`.
+
+If `modal` is set, the element will prevent the focus from exiting the element.
+It will also ensure that focus remains in the dialog.
+
+@hero hero.svg
+@demo demo/index.html
+@polymerBehavior Polymer.PaperDialogBehavior
+*/
+
+ Polymer.PaperDialogBehaviorImpl = {
+
+ hostAttributes: {
+ 'role': 'dialog',
+ 'tabindex': '-1'
+ },
+
+ properties: {
+
+ /**
+ * If `modal` is true, this implies `no-cancel-on-outside-click`, `no-cancel-on-esc-key` and `with-backdrop`.
+ */
+ modal: {
+ type: Boolean,
+ value: false
+ }
+
+ },
+
+ observers: [
+ '_modalChanged(modal, _readied)'
+ ],
+
+ listeners: {
+ 'tap': '_onDialogClick'
+ },
+
+ ready: function () {
+ // Only now these properties can be read.
+ this.__prevNoCancelOnOutsideClick = this.noCancelOnOutsideClick;
+ this.__prevNoCancelOnEscKey = this.noCancelOnEscKey;
+ this.__prevWithBackdrop = this.withBackdrop;
+ },
+
+ _modalChanged: function(modal, readied) {
+ // modal implies noCancelOnOutsideClick, noCancelOnEscKey and withBackdrop.
+ // We need to wait for the element to be ready before we can read the
+ // properties values.
+ if (!readied) {
+ return;
+ }
+
+ if (modal) {
+ this.__prevNoCancelOnOutsideClick = this.noCancelOnOutsideClick;
+ this.__prevNoCancelOnEscKey = this.noCancelOnEscKey;
+ this.__prevWithBackdrop = this.withBackdrop;
+ this.noCancelOnOutsideClick = true;
+ this.noCancelOnEscKey = true;
+ this.withBackdrop = true;
+ } else {
+ // If the value was changed to false, let it false.
+ this.noCancelOnOutsideClick = this.noCancelOnOutsideClick &&
+ this.__prevNoCancelOnOutsideClick;
+ this.noCancelOnEscKey = this.noCancelOnEscKey &&
+ this.__prevNoCancelOnEscKey;
+ this.withBackdrop = this.withBackdrop && this.__prevWithBackdrop;
+ }
+ },
+
+ _updateClosingReasonConfirmed: function(confirmed) {
+ this.closingReason = this.closingReason || {};
+ this.closingReason.confirmed = confirmed;
+ },
+
+ /**
+ * Will dismiss the dialog if user clicked on an element with dialog-dismiss
+ * or dialog-confirm attribute.
+ */
+ _onDialogClick: function(event) {
+ // Search for the element with dialog-confirm or dialog-dismiss,
+ // from the root target until this (excluded).
+ var path = Polymer.dom(event).path;
+ for (var i = 0; i < path.indexOf(this); i++) {
+ var target = path[i];
+ if (target.hasAttribute && (target.hasAttribute('dialog-dismiss') || target.hasAttribute('dialog-confirm'))) {
+ this._updateClosingReasonConfirmed(target.hasAttribute('dialog-confirm'));
+ this.close();
+ event.stopPropagation();
+ break;
+ }
+ }
+ }
+
+ };
+
+ /** @polymerBehavior */
+ Polymer.PaperDialogBehavior = [Polymer.IronOverlayBehavior, Polymer.PaperDialogBehaviorImpl];

Powered by Google App Engine
This is Rietveld 408576698