4 var ls_delay = 500; // Search delay after key up
\r
5 var ls_hidedelay = 500; // Hide delay after lose focus (must be > 0)
\r
7 var ls_mainDiv = 0, // Main div
\r
8 ls_begin_timer = new Number(0);
\r
10 function ls_postLoad()
\r
12 var ls_input = getElementsByClass('ls_search', null, 'input');
\r
13 if (ls_input == null)
\r
15 for (i=0;i<ls_input.length; i++)
\r
17 var input = ls_input[i];
\r
18 input.setAttribute("autocomplete", "off");
\r
19 addEvent(input, 'keyup', liveSearch);
\r
20 addEvent(input, 'focus', liveSearch);
\r
21 addEvent(input, 'input', liveSearch);
\r
22 addEvent(input, 'blur', ls_hide);
\r
27 ls_body = document.body || document.documentElement;
\r
28 ls_mainDiv = insertElement(ls_body, 'DIV', 'ls_my_livesearch');
\r
29 ls_mainDiv.style.position = "absolute";
\r
30 ls_mainDiv.style.zIndex = 10;
\r
31 addLoadEvent(ls_postLoad);
\r
33 function ls_dosearch(parent)
\r
35 my_AJAX.GETupload('ajax.php?ls=' + parent.alt + '&name=' + parent.value, function (text){ls_show(parent, text);});
\r
37 function liveSearch()
\r
39 var name = this.value, input = this;
\r
40 if (name.length < 2)
\r
46 ls_begin_timer.Timer(function (){ls_dosearch(input)}, ls_delay, true);
\r
50 function ls_show(parent, text)
\r
52 ls_mainDiv.innerHTML = text;
\r
53 parseHref(ls_mainDiv);
\r
54 var bounds = getBounds(parent);
\r
57 y = bounds.top + bounds.height+1,
\r
58 max_x = p.width - ls_mainDiv.offsetWidth,
\r
59 max_y = p.height - ls_mainDiv.offsetHeight,
\r
60 x = x > max_x ? max_x : x;
\r
61 y = y > max_y ? max_y : y;
\r
62 var css = ls_mainDiv.style;
\r
63 css.left = (x < p.left ? p.left : x) + 'px';
\r
64 css.top = (y < p.top ? p.top : y) + 'px';
\r
65 css.display = "block";
\r
67 function ls_doHide()
\r
69 ls_mainDiv.style.display = "none";
\r
73 ls_begin_timer.Timer('ls_doHide()', ls_hidedelay, true);
\r