0
0
mirror of https://github.com/Doodle3D/doodle3d-client.git synced 2024-11-29 11:54:55 +01:00
doodle3d-client/js/Popup.js

45 lines
1.3 KiB
JavaScript
Raw Normal View History

function Popup(element, mask) {
var autoCloseEnabled = true;
var enterEnabled = true;
2014-01-16 21:30:57 +01:00
var self = this;
this.open = function(complete, disableMaskClick) {
2014-01-16 21:30:57 +01:00
mask.fadeIn(POPUP_SHOW_DURATION);
element.fadeIn(POPUP_SHOW_DURATION, complete);
keyboardShortcutsEnabled = false;
keyboardEscapeEnterEnabled = true;
document.body.removeEventListener('touchmove', prevent, false);
mask.bind("onButtonClick", self.cancel);
$(document).bind("onEscapeKey", self.cancel);
if (enterEnabled) $(document).bind("onEnterKey", self.commit);
2014-01-16 21:30:57 +01:00
}
2014-01-16 21:30:57 +01:00
this.close = function(complete) {
mask.fadeOut(POPUP_SHOW_DURATION);
element.fadeOut(POPUP_SHOW_DURATION, complete);
keyboardShortcutsEnabled = true;
keyboardEscapeEnterEnabled = false;
2014-01-16 21:30:57 +01:00
document.body.addEventListener('touchmove', prevent, false);
mask.unbind("onButtonClick", self.cancel);
$(document).unbind("onEscapeKey", self.cancel);
if (enterEnabled) $(document).unbind("onEnterKey", self.commit);
2014-01-16 21:30:57 +01:00
}
this.setEnterEnabled = function(enabled) { enterEnabled = enabled; }
this.setAutoCloseEnabled = function(enabled) { autoCloseEnabled = enabled; }
this.cancel = function() {
$(element).trigger('onPopupCancel');
if (autoCloseEnabled) self.close();
}
this.commit = function() {
$(element).trigger('onPopupCommit');
if (autoCloseEnabled) self.close();
}
2014-01-09 17:05:03 +01:00
}