RegExp.escape = function(text)
{
if (!arguments.callee.sRE)
{
var specials = [
'/', '.', '*', '+', '?', '|',
'(', ')', '[', ']', '{', '}', '\\'
];
arguments.callee.sRE = new RegExp(
'(\\' + specials.join('|\\') + ')', 'g'
);
}
return text.replace(arguments.callee.sRE,'\\$1');
};
var BComplete = Class.create();
BComplete.prototype =
{
MAX_VISIBLE : 8,
TIMER_TICK : 10,
CANCEL_SUBMISSION_TIMEOUT : 10,
initialize : function(element,max)
{
if(max)
{
this.MAX_VISIBLE = max;
}
this.data = new Array();
this.element = $(element);
if(!this.element)
{
throw("BComplete: The specified element does not exist.");
}
this.element.setAttribute("autocomplete","off");
Element.addClassName(this.element,"bcomplete-field");
this.visible = false;
this.cancelSubmit = false;
this.scroll = 0;
this.selectedIndex = -1;
this.matches = new Array();
this.popup = document.createElement("div");
Element.hide(this.popup);
this.popup.className = "bcomplete-popup";
document.body.appendChild(this.popup);
this.upButton = document.createElement("div");
this.upButton.className = "up-button";
this.popup.appendChild(this.upButton);
this.listItems = new Array();
for(var i=0;i
var parentForm = this.element.parentNode;
while(parentForm)
{
if(parentForm.tagName.toLowerCase() == "form")
break;
parentForm = parentForm.parentNode;
}
// capture submit event for parent