Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
moodle-theme_boost_campus
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elc
moodle-theme_boost_campus
Commits
41ec250f
Commit
41ec250f
authored
7 years ago
by
Kathrin Osswald
Browse files
Options
Downloads
Patches
Plain Diff
Improved catching shortcuts feature to prevent the catching when form elements are focused.
parent
46cfdb66
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
CHANGES.md
+1
-0
1 addition, 0 deletions
CHANGES.md
amd/build/catchshortcuts.min.js
+1
-1
1 addition, 1 deletion
amd/build/catchshortcuts.min.js
amd/src/catchshortcuts.js
+31
-6
31 additions, 6 deletions
amd/src/catchshortcuts.js
with
33 additions
and
7 deletions
CHANGES.md
+
1
−
0
View file @
41ec250f
...
...
@@ -6,6 +6,7 @@ Changes
### Unreleased
*
2017-09-25 - Improved catching shortcuts feature to prevent the catching when form elements are focused.
*
2017-09-22 - Check if user is logged in before showing the switched role information box.
### Release v3.2-r3
...
...
This diff is collapsed.
Click to expand it.
amd/build/catchshortcuts.min.js
+
1
−
1
View file @
41ec250f
define
([
"
jquery
"
],
function
(
a
){
"
use strict
"
;
function
b
(
b
){
"
end
"
==
b
&&
a
(
document
).
keydown
(
function
(
a
){
35
==
a
.
keyCode
&&
c
(
a
)}),
navigator
.
appVersion
.
indexOf
(
"
Mac
"
)
!=-
1
&&
"
cmdarrowdown
"
==
b
&&
a
(
document
).
keydown
(
function
(
a
){
40
==
a
.
keyCode
&&
a
.
metaKey
&&
c
(
a
)}),
navigator
.
appVersion
.
indexOf
(
"
Win
"
)
!=-
1
&&
"
ctrlarrowdown
"
==
b
&&
a
(
document
).
keydown
(
function
(
a
){
40
==
a
.
keyCode
&&
a
.
ctrlKey
&&
c
(
a
)})}
function
c
(
b
){
b
.
preventDefault
(),
a
(
"
html, body
"
).
animate
({
scrollTop
:
a
(
"
#page-footer
"
).
offset
().
top
-
a
(
window
).
height
()
+
50
},
500
)}
return
{
init
:
function
(
a
){
for
(
var
c
=
0
,
d
=
a
.
length
;
c
<
d
;
c
++
)
b
(
a
[
c
])}}});
\ No newline at end of file
define
([
"
jquery
"
],
function
(
a
){
"
use strict
"
;
function
b
(
b
){
"
end
"
==
b
&&
a
(
document
).
keydown
(
function
(
a
){
35
==
a
.
keyCode
&&
1
!=
d
()
&&
c
(
a
)}),
navigator
.
appVersion
.
indexOf
(
"
Mac
"
)
!=-
1
&&
"
cmdarrowdown
"
==
b
&&
a
(
document
).
keydown
(
function
(
a
){
40
==
a
.
keyCode
&&
a
.
metaKey
&&
1
!=
d
()
&&
c
(
a
)}),
navigator
.
appVersion
.
indexOf
(
"
Win
"
)
!=-
1
&&
"
ctrlarrowdown
"
==
b
&&
a
(
document
).
keydown
(
function
(
a
){
40
==
a
.
keyCode
&&
a
.
ctrlKey
&&
1
!=
d
()
&&
c
(
a
)})}
function
c
(
b
){
b
.
preventDefault
(),
a
(
"
html, body
"
).
animate
({
scrollTop
:
a
(
"
#page-footer
"
).
offset
().
top
-
a
(
window
).
height
()
+
50
},
500
)}
function
d
(){
var
a
=
document
.
activeElement
.
tagName
,
b
=!
1
;
return
"
INPUT
"
!=
a
&&
"
TEXTAREA
"
!=
a
||
(
b
=!
0
),
b
}
return
{
init
:
function
(
a
){
for
(
var
c
=
0
,
d
=
a
.
length
;
c
<
d
;
c
++
)
b
(
a
[
c
])}}});
\ No newline at end of file
This diff is collapsed.
Click to expand it.
amd/src/catchshortcuts.js
+
31
−
6
View file @
41ec250f
...
...
@@ -34,9 +34,12 @@ define(['jquery'], function($) {
// Catch the end key to be able to change the behavior.
$
(
document
).
keydown
(
function
(
e
)
{
if
(
e
.
keyCode
==
35
)
{
// Additionally check no active focus in form elements.
if
(
checkForActiveFormElement
()
!=
true
)
{
// Scroll only to the bottom of the course content.
scrollToBottomOfCourse
(
e
);
}
}
});
}
// This shortcut is only relevant for users operating on MacOS.
...
...
@@ -44,9 +47,12 @@ define(['jquery'], function($) {
// Bind the cmd + arrow down shortcut to be able to change the behavior.
$
(
document
).
keydown
(
function
(
e
)
{
if
(
e
.
keyCode
==
40
&&
e
.
metaKey
)
{
// Additionally check no active focus in form elements.
if
(
checkForActiveFormElement
()
!=
true
)
{
// Scroll only to the bottom of the course content.
scrollToBottomOfCourse
(
e
);
}
}
});
}
// This shortcut is only relevant for users operating on Windows.
...
...
@@ -54,9 +60,12 @@ define(['jquery'], function($) {
// Bind the ctrl + arrow down shortcut to be able to change the behavior.
$
(
document
).
keydown
(
function
(
e
)
{
if
(
e
.
keyCode
==
40
&&
e
.
ctrlKey
)
{
// Additionally check no active focus in form elements.
if
(
checkForActiveFormElement
()
!=
true
)
{
// Scroll only to the bottom of the course content.
scrollToBottomOfCourse
(
e
);
}
}
});
}
}
...
...
@@ -75,6 +84,22 @@ define(['jquery'], function($) {
},
500
);
}
/**
* Function to check for an active form element.
*
* @return boolean
*/
function
checkForActiveFormElement
()
{
// Get the active Element for the current page.
var
activeElement
=
document
.
activeElement
.
tagName
;
var
returnvalue
=
false
;
// Check if the given active element is an input field or a textarea.
if
(
activeElement
==
'
INPUT
'
||
activeElement
==
'
TEXTAREA
'
)
{
returnvalue
=
true
;
}
return
returnvalue
;
}
return
{
init
:
function
(
params
)
{
for
(
var
i
=
0
,
len
=
params
.
length
;
i
<
len
;
i
++
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment