Commit 3df5c0bd authored by Dave Lane's avatar Dave Lane

addressed problem of greedy spacebar grabbing

parent 728b973a
......@@ -31,7 +31,7 @@ jQuery(document).ready(function() {
*/
var trigger = '.ore-trigger'; // trigger for menu content
var menu = 'ore-menu'; // the actual menu class
var menu_showing = false; // is menu currently showing?
/*
* general functions, not dependent on specific data objects
......@@ -243,10 +243,12 @@ jQuery(document).ready(function() {
$(this).next().animate({opacity: 1.0}, {duration: pausetime, complete: function() {
$(this).fadeOut(fadetime);
}
//menu_showing = false; // make sure we set this...
});
}
function create_menu(trigger, text) {
trigger.next('.'+menu).remove();
menu_showing = false; // make sure we set this...
// create the menu
trigger.after('<div class="'+menu+'">'+text+'</div>');
// manage positioning of the menus (voffset pixels above and hoffset left of trigger)
......@@ -254,6 +256,7 @@ jQuery(document).ready(function() {
var top = trigger.outerHeight()+10; // offset of 10 required
//trigger.next().css('right',right);
trigger.next().css('top',top);
menu_showing = true; // make sure we set this...
}
function enable_menu() {
LOG('enabling menu');
......@@ -263,6 +266,7 @@ jQuery(document).ready(function() {
LOG('click on menu to start delayed fade out');
$(this).animate({opacity: 1.0}, {duration: postclicktime, complete: function() {
$(this).fadeOut(fadetime);
menu_showing = false;
}});
});
});
......@@ -273,6 +277,7 @@ function close_menu() {
$('.'+menu).each(function() {
// $(this).hide();
$(this).remove();
menu_showing = false;
});
}
// process button clicks and other events
......@@ -292,6 +297,16 @@ function menu_events(target) {
return show_modal(id);
}
}
// check if a menu is currently showing...
function is_menu_showing() {
if (!menu_showing) {
LOG('no menu is showing');
return false;
} else {
LOG('menu is currently showing');
return true;
}
}
/*
* End menu stuff
*/
......@@ -636,7 +651,6 @@ function show_modal(id) {
form = $('#ore-container').append(form_markup);
// set the "current_modal" value...
current_modal = id;
} else {
LOG('do nothing: we\'re already showing the modal: ', id);
}
......@@ -720,6 +734,17 @@ function close_modal(hash = null) {
set_hash(hash);
}
}
// check if a modal is currently showing...
function is_modal_showing() {
if (current_modal === null) {
LOG('no modal is showing');
return false;
} else {
LOG('current modal = '+current_modal);
return true;
}
}
// respond to modal events like button clicks on modal forms
function modal_events(action){
var special_data = {};
......@@ -1083,13 +1108,15 @@ if (user_status()) {
$(document).click(function(){
LOG('document click - closing menus: '+menu);
$("."+menu).remove();
menu_showing = false; // make sure we set this...
});
// set this up to submit on 'enter'
//$('input').keypress( function (e) {
$(document).keydown( function (e) {
c = e.which ? e.which : e.keyCode;
LOG('input: ', c);
if (c == 13 || c == 32) { // the enter key or spacebar
//if (c == 13 || c == 32) { // the enter key or spacebar
// only do this if a menu or modal is showing...
if ((is_menu_showing() || is_modal_showing()) && c == 13) { // the enter key or spacebar
//$('#ore-default').click();
var $focused = $(':focus');
LOG('document keypress (enter or spacebar)!');
......@@ -1105,6 +1132,7 @@ $(document).keyup( function (e) {
if (e.key === 'Escape') { // ESCape pressed
LOG('document keypress (ESC) - closing menus: '+menu);
$("."+menu).remove();
menu_showing = false; // make sure we set this...
}
});
});
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment