Permalink
Browse files

Merge branch 'master' into plugin-rename

Conflicts:
	README.md
	test/Grid_headerless.html
	test/Selection.html
	test/common_cases.html
	test/destroy.html
	test/rtl.html
	test/skin.html
	test/widths.html
  • Loading branch information...
2 parents 7d6d215 + c1d560a commit 1e1704a056dd706cdfb12b53f700da050bee0243 Kenneth G. Franqueiro committed Mar 15, 2012
View
@@ -10,12 +10,13 @@ some key differences:
* dgrid supports custom getters and setters, but they are named following the
pattern of `_getFoo` and `_setFoo`, unlike Dijit's `_getFooAttr` and `_setFooAttr`.
-* Most `set*` functions found throughout dgrid components are now implemented
- as custom setters, and should thus be accessed via the central `set` method.
- For example, `setQuery(...)` is now `set("query", ...)`. Deprecation stubs
- are currently in place for the old APIs, but will be removed in the future.
* `watch` is not implemented.
+Most `set*` functions found throughout dgrid components are now implemented
+as custom setters, and should thus be accessed via the central `set` method.
+For example, `setQuery(...)` is now `set("query", ...)`. Deprecation stubs
+are currently in place for the old APIs, but will be removed in the future.
+
### sortOrder property and sort function replaced by getter/setter
Previously, `sortOrder` was the (arguably internal) instance property used to
View
@@ -30,6 +30,9 @@ function(kernel, declare, listen, has, put, List){
cell: function(target, columnId){
// summary:
// Get the cell object by node, or event, id, plus a columnId
+
+ if(target.row && target.row instanceof this._Row){ return target; }
+
if(target.target && target.target.nodeType){
// event
target = target.target;
@@ -100,6 +103,7 @@ function(kernel, declare, listen, has, put, List){
for(si = 0, sl = subRows.length; si < sl; si++){
subRow = subRows[si];
// for single-subrow cases in modern browsers, TR can be skipped
+ // http://jsperf.com/table-without-trs
tr = (sl == 1 && !has("ie")) ? tbody : put(tbody, "tr");
for(i = 0, l = subRow.length; i < l; i++){
@@ -256,7 +260,7 @@ function(kernel, declare, listen, has, put, List){
// summary:
// Extension of List.js sort to update sort arrow in UI
- this.inherited(arguments); // normalize sortOrder first
+ this.inherited(arguments); // normalize _sort first
// clean up UI from any previous sort
if(this._lastSortedArrow){
View
@@ -174,7 +174,7 @@ return declare([List], {
cell = grid.row(cellFocusedElement);
}
if(move){
- cell = cell && grid[orientation](cell, move);
+ cell = cell && grid[orientation](cell, move, true);
}
var nextFocus = cell && cell.element;
if(nextFocus){
View
81 List.js
@@ -54,20 +54,24 @@ function(arrayUtil, kernel, declare, listen, aspect, has, miscUtil, TouchScroll,
return document.getElementById(id);
}
- function move(item, steps, targetClass){
+ function move(item, steps, targetClass, visible){
var nextSibling, current, element;
element = current = item.element;
steps = steps || 1;
do{
// move in the correct direction
- if((nextSibling = current[steps < 0 ? 'previousSibling' : 'nextSibling'])){
- current = nextSibling;
- if(((current && current.className) + ' ').indexOf(targetClass + ' ') > -1){
- // it's an element with the correct class name, counts as a real move
- element = current;
- steps += steps < 0 ? 1 : -1;
- }
- }else if((current = current.parentNode) == this.domNode){ // intentional assignment
+ if(nextSibling = current[steps < 0 ? 'previousSibling' : 'nextSibling']){
+ do{
+ current = nextSibling;
+ if(((current && current.className) + ' ').indexOf(targetClass + ' ') > -1){
+ // it's an element with the correct class name, counts as a real move
+ element = current;
+ steps += steps < 0 ? 1 : -1;
+ break;
+ }
+ // if the next sibling isn't a match, drill down to search
+ }while(nextSibling = (!visible || !current.hidden) && current[steps < 0 ? 'lastChild' : 'firstChild']);
+ }else if((current = current.parentNode) == this.domNode || (current.className + ' ').indexOf("dgrid-row ") > -1){ // intentional assignment
// we stepped all the way out of the grid, given up now
break;
}
@@ -146,18 +150,26 @@ function(arrayUtil, kernel, declare, listen, aspect, has, miscUtil, TouchScroll,
if(params){
this.params = params;
declare.safeMixin(this, params);
+
+ // handle sort param - TODO: revise @ 1.0 when _sort -> sort
+ this._sort = params.sort || [];
+ delete this.sort; // ensure back-compat method isn't shadowed
+ }else{
+ this._sort = [];
}
- this.domNode = srcNodeRef || put("div");
+ var domNode = this.domNode = srcNodeRef || put("div");
// ensure arrays and hashes are initialized
this.observers = [];
this._listeners = [];
this._rowIdToObject = {};
- // handle sort param - TODO: revise @ 1.0 when _sort -> sort
- this._sort = params.sort || [];
- delete this.sort; // ensure back-compat method isn't shadowed
this.postMixInProperties && this.postMixInProperties();
+
+ // Apply id to widget and domNode,
+ // from incoming node, widget params, or autogenerated.
+ this.id = domNode.id = domNode.id || this.id || generateId();
+
this.buildRendering();
this.postCreate && this.postCreate();
@@ -177,10 +189,6 @@ function(arrayUtil, kernel, declare, listen, aspect, has, miscUtil, TouchScroll,
isRTL = this.isRTL = (document.body.dir || document.documentElement.dir ||
document.body.style.direction).toLowerCase() == "rtl";
- // Apply id to widget and domNode,
- // from incoming node, widget params, or autogenerated.
- this.id = domNode.id = domNode.id || this.id || generateId();
-
put(domNode, "[role=grid].ui-widget.dgrid.dgrid-" + this.listType);
headerNode = this.headerNode = put(domNode,
"div.dgrid-header.dgrid-header-row.ui-widget-header" +
@@ -474,6 +482,9 @@ function(arrayUtil, kernel, declare, listen, aspect, has, miscUtil, TouchScroll,
// summary:
// Get the row object by id, object, node, or event
var id;
+
+ if(target instanceof this._Row){ return target; } // no-op; already a row
+
if(target.target && target.target.nodeType){
// event
target = target.target;
@@ -506,11 +517,11 @@ function(arrayUtil, kernel, declare, listen, aspect, has, miscUtil, TouchScroll,
};
},
_move: move,
- up: function(row, steps){
- return this.row(move(row, -(steps || 1), "dgrid-row"));
+ up: function(row, steps, visible){
+ return this.row(move(row, -(steps || 1), "dgrid-row", visible));
},
- down: function(row, steps){
- return this.row(move(row, steps || 1, "dgrid-row"));
+ down: function(row, steps, visible){
+ return this.row(move(row, steps || 1, "dgrid-row", visible));
},
get: function(/*String*/ name /*, ... */){
@@ -599,20 +610,22 @@ function(arrayUtil, kernel, declare, listen, aspect, has, miscUtil, TouchScroll,
this.refresh();
if(this._lastCollection){
- // if an array was passed in, flatten to just first sort attribute
- // for default array sort logic
- if(typeof property != "string"){
- descending = property[0].descending;
- property = property[0].attribute;
+ if(property.length){
+ // if an array was passed in, flatten to just first sort attribute
+ // for default array sort logic
+ if(typeof property != "string"){
+ descending = property[0].descending;
+ property = property[0].attribute;
+ }
+
+ this._lastCollection.sort(function(a,b){
+ var aVal = a[property], bVal = b[property];
+ // fall back undefined values to "" for more consistent behavior
+ if(aVal === undefined){ aVal = ""; }
+ if(bVal === undefined){ bVal = ""; }
+ return aVal == bVal ? 0 : (aVal > bVal == !descending ? 1 : -1);
+ });
}
-
- this._lastCollection.sort(function(a,b){
- var aVal = a[property], bVal = b[property];
- // fall back undefined values to "" for more consistent behavior
- if(aVal === undefined){ aVal = ""; }
- if(bVal === undefined){ bVal = ""; }
- return aVal == bVal ? 0 : (aVal > bVal == !descending ? 1 : -1);
- });
this.renderArray(this._lastCollection);
}
},
Oops, something went wrong.

0 comments on commit 1e1704a

Please sign in to comment.