Author: abelevich
Date: 2010-10-28 06:51:49 -0400 (Thu, 28 Oct 2010)
New Revision: 19722
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/popupList.js
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/select.js
trunk/ui/input/ui/src/main/templates/inplaceSelect.template.xml
trunk/ui/input/ui/src/main/templates/select.template.xml
Log:
add scroll support for the selects
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-10-28
08:16:52 UTC (rev 19721)
+++
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceSelect.js 2010-10-28
10:51:49 UTC (rev 19722)
@@ -4,8 +4,10 @@
rf.ui.InplaceSelect = function(id, options) {
var mergedOptions = $.extend({}, defaultOptions, options);
- $super.constructor.call(this, id, mergedOptions)
- mergedOptions['attachTo'] = id;
+ $super.constructor.call(this, id, mergedOptions)
+
+ mergedOptions['attachTo'] = id;
+ mergedOptions['scrollContainer'] = $(document.getElementById(id +
"Items")).parent()[0];
this.popupList = new rf.ui.PopupList(id+"List", this, mergedOptions);
this.items = mergedOptions.items;
this.selValueInput = $(document.getElementById(id+"selValue"));
Modified:
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/popupList.js
===================================================================
---
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/popupList.js 2010-10-28
08:16:52 UTC (rev 19721)
+++
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/popupList.js 2010-10-28
10:51:49 UTC (rev 19722)
@@ -7,6 +7,7 @@
$super.constructor.call(this, id, mergedOptions);
this.selectListener = listener;
this.selectItemCss = mergedOptions.selectItemCss;
+ this.scrollContainer = $(mergedOptions.scrollContainer);
this.itemCss = mergedOptions.itemCss;
this.listCss = mergedOptions.listCss;
this.index = -1;
@@ -44,6 +45,7 @@
} else {
item.addClass(this.selectItemCss);
}
+ this.__scrollToSelectedItem(this);
},
unselectItem: function(item) {
@@ -151,8 +153,30 @@
__setItems: function(items) {
this.items = items;
+ },
+
+ __scrollToSelectedItem : function() {
+ if(this.scrollContainer) {
+ var offset = 0;
+ if(this.index > 5) {
+ var test = 5;
+ }
+
+ this.items.slice(0, this.index).each(function() {
+ offset += this.offsetHeight;
+ });
+
+ var parentContainer = this.scrollContainer;
+ 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());
+ }
+ }
+ }
}
-
}
})());
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-10-28
08:16:52 UTC (rev 19721)
+++
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/select.js 2010-10-28
10:51:49 UTC (rev 19722)
@@ -115,7 +115,8 @@
this.id = id;
var mergedOptions = $.extend({}, defaultOptions, options);
mergedOptions['attachTo'] = id;
-
+ mergedOptions['scrollContainer'] = $(document.getElementById(id +
"Items")).parent()[0];
+
this.defaultLabel = mergedOptions.defaultLabel;
var inputLabel = this.getValue() ;
this.initialValue = (inputLabel != this.defaultLabel) ? inputLabel :
"";
Modified: trunk/ui/input/ui/src/main/templates/inplaceSelect.template.xml
===================================================================
--- trunk/ui/input/ui/src/main/templates/inplaceSelect.template.xml 2010-10-28 08:16:52
UTC (rev 19721)
+++ trunk/ui/input/ui/src/main/templates/inplaceSelect.template.xml 2010-10-28 10:51:49
UTC (rev 19722)
@@ -87,8 +87,10 @@
<span class="rf-is-shdw-r"></span>
<span class="rf-is-shdw-b"></span>
<span class="rf-is-lst-dec">
- <span class="rf-is-lst-scrl" id="#{clientId}Items"
style="height: #{component.attributes['listHeight']}">
- <cdk:call expression="encodeItems(facesContext, component,
clientSelectItems);"/>
+ <span class="rf-is-lst-scrl" style="height:
#{component.attributes['listHeight']}">
+ <span id="#{clientId}Items">
+ <cdk:call expression="encodeItems(facesContext, component,
clientSelectItems);"/>
+ </span>
</span>
</span>
</span>
Modified: trunk/ui/input/ui/src/main/templates/select.template.xml
===================================================================
--- trunk/ui/input/ui/src/main/templates/select.template.xml 2010-10-28 08:16:52 UTC (rev
19721)
+++ trunk/ui/input/ui/src/main/templates/select.template.xml 2010-10-28 10:51:49 UTC (rev
19722)
@@ -54,8 +54,10 @@
<div class="rf-sel-shdw-b"></div>
<div class="rf-sel-lst-dcrtn">
- <div class="rf-sel-lst-scrl"
id="#{clientId}Items" >
- <cdk:call expression="encodeItems(facesContext, component,
clientSelectItems);"/>
+ <div class="rf-sel-lst-scrl">
+ <div id="#{clientId}Items" >
+ <cdk:call expression="encodeItems(facesContext, component,
clientSelectItems);"/>
+ </div>
</div>
</div>
</div>
Show replies by date