Author: vmolotkov
Date: 2008-08-29 14:12:15 -0400 (Fri, 29 Aug 2008)
New Revision: 10245
Modified:
trunk/ui/combobox/src/main/resources/org/richfaces/renderkit/html/scripts/combolist.js
trunk/ui/combobox/src/main/templates/combobox.jspx
Log:
https://jira.jboss.org/jira/browse/RF-4337
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-08-29
18:08:43 UTC (rev 10244)
+++
trunk/ui/combobox/src/main/resources/org/richfaces/renderkit/html/scripts/combolist.js 2008-08-29
18:12:15 UTC (rev 10245)
@@ -88,9 +88,10 @@
this.listParent.hide();
this.listParent.style.visibility = "visible";
+ //attach list to the document body
+ this.injectListToBody(this.listParent);
+
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
@@ -221,25 +222,32 @@
setPosition : function(fieldTop, fieldLeft, fieldHeight) {
var component = this.listParent.parentNode;
- component.style.position = "relative";
+ //component.style.position = "relative";
component.style.zIndex = 2;
var docHeight = Richfaces.getDocumentHeight();
var comBottom = fieldTop + fieldHeight;
var listHeight = parseInt(this.list.style.height) +
Richfaces.getBorderWidth(this.list.parentNode, "tb");
var topPosition = comBottom;
-
+
+ var showPoint = fieldHeight;
if (parseInt(listHeight) > (docHeight - comBottom)) {
if (topPosition > (docHeight - comBottom)) {
- topPosition = fieldTop - parseInt(listHeight);
+ //topPosition = fieldTop - parseInt(listHeight);
+ showPoint = -parseInt(listHeight);
+
}
}
- this.listParent.style.left = fieldLeft + "px";
+ /*this.listParent.style.left = fieldLeft + "px";
this.listParent.style.top = topPosition + "px";
if (this.iframe) {
this.iframe.style.top = topPosition + "px";
this.iframe.style.left = fieldLeft + "px";
+ }*/
+ this.clonePosition(this.listParent, this.fieldElem, showPoint);
+ if (this.iframe) {
+ this.clonePosition(this.iframe, this.fieldElem, showPoint);
}
},
@@ -422,7 +430,60 @@
// parentElem.appendChild(iframe);
parentElem.insertBefore(iframe,parentElem.firstChild);
this.iframe = $(iframe.id);
- }
+ },
+
+ PX_REGEX: /px$/,
+
+ parseToPx: function(value) {
+ var v = value.strip();
+ if (this.PX_REGEX.test(v)) {
+ try {
+ return parseFloat(v.replace(this.PX_REGEX, ""));
+ } catch (e) {
+
+ }
+ }
+
+ return NaN;
+ },
+
+ clonePosition: function(target, source, vOffset) {
+ var jqt = jQuery(target);
+ var jqs = jQuery(source);
+ var so = jqs.offset();
+
+ var hidden = (jqt.css('display') == 'none');
+ var oldVisibility;
+
+ if (hidden) {
+ oldVisibility = jqt.css('visibility');
+ jqt.css('visibility', 'hidden').css('display',
'');
+ }
+
+ var left = this.parseToPx(jqt.css('left'));
+ if (isNaN(left)) {
+ left = 0;
+ jqt.css('left', '0px');
+ }
+
+ var top = this.parseToPx(jqt.css('top'));
+ if (isNaN(top)) {
+ top = 0;
+ jqt.css('top', '0px');
+ }
+
+ var to = jqt.offset();
+
+ if (hidden) {
+ jqt.css('display', 'none').css('visibility',
oldVisibility);
+ }
+
+ // set position
+ jqt.css({
+ left: (so.left - to.left + left) + 'px',
+ top: (so.top - to.top + top + vOffset) + 'px'
+ });
+ }
}
Richfaces.ComboBoxList.getElemXY = function(elem) {
Modified: trunk/ui/combobox/src/main/templates/combobox.jspx
===================================================================
--- trunk/ui/combobox/src/main/templates/combobox.jspx 2008-08-29 18:08:43 UTC (rev
10244)
+++ trunk/ui/combobox/src/main/templates/combobox.jspx 2008-08-29 18:12:15 UTC (rev
10245)
@@ -17,6 +17,7 @@
<h:styles>css/combobox.xcss</h:styles>
<h:scripts>
new org.ajax4jsf.javascript.PrototypeScript(),
+ /org/richfaces/renderkit/html/scripts/jquery/jquery.js,
scripts/comboboxUtils.js,
scripts/combolist.js,
scripts/combobox.js,