Author: abelevich
Date: 2010-11-03 09:42:19 -0400 (Wed, 03 Nov 2010)
New Revision: 19910
Removed:
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/selectList.js
Modified:
trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/SelectRendererBase.java
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceSelect.js
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/select.js
Log:
RF-9579
Modified: trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/SelectRendererBase.java
===================================================================
---
trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/SelectRendererBase.java 2010-11-03
12:43:47 UTC (rev 19909)
+++
trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/SelectRendererBase.java 2010-11-03
13:42:19 UTC (rev 19910)
@@ -48,7 +48,6 @@
@ResourceDependency(library = "org.richfaces", name =
"inputBase.js"),
@ResourceDependency(library = "org.richfaces", name =
"popup.js"),
@ResourceDependency(library = "org.richfaces", name =
"popupList.js"),
- @ResourceDependency(library = "org.richfaces", name =
"selectList.js"),
@ResourceDependency(library = "org.richfaces", name =
"select.js"),
@ResourceDependency(library = "org.richfaces", name =
"select.ecss") })
public class SelectRendererBase extends InputRendererBase {
Modified:
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceSelect.js
===================================================================
---
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceSelect.js 2010-11-03
12:43:47 UTC (rev 19909)
+++
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceSelect.js 2010-11-03
13:42:19 UTC (rev 19910)
@@ -176,8 +176,7 @@
__onListClick: function(e) {
window.clearTimeout(this.timeoutId);
- }
-
+ }
}
})());
Modified: trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/select.js
===================================================================
---
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/select.js 2010-11-03
12:43:47 UTC (rev 19909)
+++
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/select.js 2010-11-03
13:42:19 UTC (rev 19910)
@@ -115,11 +115,10 @@
}));
}
this.selectFirst = mergedOptions.selectFirst;
- this.popupList = new rf.ui.SelectList((id+"List"), this,
mergedOptions);
+ this.popupList = new rf.ui.PopupList((id+"List"), this,
mergedOptions);
this.listElem = $(document.getElementById(id+"List"));
this.listElem.bind("click", $.proxy(this.__onListClick, this));
-
var items = this.popupList.__getItems();
var enableManualInput = mergedOptions.enableManualInput;
if (items.length>0 && enableManualInput) {
@@ -160,9 +159,10 @@
__clickHandler: function(e) {
if(!this.popupList.isVisible()) {
- this.popupList.show();
+ this.__updateItems();
+ this.showPopup();
} else {
- this.popupList.hide();
+ this.hidePopup();
}
this.__setInputFocus();
window.clearTimeout(this.timeoutId);
@@ -188,7 +188,8 @@
case rf.KEYS.DOWN:
e.preventDefault();
if(!visible) {
- this.popupList.show();
+ this.__updateItems();
+ this.showPopup();
} else {
this.popupList.__selectNext() ;
}
@@ -209,6 +210,15 @@
return false;
break;
+ case rf.KEYS.TAB:
+ break;
+
+ case rf.KEYS.ESC:
+ if(visible) {
+ this.hidePopup();
+ }
+ break;
+
default:
var _this = this;
window.clearTimeout(this.changeTimerId);
@@ -223,20 +233,11 @@
if(this.cache && this.cache.isCached(newValue)) {
- if(this.initialValue !=newValue) {
- var newItems = this.cache.getItems(newValue);
- var items = $(newItems);
- this.popupList.__setItems(items);
- $(document.getElementById(this.id+"Items")).empty().append(items);
- }
-
+ this.__updateItems();
+
if(!this.popupList.isVisible()) {
- this.popupList.show();
+ this.showPopup();
}
-
- if(this.selectFirst) {
- this.popupList.__selectByIndex(0);
- }
}
},
@@ -244,12 +245,13 @@
var inputLabel = this.getValue();
if(!inputLabel || inputLabel == "") {
this.setValue(this.defaultLabel);
+ this.selValueInput.val("");
}
},
__blurHandler: function(e) {
this.timeoutId = window.setTimeout($.proxy(function(){
- this.popupList.hide();
+ this.hidePopup();
this.__handleBlur();
}, this), 200);
},
@@ -258,13 +260,37 @@
window.clearTimeout(this.timeoutId);
},
+ __updateItems: function() {
+ var newValue = this.getValue();
+ newValue = (newValue != this.defaultLabel) ? newValue : "";
+ this.__updateItemsFromCache(newValue);
+ if(this.selectFirst) {
+ this.popupList.__selectByIndex(0);
+ }
+ },
+
+ __updateItemsFromCache: function(value) {
+ var newItems = this.cache.getItems(value);
+ var items = $(newItems);
+ this.popupList.__setItems(items);
+ $(document.getElementById(this.id+"Items")).empty().append(items);
+ },
+
+ showPopup: function() {
+ this.popupList.show();
+ },
+
+ hidePopup: function() {
+ this.popupList.hide();
+ },
+
processItem: function(item) {
var key = $(item).attr("id");
var value = this.getItemValue(key);
this.saveItemValue(value);
var label = this.getItemLabel(key);
this.setValue(label);
- this.popupList.hide();
+ this.hidePopup();
this.__setInputFocus();
},
Deleted:
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/selectList.js
===================================================================
---
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/selectList.js 2010-11-03
12:43:47 UTC (rev 19909)
+++
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/selectList.js 2010-11-03
13:42:19 UTC (rev 19910)
@@ -1,37 +0,0 @@
-(function ($, rf) {
-
- rf.ui = rf.ui || {};
-
- rf.ui.SelectList = function(id, listener, options) {
- $super.constructor.call(this, id, listener, options);
- this.selectFirst = options.selectFirst;
- };
-
- rf.ui.PopupList.extend(rf.ui.SelectList);
- var $super = rf.ui.SelectList.$super;
-
- $.extend(rf.ui.SelectList.prototype,(function () {
-
- return{
- name : "selectList",
-
- show: function() {
- if(!this.isVisible()) {
- $super.show.call(this);
- if(this.selectFirst) {
- this.__selectByIndex(0);
- }
- }
- },
-
- hide: function() {
- if(this.isVisible()) {
- $super.hide.call(this);
- this.__selectByIndex(-1);
- }
- }
- }
-
- })());
-
-})(jQuery, window.RichFaces);
\ No newline at end of file