Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
OERu
register-enrol
Commits
3df5c0bd
Commit
3df5c0bd
authored
Apr 20, 2020
by
Dave Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
addressed problem of greedy spacebar grabbing
parent
728b973a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
4 deletions
+32
-4
js/ore_script.js
js/ore_script.js
+32
-4
No files found.
js/ore_script.js
View file @
3df5c0bd
...
...
@@ -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...
}
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment