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 closure actions #264

Merged
merged 3 commits into from
Nov 12, 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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ export default ModalDialog.extend({

_initEscListener() {
const closeOnEscapeKey = (ev) => {
if (ev.keyCode === ESC_KEY) { this.get('closeAction')(); }
if (ev.keyCode === ESC_KEY) { this.get('onClose')(); }
};

Ember.$('body').on('keyup.modal-dialog', closeOnEscapeKey);
Expand All @@ -275,7 +275,7 @@ export default ModalDialog.extend(EmberKeyboardMixin, {
},

closeOnEsc: Ember.on(keyDown('Escape'), function() {
this.sendAction('close');
this.get('onClose')();
})
});
```
Expand Down
2 changes: 1 addition & 1 deletion addon/components/basic-dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export default Component.extend({
return;
}

this.sendAction('onClose');
this.get('onClose')();
};

const registerClick = () => document.addEventListener('click', this.handleClick);
Expand Down
6 changes: 3 additions & 3 deletions addon/components/modal-dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,14 @@ export default Component.extend({
},
actions: {
onClose() {
this.sendAction('onClose');
this.get('onClose')();
},
onClickOverlay(e) {
e.preventDefault();
if (this.get('onClickOverlay')) {
this.sendAction('onClickOverlay');
this.get('onClickOverlay')();
} else {
this.sendAction('onClose');
this.get('onClose')();
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions tests/dummy/app/templates/animatable.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
{{#if isShowingBasic}}
{{!-- BEGIN-SNIPPET basic-modal-dialog-animatable --}}
{{#modal-dialog
onClose='toggleBasic'
onClose=(action 'toggleBasic')
overlayPosition='sibling'
clickOutsideToClose=true
animatable=true
Expand All @@ -38,7 +38,7 @@
{{#if isShowingTranslucent}}
{{!-- BEGIN-SNIPPET translucent-modal-dialog-animatable --}}
{{#modal-dialog
onClose='toggleTranslucent'
onClose=(action 'toggleTranslucent')
translucentOverlay=true
overlayPosition='sibling'
clickOutsideToClose=true
Expand All @@ -59,7 +59,7 @@
{{#if isShowingWithoutOverlay}}
{{!-- BEGIN-SNIPPET without-overlay-modal-dialog-animatable --}}
{{#modal-dialog
onClose='toggleWithoutOverlay'
onClose=(action 'toggleWithoutOverlay')
hasOverlay=false
animatable=true
}}
Expand All @@ -80,7 +80,7 @@
{{#if isShowingWithoutOverlayClickOutsideToClose}}
{{!-- BEGIN-SNIPPET without-overlay-click-outside-to-close-modal-dialog-animatable --}}
{{#modal-dialog
onClose='toggleWithoutOverlayClickOutsideToClose'
onClose=(action 'toggleWithoutOverlayClickOutsideToClose')
hasOverlay=false
clickOutsideToClose=true
animatable=true
Expand All @@ -93,7 +93,7 @@
{{/if}}
{{#if isShowingWithoutOverlayClickOutsideToCloseAnotherOne}}
{{#modal-dialog
onClose='toggleWithoutOverlayClickOutsideToCloseAnotherOne'
onClose=(action 'toggleWithoutOverlayClickOutsideToCloseAnotherOne')
hasOverlay=false
clickOutsideToClose=true
offset='100px 0'
Expand Down Expand Up @@ -141,7 +141,7 @@
{{#if isShowingSubclassed}}
{{!-- BEGIN-SNIPPET subclass-modal-dialog-animatable --}}
{{#my-cool-modal-dialog
onClose='toggleSubclassed'
onClose=(action 'toggleSubclassed')
animatable=true
}}
<h1>Stop! Modal Time!</h1>
Expand Down
4 changes: 2 additions & 2 deletions tests/dummy/app/templates/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
{{#modal-dialog
onClose=(action (mut isShowingTranslucentWithCallback) false)
translucentOverlay=true
onClickOverlay='clickedTranslucentOverlay'
onClickOverlay=(action 'clickedTranslucentOverlay')
}}
<h1>Stop! Modal Time!</h1>
<p>Translucent Overlay with Callback</p>
Expand Down Expand Up @@ -223,7 +223,7 @@
{{#if isShowingCenteredScrolling}}
{{!-- BEGIN-SNIPPET centered-scrolling-modal-dialog --}}
{{#modal-dialog
onClose='toggleCenteredScrolling'
onClose=(action 'toggleCenteredScrolling')
translucentOverlay=true
targetAttachment='none'
containerClass='centered-scrolling-container'
Expand Down
6 changes: 3 additions & 3 deletions tests/dummy/app/templates/tethered-animatable.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
{{#if isShowingTargetSelector}}
{{!-- BEGIN-SNIPPET target-selector-modal-dialog-liquid-tether --}}
{{#modal-dialog
onClose='toggleTargetSelector'
onClose=(action 'toggleTargetSelector')
hasOverlay=false
targetAttachment=exampleTargetAttachment
attachment=exampleAttachment
Expand Down Expand Up @@ -78,7 +78,7 @@
{{#if isShowingTargetElement}}
{{!-- BEGIN-SNIPPET target-element-modal-dialog-liquid-tether --}}
{{#modal-dialog
onClose='toggleTargetElement'
onClose=(action 'toggleTargetElement')
hasOverlay=false
targetAttachment=exampleTargetAttachment
attachment=exampleAttachment
Expand All @@ -104,7 +104,7 @@
{{#if isShowingElementCenterModal}}
{{!-- BEGIN-SNIPPET element-centered-modal-dialog-liquid-tether --}}
{{#modal-dialog
onClose='toggleElementCenterModal'
onClose=(action 'toggleElementCenterModal')
translucentOverlay=true
tetherTarget='#elementCenter'
animatable=true
Expand Down
4 changes: 2 additions & 2 deletions tests/dummy/app/templates/tethered.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
{{#if isShowingTargetSelector}}
{{!-- BEGIN-SNIPPET target-selector-modal-dialog-tethered --}}
{{#modal-dialog
onClose='toggleTargetSelector'
onClose=(action 'toggleTargetSelector')
hasOverlay=false
targetAttachment=exampleTargetAttachment
attachment=exampleAttachment
Expand All @@ -77,7 +77,7 @@
{{#if isShowingTargetElement}}
{{!-- BEGIN-SNIPPET target-element-modal-dialog-tethered --}}
{{#modal-dialog
onClose='toggleTargetElement'
onClose=(action 'toggleTargetElement')
hasOverlay=false
targetAttachment=exampleTargetAttachment
attachment=exampleAttachment
Expand Down