mirror of
https://github.com/JannisX11/blockbench.git
synced 2025-01-30 15:42:42 +08:00
Fix dialog closing issues
This commit is contained in:
parent
7a7899eb31
commit
acfdf84d24
@ -51,7 +51,7 @@ var startups = parseInt(localStorage.getItem('startups')||0);
|
||||
localStorage.setItem('startups', startups+1);
|
||||
|
||||
document.getElementById('blackout').addEventListener('click', event => {
|
||||
if (open_interface instanceof Dialog) {
|
||||
if (typeof open_interface.cancel == 'function') {
|
||||
open_interface.cancel(event);
|
||||
} else if (typeof open_interface == 'string' && open_dialog) {
|
||||
$('dialog#'+open_dialog).find('.cancel_btn:not([disabled])').trigger('click');
|
||||
|
@ -399,7 +399,7 @@ window.Dialog = class Dialog {
|
||||
let result = this.onCancel();
|
||||
if (result === false) return;
|
||||
}
|
||||
if (button == this.confirmIndex && typeof this.onButton == 'function') {
|
||||
if (typeof this.onButton == 'function') {
|
||||
let result = this.onButton(button);
|
||||
if (result === false) return;
|
||||
}
|
||||
|
@ -480,7 +480,14 @@ function showDialog(dialog) {
|
||||
$('#blackout').show()
|
||||
obj.show()
|
||||
open_dialog = dialog
|
||||
open_interface = dialog
|
||||
open_interface = {
|
||||
confirm() {
|
||||
$('dialog#'+open_dialog).find('.confirm_btn:not([disabled])').trigger('click');
|
||||
},
|
||||
cancel() {
|
||||
$('dialog#'+open_dialog).find('.cancel_btn:not([disabled])').trigger('click');
|
||||
}
|
||||
}
|
||||
Prop.active_panel = 'dialog'
|
||||
//Draggable
|
||||
if (obj.hasClass('draggable')) {
|
||||
@ -489,9 +496,7 @@ function showDialog(dialog) {
|
||||
containment: '#page_wrapper'
|
||||
})
|
||||
var x = (window.innerWidth-obj.outerWidth()) / 2;
|
||||
var top = (window.innerHeight - obj.outerHeight()) / 2;
|
||||
obj.css('left', x+'px')
|
||||
obj.css('top', 'px')
|
||||
obj.css('max-height', (window.innerHeight-128)+'px')
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user