This commit is contained in:
syuilo 2017-02-21 09:59:53 +09:00
parent 2f2234f50c
commit a64632bba5
2 changed files with 19 additions and 11 deletions

View File

@ -133,29 +133,35 @@
this.text.focus();
this.refs.window.on('closing', () => {
if @done
this.opts.on-ok @text.value
else
if this.opts.on-cancel?
this.opts.on-cancel!
if (this.done) {
this.opts.onOk(this.text.value);
} else {
if (this.opts.onCancel) this.opts.onCancel();
}
});
this.refs.window.on('closed', () => {
this.unmount();
});
});
this.cancel = () => {
this.done = false
this.done = false;
this.refs.window.close();
};
this.ok = () => {
if not @allow-empty and @text.value == '' then return
this.done = true
if (!this.allowEmpty && this.text.value == '') return;
this.done = true;
this.refs.window.close();
};
this.onKeydown = (e) => {
if e.which == 13 // Enter
this.onKeydown = e => {
if (e.which == 13) { // Enter
e.preventDefault();
e.stopPropagation();
@ok!
this.ok();
}
};
</script>
</mk-input-dialog>

View File

@ -16,5 +16,7 @@
this.on('mount', () => {
this.refs.tl.on('loaded', () => {
this.trigger('loaded');
});
});
</script>
</mk-home>