Author: abelevich
Date: 2008-05-02 13:17:54 -0400 (Fri, 02 May 2008)
New Revision: 8417
Modified:
trunk/ui/combobox/src/main/resources/org/richfaces/renderkit/html/scripts/combobox.js
trunk/ui/combobox/src/main/resources/org/richfaces/renderkit/html/scripts/combolist.js
Log:
http://jira.jboss.com/jira/browse/RF-2332,
http://jira.jboss.com/jira/browse/RF-3156
Modified:
trunk/ui/combobox/src/main/resources/org/richfaces/renderkit/html/scripts/combobox.js
===================================================================
---
trunk/ui/combobox/src/main/resources/org/richfaces/renderkit/html/scripts/combobox.js 2008-05-02
17:17:26 UTC (rev 8416)
+++
trunk/ui/combobox/src/main/resources/org/richfaces/renderkit/html/scripts/combobox.js 2008-05-02
17:17:54 UTC (rev 8417)
@@ -56,8 +56,10 @@
if (Richfaces.browser.isIE6) {
//http://jira.jboss.com/jira/browse/RF-3255
+// this.comboList.createIframe(this.comboList.listParent.parentNode, listWidth,
this.combobox.id,
+// "rich-combobox-list-width rich-combobox-list-scroll
rich-combobox-list-position");
this.comboList.createIframe(this.comboList.listParent.parentNode, listWidth,
this.combobox.id,
- "rich-combobox-list-width rich-combobox-list-scroll
rich-combobox-list-position");
+ "rich-combobox-list-width rich-combobox-list-scroll
rich-combobox-list-position");
}
this.combobox.component = this;
this.initHandlers();
@@ -81,14 +83,14 @@
},
setInputWidth : function() {
- var width = (parseInt(this.field.parentNode.style.width) - this.BUTTON_WIDTH) +
Richfaces.getBorderWidth(this.field, "r");
- if (Prototype.Browser.Gecko) {
+ var width = (parseInt(this.field.parentNode.style.width) - this.BUTTON_WIDTH) +
Richfaces.getBorderWidth(this.field, "lr");
+// if (Prototype.Browser.Gecko) {
//border width and padding width not included in the general component width
- width -= Richfaces.getPaddingWidth(this.field, "lr")
- + Richfaces.getPaddingWidth(this.button, "lr")
- + Richfaces.getBorderWidth(this.field, "lr")
- + Richfaces.getBorderWidth(this.button, "lr");
- }
+// width -= Richfaces.getPaddingWidth(this.field, "lr")
+// + Richfaces.getPaddingWidth(this.button, "lr")
+// + Richfaces.getBorderWidth(this.field, "lr")
+// + Richfaces.getBorderWidth(this.button, "lr");
+// }
this.field.style.width = width + "px";
},
Modified:
trunk/ui/combobox/src/main/resources/org/richfaces/renderkit/html/scripts/combolist.js
===================================================================
---
trunk/ui/combobox/src/main/resources/org/richfaces/renderkit/html/scripts/combolist.js 2008-05-02
17:17:26 UTC (rev 8416)
+++
trunk/ui/combobox/src/main/resources/org/richfaces/renderkit/html/scripts/combolist.js 2008-05-02
17:17:54 UTC (rev 8417)
@@ -7,6 +7,7 @@
this.list = $(listId);
this.listParent = $(parentListId);
+ this.listParentContainer = this.listParent.parentNode;
//this.iframe = $(iframeId);
this.iframe = null;
this.fieldElem = $(fieldId);
@@ -71,12 +72,19 @@
},
show : function() {
- this.fieldDimensions = Richfaces.ComboBoxList.getElemXY(this.fieldElem);
+ var pos = Position.cumulativeOffset(this.fieldElem);
+ this.fieldDimensions = {};
+ this.fieldDimensions.left = pos[0];
+ this.fieldDimensions.top = pos[1];
+
+// Richfaces.ComboBoxList.getElemXY(this.fieldElem);
this.fieldDimensions.height = this.fieldElem.parentNode.offsetHeight;
-
+
this.setSize();
this.setPosition(this.fieldDimensions.top, this.fieldDimensions.left,
this.fieldDimensions.height);
-
+ //attach list to the document body
+ this.injectListToBody(this.listParent);
+
if (this.selectedItem) {
//was created new item list, so necessary to recreate selectedItem
this.doSelectItem(this.findItemBySubstr(this.selectedItem.innerHTML.unescapeHTML()));
@@ -106,6 +114,27 @@
},
+ injectListToBody: function(listElement) {
+ if (!this.listInjected) {
+ var parent = listElement.parentNode;
+ var child = document.body.insertBefore(parent.removeChild(listElement), null);
+ if (Richfaces.browser.isIE6 && this.iframe) {
+ document.body.insertBefore(parent.removeChild(this.iframe), child);
+ }
+ this.listInjected = true;
+ }
+ },
+
+ outjectListFromBody: function(parentElement, listElement) {
+ if (this.listInjected) {
+ var child = parentElement.appendChild(document.body.removeChild(listElement));
+ if (Richfaces.browser.isIE6 && this.iframe) {
+ parentElement.insertBefore(document.body.removeChild(this.iframe), child);
+ }
+ this.listInjected = false;
+ }
+ },
+
hideWithDelay : function() {
/*setTimeout(function(){
this.hide();
@@ -114,6 +143,7 @@
},
hide : function() {
+ this.outjectListFromBody(this.listParentContainer, this.listParent);
this.resetState();
if (this.iframe) {
this.iframe.hide();
@@ -201,33 +231,22 @@
component.style.position = "relative";
component.style.zIndex = 2;
-
var docHeight = Richfaces.getDocumentHeight();
- var comBottom = fieldTop + fieldHeight - document.documentElement.scrollTop;
+ var comBottom = fieldTop + fieldHeight;
var listHeight = parseInt(this.list.style.height) +
Richfaces.getBorderWidth(this.list.parentNode, "tb");
-
- //var top = 0 ;//= -4;
- var top = fieldHeight;
-// var topIframe = comBottom;
-
+ var topPosition = comBottom;
+
if (parseInt(listHeight) > (docHeight - comBottom)) {
- if (fieldTop > (docHeight - comBottom)) {
- top = 0 - parseInt(listHeight);
-// topIframe = top;
- //var upPos = true;
+ if (topPosition > (docHeight - comBottom)) {
+ topPosition = fieldTop - parseInt(listHeight);
}
- }
+ }
+ this.listParent.style.left = fieldLeft + "px";
+ this.listParent.style.top = topPosition + "px";
- this.listParent.style.top = top + "px";
- this.listParent.style.left = 0 + "px";
-
- /*if (!upPos) {
- top = Richfaces.ComboBoxList.getElemXY(this.listParent).top +
this.fieldDimensions.height;
- }*/
if (this.iframe) {
-// this.iframe.style.top = topIframe + "px";
- this.iframe.style.top = top + "px";
- this.iframe.style.left = 0 + "px";
+ this.iframe.style.top = topPosition + "px";
+ this.iframe.style.left = fieldLeft + "px";
}
},