mirror of
https://github.com/flarum/framework.git
synced 2025-05-22 22:59:57 +08:00
Implement onbeforeunload composer confirmation. closes flarum/core#113
This commit is contained in:
@ -70,6 +70,10 @@ class Composer extends Component {
|
||||
$(document)
|
||||
.on('mousemove', this.handlers.onmousemove = this.onmousemove.bind(this))
|
||||
.on('mouseup', this.handlers.onmouseup = this.onmouseup.bind(this));
|
||||
|
||||
window.onbeforeunload = e => {
|
||||
return this.component && this.component.preventExit();
|
||||
};
|
||||
}
|
||||
|
||||
configHandle(element, isInitialized) {
|
||||
@ -129,7 +133,12 @@ class Composer extends Component {
|
||||
}
|
||||
|
||||
preventExit() {
|
||||
return this.component && this.component.preventExit();
|
||||
if (this.component) {
|
||||
var preventExit = this.component.preventExit();
|
||||
if (preventExit) {
|
||||
return !confirm(preventExit);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
render(anchorToBottom) {
|
||||
|
Reference in New Issue
Block a user