[Laszlo-checkins] r8709 - in openlaszlo/trunk: lps/components/base lps/components/lz test/lzunit
bargull@openlaszlo.org
bargull at openlaszlo.org
Wed Apr 16 09:01:34 PDT 2008
Author: bargull
Date: 2008-04-16 09:01:29 -0700 (Wed, 16 Apr 2008)
New Revision: 8709
Modified:
openlaszlo/trunk/lps/components/base/basedatacombobox.lzx
openlaszlo/trunk/lps/components/base/baseslider.lzx
openlaszlo/trunk/lps/components/lz/basefloatinglist.lzx
openlaszlo/trunk/test/lzunit/testpaths.txt
Log:
Change 20080412-bargull-0 by bargull at dell--p4--2-53 on 2008-04-12 14:53:35
in /home/Admin/src/svn/openlaszlo/trunk
for http://svn.openlaszlo.org/openlaszlo/trunk
Summary: update components for lzunit
New Features:
Bugs Fixed: LPP-5645, LPP-5710
Technical Reviewer: max
QA Reviewer: ptw
c Reviewer: (pending)
Documentation:
Release Notes:
Details:
Update components, so we can run lzunit again.
Tests:
ant runlzunit,
test/components/base/lzunit-baseslider.lzx,
test/components/base/lzunit-basedatacombobox.lzx,
testcase for LPP-5549
Modified: openlaszlo/trunk/lps/components/base/basedatacombobox.lzx
===================================================================
--- openlaszlo/trunk/lps/components/base/basedatacombobox.lzx 2008-04-16 15:57:15 UTC (rev 8708)
+++ openlaszlo/trunk/lps/components/base/basedatacombobox.lzx 2008-04-16 16:01:29 UTC (rev 8709)
@@ -12,16 +12,16 @@
@keywords private -->
<class name="basedatacombobox_item" extends="textlistitem" width="${null}">
<!--- @keywords private -->
- <handler name="onmousedown">
- parent.select(this);
- </handler>
+ <handler name="onmousedown"><![CDATA[
+ this.parent.select(this);
+ ]]></handler>
<!--- Also called by the combobox when it opens if the data
might have changed.
@keywords private -->
<handler name="ondata" method="handleData"/>
- <method name="handleData" args="d"> <![CDATA[
- var target = parent.attachtarget;
+ <method name="handleData" args="d"><![CDATA[
+ var target = this.parent.attachtarget;
var t = this.datapath.xpathQuery(target.textdatapath);
var v = this.datapath.xpathQuery(target.valuedatapath);
if ($debug) {
@@ -32,16 +32,15 @@
Debug.warn("basedatacombobox_item valuedatapath result is undefined");
}
}
- this.setAttribute('text', ( t == undefined ? '' : t ));
- this.setAttribute('value', ( v == undefined ? null : v ));
+ this.setAttribute('text', ( t == void(0) ? '' : t ));
+ this.setAttribute('value', ( v == void(0) ? null : v ));
// special case for separator string
// TODO [2005-4-01, dchung] could this be rendered as a line?
this.setAttribute('enabled', (t != '-----'));
- this.setWidth(target.listwidth ? target.listwidth : target.width);
- ]]>
- </method>
+ this.setAttribute("width", target.listwidth ? target.listwidth : target.width);
+ ]]></method>
</class>
<class name="basedatacombobox" extends="baseformitem">
@@ -140,7 +139,7 @@
<event name="onisopen"/>
<!--- @keywords private -->
- <method name="init"> <![CDATA[
+ <method name="init"><![CDATA[
super.init();
if ( this.value == null && this.defaulttext != null ) {
this._cbtext.setText(this.defaulttext);
@@ -151,8 +150,7 @@
if ( this.statictext != null ) {
this._cbtext.setText( this.statictext );
}
- ]]>
- </method>
+ ]]></method>
<!--- @keywords private -->
<method name="destroy" ><![CDATA[
@@ -179,14 +177,20 @@
this._datacatchdel.unregisterAll();
}
- if (this.value == null && selectfirst) {
+ if (this.value == null && this.selectfirst) {
// set first to be the initvalue
- this._updateSelectionByIndex(0,false,true);
+ this._updateSelectionByIndex(0, false, true);
} else {
- this._updateSelectionByIndex(this._selectedIndex, true);
+ if (this._selectedIndex != -1) {
+ //fix for LPP-5549
+ this._updateSelectionByIndex(this._selectedIndex, true);
+ }
}
} else {
if (this._datacatchdel == null) {
+ //FIXME: [20080412 anba] look for dataset,
+ //does fail when there is ":/" in a predicate, but it used all over the place,
+ //we should provide a general solution!
var itmpath = this.itemdatapath;
var iof = itmpath.indexOf( ":/" );
if (iof > -1) {
@@ -201,14 +205,13 @@
]]></method>
<!--- @keywords private -->
- <handler name="ondata"> <![CDATA[
- _teardowncblist();
- if (this.value == null && selectfirst) {
+ <handler name="ondata"><![CDATA[
+ this._teardowncblist();
+ if (this.value == null && this.selectfirst) {
// set first to be the initvalue
- _updateSelectionByIndex(0,false,true);
+ this._updateSelectionByIndex(0, false, true);
}
- ]]>
- </handler>
+ ]]></handler>
<!--- Setter to set baseformitem to changed. Should be called by
subclasses whenever a value is set. The first time this is called,
@@ -217,14 +220,14 @@
This also updates the selected value in the combobox to reflect
the new value (in case it was changed).
@param Boolean isChanged: true if changed, else false. -->
- <method name="setChanged" args="isChanged">
+ <method name="setChanged" args="isChanged"><![CDATA[
super.setChanged( isChanged );
// Be sure to update the selection, because value might have been
// changed programmatically
if (this.changed) {
- this._updateSelectionByIndex( this.getItemIndex( this['value'] ), true, false );
+ this._updateSelectionByIndex(this.getItemIndex( this['value'] ), true, false);
}
- </method>
+ ]]></method>
<!--- Updates the combobox text and 'selected' attribute. Called when an
item is selected.
@@ -235,8 +238,7 @@
value.
@keywords private -->
<method name="_updateSelectionByIndex"
- args="index,dontSetValue,isinitvalue"> <![CDATA[
- if (index < 0) return;
+ args="index,dontSetValue,isinitvalue"><![CDATA[
var dp = new LzDatapointer(this);
var nodes = dp.xpathQuery(this.itemdatapath);
@@ -257,48 +259,61 @@
this._cbtext.setText(t);
}
- if ( this.selected && dp['p'] == this.selected['p'] ) return;
-
- if (! (dontSetValue || this.ismenu)) {
- if (dpValid) {
- var v = dp.xpathQuery(this.valuedatapath);
+ if (this.selected == null || dp['p'] !== this.selected['p']) {
+ if (! (dontSetValue || this.ismenu)) {
+ if (dpValid) {
+ var v = dp.xpathQuery(this.valuedatapath);
+ } else {
+ var v = null;
+ }
+ this.setValue(v, true, true);
+ }
+ this.setAttribute('text', t);
+
+ if (this.ismenu) {
+ //FIXME: [20080412 anba] datapointer leaks memory, but we cannot destroy
+ //it because it is passed to the "onselect"/"onselected" event!
+
+ // Clear the selection
+ this._selectedIndex = -1;
+ if (this._cblist['_selector']) {
+ this._cblist._selector.clearSelection();
+ }
} else {
- var v = null;
+ if (this.selected != null) {
+ this.selected.destroy();
+ }
+ this.selected = dp;
}
- this.setValue(v,true, true);
+
+ if ( this['onselected'] ) this.onselected.sendEvent(dp);
+ if ( this['onselect'] ) this.onselect.sendEvent(dp);
+ } else {
+ dp.destroy();
}
- this.setAttribute('text', t);
+ ]]></method>
- if (this.ismenu) {
- // Clear the selection
- this._selectedIndex = -1;
- if (this._cblist['_selector']) {
- this._cblist._selector.clearSelection();
- }
- }
- else {
- this.selected = dp;
- }
-
- if ( this['onselected'] ) this.onselected.sendEvent(dp);
- if ( this['onselect'] ) this.onselect.sendEvent(dp);
- ]]>
- </method>
-
<!--- @keywords private -->
- <method name="_setupcblist" args="force"> <![CDATA[
+ <method name="_setupcblist" args="force"><![CDATA[
if (this._cblist == null) {
-
if (this.itemclassname == "") {
this.itemclassname = "basedatacombobox_item";
}
var icn = this.itemclassname;
-
+ if (!(icn && lz[icn])) {
+ if ($debug) {
+ Debug.error("%s.itemclassname invalid: %s", this, icn);
+ }
+ return;
+ }
+
var flcn = this.menuclassname;
- if ($debug) {
- if (typeof lz[flcn] == "undefined")
- Debug.format("basedatacombobox floatinglist class (%w) is undefined", flcn);
+ if (!(flcn && lz[flcn])) {
+ if ($debug) {
+ Debug.error("%s.menuclassname invalid: %s", this, flcn);
+ }
+ return;
}
var cblist = new lz[flcn](this,
@@ -341,31 +356,29 @@
if (! this.ismenu) {
// Set the item for _cblist
- var item = _getItemAt(this._selectedIndex);
+ var item = this._getItemAt(this._selectedIndex);
this._cblist.select(item);
}
- ]]>
- </method>
+ ]]></method>
<!--- @keywords private -->
- <method name="_teardowncblist">
- //Debug.write("destroying _cblist");
+ <method name="_teardowncblist"><![CDATA[
if (this._selectdel != null) {
this._selectdel.unregisterAll();
- delete this._selectdel;
+ this._selectdel = null;
}
if (this._cblist != null) {
var cbl = this._cblist;
this._cblist = null;
- cbl.setVisible(false);
+ cbl.setAttribute("visible", false);
cbl.destroy();
}
- </method>
+ ]]></method>
<!--- Toggles the open/close state of the popup list. -->
- <method name="toggle">
- this.setOpen(!this.isopen)
- </method>
+ <method name="toggle"><![CDATA[
+ this.setAttribute("isopen", !this.isopen)
+ ]]></method>
<!--- Sets the open/close state of the popup list.
@param Boolean open: true to open the list, else false to close.
@@ -373,40 +386,40 @@
<method name="setOpen" args="open" ><![CDATA[
if (!this._initcomplete) {
this.isopen = open;
- return;
- }
- if (open) { // open combox
- if (this.isopen) return; // tends to get called more than once
-
- LzModeManager.makeModal( this );
-
- this._setupcblist();
-
- this._cblist.bringToFront();
- this._cblist.setVisible(true);
-
- LzFocus.setFocus( this._cblist, false );
-
- this.isopen = true;
- if (this['onisopen']) this.onisopen.sendEvent(true);
- } else { // close combox
- if (!this.isopen) return;
- LzModeManager.release( this );
- if (!this['isopen']) return;
- this._cblist.setVisible(false);
- this.isopen = false;
- if (this['onisopen']) this.onisopen.sendEvent(false);
- if ( LzFocus.getFocus() == this._cblist ) {
- if ( this.focusable ) {
- LzFocus.setFocus( this, false );
- }
+ } else {
+ if (open) { // open combox
+ if (this.isopen) return; // tends to get called more than once
+
+ LzModeManager.makeModal( this );
+
+ this._setupcblist();
+
+ this._cblist.bringToFront();
+ this._cblist.setVisible(true);
+
+ LzFocus.setFocus( this._cblist, false );
+
+ this.isopen = true;
+ if (this['onisopen']) this.onisopen.sendEvent(true);
+ } else { // close combox
+ if (!this.isopen) return;
+ LzModeManager.release( this );
+ if (!this['isopen']) return;
+
+ this._cblist.setAttribute("visible", false);
+ this.isopen = false;
+ if (this['onisopen']) this.onisopen.sendEvent(false);
+ if ( LzFocus.getFocus() === this._cblist ) {
+ if ( this.focusable ) {
+ LzFocus.setFocus( this, false );
+ }
+ }
}
}
- ]]>
- </method>
+ ]]></method>
<!--- @keywords private -->
- <method name="passModeEvent" args="eventStr,view" > <![CDATA[
+ <method name="passModeEvent" args="eventStr,view" ><![CDATA[
// Once a view has been made modal, this method
// gets called ONLY when a user clicks on a view 'outside'
// the contents of this view, or clicks on a inputtext view anywhere
@@ -424,14 +437,12 @@
if ( !view.childOf(this._cblist) ) {
// view is outside of combobox so close the combbobox
- this.setOpen(false);
-
+ this.setAttribute("isopen", false);
} else {
// view is a child of _cblist, so don't do anything.
}
-
} else {
- this.setOpen(false);
+ this.setAttribute("isopen", false);
}
}
// if we're inside a modal dialog, need to propagate event manually
@@ -446,14 +457,13 @@
// true to pass the event to the object (oustide combobox)
// that was clicked on
return true;
- ]]>
- </method>
+ ]]></method>
<!--- This method listens for the onselect event from the floating list
and then calls setValue, which indirectly sends an onselect event
to the datacombobox.
@keywords private -->
- <method name="_flistselect" args="item" > <![CDATA[
+ <method name="_flistselect" args="item" ><![CDATA[
// Just return if item is undefined. baselist will do this sometimes
if ( typeof item == "undefined" ) {
return;
@@ -474,21 +484,21 @@
if ( item && this.statictext == null ) this._cbtext.setText(item.text);
}
- this.setOpen(false);
- ]]>
- </method>
+ this.setAttribute("isopen", false);
+ ]]></method>
<!--- Find a particular item by its index. This routine only works when the
_cblist is attached and data mapped.
@param Number index: the index for the item to get.
@return Object: the item found, or null, if not.
@keywords private -->
- <method name="_getItemAt" args="index"> <![CDATA[
+ <method name="_getItemAt" args="index"><![CDATA[
var item = null;
- if (this._cblist._selector instanceof lz.datalistselector) {
- this._cblist._selector._ensureItemInViewByIndex( index );
+ var sel = this._cblist._selector;
+ if (sel is lz.datalistselector) {
+ sel._ensureItemInViewByIndex( index );
}
- var svs = this._cblist._selector.immediateparent.subviews;
+ var svs = sel.immediateparent.subviews;
if (svs) {
var sv = svs[0];
if (sv) {
@@ -502,98 +512,100 @@
}
}
return item;
- ]]>
- </method>
+ ]]></method>
<!--- Select an item by value.
@param Object value: the value of the item to select. -->
- <method name="selectItem" args="value"> <![CDATA[
+ <method name="selectItem" args="value"><![CDATA[
var i = this.getItemIndex(value);
- if (i != -1) _updateSelectionByIndex(i);
- ]]>
- </method>
+ if (i != -1) this._updateSelectionByIndex(i);
+ ]]></method>
- <!--- Get item's index by value. Note: If you have a stray character in
- dataset, this will break. CDATA is included in nodes.length.
+ <!--- Get item's index by value. Returns
@param Object value: the value of the item to select. -->
- <method name="getItemIndex" args="value"> <![CDATA[
+ <method name="getItemIndex" args="value"><![CDATA[
+ var index = -1;
var dp = new LzDatapointer(this);
var nodes = dp.xpathQuery(this.itemdatapath);
- if (! (nodes instanceof Array)) nodes = [nodes];
- dp.setPointer(nodes[0]);
- for (var i=0; i < nodes.length; i++) {
- var test_value = dp.xpathQuery(this.valuedatapath);
- if (test_value == value) return i;
- dp.selectNext();
+ if (nodes != null) {
+ if (! (nodes instanceof Array)) nodes = [nodes];
+ for (var i = 0; i < nodes.length; i++) {
+ dp.setPointer(nodes[i]);
+ var test_value = dp.xpathQuery(this.valuedatapath);
+ if (test_value == value) {
+ index = i;
+ break;
+ }
+ }
}
- return -1;
- ]]>
- </method>
+ dp.destroy();
+ return index;
+ ]]></method>
<!--- Select an item by index.
@param Number index: the index of the item to select. -->
- <method name="selectItemAt" args="index" >
- _updateSelectionByIndex(index);
+ <method name="selectItemAt" args="index" ><![CDATA[
+ this._updateSelectionByIndex(index);
this._setupcblist();
- </method>
+ ]]></method>
<!--- Set value of combobox.
@param String|Number value: value to set.
@param Boolean isinitvalue: true if value is an init value. -->
- <method name="setValue" args="value,isinitvalue, ignoreselection"><![CDATA[
- if (this['value'] == value) return;
- var i = this.getItemIndex(value);
- this._selectedIndex = i;
-
- if (! this.ismenu) { // Ignore value if we're a menu
- super.setValue(value,isinitvalue);
+ <method name="setValue" args="value, isinitvalue, ignoreselection"><![CDATA[
+ if (this['value'] != value) {
+ var i = this.getItemIndex(value);
+ this._selectedIndex = i;
+
+ if (! this.ismenu) { // Ignore value if we're a menu
+ super.setValue(value, isinitvalue);
+ }
+
+ if ( i != -1 && !ignoreselection) {
+ this._updateSelectionByIndex(i, true);
+ }
}
+ ]]></method>
- if ( i != -1 && !ignoreselection) {
- this._updateSelectionByIndex(i,true);
- }
- ]]>
- </method>
-
<!--- Override getValue because we don't want to return this.text
if this.value is null (this.text may be the defaulttext) -->
- <method name="getValue">
+ <method name="getValue"><![CDATA[
return ( this.value == null ? '' : this.value );
- </method>
+ ]]></method>
<!--- Arrow down and up, and spacebar all popup floatinglist.-->
<handler name="onkeydown" method="_dokeydown"/>
+
<!--- @keywords private -->
<method name="_dokeydown" args="key"><![CDATA[
// 38: up-arrow, 40: down-arrow, 32: space, 13: return, 27: escape
if ( (key==38) || (key==40) || (key==32) ) {
- if ( ! this.isopen ) this.setOpen(true);
+ if ( ! this.isopen ) this.setAttribute("isopen", true);
}
- ]]>
- </method>
+ ]]></method>
<!--- Since we are not focusable, defer to the datacombobox's next selection,
so that when floatinglist is tabbed out of, we can provide a next
selection since we are it's owner
@keywords private -->
- <method name="getNextSelection">
+ <method name="getNextSelection"><![CDATA[
// must ensure the floatinglist is closed so that if it is being tabbed from,
// we can change the focus. (focus is normally not allowed to escape from
// a modal view).
- this.setOpen(false);
+ this.setAttribute("isopen", false);
return LzFocus.getNext(this);
- </method>
+ ]]></method>
<!--- since we are not focusable, this provides an api for asking what child to send focus
to, as is the case when floatinglist is shift-tabbed back to us.
@keywords private -->
- <method name="resolveSelection">
+ <method name="resolveSelection"><![CDATA[
// must ensure the floatinglist is closed so that if it is being tabbed from,
// we can change the focus. (focus is normally not allowed to escape from
// a modal view).
- this.setOpen(false);
+ this.setAttribute("isopen", false);
return this;
- </method>
+ ]]></method>
<!-- ============================================================ -->
<!-- focus kludge for combobox -->
@@ -603,27 +615,27 @@
<event name="oncombofocus" />
<!--- The equivalent for onblur for combobox. -->
<event name="oncomboblur" />
+
<!--- @keywords private -->
<handler name="onfocus"><![CDATA[
- //Debug.write("cb onfocus", this, LzFocus.lastfocus);
// LzFocus.lastfocus is the blurred view
- if ( LzFocus.lastfocus != this._cblist ||
- (this._cblist != null && this._cblist.attachtarget != this) ) {
+ if ( LzFocus.lastfocus !== this._cblist ||
+ (this._cblist != null && this._cblist.attachtarget !== this) ) {
if (this.oncombofocus) {
this.oncombofocus.sendEvent(LzFocus.lastfocus);
}
}
]]></handler>
+
<!--- @keywords private -->
<handler name="onblur" args="focusview"><![CDATA[
- //Debug.write("cb onblur", this, focusview);
- if (focusview != null && focusview != this._cblist) {
+ if (focusview != null && focusview !== this._cblist) {
if (this.oncomboblur) {
this.oncomboblur.sendEvent(focusview);
}
// destroy floating list when we lose focus
if (this._cblist != null &&
- LzFocus.lastfocus != this) {
+ LzFocus.lastfocus !== this) {
this._teardowncblist();
}
}
Modified: openlaszlo/trunk/lps/components/base/baseslider.lzx
===================================================================
--- openlaszlo/trunk/lps/components/base/baseslider.lzx 2008-04-16 15:57:15 UTC (rev 8708)
+++ openlaszlo/trunk/lps/components/base/baseslider.lzx 2008-04-16 16:01:29 UTC (rev 8709)
@@ -57,54 +57,65 @@
if (this.value > this.maxvalue) this.value = this.maxvalue;
// and since we didn't send events in the pre-init case, do those now too
- if (onvalue) onvalue.sendEvent();
- if (onminvalue) onminvalue.sendEvent();
- if (onmaxvalue) onmaxvalue.sendEvent();
+ if (this['onvalue']) this.onvalue.sendEvent();
+ if (this['onminvalue']) this.onminvalue.sendEvent();
+ if (this['onmaxvalue']) this.onmaxvalue.sendEvent();
+
+ // since we didn't handle view consistency in the pre-init case, do it now
+ this._adjustThumb();
]]></method>
- <!--- @keywords private -->
- <handler name="oninit">
- // since we didn't handle view consistency in the pre-init case, do it now
- _adjustThumb();
- </handler>
-
<!--- Get the minimum value of the slider.
@return Number: the minimum value. -->
- <method name="getMinValue">
- return minvalue;
- </method>
+ <method name="getMinValue"><![CDATA[
+ //TODO: [20080412 anba] deprecate?
+ if ($debug) {
+ Debug.info("%w.%s() is deprecated. Use %w[%#w] instead.", this, arguments.callee, this, "minvalue");
+ }
+ return this.minvalue;
+ ]]></method>
+
<!--- Get the maximum value of the slider.
@return Number: the maximum value. -->
- <method name="getMaxValue">
- return maxvalue;
- </method>
+ <method name="getMaxValue"><![CDATA[
+ //TODO: [20080412 anba] deprecate?
+ if ($debug) {
+ Debug.info("%w.%s() is deprecated. Use %w[%#w] instead.", this, arguments.callee, this, "maxvalue");
+ }
+ return this.maxvalue;
+ ]]></method>
<!--- Set the minimum value.
@param Number v: the minimum value. -->
<method name="setMinValue" args="v"><![CDATA[
v = v * 1;
- if (!isinited) {
- // bounds check and sendEvent are done in init() override in this case
- this.minvalue = v;
- return;
+ if (isNaN(v)) {
+ if ($debug) {
+ Debug.warn("%w.%s must not be set to %s", this, "minvalue", v);
+ }
+ v = 0;
}
-
- if (this.minvalue == v) return;
-
- // ensure no crossover
- if (this.maxvalue < v) v = this.maxvalue;
-
- // doing this before setting the attribute means we assume consistency
- // on function entry and try to send events only when in a consistent state.
- if (v > this.value) this.setAttribute("value",v);
-
- this.minvalue = v;
-
- if (onminvalue) onminvalue.sendEvent();
-
- _adjustThumb();
-
+
+ if (!this._initcomplete) {
+ // bounds check and sendEvent are done in init() override in this case
+ this.minvalue = v;
+ } else {
+ if (this.minvalue == v) return;
+
+ // ensure no crossover
+ if (this.maxvalue < v) v = this.maxvalue;
+
+ // doing this before setting the attribute means we assume consistency
+ // on function entry and try to send events only when in a consistent state.
+ if (v > this.value) this.setAttribute("value", v);
+
+ this.minvalue = v;
+
+ if (this['onminvalue']) this.onminvalue.sendEvent();
+
+ this._adjustThumb();
+ }
]]></method>
<!--- Set the maximum value.
@@ -112,26 +123,32 @@
<method name="setMaxValue" args="v"><![CDATA[
v = v * 1;
- if (!isinited) {
+ if (isNaN(v)) {
+ if ($debug) {
+ Debug.warn("%w.%s must not be set to %s", this, "maxvalue", v);
+ }
+ v = 0;
+ }
+
+ if (!this._initcomplete) {
// bounds check and sendEvent are done in init() override in this case
this.maxvalue = v;
- return;
+ } else {
+ if (this.maxvalue == v) return;
+
+ // ensure no crossover
+ if (this.minvalue > v) v = this.minvalue;
+
+ // doing this before setting the attribute means we assume consistency
+ // on function entry and try to send events only when in a consistent state.
+ if (this.value > v) this.setAttribute("value", v);
+
+ this.maxvalue = v;
+
+ if (this['onmaxvalue']) this.onmaxvalue.sendEvent();
+
+ this._adjustThumb();
}
-
- if (this.maxvalue == v) return;
-
- // ensure no crossover
- if (this.minvalue > v) v = this.minvalue;
-
- // doing this before setting the attribute means we assume consistency
- // on function entry and try to send events only when in a consistent state.
- if (this.value > v) this.setAttribute("value",v);
-
- this.maxvalue = v;
-
- if (onmaxvalue) onmaxvalue.sendEvent();
-
- _adjustThumb();
]]></method>
<!--- Sets the value for the slider that must be within min and
@@ -141,74 +158,83 @@
<method name="setValue" args="v"><![CDATA[
v = v * 1;
- if (!isinited) {
- // bounds check and sendEvent are done in init() override in this case
- this.value = v;
- return;
+ if (isNaN(v)) {
+ if ($debug) {
+ Debug.warn("%w.%s must not be set to %s", this, "value", v);
+ }
+ v = 0;
}
- if (this.value == v) return;
-
- // ensure in bounds
- if (v < this.minvalue) v = this.minvalue;
- if (v > this.maxvalue) v = this.maxvalue;
-
- this.value = v;
-
- if (onvalue) onvalue.sendEvent(v);
-
- _adjustThumb();
+ if (!this._initcomplete) {
+ // bounds check and sendEvent are done in init() override in this case
+ this.value = v;
+ } else {
+ if (this.value == v) return;
+
+ // ensure in bounds
+ if (v < this.minvalue) v = this.minvalue;
+ if (v > this.maxvalue) v = this.maxvalue;
+
+ this.value = v;
+
+ if (this['onvalue']) this.onvalue.sendEvent(v);
+
+ this._adjustThumb();
+ }
]]></method>
<!--- Set the value by percentage of range from min to max.
@param Number p: a percentage between the min and
the max. -->
- <method name="setPercentage" args="p">
- v = v * 1;
- var diff = this.minvalue-this.maxvalue;
- setValue( diff*p + this.minvalue );
- </method>
+ <method name="setPercentage" args="p"><![CDATA[
+ var diff = this.minvalue - this.maxvalue;
+ this.setAttribute("value", diff * p + this.minvalue);
+ ]]></method>
<!--- Get the percentage of the range selected by the value.
@return Number: the percentage selected. -->
- <method name="getPercentage">
- if (this.maxvalue-this.minvalue == 0) {
- if ($debug) {
- Debug.error("%s.%s can not be computed, range is empty", this, arguments.callee);
- }
+ <method name="getPercentage"><![CDATA[
+ if ($debug) {
+ if (this.maxvalue - this.minvalue == 0) {
+ Debug.error("%s.%s can not be computed, range is empty", this, arguments.callee);
+ }
}
- return (this.value-this.minvalue) / (this.maxvalue-this.minvalue);
- </method>
+ return (this.value - this.minvalue) / (this.maxvalue - this.minvalue);
+ ]]></method>
<!--- adjusts the thumb location
@keywords private -->
- <method name="_adjustThumb">
- if (this.track) {
- this.track.thumb.setX(track.thumb._thumbFromValue());
- }
- </method>
+ <method name="_adjustThumb"><![CDATA[
+ var track = this.track;
+ if (track) {
+ var thumb = track.thumb;
+ thumb.setAttribute("x", thumb._thumbFromValue());
+ }
+ ]]></method>
<!--- @keywords private -->
- <handler name="onkeydown" args="k">
- //left arrow
- if (this.track) {
- if (k==37) {
- this.track.thumb.setX(this.track.thumb.x-keystep);
- } else if (k==39) {
- //right arrow
- this.track.thumb.setX(this.track.thumb.x+keystep);
- }
- }
- </handler>
+ <handler name="onkeydown" args="k"><![CDATA[
+ //left arrow
+ var track = this.track;
+ if (track) {
+ var thumb = track.thumb;
+ if (k == 37) {
+ thumb.setAttribute("x", thumb.x - this.keystep);
+ } else if (k == 39) {
+ //right arrow
+ thumb.setAttribute("x", thumb.x + this.keystep);
+ }
+ }
+ ]]></handler>
<!--- @keywords private -->
- <method name="getFocusRect">
- var fx = this.getAttributeRelative('x',canvas);
- var fy = this.getAttributeRelative('y',canvas) - 4;
- var fw = this.getAttributeRelative('width',canvas) + 2;
- var fh = this.getAttributeRelative('height',canvas) + 6;
- return [fx,fy,fw,fh];
- </method>
+ <method name="getFocusRect"><![CDATA[
+ var fx = this.getAttributeRelative('x', canvas);
+ var fy = this.getAttributeRelative('y', canvas) - 4;
+ var fw = this.getAttributeRelative('width', canvas) + 2;
+ var fh = this.getAttributeRelative('height', canvas) + 6;
+ return [fx, fy, fw, fh];
+ ]]></method>
<doc>
<tag name="shortdesc"><text>A non-visual base class for implementing sliders.</text></tag>
<text>
@@ -221,75 +247,89 @@
<!--- Baseslidertrack expects to be within a baseslider (or its
subclass). In other words, its "classroot" should be a slider. -->
- <class name="baseslidertrack" width="100%" height="${classroot.trackheight}" bgcolor="0x333333" >
- <handler name="oninit">
- classroot.track = this;
- </handler>
+ <class name="baseslidertrack" width="100%" height="${this.classroot.trackheight}" bgcolor="0x333333" >
+ <handler name="oninit"><![CDATA[
+ this.classroot.track = this;
+ ]]></handler>
</class>
<!--- Basesliderthumb expects to be within a baseslidertrack (or its
subclass). In other words, its "classroot" should be a slidertrack. -->
- <class name="basesliderthumb" extends="button" width="${parent.classroot.thumbwidth}" height="${parent.classroot.thumbheight}"
- onmousedown="thedragstate.apply();"
- onmouseup="thedragstate.remove();"
+ <class name="basesliderthumb" extends="button"
+ width="${this.parent.classroot.thumbwidth}"
+ height="${this.parent.classroot.thumbheight}"
+ onmousedown="this.thedragstate.apply();"
+ onmouseup="this.thedragstate.remove();"
focusable="false"
x="0"
- y="${(parent.height-height)/2}"
+ y="${(this.parent.height - this.height) / 2}"
>
<!--- Toggles the floating value text when dragging thumb. -->
- <attribute name="showvalue" value="${parent.parent.showvalue}"/>
+ <attribute name="showvalue" value="${this.parent.parent.showvalue}"/>
<!--- @keywords private -->
<dragstate name="thedragstate" drag_axis="x">
<text name="t"
resize="true"
- x="${classroot.width/2-width/2}"
+ x="${(this.classroot.width / 2) - (this.width / 2)}"
y="-14"
- text="${parent.parent.parent.value}"
- visible="${classroot.showvalue}"
- fgcolor="${classroot.style.textcolor}"
+ text="${this.parent.parent.parent.value}"
+ visible="${this.classroot.showvalue}"
+ fgcolor="${this.classroot.style.textcolor}"
/>
</dragstate>
<!--- compute thumb position from slider value
@keywords private -->
- <method name="_thumbFromValue">
- var slider = parent.parent;
- var delta = slider.maxvalue-slider.minvalue;
- var perc = (delta == 0) ? 0 : (slider.value-slider.minvalue) / delta;
- var pos = (slider.width - this.width) * perc;
- return pos;
- </method>
+ <method name="_thumbFromValue"><![CDATA[
+ var slider = this.parent.parent;
+ var delta = slider.maxvalue - slider.minvalue;
+ var perc = (delta == 0) ? 0 : (slider.value - slider.minvalue) / delta;
+ var pos = (slider.width - this.width) * perc;
+ return pos;
+ ]]></method>
<!--- compute slider value from thumb position
@keywords private -->
- <method name="_valueFromThumb">
- var slider = parent.parent;
+ <method name="_valueFromThumb"><![CDATA[
+ var slider = this.parent.parent;
var delta = slider.width - this.width;
- var perc = (delta == 0) ? 0 : ( (x) / (slider.width - this.width) );
- return Math.round( ((perc)*(slider.maxvalue-slider.minvalue))+slider.minvalue);
- </method>
+ var perc = (delta == 0) ? 0 : (this.x / (slider.width - this.width));
+ var val = Math.round((perc * (slider.maxvalue - slider.minvalue)) + slider.minvalue);
+ return val;
+ ]]></method>
<!--- constrain to parents bounds, and adjust slider value when dragged
@keywords private -->
- <method name="setX" args="x">
+ <method name="setX" args="x"><![CDATA[
var boundedx = x;
- if ( x > parent.width-width ) {
- var constrainX = parent.width-width;
- boundedx = constrainX;
- } else
- if (parent.x > x) {
- boundedx = parent.x;
+
+ var w = this.width;
+ var pwidth = this.parent.width;
+ if ( x > pwidth - w ) {
+ var constrainX = pwidth - w;
+ boundedx = constrainX;
+ } else {
+ var px = this.parent.x;
+ if (px > x) {
+ boundedx = px;
+ }
}
+
super.setX(boundedx);
//update slider value
- var thumbVal = _valueFromThumb();
- if (thumbVal != parent.parent.value) {
- parent.parent.setValue(thumbVal);
+ var slider = this.parent.parent;
+ if (slider.isinited) {
+ //set after slider is inited, see LPP-5710
+ var thumbVal = this._valueFromThumb();
+
+ if (thumbVal != slider.value) {
+ slider.setAttribute("value", thumbVal);
+ }
}
- </method>
+ ]]></method>
</class><!-- end basesliderthumb class -->
</library>
<!-- * X_LZ_COPYRIGHT_BEGIN ***************************************************
Modified: openlaszlo/trunk/lps/components/lz/basefloatinglist.lzx
===================================================================
--- openlaszlo/trunk/lps/components/lz/basefloatinglist.lzx 2008-04-16 15:57:15 UTC (rev 8708)
+++ openlaszlo/trunk/lps/components/lz/basefloatinglist.lzx 2008-04-16 16:01:29 UTC (rev 8709)
@@ -5,6 +5,8 @@
options="ignorelayout" x="-1000" y="-1000">
<!--- @keywords private -->
<attribute name="owner" />
+ <!--- @keywords private -->
+ <attribute name="wouldbename" value="" type="string" />
<!--- Where this floatinglist should attach to its owner. Possible
values: bottom, top, left, right. In the event of a canvas
@@ -353,7 +355,7 @@
</library>
<!-- * X_LZ_COPYRIGHT_BEGIN ***************************************************
-* Copyright 2001-2007 Laszlo Systems, Inc. All Rights Reserved. *
+* Copyright 2001-2008 Laszlo Systems, Inc. All Rights Reserved. *
* Use is subject to license terms. *
* X_LZ_COPYRIGHT_END ****************************************************** -->
<!-- @LZX_VERSION@ -->
Modified: openlaszlo/trunk/test/lzunit/testpaths.txt
===================================================================
--- openlaszlo/trunk/test/lzunit/testpaths.txt 2008-04-16 15:57:15 UTC (rev 8708)
+++ openlaszlo/trunk/test/lzunit/testpaths.txt 2008-04-16 16:01:29 UTC (rev 8709)
@@ -13,8 +13,8 @@
# test/lfc/lzunit-lzutils.lzx [BROKEN see LPP-4732 dectohex fails unit test lzunit-lzutils]
test/components/base/lzunit-basecomponent.lzx
test/components/base/lzunit-baseform.lzx
-# See LPP-5710 test/components/base/lzunit-baseslider.lzx
+test/components/base/lzunit-baseslider.lzx
test/components/base/lzunit-baselist.lzx
test/components/base/lzunit-basetabs.lzx
-# See LPP-5645 test/components/base/lzunit-basedatacombobox.lzx
+test/components/base/lzunit-basedatacombobox.lzx
test/components/lz/lzunit-components.lzx
More information about the Laszlo-checkins
mailing list