Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/phpmyadmin/phpmyadmin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAayush <aayushism12@gmail.com>2014-03-25 21:35:52 +0400
committerAayush <aayushism12@gmail.com>2014-03-25 21:35:52 +0400
commit25c227ac04d129f3c4746dd480aa1c0f742985cf (patch)
tree27aac740ab189a9b74bf3f64000a1488e06218e7 /js/keyhandler.js
parent199d560e8e5a74555939d2083322fe3435ca6a5e (diff)
complete patch for #4279 ctrl +up/down + ff issue
Signed-off-by: Aayush Anand aayushism12@gmail.com
Diffstat (limited to 'js/keyhandler.js')
-rw-r--r--js/keyhandler.js78
1 files changed, 49 insertions, 29 deletions
diff --git a/js/keyhandler.js b/js/keyhandler.js
index a378249c7a..6e46677a3b 100644
--- a/js/keyhandler.js
+++ b/js/keyhandler.js
@@ -1,8 +1,7 @@
/* vim: set expandtab sw=4 ts=4 sts=4: */
-// gloabl vars to hold Arrow Down event timeStamps
-var prevTimeStamp = 0;
-var curTimeStamp = 0;
+// gloabl vars that holds: 0- if ctrl key is not pressed 1- if ctrl key is pressed
+var ctrlKeyHistory = 0;
/**
* Allows moving around inputs/select by Ctrl+arrows
@@ -13,16 +12,6 @@ function onKeyDownArrowsHandler(e)
{
e = e || window.event;
- curTimeStamp = e.timeStamp;
- if( prevTimeStamp == 0 ) {
- prevTimeStamp = curTimeStamp;
- }
- else if( Math.abs(curTimeStamp-prevTimeStamp) < 150 ) {
- // event in a very quick succession
- return;
- }
- prevTimeStamp = curTimeStamp;
-
var o = (e.srcElement || e.target);
if (!o) {
return;
@@ -30,19 +19,31 @@ function onKeyDownArrowsHandler(e)
if (o.tagName != "TEXTAREA" && o.tagName != "INPUT" && o.tagName != "SELECT") {
return;
}
- if (navigator.userAgent.toLowerCase().indexOf('applewebkit/') != -1) {
- if (e.ctrlKey || e.shiftKey || !e.altKey) {
- return;
+ if ((e.which != 17) && (e.which != 37) && (e.which != 38) && (e.which != 39) && (e.which !=40)) {
+ return;
+ }
+ if (!o.id) {
+ return;
+ }
+
+ if (e.type == "keyup") {
+ if (e.which==17) {
+ ctrlKeyHistory = 0;
}
- } else {
- if (!e.ctrlKey || e.shiftKey || e.altKey) {
- return;
+ return;
+ }
+ else if (e.type == "keydown") {
+ if (e.which == 17) {
+ ctrlKeyHistory = 1;
}
}
- if (!o.id) {
+
+ if (ctrlKeyHistory != 1) {
return;
}
+ e.preventDefault();
+
var pos = o.id.split("_");
if (pos[0] != "field" || typeof pos[2] == "undefined") {
return;
@@ -75,11 +76,6 @@ function onKeyDownArrowsHandler(e)
var is_firefox = navigator.userAgent.toLowerCase().indexOf("firefox/") > -1;
- // restore selected index, bug #3799
- if (is_firefox && e.type == "keyup") {
- o.selectedIndex = window["selectedIndex_" + o.id];
- }
-
var id = "field_" + y + "_" + x;
nO = document.getElementById(id);
if (! nO) {
@@ -91,12 +87,36 @@ function onKeyDownArrowsHandler(e)
if (! nO) {
return;
}
- if (e.type == "keydown") {
- nO.focus();
- if (is_firefox) {
- window["selectedIndex_" + nO.id] = nO.selectedIndex;
+
+ // for firefox select tag
+ var lvalue = o.selectedIndex;
+ var nOvalue = nO.selectedIndex;
+
+ nO.focus();
+
+ if (is_firefox) {
+ var ffversion = '24';
+ var is_firefox_v_24 = navigator.userAgent.toLowerCase().indexOf('firefox/'+ffversion) > -1;
+ if (is_firefox_v_24) {
+ if (e.which == 38 || e.which == 37) {
+ nOvalue++;
+ }
+ else if (e.which == 40 || e.which == 39) {
+ nOvalue--;
+ }
+ nO.selectedIndex=nOvalue;
+ }
+ else {
+ if (e.which == 38 || e.which == 37) {
+ lvalue++;
+ }
+ else if (e.which == 40 || e.which == 39) {
+ lvalue--;
+ }
+ o.selectedIndex=lvalue;
}
}
+
if (nO.tagName != 'SELECT') {
nO.select();
}