-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from pzuraq/v2.0.0-beta.2
Revision 2
- Loading branch information
Showing
59 changed files
with
870 additions
and
588 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,27 @@ | ||
import Ember from 'ember'; | ||
|
||
export default Ember.Component.extend({ | ||
willInsertElement() { | ||
const wormhole = this.get('wormhole'); | ||
didUpdateAttrs() { | ||
if (this.get('replaceNodes')) { | ||
const nodes = this.get('nodes'); | ||
|
||
if (wormhole && wormhole.willAppendNodes) { | ||
wormhole.willAppendNodes(this.element); | ||
this.$().children().remove(); | ||
this.$().append(nodes); | ||
} | ||
}, | ||
|
||
didInsertElement() { | ||
const wormhole = this.get('wormhole'); | ||
const nodes = this.get('wormhole.nodes'); | ||
const notify = this.get('notify'); | ||
const nodes = this.get('nodes'); | ||
|
||
if (notify && notify.willAppendNodes) { | ||
notify.willAppendNodes(this.element); | ||
} | ||
|
||
this.$().append(nodes); | ||
|
||
if (wormhole && wormhole.didAppendNodes) { | ||
wormhole.didAppendNodes(this.element); | ||
if (notify && notify.didAppendNodes) { | ||
notify.didAppendNodes(this.element); | ||
} | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import Ember from 'ember'; | ||
import HashMap from 'perf-primitives/hash-map'; | ||
import getOwnerPolyfill from 'ember-getowner-polyfill'; | ||
|
||
const { getOwner } = Ember; | ||
|
||
export default Ember.Service.extend({ | ||
init() { | ||
this._super(...arguments); | ||
|
||
this.destination = new HashMap(); | ||
}, | ||
|
||
appendWormhole(wormhole, destinationName = 'default') { | ||
let destination = this.destination.get(destinationName); | ||
|
||
if (destination === undefined) { | ||
if (destinationName === 'default') { | ||
destination = this.addDefaultDestination(); | ||
} else { | ||
throw new Error('Liquid Wormhole destination does not exist'); | ||
} | ||
} | ||
|
||
destination.appendWormhole(wormhole); | ||
}, | ||
|
||
removeWormhole(wormhole, destinationName = 'default') { | ||
const destination = this.destination.get(destinationName); | ||
|
||
if (destination === undefined) { | ||
throw new Error('Liquid Wormhole destination does not exist'); | ||
} | ||
|
||
destination.removeWormhole(wormhole); | ||
}, | ||
|
||
registerDestination(destinationName, destination) { | ||
if (this.destination.get(destinationName)) { | ||
throw new Error(`Liquid Wormhole destination '${destinationName}' already created`); | ||
} | ||
this.destination.set(destinationName, destination); | ||
}, | ||
|
||
willDestroy() { | ||
this.removeDefaultDestination(); | ||
}, | ||
|
||
addDefaultDestination() { | ||
const instance = getOwner ? getOwner(this) : getOwnerPolyfill(this); | ||
const destination = instance.lookup('component:liquid-destination'); | ||
destination.set('classNames', ['liquid-destination', 'default-liquid-destination']); | ||
|
||
if (instance.rootElement) { | ||
destination.appendTo(instance.rootElement); | ||
} else if (Ember.$('.ember-application').length > 0) { | ||
destination.appendTo(Ember.$('.ember-application')[0]); | ||
} else { | ||
destination.appendTo(document); | ||
} | ||
|
||
this.defaultDestination = destination; | ||
|
||
return destination; | ||
}, | ||
|
||
removeDefaultDestination() { | ||
if (this.defaultDestination) { | ||
this.defaultDestination.destroy(); | ||
} | ||
} | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,13 @@ | ||
<div id={{wormholeId}} class="{{wormholeClass}} liquid-wormhole-element"> | ||
{{yield}} | ||
</div> | ||
{{#if hasSend}} | ||
{{#if hasBlock}} | ||
{{#component send id=wormholeId class=(concat wormholeClass " liquid-wormhole-element")}} | ||
{{yield}} | ||
{{/component}} | ||
{{else}} | ||
{{component send id=wormholeId class=(concat wormholeClass " liquid-wormhole-element")}} | ||
{{/if}} | ||
{{else}} | ||
<div id={{wormholeId}} class="{{wormholeClass}} liquid-wormhole-element"> | ||
{{yield}} | ||
</div> | ||
{{/if}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from 'liquid-wormhole/components/liquid-destination'; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.