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

Remove ember wormhole #915

Merged
merged 2 commits into from
May 10, 2018
Merged
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
9 changes: 8 additions & 1 deletion addon/components/paper-autocomplete-content.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import ContentComponent from 'ember-basic-dropdown/components/basic-dropdown/content';
import layout from '../templates/components/paper-autocomplete-content';
import { computed } from '@ember/object';

export default ContentComponent.extend({
layout
layout,

// returns `destinationElement` for ember-basic-dropdown >= 1.0.0
// finds destination by `to` for ember-basic-dropdown < 1.0.0
destinationEl: computed('destinationElement', 'to', function() {
return this.get('destinationElement') || document.getElementById(this.get('to'));
})
});
15 changes: 10 additions & 5 deletions addon/components/paper-dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,31 +38,36 @@ export default Component.extend({
let config = getOwner(this).resolveRegistration('config:environment');

if (config.environment === 'test' && !this.get('parent')) {
return 'ember-testing';
return '#ember-testing';
}
let parent = this.get('defaultedParent');
let $parent = $(parent);
// If the parent isn't found, assume that it is an id, but that the DOM doesn't
// exist yet. This only happens during integration tests or if entire application
// route is a dialog.
if ($parent.length === 0 && parent.charAt(0) === '#') {
return parent.substring(1);
return `#${parent.substring(1)}`;
} else {
let id = $parent.attr('id');
if (!id) {
id = `${this.elementId}-parent`;
$parent.get(0).id = id;
}
return id;
return `#${id}`;
}
}),

// Find the element referenced by destinationId
destinationEl: computed('destinationId', function() {
return document.querySelector(this.get('destinationId'));
}),

constants: service(),

didInsertElement() {
this._super(...arguments);
if (this.get('escapeToClose')) {
$(`#${this.get('destinationId')}`).on(`keydown.${this.elementId}`, (e) => {
$(this.get('destinationId')).on(`keydown.${this.elementId}`, (e) => {
if (e.keyCode === this.get('constants.KEYCODE.ESCAPE') && this.get('onClose')) {
this.sendAction('onClose');
}
Expand All @@ -73,7 +78,7 @@ export default Component.extend({
willDestroyElement() {
this._super(...arguments);
if (this.get('escapeToClose')) {
$(`#${this.get('destinationId')}`).off(`keydown.${this.elementId}`);
$(this.get('destinationId')).off(`keydown.${this.elementId}`);
}
},

Expand Down
6 changes: 6 additions & 0 deletions addon/components/paper-menu-content.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ export default ContentComponent.extend({
}
}),

// returns `destinationElement` for ember-basic-dropdown >= 1.0.0
// finds destination by `to` for ember-basic-dropdown < 1.0.0
destinationEl: computed('destinationElement', 'to', function() {
return this.get('destinationElement') || document.getElementById(this.get('to'));
}),

startObservingDomMutations() {
if (MutObserver) {
this.mutationObserver = new MutObserver((mutations) => {
Expand Down
17 changes: 11 additions & 6 deletions addon/components/paper-toast.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,25 +46,30 @@ export default Component.extend({
let config = getOwner(this).resolveRegistration('config:environment');

if (config.environment === 'test' && !this.get('parent')) {
return 'ember-testing';
return '#ember-testing';
}
let parent = this.get('defaultedParent');
let $parent = $(parent);
// If the parent isn't found, assume that it is an id, but that the DOM doesn't
// exist yet. This only happens during integration tests or if entire application
// route is a dialog.
if ($parent.length === 0 && parent.charAt(0) === '#') {
return parent.substring(1);
return `#${parent.substring(1)}`;
} else {
let id = $parent.attr('id');
if (!id) {
id = `${this.uniqueId}-parent`;
$parent.get(0).id = id;
}
return id;
return `#${id}`;
}
}),

// Find the element referenced by destinationId
destinationEl: computed('destinationId', function() {
return document.querySelector(this.get('destinationId'));
}),

constants: service(),

_destroyMessage() {
Expand All @@ -80,7 +85,7 @@ export default Component.extend({

willInsertElement() {
this._super(...arguments);
$(`#${this.get('destinationId')}`).addClass('md-toast-animating');
$(this.get('destinationId')).addClass('md-toast-animating');
},

didInsertElement() {
Expand All @@ -100,7 +105,7 @@ export default Component.extend({
}

let y = this.get('top') ? 'top' : 'bottom';
$(`#${this.get('destinationId')}`).addClass(`md-toast-open-${y}`);
$(this.get('destinationId')).addClass(`md-toast-open-${y}`);
},

willDestroyElement() {
Expand All @@ -110,7 +115,7 @@ export default Component.extend({
}

let y = this.get('top') ? 'top' : 'bottom';
$(`#${this.get('destinationId')}`).removeClass(`md-toast-open-${y} md-toast-animating`);
$(this.get('destinationId')).removeClass(`md-toast-open-${y} md-toast-animating`);
},

swipeAction() {
Expand Down
11 changes: 8 additions & 3 deletions addon/components/paper-tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,30 @@ export default Component.extend({
let config = getOwner(this).resolveRegistration('config:environment');

if (config.environment === 'test' && !this.get('parent')) {
return 'ember-testing';
return '#ember-testing';
}
let parent = this.get('defaultedParent');
let $parent = $(parent);
// If the parent isn't found, assume that it is an id, but that the DOM doesn't
// exist yet. This only happens during integration tests or if entire application
// route is a dialog.
if ($parent.length === 0 && parent.charAt(0) === '#') {
return parent.substring(1);
return `#${parent.substring(1)}`;
} else {
let id = $parent.attr('id');
if (!id) {
id = `${this.elementId}-parent`;
$parent.get(0).id = id;
}
return id;
return `#${id}`;
}
}),

// Find the element referenced by destinationId
destinationEl: computed('destinationId', function() {
return document.querySelector(this.get('destinationId'));
}),

zIndex: 100,

containerStyle: computed('zIndex', function() {
Expand Down
4 changes: 2 additions & 2 deletions addon/templates/components/paper-autocomplete-content.hbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{#if dropdown.isOpen}}
{{#ember-wormhole to=destination renderInPlace=renderInPlace}}
{{#maybe-in-element destinationEl renderInPlace}}
{{#paper-virtual-repeat (readonly select.results)
id=(readonly dropdownId)
class=(concat class " ember-basic-dropdown-content "
Expand All @@ -13,5 +13,5 @@
as |rawItems virtualItems|}}
{{yield virtualItems}}
{{/paper-virtual-repeat}}
{{/ember-wormhole}}
{{/maybe-in-element}}
{{/if}}
4 changes: 2 additions & 2 deletions addon/templates/components/paper-dialog.hbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{#ember-wormhole to=destinationId}}
{{#-in-element destinationEl}}
{{paper-backdrop
locked-open=isLockedOpen
opaque=opaque
Expand All @@ -17,4 +17,4 @@
{{yield}}
{{/paper-dialog-inner}}
{{/paper-dialog-container}}
{{/ember-wormhole}}
{{/-in-element}}
4 changes: 2 additions & 2 deletions addon/templates/components/paper-menu-content.hbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{#if dropdown.isOpen}}
{{#ember-wormhole to=to renderInPlace=renderInPlace}}
{{#maybe-in-element destinationEl renderInPlace}}
{{!-- we already have our own paper-backdrop
{{#if overlay}}
<div class="ember-basic-dropdown-overlay"></div>
Expand All @@ -16,5 +16,5 @@
{{yield innerContentHash}}
{{/paper-menu-content-inner}}
</div>
{{/ember-wormhole}}
{{/maybe-in-element}}
{{/if}}
4 changes: 2 additions & 2 deletions addon/templates/components/paper-select-content.hbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{#if dropdown.isOpen}}
{{#ember-wormhole to=to renderInPlace=renderInPlace}}
{{#maybe-in-element destinationEl renderInPlace}}
{{!-- we already have our own paper-backdrop
{{#if overlay}}
<div class="ember-basic-dropdown-overlay"></div>
Expand All @@ -16,5 +16,5 @@
{{yield innerContentHash}}
{{/paper-select-menu-inner}}
</div>
{{/ember-wormhole}}
{{/maybe-in-element}}
{{/if}}
4 changes: 2 additions & 2 deletions addon/templates/components/paper-toast.hbs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{#ember-wormhole to=destinationId}}
{{#-in-element destinationEl}}
{{#paper-toast-inner swipe=swipeAction swipeToClose=swipeToClose onClose=onClose top=top left=left capsule=capsule class=class}}
{{yield (hash
text=(component "paper-toast-text")
)}}
{{/paper-toast-inner}}
{{/ember-wormhole}}
{{/-in-element}}
6 changes: 3 additions & 3 deletions addon/templates/components/paper-tooltip.hbs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{{#if renderTooltip}}
{{#ember-wormhole to=destinationId}}
{{#-in-element destinationEl}}
<div class="md-panel-outer-wrapper md-panel-is-showing" style={{containerStyle}}>
{{#paper-tooltip-inner class=class position=position anchorElement=anchorElement hide=hideTooltip}}
{{yield}}
{{/paper-tooltip-inner}}
</div>
{{/ember-wormhole}}
{{/if}}
{{/-in-element}}
{{/if}}
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,14 @@
"broccoli-filter": "^1.2.4",
"broccoli-funnel": "^1.2.0",
"broccoli-merge-trees": "^2.0.0",
"ember-basic-dropdown": "^0.33.1 || ^1.0.0-beta.3",
"ember-basic-dropdown": "^1.0.0",
"ember-cli-babel": "^6.6.0",
"ember-cli-htmlbars": "^2.0.1",
"ember-composability-tools": "0.0.9",
"ember-css-transitions": "^0.1.12",
"ember-get-config": "^0.2.3",
"ember-power-select": "^1.8.5 || ^2.0.0-beta.2",
"ember-wormhole": "0.5.2",
"ember-maybe-in-element": "^0.1.3",
"ember-power-select": "^2.0.0",
"fastboot-transform": "^0.1.2",
"hammerjs": "^2.0.8",
"matchmedia-polyfill": "^0.3.0",
Expand Down
Loading