Skip to content

Commit

Permalink
feat(actionsheet): disable clicking backdrop to dismiss
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdbradley committed Feb 5, 2016
1 parent c6067c0 commit 7686767
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
19 changes: 14 additions & 5 deletions ionic/components/action-sheet/action-sheet.ts
Expand Up @@ -4,6 +4,7 @@ import {NgFor, NgIf} from 'angular2/common';
import {Animation} from '../../animations/animation';
import {Config} from '../../config/config';
import {Icon} from '../icon/icon';
import {isDefined} from '../../util/util';
import {NavParams} from '../nav/nav-params';
import {ViewController} from '../nav/view-controller';

Expand Down Expand Up @@ -82,9 +83,11 @@ import {ViewController} from '../nav/view-controller';
title?: string,
subTitle?: string,
cssClass?: string,
enableBackdropDismiss?: boolean,
buttons?: Array<any>
} = {}) {
opts.buttons = opts.buttons || [];
opts.enableBackdropDismiss = isDefined(opts.enableBackdropDismiss) ? !!opts.enableBackdropDismiss : true;

super(ActionSheetCmp, opts);
this.viewType = 'action-sheet';
Expand Down Expand Up @@ -242,19 +245,25 @@ class ActionSheetCmp {
}

bdClick() {
if (this.d.cancelButton) {
this.click(this.d.cancelButton, 1);
if (this.d.enableBackdropDismiss) {
if (this.d.cancelButton) {
this.click(this.d.cancelButton, 1);

} else {
this.dismiss('backdrop');
} else {
this.dismiss('backdrop');
}
}
}

dismiss(role): Promise<any> {
return this._viewCtrl.dismiss(null, role);
}

onPageDidLeave() {
onPageWillLeave() {
document.removeEventListener('keyup', this.keyUp);
}

ngOnDestroy() {
document.removeEventListener('keyup', this.keyUp);
}
}
Expand Down
1 change: 1 addition & 0 deletions ionic/components/action-sheet/test/basic/index.ts
Expand Up @@ -57,6 +57,7 @@ class E2EPage {
this.result = '';

let actionSheet = ActionSheet.create({
enableBackdropDismiss: false,
buttons: [
{
text: 'Archive',
Expand Down
2 changes: 1 addition & 1 deletion ionic/components/alert/alert.ts
Expand Up @@ -137,7 +137,7 @@ export class Alert extends ViewController {
} = {}) {
opts.inputs = opts.inputs || [];
opts.buttons = opts.buttons || [];
opts.enableBackdropDismiss = (opts.enableBackdropDismiss === false ? false : true);
opts.enableBackdropDismiss = isDefined(opts.enableBackdropDismiss) ? !!opts.enableBackdropDismiss : true;

super(AlertCmp, opts);
this.viewType = 'alert';
Expand Down

0 comments on commit 7686767

Please sign in to comment.