mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-01 12:23:50 +01:00
Backport Javascript fix for ajax select widget on IE
This commit is contained in:
parent
71c52d4e43
commit
ec3d8a7869
@ -26,6 +26,8 @@ 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
|
// These keys will not trigger a search if the results box is currently displayed
|
||||||
var no_search_keys = [
|
var no_search_keys = [
|
||||||
'9', // Tab
|
'9', // Tab
|
||||||
@ -212,6 +214,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);
|
||||||
@ -224,8 +232,17 @@ 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;
|
||||||
}
|
}
|
||||||
@ -235,7 +252,7 @@ function change(e, value) {
|
|||||||
}
|
}
|
||||||
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;
|
||||||
@ -243,6 +260,9 @@ 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('['));
|
||||||
@ -254,8 +274,14 @@ function change(e, value) {
|
|||||||
* We check for Tab, Up and Down
|
* We check for Tab, Up and Down
|
||||||
*/
|
*/
|
||||||
var interested = false;
|
var interested = false;
|
||||||
|
var keycode = '';
|
||||||
for(var i = 0; i < no_search_keys.length; i++) {
|
for(var i = 0; i < no_search_keys.length; i++) {
|
||||||
if(e.keyCode == no_search_keys[i]) {
|
if(e.which) {
|
||||||
|
keycode = e.which;
|
||||||
|
} else if(e && e.keyCode) {
|
||||||
|
keycode = e.keyCode;
|
||||||
|
}
|
||||||
|
if(keycode == no_search_keys[i]) {
|
||||||
interested = true;
|
interested = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -285,6 +311,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