Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use blocking-elements #80

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
"iron-pages": "polymerelements/iron-pages#^1.0.0",
"iron-selector": "polymerelements/iron-selector#^1.0.0",
"paper-icon-button": "polymerelements/paper-icon-button#^1.0.0",
"paper-spinner": "polymerelements/paper-spinner#^1.0.0"
"paper-spinner": "polymerelements/paper-spinner#^1.0.0",
"blockingElements": "PolymerLabs/blockingElements#issue-2",
"inert": "WICG/inert"
},
"devDependencies": {
"web-component-tester": "^4.0.0"
Expand Down
3 changes: 3 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,8 @@
})();
</script>

<script src="/bower_components/blockingElements/blocking-elements.js"></script>
<script src="/bower_components/inert/inert.js"></script>

</body>
</html>
13 changes: 12 additions & 1 deletion src/shop-app.html
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@
<!-- Lazy-create the drawer for small screen sizes. -->
<template is="dom-if" if="[[_shouldRenderDrawer]]">
<!-- Two-way bind `drawerOpened` since app-drawer can update `opened` itself. -->
<app-drawer opened="{{drawerOpened}}" swipe-open tabindex="0">
<app-drawer opened="{{drawerOpened}}" swipe-open no-focus-trap on-opened-changed="_updateBlockingElements">
<iron-selector role="navigation" class="drawer-list" selected="[[categoryName]]" attr-for-selected="name">
<template is="dom-repeat" items="[[categories]]" as="category" initial-count="4">
<a name="[[category.name]]" href="/list/[[category.name]]">[[category.title]]</a>
Expand Down Expand Up @@ -472,6 +472,7 @@
_onAddCartItem: function(event) {
if (!this._cartModal) {
this._cartModal = document.createElement('shop-cart-modal');
this._cartModal.addEventListener('opened-changed', this._updateBlockingElements.bind(this));
Polymer.dom(this.root).appendChild(this._cartModal);
}
this.$.cart.addItem(event.detail);
Expand Down Expand Up @@ -532,6 +533,16 @@

_computePluralizedQuantity: function(quantity) {
return quantity + ' ' + (quantity === 1 ? 'item' : 'items');
},

_updateBlockingElements: function(event) {
var opened = event.detail.value;
var element = event.target;
if (opened) {
document.$blockingElements.push(element);
} else {
document.$blockingElements.remove(element);
}
}

});
Expand Down
9 changes: 0 additions & 9 deletions src/shop-cart-modal.html
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,6 @@
Polymer.IronOverlayBehaviorImpl
],

properties: {
withBackdrop: {
type: Boolean,
value: true
}
},

hostAttributes: {
role: 'dialog',
'aria-modal': 'true'
Expand All @@ -133,7 +126,6 @@

_renderOpened: function() {
this.restoreFocusOnClose = true;
this.backdropElement.style.display = 'none';
this.classList.add('opened');
},

Expand All @@ -157,7 +149,6 @@
this.fire('announce', 'Item added to the cart');
} else {
this._finishRenderClosed();
this.backdropElement.style.display = '';
}
},

Expand Down