You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
788 B
41 lines
788 B
9 years ago
|
/** Module for toggling a modal overlay */
|
||
|
var modal = (function () {
|
||
|
var modal = {};
|
||
|
|
||
|
modal.show = function (sel) {
|
||
|
var $m = $(sel);
|
||
|
$m.removeClass('hidden visible');
|
||
|
setTimeout(function () {
|
||
|
$m.addClass('visible');
|
||
|
}, 1);
|
||
|
};
|
||
|
|
||
|
modal.hide = function (sel) {
|
||
|
var $m = $(sel);
|
||
|
$m.removeClass('visible');
|
||
|
setTimeout(function () {
|
||
|
$m.addClass('hidden');
|
||
|
}, 500); // transition time
|
||
|
};
|
||
|
|
||
|
modal.init = function () {
|
||
|
// close modal by click outside the dialog
|
||
|
$('.Modal').on('click', function () {
|
||
|
modal.hide(this);
|
||
|
});
|
||
|
|
||
|
$('.Dialog').on('click', function (e) {
|
||
|
e.stopImmediatePropagation();
|
||
|
});
|
||
|
|
||
|
// Hide all modals on esc
|
||
|
$(window).on('keydown', function (e) {
|
||
|
if (e.which == 27) {
|
||
|
modal.hide('.Modal');
|
||
|
}
|
||
|
});
|
||
|
};
|
||
|
|
||
|
return modal;
|
||
|
})();
|