Skip to content
Snippets Groups Projects
Commit 41ec250f authored by Kathrin Osswald's avatar Kathrin Osswald
Browse files

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
......@@ -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
......
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
......@@ -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++) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment