Author: pyaschenko
Date: 2008-03-27 08:40:05 -0400 (Thu, 27 Mar 2008)
New Revision: 7298
Modified:
trunk/samples/suggestionbox-sample/src/main/webapp/pages/index.jsp
trunk/ui/suggestionbox/src/main/java/org/richfaces/renderkit/html/SuggestionBoxRenderer.java
trunk/ui/suggestionbox/src/main/resources/org/richfaces/renderkit/html/css/suggestionbox.xcss
trunk/ui/suggestionbox/src/main/resources/org/richfaces/renderkit/html/scripts/suggestionbox.js
Log:
http://jira.jboss.com/jira/browse/RF-2340
Modified: trunk/samples/suggestionbox-sample/src/main/webapp/pages/index.jsp
===================================================================
--- trunk/samples/suggestionbox-sample/src/main/webapp/pages/index.jsp 2008-03-27 12:35:45
UTC (rev 7297)
+++ trunk/samples/suggestionbox-sample/src/main/webapp/pages/index.jsp 2008-03-27 12:40:05
UTC (rev 7298)
@@ -39,7 +39,6 @@
<f:verbatim> </f:verbatim>
-
<h:panelGroup>
<h:inputText value="#{suggestionBox.property}"
id="text"/>
<rich:suggestionbox id="suggestionBoxId" for="text"
Modified:
trunk/ui/suggestionbox/src/main/java/org/richfaces/renderkit/html/SuggestionBoxRenderer.java
===================================================================
---
trunk/ui/suggestionbox/src/main/java/org/richfaces/renderkit/html/SuggestionBoxRenderer.java 2008-03-27
12:35:45 UTC (rev 7297)
+++
trunk/ui/suggestionbox/src/main/java/org/richfaces/renderkit/html/SuggestionBoxRenderer.java 2008-03-27
12:40:05 UTC (rev 7298)
@@ -266,10 +266,10 @@
// suggestionBox.setPopup(popupFacet.getClientId(context));
renderChild(context, popupFacet);
}
+ writer.endElement(HTML.DIV_ELEM);
writer.startElement(HTML.SCRIPT_ELEM, component);
writer.writeText(getScript(context, component), "script");
writer.endElement(HTML.SCRIPT_ELEM);
- writer.endElement(HTML.DIV_ELEM);
writer.startElement("iframe", component);
writer.writeAttribute("src",
getResource("/org/richfaces/renderkit/html/images/spacer.gif")
Modified:
trunk/ui/suggestionbox/src/main/resources/org/richfaces/renderkit/html/css/suggestionbox.xcss
===================================================================
---
trunk/ui/suggestionbox/src/main/resources/org/richfaces/renderkit/html/css/suggestionbox.xcss 2008-03-27
12:35:45 UTC (rev 7297)
+++
trunk/ui/suggestionbox/src/main/resources/org/richfaces/renderkit/html/css/suggestionbox.xcss 2008-03-27
12:40:05 UTC (rev 7298)
@@ -31,8 +31,7 @@
}
.dr-sb-overflow {
- overflow-y : auto;
- overflow-x : auto;
+ overflow : auto;
}
.dr-sb-int-decor-table {
Modified:
trunk/ui/suggestionbox/src/main/resources/org/richfaces/renderkit/html/scripts/suggestionbox.js
===================================================================
---
trunk/ui/suggestionbox/src/main/resources/org/richfaces/renderkit/html/scripts/suggestionbox.js 2008-03-27
12:35:45 UTC (rev 7297)
+++
trunk/ui/suggestionbox/src/main/resources/org/richfaces/renderkit/html/scripts/suggestionbox.js 2008-03-27
12:40:05 UTC (rev 7298)
@@ -128,8 +128,7 @@
this.onScrollListener = this.onScroll.bindAsEventListener(this);
if (options.popupClass)
- Element.addClassName(document.getElementsByClassName("dr-sb-ext-decor-3",
- this.update)[0], options.popupClass);
+ Element.addClassName(this.update.select(".dr-sb-ext-decor-3")[0],
options.popupClass);
this.onNothingLabelClick = this.hideNLabel.bindAsEventListener(this);
},
@@ -194,7 +193,7 @@
this.wasScroll = false;
this.wasBlur = false;
if (!this.overflow)
- this.overflow = document.getElementsByClassName("dr-sb-overflow",
this.update)[0];
+ this.overflow = this.update.select(".dr-sb-overflow")[0];
Event.observe(this.overflow, "scroll", this.onScrollListener);
}
if (Element.getStyle(this.update, 'display')
@@ -340,7 +339,6 @@
|| event.keyCode == Event.KEY_ESC) {
return;
}
-
this.changed = true;
this.hasFocus = true;
@@ -453,7 +451,7 @@
while (item && (item != scroll)) {
// Avoid bug in Safari. Details:
http://jacob.peargrove.com/blog/2006/technical/table-row-offsettop-bug-in...
if (RichFaces.SAFARI == RichFaces.navigatorType() && "TR" ==
item.tagName.toUpperCase()) {
- realOffset += document.getElementsByClassName("dr-sb-cell-padding",
item)[0].offsetTop;
+ realOffset += item.select(".dr-sb-cell-padding")[0].offsetTop;
}
else
realOffset += item.offsetTop;
@@ -463,7 +461,7 @@
var entryOffsetHeight;
if (RichFaces.SAFARI == RichFaces.navigatorType()) {
- var tdElement = document.getElementsByClassName("dr-sb-cell-padding",
item)[0];
+ var tdElement = item.select(".dr-sb-cell-padding")[0];
entryOffsetHeight = tdElement.offsetTop + tdElement.offsetHeight;
} else
entryOffsetHeight = entry.offsetHeight;
@@ -472,7 +470,7 @@
countVisibleEntries: function() {
var entry = this.getEntry(this.index);
- var scroll = document.getElementsByClassName("_suggestion_size_",
this.update)[0]
+ var scroll = this.update.select("._suggestion_size_")[0]
|| this.update;
var entryPosition = this.calcEntryPosition(entry,scroll);
@@ -491,14 +489,14 @@
for (var i = 0; i < this.options.selectedClasses.length; i++)
Element.addClassName(entry, this.options.selectedClasses[i]);
- var cells =
document.getElementsByClassName("dr-sb-cell-padding" , entry);
+ var cells = entry.select(".dr-sb-cell-padding");
for (var i = 0; i < cells.length; i++) {
Element.addClassName(cells[i], this.options.selectValueClass);
}
// Calc scroll position :
if (this.keyEvent) {
- var scroll =
document.getElementsByClassName("_suggestion_size_", this.update)[0]
+ var scroll = this.update.select("._suggestion_size_")[0]
|| this.update;
var entryPosition = this.calcEntryPosition(entry,scroll);
@@ -518,7 +516,7 @@
if (this.prevIndex >= 0) {
var prevEntry = this.getEntry(this.prevIndex);
if (prevEntry) {
- var prevCells =
document.getElementsByClassName("dr-sb-cell-padding" , prevEntry);
+ var prevCells = prevEntry.select(".dr-sb-cell-padding");
for (var i = 0; i < prevCells.length; i++) {
Element.removeClassName(prevCells[i], this.options.selectValueClass);
}
@@ -571,11 +569,15 @@
},
getEntry: function(index) {
- if (this.options.entryClass) {
- return document.getElementsByClassName(this.options.entryClass,
this.update)[index];
+ /*if (this.options.entryClass) {
+ return this.update.select("."+this.options.entryClass)[index];
} else {
- return this.update.firstChild.firstChild.childNodes[index];
- }
+ return $(this.update.firstChild.firstChild.childNodes[index]);
+ }*/
+ // optimization
+ var element = $(this.contentTable).firstChild;
+ while (!element.tagName || element.tagName.toLowerCase()!="tbody")
element = element.nextSibling;
+ return $(element.childNodes[index]);
},
getCurrentEntry: function() {
@@ -605,13 +607,9 @@
return;
}
var value = '';
- if (this.options.select) {
- var nodes = document.getElementsByClassName(this.options.select,
selectedElement)
- || [];
- if (nodes.length > 0) value
- = Element.collectTextNodes(nodes[0], this.options.select);
- } else
- value = Element.collectTextNodesIgnoreClass(selectedElement,
'informal');
+ var obj = selectedElement.firstChild;
+ while (!obj.tagName || obj.tagName.toLowerCase()!="td") obj =
obj.nextSibling;
+ value = Element.collectTextNodes(obj);
this.insertValue(value, event);
this.oldValue = this.element.value;
@@ -629,7 +627,7 @@
// TODO - get entry elements by tag name or class
var entryes = [];
if (this.options.entryClass) {
- entryes = document.getElementsByClassName(this.options.entryClass,
this.update)
+ entryes = this.update.select("."+this.options.entryClass)
|| [];
} else if (this.update.firstChild
&& this.update.firstChild.firstChild
@@ -650,7 +648,7 @@
}
this.stopIndicator();
- var scroll = document.getElementsByClassName("_suggestion_size_",
this.update)[0]
+ var scroll = this.update.select("_suggestion_size_")[0]
|| this.update;
scroll.scrollTop = -1;
scroll.scrollLeft = -1;
@@ -852,6 +850,7 @@
this.options.oncomplete = this.onComplete.bind(this);
this.options.defaultParams = this.options.parameters || null;
this.content = content;
+ this.contentTable = content+":suggest";
this.containerId = containerId;
this.actionUrl = actionUrl;