much cooler way of handling the options menu

10.3.x-maintenance
cTn 2014-07-16 13:38:11 +02:00
parent 85bee11712
commit 1fb3dd87e3
1 changed files with 14 additions and 5 deletions

19
main.js
View File

@ -118,6 +118,7 @@ $(document).ready(function() {
if (!el.hasClass('active')) { if (!el.hasClass('active')) {
el.addClass('active'); el.addClass('active');
el.after('<div id="options-window"></div>'); el.after('<div id="options-window"></div>');
$('div#options-window').load('./tabs/options.html', function() { $('div#options-window').load('./tabs/options.html', function() {
googleAnalytics.sendAppView('Options'); googleAnalytics.sendAppView('Options');
@ -147,13 +148,21 @@ $(document).ready(function() {
googleAnalyticsConfig.setTrackingPermitted(result); googleAnalyticsConfig.setTrackingPermitted(result);
}); });
function close_and_cleanup(e) {
if (!$.contains($('div#options-window')[0], e.target)) {
$(document).unbind('click', close_and_cleanup);
$('div#options-window').slideUp(function() {
el.removeClass('active');
$(this).empty().remove();
});
}
}
$(document).bind('click', close_and_cleanup);
$(this).slideDown(); $(this).slideDown();
}); });
} else {
$('div#options-window').slideUp(function() {
el.removeClass('active');
$(this).empty().remove();
});
} }
}); });