mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-22 05:21:52 +08:00
alert wip
This commit is contained in:
57
ionic/components/nav/overlay-controller.ts
Normal file
57
ionic/components/nav/overlay-controller.ts
Normal file
@ -0,0 +1,57 @@
|
||||
import {ViewController} from '../view-controller';
|
||||
import {Config} from '../../config/config';
|
||||
import {IonicApp} from '../app/app';
|
||||
|
||||
|
||||
export class OverlayController extends ViewController {
|
||||
|
||||
constructor(navCtrl, componentType, opts={}) {
|
||||
super(null, AlertCmp, opts);
|
||||
|
||||
this.data.inputs = this.data.inputs || [];
|
||||
let buttons = this.data.buttons || [];
|
||||
this.data.buttons = [];
|
||||
for (let button of buttons) {
|
||||
this.addButton(button);
|
||||
}
|
||||
|
||||
this.enterAnimationKey = 'alertEnter';
|
||||
this.leaveAnimationKey = 'alertLeave';
|
||||
}
|
||||
|
||||
setTitle(title) {
|
||||
this.data.title = title;
|
||||
}
|
||||
|
||||
setSubTitle(subTitle) {
|
||||
this.data.subTitle = subTitle;
|
||||
}
|
||||
|
||||
setBody(body) {
|
||||
this.data.body = body;
|
||||
}
|
||||
|
||||
addInput(input) {
|
||||
input.value = isDefined(input.value) ? input.value : '';
|
||||
this.data.inputs.push(input);
|
||||
}
|
||||
|
||||
addButton(button) {
|
||||
if (typeof button === 'string') {
|
||||
button = {
|
||||
text: button
|
||||
};
|
||||
}
|
||||
this.data.buttons.push(button);
|
||||
}
|
||||
|
||||
close() {
|
||||
let index = this._nav.indexOf(this);
|
||||
this._nav.remove(index, { animateFirst: true });
|
||||
}
|
||||
|
||||
onClose(handler) {
|
||||
this.data.onClose = handler;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user