You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xap-commits@incubator.apache.org by mt...@apache.org on 2006/11/07 00:23:40 UTC
svn commit: r471945 - in /incubator/xap/trunk/src/xap:
bridges/xap/ListBoxBridge.js bridges/xap/XapComboBoxBridge.js
widgets/ListBox.js widgets/XapComboBox.js
Author: mturyn
Date: Mon Nov 6 16:23:39 2006
New Revision: 471945
URL: http://svn.apache.org/viewvc?view=rev&rev=471945
Log:
Seems o.k. now, ComboBox is a dropdown, ListBox looks like a list. Just have to get onCommand working.
Modified:
incubator/xap/trunk/src/xap/bridges/xap/ListBoxBridge.js
incubator/xap/trunk/src/xap/bridges/xap/XapComboBoxBridge.js
incubator/xap/trunk/src/xap/widgets/ListBox.js
incubator/xap/trunk/src/xap/widgets/XapComboBox.js
Modified: incubator/xap/trunk/src/xap/bridges/xap/ListBoxBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/bridges/xap/ListBoxBridge.js?view=diff&rev=471945&r1=471944&r2=471945
==============================================================================
--- incubator/xap/trunk/src/xap/bridges/xap/ListBoxBridge.js (original)
+++ incubator/xap/trunk/src/xap/bridges/xap/ListBoxBridge.js Mon Nov 6 16:23:39 2006
@@ -31,7 +31,6 @@
this.isChildOfComboBox = false;
this._setEventOnce = true;
-
}
Xap.setupClassAsSubclassOf("xap.bridges.xap.ListBoxBridge", "xap.bridges.dojo.DojoWidgetBridge");
@@ -40,13 +39,36 @@
return "ListBox" ;
}
+
xap.bridges.xap.ListBoxBridge.prototype.addChild = function(childHandler) {
var elementListItem = childHandler.getElement();
var childPeer = childHandler.getPeer();
childPeer.setDetail(elementListItem.getAttribute('text'), elementListItem.getAttribute('value'));
- this.getPeer().addChild(childPeer);
+ var peer = this.getPeer() ;
+ peer.addChild(childPeer);
+ if( !peer.trueSize ){
+ peer.trueSize = 0 ;
+ }
+ ++peer.trueSize ;
+
+ if(this.isChildOfComboBox){
+ // ComboBox "size" is always 0, so list isn't displayed
+ // until we might want it to be:
+ peer.size = 1 ;
+ } else {
+ // ListBox "size" is always at least 2, so the
+ // list is always displayed---though not necesarily all at
+ // once: it might be scrolled if item-height*size > list-height:
+ if( peer.trueSize>1){
+ var cacheHeight = peer.select.height ;
+ peer.select.size = peer.trueSize ;
+ peer.select.height = cacheHeight ;
+ }
+
+ }
+
if (this._setEventOnce && !this.isChildOfComboBox) {
this.getPeer().setOnStateChange(this, 'fireEvent', 'onStateChange');
@@ -56,8 +78,28 @@
}
xap.bridges.xap.ListBoxBridge.prototype.removeChild = function( childHandler ){
- this.getPeer().removeChild(childHandler.getPeer());
+ var peer = this.getPeer() ;
+ peer.removeChild(childHandler.getPeer());
+ --peer.trueSize ;
+ // See addChild() above:
+ if(this.isChildOfComboBox){
+ // ComboBox "size" is always 1, so list isn't displayed
+ // until we might want it to be:
+ peer.size = 1 ;
+ } else {
+ // ListBox "size" is always at least 2, so the
+ // list is always displayed---though not necesarily all at
+ // once: it might be scrolled if item-height*size > list-height:
+ if( peer.trueSize>1){
+ var cacheHeight = peer.select.height ;
+ peer.select.size = peer.trueSize ;
+ peer.select.height = cacheHeight ;
+ }
+
+ }
+
}
+
xap.bridges.xap.ListBoxBridge.prototype.getNewAllowedAttributes = function(){
Modified: incubator/xap/trunk/src/xap/bridges/xap/XapComboBoxBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/bridges/xap/XapComboBoxBridge.js?view=diff&rev=471945&r1=471944&r2=471945
==============================================================================
--- incubator/xap/trunk/src/xap/bridges/xap/XapComboBoxBridge.js (original)
+++ incubator/xap/trunk/src/xap/bridges/xap/XapComboBoxBridge.js Mon Nov 6 16:23:39 2006
@@ -64,12 +64,16 @@
this._myListBox.select.multiple = null;
this._myListBox.select.removeAttribute('multiple');
- this._myListBox.select.size = 1;
+ this._myListBox.select.size = 1 ;
this.getPeer().addChild(this._myListBox);
- /* let the child listBoxBridge know that the parent is a combobox so that it doesn't set the onchange event of the html select */
+ /*
+ let the child listBoxBridge know that
+ the parent is a combobox so that it doesn't
+ set the onchange event of the html select
+ */
childHandler.isChildOfComboBox = true;
this._myListBox.setOnStateChange(this, 'fireEvent', 'onTextChange');
Modified: incubator/xap/trunk/src/xap/widgets/ListBox.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/widgets/ListBox.js?view=diff&rev=471945&r1=471944&r2=471945
==============================================================================
--- incubator/xap/trunk/src/xap/widgets/ListBox.js (original)
+++ incubator/xap/trunk/src/xap/widgets/ListBox.js Mon Nov 6 16:23:39 2006
@@ -10,7 +10,6 @@
xap.widgets.ListBox = function(){
dojo.widget.HtmlWidget.call(this);
- this.trueSize = 0 ;
}
dojo.inherits(xap.widgets.ListBox, dojo.widget.HtmlWidget);
@@ -25,12 +24,6 @@
addChild: function(child) { /* elementListItem */
this.select.appendChild(child.domNode);
- ++this.trueSize ;
- if( this.trueSize>1){
- var cacheHeight = this.select.height ;
- this.select.size = this.trueSize ;
- this.select.height = cacheHeight ;
- }
//alert('adding an option');
},
@@ -44,13 +37,6 @@
for (var i = 0; i < options.length; i++) {
if (options[i] == child.domNode){
options[i] = null;
- // Keep this from turning a list box into a combo box
- --this.trueSize ;
- if(this.trueSize > 1){
- var cacheHeight = this.select.height ;
- this.select.size = this.trueSize ;
- this.select.height = cacheHeight ;
- }
}
/* IE doesn't update the page with dom node removal so we have to do this*/
}
Modified: incubator/xap/trunk/src/xap/widgets/XapComboBox.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/widgets/XapComboBox.js?view=diff&rev=471945&r1=471944&r2=471945
==============================================================================
--- incubator/xap/trunk/src/xap/widgets/XapComboBox.js (original)
+++ incubator/xap/trunk/src/xap/widgets/XapComboBox.js Mon Nov 6 16:23:39 2006
@@ -27,7 +27,7 @@
isContainer: true,
addChild: function(child) {
- xap.widgets.XapComboBox.superclass.addChild.call(this, child); /* add dojo widget to dojo widget */
+ xap.widgets.XapComboBox.superclass.addChild.call(this, child); /* add dojo widget to dojo widget */
},