0
0
mirror of https://github.com/Doodle3D/doodle3d-client.git synced 2024-11-25 18:47:57 +01:00
doodle3d-client/js/Popup.js

34 lines
1.2 KiB
JavaScript
Raw Normal View History

function Popup(element, mask) {
2014-01-16 21:30:57 +01:00
var self = this;
var escapeKeyHandler = null;
var enterKeyHandler = null;
2014-01-16 21:30:57 +01:00
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);
2014-01-16 21:30:57 +01:00
mask.bind("onButtonClick", function() { self.close() });
if (escapeKeyHandler) $(document).bind("onEscapeKey", escapeKeyHandler);
if (enterKeyHandler) $(document).bind("onEnterKey", enterKeyHandler);
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);
2014-01-16 21:30:57 +01:00
mask.unbind("onButtonClick");
if (escapeKeyHandler) $(document).unbind("onEscapeKey", escapeKeyHandler);
if (enterKeyHandler) $(document).unbind("onEnterKey", enterKeyHandler);
2014-01-16 21:30:57 +01:00
}
this.setEscapeKeyHandler = function(hnd) { escapeKeyHandler = hnd; }
this.setEnterKeyHandler = function(hnd) { enterKeyHandler = hnd; }
2014-01-09 17:05:03 +01:00
}