[richfaces-svn-commits] JBoss Rich Faces SVN: r18734 - in branches/RF-9096/src/main: resources/META-INF/resources/org.richfaces and 1 other directory.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Tue Aug 17 15:11:28 EDT 2010


Author: nbelaevski
Date: 2010-08-17 15:11:27 -0400 (Tue, 17 Aug 2010)
New Revision: 18734

Added:
   branches/RF-9096/src/main/resources/META-INF/resources/org.richfaces/Autocomplete.ecss
   branches/RF-9096/src/main/resources/META-INF/resources/org.richfaces/Autocomplete.js
   branches/RF-9096/src/main/resources/META-INF/resources/org.richfaces/AutocompleteBase.js
Removed:
   branches/RF-9096/src/main/resources/META-INF/resources/org.richfaces/Auto_complete.ecss
   branches/RF-9096/src/main/resources/META-INF/resources/org.richfaces/Auto_complete.js
   branches/RF-9096/src/main/resources/META-INF/resources/org.richfaces/Auto_completeBase.js
Modified:
   branches/RF-9096/src/main/java/org/richfaces/renderkit/html/images/AutocompleteButtonGradient.java
   branches/RF-9096/src/main/java/org/richfaces/renderkit/html/images/AutocompleteFieldGradient.java
Log:
RF-9096

Modified: branches/RF-9096/src/main/java/org/richfaces/renderkit/html/images/AutocompleteButtonGradient.java
===================================================================
--- branches/RF-9096/src/main/java/org/richfaces/renderkit/html/images/AutocompleteButtonGradient.java	2010-08-17 19:07:20 UTC (rev 18733)
+++ branches/RF-9096/src/main/java/org/richfaces/renderkit/html/images/AutocompleteButtonGradient.java	2010-08-17 19:11:27 UTC (rev 18734)
@@ -29,7 +29,7 @@
  * 
  */
 @DynamicResource
-public class AutocompleteButtonGradient extends Auto_completeBaseGradient {
+public class AutocompleteButtonGradient extends AutocompleteBaseGradient {
 
     public AutocompleteButtonGradient() {
         setTopColorSkinParameter(Skin.HEADER_GRADIENT_COLOR);

Modified: branches/RF-9096/src/main/java/org/richfaces/renderkit/html/images/AutocompleteFieldGradient.java
===================================================================
--- branches/RF-9096/src/main/java/org/richfaces/renderkit/html/images/AutocompleteFieldGradient.java	2010-08-17 19:07:20 UTC (rev 18733)
+++ branches/RF-9096/src/main/java/org/richfaces/renderkit/html/images/AutocompleteFieldGradient.java	2010-08-17 19:11:27 UTC (rev 18734)
@@ -29,7 +29,7 @@
  * 
  */
 @DynamicResource
-public class AutocompleteFieldGradient extends Auto_completeBaseGradient {
+public class AutocompleteFieldGradient extends AutocompleteBaseGradient {
 
     public AutocompleteFieldGradient() {
         setTopColorSkinParameter(Skin.ADDITIONAL_BACKGROUND_COLOR);

Deleted: branches/RF-9096/src/main/resources/META-INF/resources/org.richfaces/Auto_complete.ecss
===================================================================
--- branches/RF-9096/src/main/resources/META-INF/resources/org.richfaces/Auto_complete.ecss	2010-08-17 19:07:20 UTC (rev 18733)
+++ branches/RF-9096/src/main/resources/META-INF/resources/org.richfaces/Auto_complete.ecss	2010-08-17 19:11:27 UTC (rev 18734)
@@ -1,152 +0,0 @@
-.rf-au-f-w{
-	width: 200px;
-}
-
-.rf-au-l-w{
-	width: 200px;
-}
-
-.rf-au-l-h{
-	max-height: 100px;
-	min-height: 20px;
-}
-
-.rf-au-i.rf-au-ft, .rf-au-o.rf-au-ft{
-	color: '#{richSkin.generalTextColor}';
-	font-size: '#{richSkin.generalSizeFont}';
-	font-family: '#{richSkin.generalFamilyFont}';
-}
-
-input.rf-au-i {
-	border-width: 0px;
-	background: none;
-	width: 100%;
-}
-
-.rf-au-f{
-	position: inline-block;
-	border-width: 1px;
-	border-style: solid;
-	border-color: '#{richSkin.panelBorderColor}';
-	display: inline-block;
-	background-image: "url(#{resource['org.richfaces.renderkit.html.images.AutocompleteFieldGradient']})";
-	background-repeat: repeat-x;
-	background-position: top left;
-	background-color: '#{richSkin.controlBackgroundColor}';
-}
-
-.rf-au-b{
-	background-image: "url(#{resource['org.richfaces.renderkit.html.images.AutocompleteButtonGradient']})";
-	background-repeat: repeat-x;
-	background-position: top left;
-	background-color: '#{richSkin.headerBackgroundColor}';
-	text-align: center;
-	border-left-style: solid;
-	border-left-width: 1px;
-	border-left-color: '#{richSkin.panelBorderColor}';
-	width: 15px;
-	position: absolute;
-	top: 0px;
-	right: 0px;
-	height: 200px;
-	padding-top: 1px
-}
-
-.rf-au-b-a{
-	background-position: center;
-	background-repeat: no-repeat;
-	background-image: "url(#{resource['org.richfaces:combo_down_button.gif']})";
-	cursor: pointer;
-	width: 15px;
-	height: 15px;
-}
-
-.rf-au-l-c{
-	position: absolute;
-	/* TODO nick - review: font-size: 0px; */
-	display: none;
-}
-
-.rf-au-l-d{
-	border-width: 1px;
-	border-style: solid;
-	border-color: '#{richSkin.panelBorderColor}';
-	padding: 0px;
-	background-color: '#{richSkin.tableBackgroundColor}';
-}
-
-.rf-au-l-s{
-	overflow: auto;
-	overflow-x: hidden;
-}
-
-.rf-au-o{
-	padding: 2px;
-	white-space: nowrap;
-	cursor: default;
-	list-style-type: none;
-}
-
-.rf-au-s{
-	padding: 1px;
-	width: 100%;
-	background-color: '#{richSkin.headerBackgroundColor}';
-	border-width: 1px;
-	border-style: dotted;
-	border-color: '#{richSkin.generalTextColor}';
-}
-
-.rf-au-shw{
-	border: 0px solid red;
-	display: inline-block;
-	position: absolute;
-	float: left;
-	padding: 6px 6px 6px 6px;
-	top: -6px;
-	left: -7px;
-}
-
-.rf-au-shw-t{
-	background-image: "url(#{resource['org.richfaces:combo_list_shadow.png']})";
-	background-position: top left;
-	position: absolute;
-	width: 6px;
-	top: 0px;
-	bottom: 6px;
-	left: 0px
-}
-
-.rf-au-shw-l{
-	background-image: "url(#{resource['org.richfaces:combo_list_shadow.png']})";
-	background-position: bottom left;
-	position: absolute;
-	height: 6px;
-	bottom: 0px;
-	left: 0px;
-	right: 6px;
-}
-
-.rf-au-shw-r{
-	background-image: "url(#{resource['org.richfaces:combo_list_shadow.png']})";
-	background-position: bottom right;
-	position: absolute;
-	width: 6px;
-	top: 6px;
-	bottom: 0px;
-	right: 0px;
-}
-
-.rf-au-shw-b{
-	background-image: "url(#{resource['org.richfaces:combo_list_shadow.png']})";
-	background-position: right top;
-	position: absolute;
-	height: 6px;
-	top: 0px;
-	left: 6px;
-	right: 0px;
-}
-
-.rf-au-l-ul{
-	margin: 0px;
-	padding: 0px;
-}
\ No newline at end of file

Deleted: branches/RF-9096/src/main/resources/META-INF/resources/org.richfaces/Auto_complete.js
===================================================================
--- branches/RF-9096/src/main/resources/META-INF/resources/org.richfaces/Auto_complete.js	2010-08-17 19:07:20 UTC (rev 18733)
+++ branches/RF-9096/src/main/resources/META-INF/resources/org.richfaces/Auto_complete.js	2010-08-17 19:11:27 UTC (rev 18734)
@@ -1,408 +0,0 @@
-(function ($, rf) {
-	rf.utils = rf.utils || {};
-
-	rf.utils.Cache = function (key, items, values) {
-		this.key = key;
-		this.cache = {}
-		this.cache[this.key] = items || [];
-		this.values = typeof values != "function" ? values || this.cache[this.key] : values(items);
-	};
-
-	var getItems = function (key) {
-		var newCache = [];
-		
-		if (key.length < this.key.length) {
-			return newCache;
-		}
-
-		if (this.cache[key]) {
-			newCache = this.cache[key];
-		} else {
-			var itemsCache = this.cache[this.key];
-			for (var i = 0; i<this.values.length; i++) {
-				var value = this.values[i].toLowerCase();
-				var p = value.indexOf(key.toLowerCase());
-				if (p == 0) {
-					newCache.push(itemsCache[i]);
-				}
-			}
-
-			if ((!this.lastKey || key.indexOf(this.lastKey)!=0) && newCache.length > 0) {
-				this.cache[key] = newCache;
-				if (newCache.length==1) {
-					this.lastKey = key;
-				}
-			}
-		}
-
-		return newCache;
-	};
-	
-	var getItemValue = function (item) {
-		return this.values[this.cache[this.key].index(item)];
-	};
-	
-	var isCached = function (key) {
-		return this.cache[key];
-	};
-
-	$.extend(rf.utils.Cache.prototype, (function () {
-		return  {
-			getItems: getItems,
-			getItemValue: getItemValue,
-			isCached: isCached
-		};
-	})());
-
-})(jQuery, RichFaces);
-
-(function ($, rf) {
-
-	/*
-	 * TODO: add user's event handlers call from options
-	 * TODO: add fire events
-	 */
-	
-	rf.ui = rf.ui || {};
-	// Constructor definition
-	rf.ui.Autocomplete = function(componentId, fieldId, options) {
-		this.namespace = "."+rf.Event.createNamespace(this.name, this.id);
-		this.options = {};
-		// call constructor of parent class
-		$super.constructor.call(this, componentId, componentId+ID.SELECT, fieldId, options);
-		this.attachToDom(componentId);
-		this.options = $.extend(this.options, defaultOptions, options);
-		this.value = this.__getSubValue();
-		this.index = -1;
-		this.isFirstAjax = true;
-		updateTokenOptions.call(this);
-		bindEventHandlers.call(this);
-		updateItemsList.call(this, "");
-	};
-
-	// Extend component class and add protected methods from parent class to our container
-	rf.ui.AutocompleteBase.extend(rf.ui.Autocomplete);
-
-	// define super class link
-	var $super = rf.ui.Autocomplete.$super;
-
-	var defaultOptions = {
-		selectedItemClass:'rf-au-s',
-		autoFill:true,
-		minChars:1,
-		selectFirst:true,
-		ajaxMode:true,
-		tokens: ",",
-		attachToBody:true
-	};
-
-	var ID = {
-		SELECT:'List',
-		ITEMS:'Items',
-		VALUE:'Value'
-	};
-	
-	var REGEXP_TRIM = /^[\n\s]*(.*)[\n\s]*$/;
-	var REGEXP_TOKEN_LEFT;
-	var REGEXP_TOKEN_RIGHT;
-	
-	var getData = function (nodeList) {
-		var data = [];
-		nodeList.each(function () {;
-			data.push($(this).text().replace(REGEXP_TRIM, "$1"));
-		});
-		return data;
-	}
-	
-	var updateTokenOptions = function () {
-		this.useTokens = (typeof this.options.tokens == "string" && this.options.tokens.length>0);
-		if (this.useTokens) {
-			var escapedTokens = this.options.tokens.split('').join("\\");
-			REGEXP_TOKEN_LEFT = new RegExp('[^'+escapedTokens+']+$','i');
-			REGEXP_TOKEN_RIGHT = new RegExp('['+escapedTokens+']','i');
-			this.hasSpaceToken = this.options.tokens.indexOf(' ')!=-1;
-		};
-	};
-
-	var bindEventHandlers = function () {
-		rf.Event.bind(rf.getDomElement(this.id+ID.ITEMS).parentNode, "click"+this.namespace+" mouseover"+this.namespace, onMouseAction, this);
-	};
-
-	var onMouseAction = function(event) {
-		var element = $(event.target).closest(".rf-ac-i", event.currentTarget).get(0);
-
-		if (element) {
-			if (event.type=="mouseover") {
-				var index = this.items.index(element);
-				if (index!=this.index) {
-					selectItem.call(this, index);
-				}
-			} else {
-				this.__onChangeValue(event, getSelectedItemValue.call(this));
-				rf.Selection.setCaretTo(rf.getDomElement(this.fieldId));
-				this.hide(event);
-			}
-		}
-	};
-
-	var updateItemsList = function (value, fetchValues) {
-		this.items = $(rf.getDomElement(this.id+ID.ITEMS)).find(".rf-ac-i");
-		if (this.items.length>0) {
-			this.cache = new rf.utils.Cache(value, this.items, fetchValues || getData);
-		}
-	};
-
-	var scrollToSelectedItem = function() {
-        var offset = 0;
-        this.items.slice(0, this.index).each(function() {
-			offset += this.offsetHeight;
-		});
-        var parentContainer = $(rf.getDomElement(this.id+ID.ITEMS)).parent();
-        if(offset < parentContainer.scrollTop()) {
-        	parentContainer.scrollTop(offset);
-        } else {
-        	offset+=this.items.get(this.index).offsetHeight;
-        	if(offset - parentContainer.scrollTop() > parentContainer.get(0).clientHeight) {
-        		parentContainer.scrollTop(offset - parentContainer.innerHeight());
-            }
-        }
-	};
-
-	var autoFill = function (inputValue, value) {
-		if( this.options.autoFill) {
-			var field = rf.getDomElement(this.fieldId);
-			var start = rf.Selection.getStart(field);
-			this.setInputValue(inputValue + value.substring(inputValue.length));
-			var end = start+value.length - inputValue.length;
-			rf.Selection.set(field, start, end);
-		}
-	};
-
-	var callAjax = function(event, value) {
-		
-		$(rf.getDomElement(this.id+ID.ITEMS)).removeData().empty();
-		rf.getDomElement(this.id+ID.VALUE).value = value;
-		
-		var _this = this;
-		var ajaxSuccess = function (event) {
-			updateItemsList.call(_this, _this.value, event.componentData && event.componentData[_this.id]);
-			if (_this.isVisible && _this.options.selectFirst) {
-				selectItem.call(_this, 0);
-			}
-		}
-		
-		var ajaxError = function (event) {
-			//alert("error");
-		}
-		
-		this.isFirstAjax = false;
-		//caution: JSF submits inputs with empty names causing "WARNING: Parameters: Invalid chunk ignored." in Tomcat log
-		var params = {};
-		params[this.id + ".ajax"] = "1";
-		rf.ajax(this.id, event, {parameters: params, error: ajaxError, complete:ajaxSuccess});
-	};
-	
-	var selectItem = function(index, isOffset, noAutoFill) {
-		if (this.items.length==0) return;
-	
-		if (this.index!=-1) {
-				this.items.eq(this.index).removeClass(this.options.selectedItemClass);
-		}
-
-		if (index==undefined) {
-			this.index = -1;
-			return;
-		}
-
-		if (isOffset) {
-			this.index += index;
-		if ( this.index<0 ) {
-			this.index = this.items.length - 1;
-		} else if (this.index >= this.items.length) {
-			this.index = 0;
-		}
-		} else {
-			if (index<0) {
-				index = 0;
-			} else if (index>=this.items.length) {
-				index = this.items.length - 1;
-			}
-			this.index = index;
-		}
-		var item = this.items.eq(this.index);
-		item.addClass(this.options.selectedItemClass);
-		scrollToSelectedItem.call(this);
-		!noAutoFill && autoFill.call(this, this.value, getSelectedItemValue.call(this));
-	};
-	
-	var onChangeValue = function (event, value) {
-		//if(this.options.onchange){
-				//this.options.onchange.call(this, event);
-		//}
-		selectItem.call(this);
-		
-		// value is undefined if called from AutocompleteBase onChange
-		var subValue = (typeof value == "undefined") ? this.__getSubValue() : value;
-		
-		// TODO: ajax call here if needed
-		if ((!this.cache || subValue.length==0 || subValue.toLowerCase().indexOf(this.cache.key.toLowerCase())!=0) && 
-				subValue.length>=this.options.minChars) {
-			this.value = subValue;
-			this.options.ajaxMode && callAjax.call(this, event, subValue);
-			return;
-		}
-		if(!this.cache){
-			return;
-		}
-		var newItems = this.cache.getItems(subValue);
-		this.items = $(newItems);
-		//TODO: works only with simple markup, not with <tr>
-		$(rf.getDomElement(this.id+ID.ITEMS)).empty().append(newItems);
-		this.index = -1;
-		this.value = subValue;
-		if (subValue.length<this.options.minChars){
-			this.hide();
-		}
-		if (this.options.selectFirst) {
-			if (event.which == rf.KEYS.RETURN || event.type == "click") {
-				this.setInputValue(subValue);
-				return;
-			} else {
-				selectItem.call(this, 0, false, event.which == rf.KEYS.BACKSPACE || event.which == rf.KEYS.LEFT || event.which == rf.KEYS.RIGHT);
-				return;
-			}
-		}
-		this.setInputValue(subValue);
-	};
-	
-	var getSelectedItemValue = function () {
-		if ( this.index>=0) {
-			var element = this.items.eq(this.index);
-			return this.cache.getItemValue(element);
-		}
-		return undefined;
-	};
-	
-	var getSubValue = function () {
-		//TODO: add posibility to use space chars before and after tokens if space not a token char
-		if (this.useTokens) {
-			var field = rf.getDomElement(this.fieldId);
-			var value = field.value;
-			var cursorPosition = rf.Selection.getStart(field);
-			var beforeCursorStr = value.substring(0, cursorPosition);
-			var afterCursorStr = value.substring(cursorPosition);
-			var r = REGEXP_TOKEN_LEFT.exec(beforeCursorStr);
-			var result = "";
-			if (r) {
-				result = r[0];
-			}
-			r = afterCursorStr.search(REGEXP_TOKEN_RIGHT);
-			if (r==-1) r = afterCursorStr.length;
-			result += afterCursorStr.substring(0, r);
-
-			return result;
-		} else {
-			return this.getInputValue();
-		}
-	};
-	
-	var updateInputValue = function (value) {
-		var field = rf.getDomElement(this.fieldId);
-		var inputValue = field.value;
-		
-		var cursorPosition = rf.Selection.getStart(field);
-		var beforeCursorStr = inputValue.substring(0, cursorPosition);
-		var afterCursorStr = inputValue.substring(cursorPosition);
-		
-		var pos = beforeCursorStr.search(REGEXP_TOKEN_LEFT);
-		var startPos = pos!=-1 ? pos : beforeCursorStr.length;
-		pos = afterCursorStr.search(REGEXP_TOKEN_RIGHT);
-		var endPos = pos!=-1 ? pos : afterCursorStr.length;
-		
-		var beginNewValue = inputValue.substring(0, startPos) + value;
-		cursorPosition = beginNewValue.length;
-		field.value = beginNewValue + afterCursorStr.substring(endPos);
-		field.focus();
-		rf.Selection.setCaretTo(field, cursorPosition);
-		return field.value;
-	};
-	
-	/*
-	 * Prototype definition
-	 */
-	$.extend(rf.ui.Autocomplete.prototype, (function () {
-		return {
-			/*
-			 * public API functions
-			 */
- 			name:"Autocomplete",
- 			/*
- 			 * Protected methods
- 			 */
- 			__updateState: function (event) {
-				var subValue = this.__getSubValue();
-				// called from onShow method, not actually value changed
-				if (this.items.length==0 && this.isFirstAjax) {
-					this.options.ajaxMode && callAjax.call(this, event, subValue);
-				}
-				return;
-			},
- 			__getSubValue: getSubValue,
- 			__updateInputValue: function (value) {
-				if (this.useTokens) {
-					return updateInputValue.call(this, value);
-				} else {
-					return $super.__updateInputValue.call(this, value);
-				}
- 			},
- 			__onChangeValue: onChangeValue,
- 			/*
- 			 * Override abstract protected methods
- 			 */
- 			__onKeyUp: function () {
- 				selectItem.call(this, -1, true);
- 			},
- 			__onKeyDown: function () {
- 				selectItem.call(this, 1, true);
- 			},
- 			__onPageUp: function () {
-
- 			},
- 			__onPageDown: function () {
-
- 			},
- 			__onBeforeShow: function (event) {
- 			},
- 			__onEnter: function (event) {
- 				this.__onChangeValue(event, getSelectedItemValue.call(this));
-				//rf.getDomElement(this.fieldId).blur();
-				//rf.Selection.setCaretTo(rf.getDomElement(this.fieldId));
-				//rf.getDomElement(this.fieldId).focus();
- 			},
- 			__onShow: function (event) {
- 				if (event.which != rf.KEYS.BACKSPACE) {
- 					if(this.items && this.items.length>0){
- 						if (this.index!=0 && this.options.selectFirst) {
- 							selectItem.call(this, 0);
- 						}
- 					}
- 				}
- 			},
- 			__onHide: function () {
- 				selectItem.call(this);
- 			},
- 			/*
- 			 * Destructor
- 			 */
- 			destroy: function () {
-				//TODO: add all unbind
-				this.items = null;
-				this.cache = null;
-				var itemsContainer = rf.getDomElement(this.id+ID.ITEMS);
-				$(itemsContainer).removeData();
-				rf.Event.unbind(itemsContainer.parentNode, this.namespace);
-				$super.destroy.call(this);
- 			}
-		};
-	})());
-})(jQuery, RichFaces);
\ No newline at end of file

Deleted: branches/RF-9096/src/main/resources/META-INF/resources/org.richfaces/Auto_completeBase.js
===================================================================
--- branches/RF-9096/src/main/resources/META-INF/resources/org.richfaces/Auto_completeBase.js	2010-08-17 19:07:20 UTC (rev 18733)
+++ branches/RF-9096/src/main/resources/META-INF/resources/org.richfaces/Auto_completeBase.js	2010-08-17 19:11:27 UTC (rev 18734)
@@ -1,297 +0,0 @@
-// TODO: move this extend to RichFaces.Event for exapmle
-$.extend(RichFaces.Event, {
-	bindScrollEventHandlers: function(element, handler, component) {
-		var elements = [];
-		element = RichFaces.getDomElement(element).parentNode;
-		while (element && element!=window.document.body)
-		{
-			if (element.offsetWidth!=element.scrollWidth || element.offsetHeight!=element.scrollHeight)
-			{
-				elements.push(element);
-				RichFaces.Event.bind(element, "scroll"+component.getNamespace(), handler, component);
-			}
-			element = element.parentNode;
-		}
-		return elements;
-	},
-	unbindScrollEventHandlers: function(elements, component) {
-		RichFaces.Event.unbind(elements, component.getNamespace());
-	}
-});
-
-(function (rf) {
-	rf.KEYS = {
-		BACKSPACE: 8,	
-		TAB: 9,
-		RETURN: 13,
-		ESC: 27,
-		PAGEUP: 33,
-		PAGEDOWN: 34,
-		LEFT: 37,
-		UP: 38,
-		RIGHT: 39,
-		DOWN: 40,
-		DEL: 46,
-	}
-})(RichFaces);
-
-(function ($, rf) {
-
-	rf.ui = rf.ui || {}; 
-	
-	// Constructor definition
-	rf.ui.AutocompleteBase = function(componentId, selectId, fieldId, options) {
-		// call constructor of parent class
-		$super.constructor.call(this, componentId);
-		this.selectId = selectId;
-		this.fieldId = fieldId;
-		this.options = $.extend({}, defaultOptions, options);
-		this.namespace = this.namespace || "."+rf.Event.createNamespace(this.name, this.selectId);
-		this.currentValue = this.getInputValue();
-		bindEventHandlers.call(this);
-	};
-	
-	// Extend component class and add protected methods from parent class to our container
-	rf.BaseComponent.extend(rf.ui.AutocompleteBase);
-	
-	// define super class link
-	var $super = rf.ui.AutocompleteBase.$super;
-	
-	var defaultOptions = {
-			changeDelay:8
-	};
-	
-	var bindEventHandlers = function() {
-		
-		var inputEventHandlers = {};
-		
-		if (this.options.buttonId && !this.options.disabled) {
-			inputEventHandlers["mousedown"+this.namespace] = onButtonShow;
-			inputEventHandlers["mouseup"+this.namespace] = onSelectMouseUp;
-			rf.Event.bindById(this.options.buttonId, inputEventHandlers, this);
-		}
-		
-		inputEventHandlers = {};
-		inputEventHandlers["focus"+this.namespace] = onFocus;
-		inputEventHandlers["blur"+this.namespace] = onBlur;
-		inputEventHandlers["click"+this.namespace] = onClick;
-		inputEventHandlers[($.browser.opera ? "keypress" : "keydown")+this.namespace] = onKeyDown;
-		rf.Event.bindById(this.fieldId, inputEventHandlers, this);
-		
-		inputEventHandlers = {};
-		inputEventHandlers["mousedown"+this.namespace] = onSelectMouseDown;
-		inputEventHandlers["mouseup"+this.namespace] = onSelectMouseUp;
-		rf.Event.bindById(this.selectId, inputEventHandlers, this);
-	};
-	
-	var onSelectMouseDown = function () {
-		this.isMouseDown = true;
-	};
-	var onSelectMouseUp = function () {
-		rf.getDomElement(this.fieldId).focus();
-	};
-	
-	var onButtonShow = function (event) {
-		this.isMouseDown = true;
-		if (this.timeoutId) {
-			window.clearTimeout(this.timeoutId);
-			this.timeoutId = null;
-			rf.getDomElement(this.fieldId).focus();
-		}
-		
-		if (this.isVisible) {
-			this.hide(event);
-		} else {
-			onShow.call(this, event);
-		}
-	};
-	
-	var onFocus = function (event) {
-	};
-	
-	var onBlur = function (event) {
-		if (this.isMouseDown) {
-			rf.getDomElement(this.fieldId).focus();
-			this.isMouseDown = false;
-		} else if (this.isVisible && !this.isMouseDown) {
-			var _this = this;
-			this.timeoutId = window.setTimeout(function(){_this.hide();}, 200);
-		}
-	};
-	
-	var onClick = function (event) {
-	};
-	
-	var onChange = function (event) {
-		var value = this.getInputValue();
-		var flag = value != this.currentValue;
-		//TODO: is it needed to chesk keys?
-		//TODO: we need to set value when autoFill used when LEFT or RIGHT was pressed
-		if (event.which == rf.KEYS.LEFT || event.which == rf.KEYS.RIGHT || flag) {
-			if (flag || this.isVisible) {
-				this.__onChangeValue(event);
-			}
-			if (flag) {
-				this.currentValue = this.getInputValue();
-				if(value && value.length>=this.options.minChars){
-					onShow.call(this, event);
-				}
-				
-			}
-		}
-	};
-	
-	var onShow = function (event) {
-		this.__updateState(event);
-		this.show(event);
-	};
-	
-	var onKeyDown = function (event) {
-		switch(event.which) {
-			case rf.KEYS.UP:
-				event.preventDefault();
-				if (this.isVisible) {
-					this.__onKeyUp(event);
-				}
-				break;
-			case rf.KEYS.DOWN:
-				event.preventDefault();
-				if (this.isVisible) {
-					this.__onKeyDown(event);
-				} else {
-					onShow.call(this, event);
-				}
-				break;
-			case rf.KEYS.PAGEUP:
-				event.preventDefault();
-				if (this.isVisible) {
-					this.__onPageUp(event);
-				}
-				break;
-			case rf.KEYS.PAGEDOWN:
-				event.preventDefault();
-				if (this.isVisible) {
-					this.__onPageDown(event);
-				}
-				break;
-			case rf.KEYS.RETURN:
-
-				event.preventDefault();
-				this.__onEnter(event);
-				//TODO: bind form submit event handler to cancel form submit under the opera
-				//cancelSubmit = true;
-				this.hide();
-				return false;
-				break;
-			case rf.KEYS.ESC:
-				this.hide();
-				break;
-			default:
-				if (!this.options.selectOnly) {
-					var _this = this;
-					window.clearTimeout(this.changeTimerId);
-					this.changeTimerId = window.setTimeout(function(){onChange.call(_this, event);}, this.options.changeDelay)
-				}
-				break;
-		}
-	}
-	
-	/*
-	 * public API functions definition
-	 */
-	var show = function (event, showButtonPressed) {
-		if (!this.isVisible) {
-			if (this.__onBeforeShow(event)!=false) {
-				this.scrollElements = rf.Event.bindScrollEventHandlers(this.selectId, this.hide, this, this.namespace);
-				if (this.options.attachToBody) {
-					var element = rf.getDomElement(this.selectId);
-					this.parentElement = element.parentNode;
-					$(element).detach().appendTo("body");
-				}
-				$(rf.getDomElement(this.selectId)).setPosition({id: this.fieldId}, {type:"DROPDOWN", offset:[0,20]}).show();
-				this.isVisible = true;
-				this.__onShow(event, showButtonPressed);
-			}
-		}
-	};
-	var hide = function (event) {
-		if (this.isVisible) {
-			rf.Event.unbindScrollEventHandlers(this.scrollElements, this);
-			this.scrollElements = null;
-				$(rf.getDomElement(this.selectId)).hide();
-				this.isVisible = false;
-				if (this.options.attachToBody && this.parentElement) {
-				$(rf.getDomElement(this.selectId)).detach().appendTo(this.parentElement);
-				this.parentElement = null;
-			}
-		    this.__onHide(event);
-		}
-	};
-	
-	/*
-	 * Prototype definition
-	 */
-	$.extend(rf.ui.AutocompleteBase.prototype, (function () {
-		return {
-			/*
-			 * public API functions
-			 */
- 			name:"AutocompleteBase",
- 			show: show,
- 			hide: hide,
- 			getNamespace: function () {
- 				return this.namespace;
- 			},
- 			getInputValue: function () {
- 				return this.fieldId ? rf.getDomElement(this.fieldId).value : "";
- 			},
- 			setInputValue: function (value) {
- 				this.currentValue = this.__updateInputValue(value); 
- 			},
- 			/*
- 			 * Protected methods
- 			 */
- 			__updateInputValue: function (value) {
- 				if (this.fieldId) {
- 					 rf.getDomElement(this.fieldId).value = value;
- 					 return value;
- 				} else {
- 					return "";
- 				}
- 			},
- 			/*
- 			 * abstract protected methods
- 			 */
- 			__onChangeValue: function (event) {
- 			},			
- 			__onKeyUp: function () {
- 			},
- 			__onKeyDown: function () {
- 			},
- 			__onPageUp: function () {
- 			},
- 			__onPageDown: function () {
- 			},
- 			__onBeforeShow: function () {
- 			},
- 			__onShow: function () {
- 			},
- 			__onHide: function () {
- 			},
- 			/*
- 			 * Destructor
- 			 */
- 			destroy: function () {
- 				this.parentNode = null;
- 				if (this.scrollElements) {
- 					rf.Event.unbindScrollEventHandlers(this.scrollElements, this);
- 					this.scrollElements = null;
- 				}
- 				this.options.buttonId && rf.Event.unbindById(this.options.buttonId, this.namespace);
- 				rf.Event.unbindById(this.fieldId, this.namespace);
- 				rf.Event.unbindById(this.selectId, this.namespace);
- 				$super.destroy.call(this);
- 			}
-		};
-	})());
-})(jQuery, RichFaces);
\ No newline at end of file

Copied: branches/RF-9096/src/main/resources/META-INF/resources/org.richfaces/Autocomplete.ecss (from rev 18733, branches/RF-9096/src/main/resources/META-INF/resources/org.richfaces/Auto_complete.ecss)
===================================================================
--- branches/RF-9096/src/main/resources/META-INF/resources/org.richfaces/Autocomplete.ecss	                        (rev 0)
+++ branches/RF-9096/src/main/resources/META-INF/resources/org.richfaces/Autocomplete.ecss	2010-08-17 19:11:27 UTC (rev 18734)
@@ -0,0 +1,152 @@
+.rf-au-f-w{
+	width: 200px;
+}
+
+.rf-au-l-w{
+	width: 200px;
+}
+
+.rf-au-l-h{
+	max-height: 100px;
+	min-height: 20px;
+}
+
+.rf-au-i.rf-au-ft, .rf-au-o.rf-au-ft{
+	color: '#{richSkin.generalTextColor}';
+	font-size: '#{richSkin.generalSizeFont}';
+	font-family: '#{richSkin.generalFamilyFont}';
+}
+
+input.rf-au-i {
+	border-width: 0px;
+	background: none;
+	width: 100%;
+}
+
+.rf-au-f{
+	position: inline-block;
+	border-width: 1px;
+	border-style: solid;
+	border-color: '#{richSkin.panelBorderColor}';
+	display: inline-block;
+	background-image: "url(#{resource['org.richfaces.renderkit.html.images.AutocompleteFieldGradient']})";
+	background-repeat: repeat-x;
+	background-position: top left;
+	background-color: '#{richSkin.controlBackgroundColor}';
+}
+
+.rf-au-b{
+	background-image: "url(#{resource['org.richfaces.renderkit.html.images.AutocompleteButtonGradient']})";
+	background-repeat: repeat-x;
+	background-position: top left;
+	background-color: '#{richSkin.headerBackgroundColor}';
+	text-align: center;
+	border-left-style: solid;
+	border-left-width: 1px;
+	border-left-color: '#{richSkin.panelBorderColor}';
+	width: 15px;
+	position: absolute;
+	top: 0px;
+	right: 0px;
+	height: 200px;
+	padding-top: 1px
+}
+
+.rf-au-b-a{
+	background-position: center;
+	background-repeat: no-repeat;
+	background-image: "url(#{resource['org.richfaces:combo_down_button.gif']})";
+	cursor: pointer;
+	width: 15px;
+	height: 15px;
+}
+
+.rf-au-l-c{
+	position: absolute;
+	/* TODO nick - review: font-size: 0px; */
+	display: none;
+}
+
+.rf-au-l-d{
+	border-width: 1px;
+	border-style: solid;
+	border-color: '#{richSkin.panelBorderColor}';
+	padding: 0px;
+	background-color: '#{richSkin.tableBackgroundColor}';
+}
+
+.rf-au-l-s{
+	overflow: auto;
+	overflow-x: hidden;
+}
+
+.rf-au-o{
+	padding: 2px;
+	white-space: nowrap;
+	cursor: default;
+	list-style-type: none;
+}
+
+.rf-au-s{
+	padding: 1px;
+	width: 100%;
+	background-color: '#{richSkin.headerBackgroundColor}';
+	border-width: 1px;
+	border-style: dotted;
+	border-color: '#{richSkin.generalTextColor}';
+}
+
+.rf-au-shw{
+	border: 0px solid red;
+	display: inline-block;
+	position: absolute;
+	float: left;
+	padding: 6px 6px 6px 6px;
+	top: -6px;
+	left: -7px;
+}
+
+.rf-au-shw-t{
+	background-image: "url(#{resource['org.richfaces:combo_list_shadow.png']})";
+	background-position: top left;
+	position: absolute;
+	width: 6px;
+	top: 0px;
+	bottom: 6px;
+	left: 0px
+}
+
+.rf-au-shw-l{
+	background-image: "url(#{resource['org.richfaces:combo_list_shadow.png']})";
+	background-position: bottom left;
+	position: absolute;
+	height: 6px;
+	bottom: 0px;
+	left: 0px;
+	right: 6px;
+}
+
+.rf-au-shw-r{
+	background-image: "url(#{resource['org.richfaces:combo_list_shadow.png']})";
+	background-position: bottom right;
+	position: absolute;
+	width: 6px;
+	top: 6px;
+	bottom: 0px;
+	right: 0px;
+}
+
+.rf-au-shw-b{
+	background-image: "url(#{resource['org.richfaces:combo_list_shadow.png']})";
+	background-position: right top;
+	position: absolute;
+	height: 6px;
+	top: 0px;
+	left: 6px;
+	right: 0px;
+}
+
+.rf-au-l-ul{
+	margin: 0px;
+	padding: 0px;
+}
\ No newline at end of file

Copied: branches/RF-9096/src/main/resources/META-INF/resources/org.richfaces/Autocomplete.js (from rev 18733, branches/RF-9096/src/main/resources/META-INF/resources/org.richfaces/Auto_complete.js)
===================================================================
--- branches/RF-9096/src/main/resources/META-INF/resources/org.richfaces/Autocomplete.js	                        (rev 0)
+++ branches/RF-9096/src/main/resources/META-INF/resources/org.richfaces/Autocomplete.js	2010-08-17 19:11:27 UTC (rev 18734)
@@ -0,0 +1,408 @@
+(function ($, rf) {
+	rf.utils = rf.utils || {};
+
+	rf.utils.Cache = function (key, items, values) {
+		this.key = key;
+		this.cache = {}
+		this.cache[this.key] = items || [];
+		this.values = typeof values != "function" ? values || this.cache[this.key] : values(items);
+	};
+
+	var getItems = function (key) {
+		var newCache = [];
+		
+		if (key.length < this.key.length) {
+			return newCache;
+		}
+
+		if (this.cache[key]) {
+			newCache = this.cache[key];
+		} else {
+			var itemsCache = this.cache[this.key];
+			for (var i = 0; i<this.values.length; i++) {
+				var value = this.values[i].toLowerCase();
+				var p = value.indexOf(key.toLowerCase());
+				if (p == 0) {
+					newCache.push(itemsCache[i]);
+				}
+			}
+
+			if ((!this.lastKey || key.indexOf(this.lastKey)!=0) && newCache.length > 0) {
+				this.cache[key] = newCache;
+				if (newCache.length==1) {
+					this.lastKey = key;
+				}
+			}
+		}
+
+		return newCache;
+	};
+	
+	var getItemValue = function (item) {
+		return this.values[this.cache[this.key].index(item)];
+	};
+	
+	var isCached = function (key) {
+		return this.cache[key];
+	};
+
+	$.extend(rf.utils.Cache.prototype, (function () {
+		return  {
+			getItems: getItems,
+			getItemValue: getItemValue,
+			isCached: isCached
+		};
+	})());
+
+})(jQuery, RichFaces);
+
+(function ($, rf) {
+
+	/*
+	 * TODO: add user's event handlers call from options
+	 * TODO: add fire events
+	 */
+	
+	rf.ui = rf.ui || {};
+	// Constructor definition
+	rf.ui.Autocomplete = function(componentId, fieldId, options) {
+		this.namespace = "."+rf.Event.createNamespace(this.name, this.id);
+		this.options = {};
+		// call constructor of parent class
+		$super.constructor.call(this, componentId, componentId+ID.SELECT, fieldId, options);
+		this.attachToDom(componentId);
+		this.options = $.extend(this.options, defaultOptions, options);
+		this.value = this.__getSubValue();
+		this.index = -1;
+		this.isFirstAjax = true;
+		updateTokenOptions.call(this);
+		bindEventHandlers.call(this);
+		updateItemsList.call(this, "");
+	};
+
+	// Extend component class and add protected methods from parent class to our container
+	rf.ui.AutocompleteBase.extend(rf.ui.Autocomplete);
+
+	// define super class link
+	var $super = rf.ui.Autocomplete.$super;
+
+	var defaultOptions = {
+		selectedItemClass:'rf-au-s',
+		autoFill:true,
+		minChars:1,
+		selectFirst:true,
+		ajaxMode:true,
+		tokens: ",",
+		attachToBody:true
+	};
+
+	var ID = {
+		SELECT:'List',
+		ITEMS:'Items',
+		VALUE:'Value'
+	};
+	
+	var REGEXP_TRIM = /^[\n\s]*(.*)[\n\s]*$/;
+	var REGEXP_TOKEN_LEFT;
+	var REGEXP_TOKEN_RIGHT;
+	
+	var getData = function (nodeList) {
+		var data = [];
+		nodeList.each(function () {;
+			data.push($(this).text().replace(REGEXP_TRIM, "$1"));
+		});
+		return data;
+	}
+	
+	var updateTokenOptions = function () {
+		this.useTokens = (typeof this.options.tokens == "string" && this.options.tokens.length>0);
+		if (this.useTokens) {
+			var escapedTokens = this.options.tokens.split('').join("\\");
+			REGEXP_TOKEN_LEFT = new RegExp('[^'+escapedTokens+']+$','i');
+			REGEXP_TOKEN_RIGHT = new RegExp('['+escapedTokens+']','i');
+			this.hasSpaceToken = this.options.tokens.indexOf(' ')!=-1;
+		};
+	};
+
+	var bindEventHandlers = function () {
+		rf.Event.bind(rf.getDomElement(this.id+ID.ITEMS).parentNode, "click"+this.namespace+" mouseover"+this.namespace, onMouseAction, this);
+	};
+
+	var onMouseAction = function(event) {
+		var element = $(event.target).closest(".rf-ac-i", event.currentTarget).get(0);
+
+		if (element) {
+			if (event.type=="mouseover") {
+				var index = this.items.index(element);
+				if (index!=this.index) {
+					selectItem.call(this, index);
+				}
+			} else {
+				this.__onChangeValue(event, getSelectedItemValue.call(this));
+				rf.Selection.setCaretTo(rf.getDomElement(this.fieldId));
+				this.hide(event);
+			}
+		}
+	};
+
+	var updateItemsList = function (value, fetchValues) {
+		this.items = $(rf.getDomElement(this.id+ID.ITEMS)).find(".rf-ac-i");
+		if (this.items.length>0) {
+			this.cache = new rf.utils.Cache(value, this.items, fetchValues || getData);
+		}
+	};
+
+	var scrollToSelectedItem = function() {
+        var offset = 0;
+        this.items.slice(0, this.index).each(function() {
+			offset += this.offsetHeight;
+		});
+        var parentContainer = $(rf.getDomElement(this.id+ID.ITEMS)).parent();
+        if(offset < parentContainer.scrollTop()) {
+        	parentContainer.scrollTop(offset);
+        } else {
+        	offset+=this.items.get(this.index).offsetHeight;
+        	if(offset - parentContainer.scrollTop() > parentContainer.get(0).clientHeight) {
+        		parentContainer.scrollTop(offset - parentContainer.innerHeight());
+            }
+        }
+	};
+
+	var autoFill = function (inputValue, value) {
+		if( this.options.autoFill) {
+			var field = rf.getDomElement(this.fieldId);
+			var start = rf.Selection.getStart(field);
+			this.setInputValue(inputValue + value.substring(inputValue.length));
+			var end = start+value.length - inputValue.length;
+			rf.Selection.set(field, start, end);
+		}
+	};
+
+	var callAjax = function(event, value) {
+		
+		$(rf.getDomElement(this.id+ID.ITEMS)).removeData().empty();
+		rf.getDomElement(this.id+ID.VALUE).value = value;
+		
+		var _this = this;
+		var ajaxSuccess = function (event) {
+			updateItemsList.call(_this, _this.value, event.componentData && event.componentData[_this.id]);
+			if (_this.isVisible && _this.options.selectFirst) {
+				selectItem.call(_this, 0);
+			}
+		}
+		
+		var ajaxError = function (event) {
+			//alert("error");
+		}
+		
+		this.isFirstAjax = false;
+		//caution: JSF submits inputs with empty names causing "WARNING: Parameters: Invalid chunk ignored." in Tomcat log
+		var params = {};
+		params[this.id + ".ajax"] = "1";
+		rf.ajax(this.id, event, {parameters: params, error: ajaxError, complete:ajaxSuccess});
+	};
+	
+	var selectItem = function(index, isOffset, noAutoFill) {
+		if (this.items.length==0) return;
+	
+		if (this.index!=-1) {
+				this.items.eq(this.index).removeClass(this.options.selectedItemClass);
+		}
+
+		if (index==undefined) {
+			this.index = -1;
+			return;
+		}
+
+		if (isOffset) {
+			this.index += index;
+		if ( this.index<0 ) {
+			this.index = this.items.length - 1;
+		} else if (this.index >= this.items.length) {
+			this.index = 0;
+		}
+		} else {
+			if (index<0) {
+				index = 0;
+			} else if (index>=this.items.length) {
+				index = this.items.length - 1;
+			}
+			this.index = index;
+		}
+		var item = this.items.eq(this.index);
+		item.addClass(this.options.selectedItemClass);
+		scrollToSelectedItem.call(this);
+		!noAutoFill && autoFill.call(this, this.value, getSelectedItemValue.call(this));
+	};
+	
+	var onChangeValue = function (event, value) {
+		//if(this.options.onchange){
+				//this.options.onchange.call(this, event);
+		//}
+		selectItem.call(this);
+		
+		// value is undefined if called from AutocompleteBase onChange
+		var subValue = (typeof value == "undefined") ? this.__getSubValue() : value;
+		
+		// TODO: ajax call here if needed
+		if ((!this.cache || subValue.length==0 || subValue.toLowerCase().indexOf(this.cache.key.toLowerCase())!=0) && 
+				subValue.length>=this.options.minChars) {
+			this.value = subValue;
+			this.options.ajaxMode && callAjax.call(this, event, subValue);
+			return;
+		}
+		if(!this.cache){
+			return;
+		}
+		var newItems = this.cache.getItems(subValue);
+		this.items = $(newItems);
+		//TODO: works only with simple markup, not with <tr>
+		$(rf.getDomElement(this.id+ID.ITEMS)).empty().append(newItems);
+		this.index = -1;
+		this.value = subValue;
+		if (subValue.length<this.options.minChars){
+			this.hide();
+		}
+		if (this.options.selectFirst) {
+			if (event.which == rf.KEYS.RETURN || event.type == "click") {
+				this.setInputValue(subValue);
+				return;
+			} else {
+				selectItem.call(this, 0, false, event.which == rf.KEYS.BACKSPACE || event.which == rf.KEYS.LEFT || event.which == rf.KEYS.RIGHT);
+				return;
+			}
+		}
+		this.setInputValue(subValue);
+	};
+	
+	var getSelectedItemValue = function () {
+		if ( this.index>=0) {
+			var element = this.items.eq(this.index);
+			return this.cache.getItemValue(element);
+		}
+		return undefined;
+	};
+	
+	var getSubValue = function () {
+		//TODO: add posibility to use space chars before and after tokens if space not a token char
+		if (this.useTokens) {
+			var field = rf.getDomElement(this.fieldId);
+			var value = field.value;
+			var cursorPosition = rf.Selection.getStart(field);
+			var beforeCursorStr = value.substring(0, cursorPosition);
+			var afterCursorStr = value.substring(cursorPosition);
+			var r = REGEXP_TOKEN_LEFT.exec(beforeCursorStr);
+			var result = "";
+			if (r) {
+				result = r[0];
+			}
+			r = afterCursorStr.search(REGEXP_TOKEN_RIGHT);
+			if (r==-1) r = afterCursorStr.length;
+			result += afterCursorStr.substring(0, r);
+
+			return result;
+		} else {
+			return this.getInputValue();
+		}
+	};
+	
+	var updateInputValue = function (value) {
+		var field = rf.getDomElement(this.fieldId);
+		var inputValue = field.value;
+		
+		var cursorPosition = rf.Selection.getStart(field);
+		var beforeCursorStr = inputValue.substring(0, cursorPosition);
+		var afterCursorStr = inputValue.substring(cursorPosition);
+		
+		var pos = beforeCursorStr.search(REGEXP_TOKEN_LEFT);
+		var startPos = pos!=-1 ? pos : beforeCursorStr.length;
+		pos = afterCursorStr.search(REGEXP_TOKEN_RIGHT);
+		var endPos = pos!=-1 ? pos : afterCursorStr.length;
+		
+		var beginNewValue = inputValue.substring(0, startPos) + value;
+		cursorPosition = beginNewValue.length;
+		field.value = beginNewValue + afterCursorStr.substring(endPos);
+		field.focus();
+		rf.Selection.setCaretTo(field, cursorPosition);
+		return field.value;
+	};
+	
+	/*
+	 * Prototype definition
+	 */
+	$.extend(rf.ui.Autocomplete.prototype, (function () {
+		return {
+			/*
+			 * public API functions
+			 */
+ 			name:"Autocomplete",
+ 			/*
+ 			 * Protected methods
+ 			 */
+ 			__updateState: function (event) {
+				var subValue = this.__getSubValue();
+				// called from onShow method, not actually value changed
+				if (this.items.length==0 && this.isFirstAjax) {
+					this.options.ajaxMode && callAjax.call(this, event, subValue);
+				}
+				return;
+			},
+ 			__getSubValue: getSubValue,
+ 			__updateInputValue: function (value) {
+				if (this.useTokens) {
+					return updateInputValue.call(this, value);
+				} else {
+					return $super.__updateInputValue.call(this, value);
+				}
+ 			},
+ 			__onChangeValue: onChangeValue,
+ 			/*
+ 			 * Override abstract protected methods
+ 			 */
+ 			__onKeyUp: function () {
+ 				selectItem.call(this, -1, true);
+ 			},
+ 			__onKeyDown: function () {
+ 				selectItem.call(this, 1, true);
+ 			},
+ 			__onPageUp: function () {
+
+ 			},
+ 			__onPageDown: function () {
+
+ 			},
+ 			__onBeforeShow: function (event) {
+ 			},
+ 			__onEnter: function (event) {
+ 				this.__onChangeValue(event, getSelectedItemValue.call(this));
+				//rf.getDomElement(this.fieldId).blur();
+				//rf.Selection.setCaretTo(rf.getDomElement(this.fieldId));
+				//rf.getDomElement(this.fieldId).focus();
+ 			},
+ 			__onShow: function (event) {
+ 				if (event.which != rf.KEYS.BACKSPACE) {
+ 					if(this.items && this.items.length>0){
+ 						if (this.index!=0 && this.options.selectFirst) {
+ 							selectItem.call(this, 0);
+ 						}
+ 					}
+ 				}
+ 			},
+ 			__onHide: function () {
+ 				selectItem.call(this);
+ 			},
+ 			/*
+ 			 * Destructor
+ 			 */
+ 			destroy: function () {
+				//TODO: add all unbind
+				this.items = null;
+				this.cache = null;
+				var itemsContainer = rf.getDomElement(this.id+ID.ITEMS);
+				$(itemsContainer).removeData();
+				rf.Event.unbind(itemsContainer.parentNode, this.namespace);
+				$super.destroy.call(this);
+ 			}
+		};
+	})());
+})(jQuery, RichFaces);
\ No newline at end of file

Copied: branches/RF-9096/src/main/resources/META-INF/resources/org.richfaces/AutocompleteBase.js (from rev 18733, branches/RF-9096/src/main/resources/META-INF/resources/org.richfaces/Auto_completeBase.js)
===================================================================
--- branches/RF-9096/src/main/resources/META-INF/resources/org.richfaces/AutocompleteBase.js	                        (rev 0)
+++ branches/RF-9096/src/main/resources/META-INF/resources/org.richfaces/AutocompleteBase.js	2010-08-17 19:11:27 UTC (rev 18734)
@@ -0,0 +1,297 @@
+// TODO: move this extend to RichFaces.Event for exapmle
+$.extend(RichFaces.Event, {
+	bindScrollEventHandlers: function(element, handler, component) {
+		var elements = [];
+		element = RichFaces.getDomElement(element).parentNode;
+		while (element && element!=window.document.body)
+		{
+			if (element.offsetWidth!=element.scrollWidth || element.offsetHeight!=element.scrollHeight)
+			{
+				elements.push(element);
+				RichFaces.Event.bind(element, "scroll"+component.getNamespace(), handler, component);
+			}
+			element = element.parentNode;
+		}
+		return elements;
+	},
+	unbindScrollEventHandlers: function(elements, component) {
+		RichFaces.Event.unbind(elements, component.getNamespace());
+	}
+});
+
+(function (rf) {
+	rf.KEYS = {
+		BACKSPACE: 8,	
+		TAB: 9,
+		RETURN: 13,
+		ESC: 27,
+		PAGEUP: 33,
+		PAGEDOWN: 34,
+		LEFT: 37,
+		UP: 38,
+		RIGHT: 39,
+		DOWN: 40,
+		DEL: 46,
+	}
+})(RichFaces);
+
+(function ($, rf) {
+
+	rf.ui = rf.ui || {}; 
+	
+	// Constructor definition
+	rf.ui.AutocompleteBase = function(componentId, selectId, fieldId, options) {
+		// call constructor of parent class
+		$super.constructor.call(this, componentId);
+		this.selectId = selectId;
+		this.fieldId = fieldId;
+		this.options = $.extend({}, defaultOptions, options);
+		this.namespace = this.namespace || "."+rf.Event.createNamespace(this.name, this.selectId);
+		this.currentValue = this.getInputValue();
+		bindEventHandlers.call(this);
+	};
+	
+	// Extend component class and add protected methods from parent class to our container
+	rf.BaseComponent.extend(rf.ui.AutocompleteBase);
+	
+	// define super class link
+	var $super = rf.ui.AutocompleteBase.$super;
+	
+	var defaultOptions = {
+			changeDelay:8
+	};
+	
+	var bindEventHandlers = function() {
+		
+		var inputEventHandlers = {};
+		
+		if (this.options.buttonId && !this.options.disabled) {
+			inputEventHandlers["mousedown"+this.namespace] = onButtonShow;
+			inputEventHandlers["mouseup"+this.namespace] = onSelectMouseUp;
+			rf.Event.bindById(this.options.buttonId, inputEventHandlers, this);
+		}
+		
+		inputEventHandlers = {};
+		inputEventHandlers["focus"+this.namespace] = onFocus;
+		inputEventHandlers["blur"+this.namespace] = onBlur;
+		inputEventHandlers["click"+this.namespace] = onClick;
+		inputEventHandlers[($.browser.opera ? "keypress" : "keydown")+this.namespace] = onKeyDown;
+		rf.Event.bindById(this.fieldId, inputEventHandlers, this);
+		
+		inputEventHandlers = {};
+		inputEventHandlers["mousedown"+this.namespace] = onSelectMouseDown;
+		inputEventHandlers["mouseup"+this.namespace] = onSelectMouseUp;
+		rf.Event.bindById(this.selectId, inputEventHandlers, this);
+	};
+	
+	var onSelectMouseDown = function () {
+		this.isMouseDown = true;
+	};
+	var onSelectMouseUp = function () {
+		rf.getDomElement(this.fieldId).focus();
+	};
+	
+	var onButtonShow = function (event) {
+		this.isMouseDown = true;
+		if (this.timeoutId) {
+			window.clearTimeout(this.timeoutId);
+			this.timeoutId = null;
+			rf.getDomElement(this.fieldId).focus();
+		}
+		
+		if (this.isVisible) {
+			this.hide(event);
+		} else {
+			onShow.call(this, event);
+		}
+	};
+	
+	var onFocus = function (event) {
+	};
+	
+	var onBlur = function (event) {
+		if (this.isMouseDown) {
+			rf.getDomElement(this.fieldId).focus();
+			this.isMouseDown = false;
+		} else if (this.isVisible && !this.isMouseDown) {
+			var _this = this;
+			this.timeoutId = window.setTimeout(function(){_this.hide();}, 200);
+		}
+	};
+	
+	var onClick = function (event) {
+	};
+	
+	var onChange = function (event) {
+		var value = this.getInputValue();
+		var flag = value != this.currentValue;
+		//TODO: is it needed to chesk keys?
+		//TODO: we need to set value when autoFill used when LEFT or RIGHT was pressed
+		if (event.which == rf.KEYS.LEFT || event.which == rf.KEYS.RIGHT || flag) {
+			if (flag || this.isVisible) {
+				this.__onChangeValue(event);
+			}
+			if (flag) {
+				this.currentValue = this.getInputValue();
+				if(value && value.length>=this.options.minChars){
+					onShow.call(this, event);
+				}
+				
+			}
+		}
+	};
+	
+	var onShow = function (event) {
+		this.__updateState(event);
+		this.show(event);
+	};
+	
+	var onKeyDown = function (event) {
+		switch(event.which) {
+			case rf.KEYS.UP:
+				event.preventDefault();
+				if (this.isVisible) {
+					this.__onKeyUp(event);
+				}
+				break;
+			case rf.KEYS.DOWN:
+				event.preventDefault();
+				if (this.isVisible) {
+					this.__onKeyDown(event);
+				} else {
+					onShow.call(this, event);
+				}
+				break;
+			case rf.KEYS.PAGEUP:
+				event.preventDefault();
+				if (this.isVisible) {
+					this.__onPageUp(event);
+				}
+				break;
+			case rf.KEYS.PAGEDOWN:
+				event.preventDefault();
+				if (this.isVisible) {
+					this.__onPageDown(event);
+				}
+				break;
+			case rf.KEYS.RETURN:
+
+				event.preventDefault();
+				this.__onEnter(event);
+				//TODO: bind form submit event handler to cancel form submit under the opera
+				//cancelSubmit = true;
+				this.hide();
+				return false;
+				break;
+			case rf.KEYS.ESC:
+				this.hide();
+				break;
+			default:
+				if (!this.options.selectOnly) {
+					var _this = this;
+					window.clearTimeout(this.changeTimerId);
+					this.changeTimerId = window.setTimeout(function(){onChange.call(_this, event);}, this.options.changeDelay)
+				}
+				break;
+		}
+	}
+	
+	/*
+	 * public API functions definition
+	 */
+	var show = function (event, showButtonPressed) {
+		if (!this.isVisible) {
+			if (this.__onBeforeShow(event)!=false) {
+				this.scrollElements = rf.Event.bindScrollEventHandlers(this.selectId, this.hide, this, this.namespace);
+				if (this.options.attachToBody) {
+					var element = rf.getDomElement(this.selectId);
+					this.parentElement = element.parentNode;
+					$(element).detach().appendTo("body");
+				}
+				$(rf.getDomElement(this.selectId)).setPosition({id: this.fieldId}, {type:"DROPDOWN", offset:[0,20]}).show();
+				this.isVisible = true;
+				this.__onShow(event, showButtonPressed);
+			}
+		}
+	};
+	var hide = function (event) {
+		if (this.isVisible) {
+			rf.Event.unbindScrollEventHandlers(this.scrollElements, this);
+			this.scrollElements = null;
+				$(rf.getDomElement(this.selectId)).hide();
+				this.isVisible = false;
+				if (this.options.attachToBody && this.parentElement) {
+				$(rf.getDomElement(this.selectId)).detach().appendTo(this.parentElement);
+				this.parentElement = null;
+			}
+		    this.__onHide(event);
+		}
+	};
+	
+	/*
+	 * Prototype definition
+	 */
+	$.extend(rf.ui.AutocompleteBase.prototype, (function () {
+		return {
+			/*
+			 * public API functions
+			 */
+ 			name:"AutocompleteBase",
+ 			show: show,
+ 			hide: hide,
+ 			getNamespace: function () {
+ 				return this.namespace;
+ 			},
+ 			getInputValue: function () {
+ 				return this.fieldId ? rf.getDomElement(this.fieldId).value : "";
+ 			},
+ 			setInputValue: function (value) {
+ 				this.currentValue = this.__updateInputValue(value); 
+ 			},
+ 			/*
+ 			 * Protected methods
+ 			 */
+ 			__updateInputValue: function (value) {
+ 				if (this.fieldId) {
+ 					 rf.getDomElement(this.fieldId).value = value;
+ 					 return value;
+ 				} else {
+ 					return "";
+ 				}
+ 			},
+ 			/*
+ 			 * abstract protected methods
+ 			 */
+ 			__onChangeValue: function (event) {
+ 			},			
+ 			__onKeyUp: function () {
+ 			},
+ 			__onKeyDown: function () {
+ 			},
+ 			__onPageUp: function () {
+ 			},
+ 			__onPageDown: function () {
+ 			},
+ 			__onBeforeShow: function () {
+ 			},
+ 			__onShow: function () {
+ 			},
+ 			__onHide: function () {
+ 			},
+ 			/*
+ 			 * Destructor
+ 			 */
+ 			destroy: function () {
+ 				this.parentNode = null;
+ 				if (this.scrollElements) {
+ 					rf.Event.unbindScrollEventHandlers(this.scrollElements, this);
+ 					this.scrollElements = null;
+ 				}
+ 				this.options.buttonId && rf.Event.unbindById(this.options.buttonId, this.namespace);
+ 				rf.Event.unbindById(this.fieldId, this.namespace);
+ 				rf.Event.unbindById(this.selectId, this.namespace);
+ 				$super.destroy.call(this);
+ 			}
+		};
+	})());
+})(jQuery, RichFaces);
\ No newline at end of file



More information about the richfaces-svn-commits mailing list