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 2007/04/27 20:01:01 UTC
svn commit: r533202 - in /incubator/xap/trunk/codebase: css/
src/xap/bridges/dojo/ src/xap/widgets/dojo/ src/xap/widgets/dojo/images/
Author: mturyn
Date: Fri Apr 27 13:00:59 2007
New Revision: 533202
URL: http://svn.apache.org/viewvc?view=rev&rev=533202
Log:
Added header alignment, as well as settable placement of sorting indicator.
To do this, changed the way headers are made so that they're just standard
standard buttons that handle their own settable images (up/down/none), rather
than buttons with subnodes altered by the table..
Also:
1.) Fixed bug that was throwing an error under IE.
2.) Worked around bug that was changing the table size on first sort (post a resize)---just
block resizing immediately post the sort.
3.) Made reversed sorting more efficient by using (essentially) a NOT'd sort
function insteadof running the sorter and then reversing the rows.
Added:
incubator/xap/trunk/codebase/src/xap/widgets/dojo/images/
incubator/xap/trunk/codebase/src/xap/widgets/dojo/images/arrow_down.gif (with props)
incubator/xap/trunk/codebase/src/xap/widgets/dojo/images/arrow_up.gif (with props)
incubator/xap/trunk/codebase/src/xap/widgets/dojo/images/spaced.gif (with props)
Removed:
incubator/xap/trunk/codebase/css/arrow_down.gif
incubator/xap/trunk/codebase/css/arrow_up.gif
incubator/xap/trunk/codebase/css/spaced.gif
Modified:
incubator/xap/trunk/codebase/css/xapDefault.css
incubator/xap/trunk/codebase/src/xap/bridges/dojo/ColumnBridge.js
incubator/xap/trunk/codebase/src/xap/widgets/dojo/TreeTable.js
Modified: incubator/xap/trunk/codebase/css/xapDefault.css
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/css/xapDefault.css?view=diff&rev=533202&r1=533201&r2=533202
==============================================================================
--- incubator/xap/trunk/codebase/css/xapDefault.css (original)
+++ incubator/xap/trunk/codebase/css/xapDefault.css Fri Apr 27 13:00:59 2007
@@ -290,6 +290,9 @@
/* TABLE SORT ARROWS */
+/* Deprecated way of showing asc/desc sorting
+ or its lack...but we might need to go back
+ it:
.xapSortAscendingImage{
background-image: url(arrow_up.gif);
background-repeat: no-repeat;
@@ -307,6 +310,8 @@
.xapSortNoneImage{
padding: 8px;
}
+*/
+
/* TREETABLE */
Modified: incubator/xap/trunk/codebase/src/xap/bridges/dojo/ColumnBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/xap/bridges/dojo/ColumnBridge.js?view=diff&rev=533202&r1=533201&r2=533202
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/bridges/dojo/ColumnBridge.js (original)
+++ incubator/xap/trunk/codebase/src/xap/bridges/dojo/ColumnBridge.js Fri Apr 27 13:00:59 2007
@@ -68,7 +68,10 @@
xap.bridges.dojo.ColumnBridge.prototype.addChild = function(childHandler, index){
- this.getPeer().setHeader(childHandler.getPeer());
+ var peer = childHandler.getPeer() ;
+ peer._horizontalAlignment = childHandler.getElement().getAttribute("horizontalAlignment") ;
+ peer._horizontalTextToImagePlacement = childHandler.getElement().getAttribute("horizontalTextToImagePlacement") ;
+ this.getPeer().setHeader(peer);
}
/**
@@ -81,6 +84,9 @@
if( peer ){
peer._explicitColumnWidth = this.getElement().getAttribute("width") ;
peer._horizontalAlignment = this.getElement().getAttribute("horizontalAlignment") ;
+ if(peer.header && peer._horizontalAlignment){
+ peer.header.setHorizontalAlignment(peer._horizontalAlignment) ;
+ }
}
}
Modified: incubator/xap/trunk/codebase/src/xap/widgets/dojo/TreeTable.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/xap/widgets/dojo/TreeTable.js?view=diff&rev=533202&r1=533201&r2=533202
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/widgets/dojo/TreeTable.js (original)
+++ incubator/xap/trunk/codebase/src/xap/widgets/dojo/TreeTable.js Fri Apr 27 13:00:59 2007
@@ -97,8 +97,6 @@
postCreate: function(){
xap.widgets.dojo.TreeTable.superclass.postCreate.apply(this,arguments) ;
this._created = true ;
-window.foo = this;
-window.goo = this.columnsSizer ;
},
/**
@@ -354,7 +352,13 @@
this._rebuildRowsTask = null;
// resize columns in the case of new rows added
- this._resizeTable ();
+ // ---absolutely avoid this if we've just sorted.
+
+ if(this._justSorted ){
+ delete this._justSorted ;
+ } else {
+ this._resizeTable();
+ }
this._recolorAlternateRows();
},
@@ -403,7 +407,6 @@
this.headerBody.appendChild(this.headerRow);
for (var i = 0; i<this._columns.length; i++){
var cell = document.createElement("td");
-//debugging aid dojo.html.addClass(cell,'col_cell');
dojo.html.addClass(cell,'xapHeaderWrapper');
cell.style.whiteSpace = "nowrap";
@@ -417,18 +420,32 @@
if(hasColumns){
if(w=this._columns[i].getBestWidth()){
cell.style.width = w ;
- } else {
- cell.style
- }
- }
- this.headerRow.appendChild(cell);
+ }
+ }
+
- if (this._columns[i]._header && this._columns[i]._header._rootDomNode){
- var subnode = this._columns[i]._header._rootDomNode ;
- subnode.style.overflow = "hidden" ;
- cell.appendChild(subnode);
+ this.headerRow.appendChild(cell);
+
+
+ var header = null ;
+ if (header = this._columns[i]._header){
+
+ var hAlign = this._columns[i]._horizontalAlignment ;
+ if( !hAlign ){
+ // Default alignment:
+ hAlign = "left" ;
+ }
+ // This is another of our widgets, a Button
+ // instance:
+ header.setAlignHorizontal(hAlign) ;
+ if(header._rootDomNode){
+ var subnode= header._rootDomNode ;
+ subnode.style.overflow = "hidden" ;
+ cell.appendChild(subnode);
+ }
}
cell.style.visibility = this._headerVisibility;
+
}
if (this._headerVisibility=='hidden'){
@@ -777,10 +794,10 @@
//blank out the sort icon on the column we previously sorted
if (this._lastSortedColumn && (this._lastSortedColumn != column)){
- var oldHint = this._lastSortedColumn ._header.getImgHint();
- dojo.html.removeClass(oldHint,'xapSortDescendingImage');
- dojo.html.removeClass(oldHint,'xapSortAscendingImage');
- dojo.html.addClass(oldHint,'xapSortNoneImage');
+ this._lastSortedColumn.setSortNone() ;
+ // Block resizing the table
+ // as a result of this sort:
+ this._justSorted = true ;
}
var dataType = column._dataType || "string";
@@ -810,21 +827,31 @@
}
- //sort the array and change _rows to match
- this._rows.sort(sortFunction);
+ var bSortAscending = !column._sort || column._sort=='descending' ;
+ //sort the array and change _rows to match
+ this._rows.sort( bSortAscending?
+ sortFunction
+ :function(a,b){ return sortFunction.call(this,b,a) ; }
+ );
- var headerHint = column._header.getImgHint();
if (!column._sort || column._sort=='descending'){
- column._sort = "ascending";
- dojo.html.removeClass(headerHint,'xapSortDescendingImage');
- dojo.html.addClass(headerHint,'xapSortAscendingImage');
+ column.setSortAsc();
+ // Block resizing the table
+ // as a result of this sort:
+ this._justSorted = true ;
}
else{
- column._sort = "descending";
- dojo.html.removeClass(headerHint,'xapSortAscendingImage');
- dojo.html.addClass(headerHint,'xapSortDescendingImage');
- this._rows.reverse();
+ column.setSortDesc() ;
+ // This was a simple way
+ // of doing it, but a bit bogus:
+ // this._rows.reverse();
+ // altered the sort
+
+ // Block resizing the table
+ // as a result of this sort:
+ this._justSorted = true ;
+
}
// before we do anything set the widths of what will become the new first row of cells
@@ -1163,31 +1190,84 @@
isContainer: true,
_horizontalAlignment: "left",
-
+ ascImageUri:dojo.uri.moduleUri("xap","widgets/dojo/images/arrow_up.gif"),
+ descImageUri:dojo.uri.moduleUri("xap","widgets/dojo/images/arrow_down.gif"),
+ noneImageUri:dojo.uri.moduleUri("xap","widgets/dojo/images/spaced.gif"),
+
//we need this because setting the template string to
//<col></col> doesn't work for whatever reason,
//oversight in dojo code
fillInTemplate: function(args, frag){
this.domNode = document.createElement("col");
},
+
+ setSortNone: function( aXapLabel ){
+ var xapLabel = aXapLabel || this._header ;
+// var oldHint = xapLabel.getImgHint();
+// dojo.html.removeClass(oldHint,'xapSortDescendingImage');
+// dojo.html.removeClass(oldHint,'xapSortAscendingImage');
+// dojo.html.addClass(oldHint,'xapSortNoneImage');
+ xapLabel.setImg(this.noneImageUri);
+ delete this._sort ;
+ },
+
+ setSortDesc: function( aXapLabel ){
+ var xapLabel = aXapLabel || this._header ;
+// var oldHint = xapLabel.getImgHint();
+// dojo.html.removeClass(oldHint,'xapSortNoneImage');
+// dojo.html.removeClass(oldHint,'xapSortAscendingImage');
+// dojo.html.addClass(oldHint,'xapSortDescendingImage');
+ xapLabel.setImg(this.descImageUri);
+ this._sort = "descending" ;
+ },
+
+ setSortAsc: function( aXapLabel ){
+ var xapLabel = aXapLabel || this._header ;
+// var oldHint = xapLabel.getImgHint();
+// dojo.html.removeClass(oldHint,'xapSortNoneImage');
+// dojo.html.removeClass(oldHint,'xapSortDescendingImage');
+// dojo.html.addClass(oldHint,'xapSortAscendingImage');
+ xapLabel.setImg(this.ascImageUri);
+ this._sort = "ascending" ;
+ },
+
setHeader: function( xapLabel ){
this._header = xapLabel;
- dojo.html.addClass(xapLabel.getImgHint(),'xapSortNoneImage');
- dojo.event.connect(xapLabel._rootDomNode, "onclick", this, "onClickCallback");
+ this.setSortNone();
+
+ // Default for headers is image to the right of the
+ // text, opposite sense as for buttons:
+
+ var hTextToImageAlignment
+ = xapLabel._horizontalTextToImagePlacement || "left" ;
+ xapLabel.setTextPlacementHorizontal(hTextToImageAlignment) ;
+
+ xapLabel._showImg();
+// dojo.event.connect(xapLabel._rootDomNode, "onclick", this, "onClickCallback");
+ dojo.event.connect(xapLabel,"_styleMousedown",this,"onMouseDownCallback") ;
+
// if there's an explicitly-set width in the header
// then save it, else stick with any we might have got from XAL:
if ( xapLabel._rootDomNode.style.width ){
this._headerWidth = xapLabel._rootDomNode.style.width;
}
+ // if no h-align stated, use column's if exists,
+ // else default to "left":
+ var hAlign = xapLabel._horizontalAlignment
+ || this._horizontalAlignment
+ || "left" ;
+
+ dojo.lang.setTimeout(xapLabel,xapLabel.setAlignHorizontal,0,hAlign);
+
},
setTable: function(table){
this._table = table;
},
- onClickCallback : function(){
+ onMouseDownCallback : function(){
if (this._table){
this._table.sortColumn(this);
}
@@ -1277,7 +1357,7 @@
td.style.whiteSpace = "nowrap";
td.style.overflow = "hidden";
- var hAlignment ="left";
+ var hAlignment = null ;
if ( cell.style.textAlign ) {
hAlignment = cell.style.textAlign;
//td.appendChild(document.createTextNode(hAlignment.toUpperCase().substring(0,1))) ;
@@ -1288,10 +1368,11 @@
//td.appendChild(document.createTextNode(hAlignment.toUpperCase().substring(0,1))) ;
}
}
- td.align = hAlignment ;
+
+ if( hAlignment ){
+ td.align = hAlignment ;
+ }
-// td.appendChild(document.createTextNode("1:"+hAlignment.substring(0,1))) ;
-
td.valign = "top";
Added: incubator/xap/trunk/codebase/src/xap/widgets/dojo/images/arrow_down.gif
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/xap/widgets/dojo/images/arrow_down.gif?view=auto&rev=533202
==============================================================================
Binary file - no diff available.
Propchange: incubator/xap/trunk/codebase/src/xap/widgets/dojo/images/arrow_down.gif
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/xap/trunk/codebase/src/xap/widgets/dojo/images/arrow_up.gif
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/xap/widgets/dojo/images/arrow_up.gif?view=auto&rev=533202
==============================================================================
Binary file - no diff available.
Propchange: incubator/xap/trunk/codebase/src/xap/widgets/dojo/images/arrow_up.gif
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/xap/trunk/codebase/src/xap/widgets/dojo/images/spaced.gif
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/xap/widgets/dojo/images/spaced.gif?view=auto&rev=533202
==============================================================================
Binary file - no diff available.
Propchange: incubator/xap/trunk/codebase/src/xap/widgets/dojo/images/spaced.gif
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream