feat(alert): disable clicking backdrop to dismiss

This commit is contained in:
Adam Bradley
2016-02-05 07:50:14 -06:00
parent b08794e44d
commit 53e014fb0b
2 changed files with 9 additions and 10 deletions

View File

@@ -133,10 +133,11 @@ export class Alert extends ViewController {
id?: string
}>,
buttons?: Array<any>,
disableClickBackdropToDismiss?: boolean
enableBackdropDismiss?: boolean
} = {}) {
opts.inputs = opts.inputs || [];
opts.buttons = opts.buttons || [];
opts.enableBackdropDismiss = (opts.enableBackdropDismiss === false ? false : true);
super(AlertCmp, opts);
this.viewType = 'alert';
@@ -227,7 +228,7 @@ export class Alert extends ViewController {
id?: string
}>,
buttons?: Array<any>,
disableClickBackdropToDismiss?: boolean
enableBackdropDismiss?: boolean
} = {}) {
return new Alert(opts);
}
@@ -373,13 +374,12 @@ class AlertCmp {
let self = this;
self.keyUp = function(ev) {
if (ev.keyCode === 13) {
// enter
console.debug('alert enter');
console.debug('alert, enter button');
let button = self.d.buttons[self.d.buttons.length - 1];
self.btnClick(button);
} else if (ev.keyCode === 27) {
console.debug('alert escape');
console.debug('alert, escape button');
self.bdClick();
}
};
@@ -432,7 +432,7 @@ class AlertCmp {
}
bdClick() {
if (!this.d.disableClickBackdropToDismiss) {
if (this.d.enableBackdropDismiss) {
let cancelBtn = this.d.buttons.find(b => b.role === 'cancel');
if (cancelBtn) {
this.btnClick(cancelBtn, 1);
@@ -470,7 +470,7 @@ class AlertCmp {
return values;
}
onPageDidLeave() {
onPageWillLeave() {
document.removeEventListener('keyup', this.keyUp);
}
}

View File

@@ -239,11 +239,10 @@ class E2EPage {
doDisabledBackdropAlert() {
let alert = Alert.create({
disableClickBackdropToDismiss: true
enableBackdropDismiss: false
});
alert.setTitle('Disabled Backdrop Click'),
alert.setSubTitle('Subtitle'),
alert.setMessage('This is an alert message.'),
alert.setMessage('Cannot dismiss alert from clickings the backdrop'),
alert.addButton({
text: 'Cancel',
role: 'cancel',