mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-02-15 01:39:34 +01:00
Backport Javascript fix for ajax select widget on IE
This commit is contained in:
parent
ae446948e9
commit
df56a3908b
@ -26,6 +26,15 @@ var current_app = 'etemplate';
|
|||||||
var ajax_select_timer_id = 0;
|
var ajax_select_timer_id = 0;
|
||||||
var ajax_select_timeout = 300;
|
var ajax_select_timeout = 300;
|
||||||
|
|
||||||
|
var ajax_select_event = null;
|
||||||
|
|
||||||
|
// These keys will not trigger a search if the results box is currently displayed
|
||||||
|
var no_search_keys = [
|
||||||
|
'9', // Tab
|
||||||
|
'38', '63232', // Up
|
||||||
|
'40', '63233' // Down
|
||||||
|
];
|
||||||
|
|
||||||
function ajax_select_widget_setup(widget_id, onchange, options, currentapp) {
|
function ajax_select_widget_setup(widget_id, onchange, options, currentapp) {
|
||||||
current_app = currentapp;
|
current_app = currentapp;
|
||||||
if(onchange) {
|
if(onchange) {
|
||||||
@ -197,6 +206,12 @@ function timer_change(e, value) {
|
|||||||
if ( ajax_select_timer_id != 0) {
|
if ( ajax_select_timer_id != 0) {
|
||||||
clearTimeout(ajax_select_timer_id);
|
clearTimeout(ajax_select_timer_id);
|
||||||
}
|
}
|
||||||
|
if(!e) {
|
||||||
|
var e = cloneObject(window.event);
|
||||||
|
} else {
|
||||||
|
var e = cloneObject(e);
|
||||||
|
}
|
||||||
|
ajax_select_event = e;
|
||||||
ajax_select_timer_id = setTimeout(
|
ajax_select_timer_id = setTimeout(
|
||||||
function() {
|
function() {
|
||||||
change(e, value);
|
change(e, value);
|
||||||
@ -209,18 +224,27 @@ function change(e, value) {
|
|||||||
if(!e) {
|
if(!e) {
|
||||||
var e = window.event;
|
var e = window.event;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(e.target) {
|
if(e.target) {
|
||||||
var target = e.target;
|
var target = e.target;
|
||||||
|
} else if (ajax_select_event) {
|
||||||
|
var e = ajax_select_event;
|
||||||
|
ajax_select_event = null;
|
||||||
|
if(e.target) {
|
||||||
|
var target = e.target;
|
||||||
|
} else if (e.srcElement) {
|
||||||
|
var target = e.srcElement;
|
||||||
|
}
|
||||||
} else if (e.srcElement) {
|
} else if (e.srcElement) {
|
||||||
var target = e.srcElement;
|
var target = e.srcElement;
|
||||||
}
|
}
|
||||||
if(target) {
|
if(target) {
|
||||||
if (target.nodeType == 3) { // defeat Safari bug
|
if (target.nodeType == 3) { // defeat Safari bug
|
||||||
target = target.parentNode;
|
target = target.parentNode;
|
||||||
}
|
}
|
||||||
var id = target.id;
|
var id = target.id;
|
||||||
var value = target.value;
|
var value = target.value;
|
||||||
} else if (e) {
|
} else if (typeof(e) == 'string' ) {
|
||||||
var id = e;
|
var id = e;
|
||||||
if(value) {
|
if(value) {
|
||||||
var value = value;
|
var value = value;
|
||||||
@ -228,14 +252,30 @@ function change(e, value) {
|
|||||||
var value = e.value;
|
var value = e.value;
|
||||||
}
|
}
|
||||||
var set_id = id.substr(0, id.lastIndexOf('['));
|
var set_id = id.substr(0, id.lastIndexOf('['));
|
||||||
|
} else {
|
||||||
|
alert('Error in events');
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var base_id = id.substr(0, id.lastIndexOf('['));
|
var base_id = id.substr(0, id.lastIndexOf('['));
|
||||||
if(document.getElementById(base_id + '[results]')) {
|
if(document.getElementById(base_id + '[results]')) {
|
||||||
set_id = base_id + '[results]';
|
set_id = base_id + '[results]';
|
||||||
// Tab doesn't trigger the search
|
|
||||||
if(e.keyCode == 9 ) {
|
/*
|
||||||
return;
|
* We check for Tab, Up and Down
|
||||||
|
*/
|
||||||
|
var interested = false;
|
||||||
|
var keycode = '';
|
||||||
|
for(var i = 0; i < no_search_keys.length; i++) {
|
||||||
|
if(e.which) {
|
||||||
|
keycode = e.which;
|
||||||
|
} else if(e && e.keyCode) {
|
||||||
|
keycode = e.keyCode;
|
||||||
|
}
|
||||||
|
if(keycode == no_search_keys[i]) {
|
||||||
|
interested = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
set_id = base_id + '[search]';
|
set_id = base_id + '[search]';
|
||||||
@ -257,6 +297,18 @@ function change(e, value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deep copy an object
|
||||||
|
* Used because IE thinks its a good idea to use a global var for events
|
||||||
|
*/
|
||||||
|
function cloneObject(obj) {
|
||||||
|
var clone = {};
|
||||||
|
for(var i in obj) {
|
||||||
|
clone[i] = obj[i];
|
||||||
|
}
|
||||||
|
return clone;
|
||||||
|
}
|
||||||
|
|
||||||
/* Remove options from a results box
|
/* Remove options from a results box
|
||||||
* @param id - The id of the select
|
* @param id - The id of the select
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user