datatable-sort.js revision 03dbde2a7e9a9085567853a25059a0bc411069a8
//TODO: break out into own component
Y.Sort = {
/**
* Comparator function for simple case-insensitive string sorting.
*
* @method compare
* @param a {Object} First sort argument.
* @param b {Object} Second sort argument.
* @param desc {Boolean} True if sort direction is descending, false if
* sort direction is ascending.
* @return {Boolean} Return -1 when a < b. Return 0 when a = b.
* Return 1 when a > b.
*/
if((a === null) || (typeof a == "undefined")) {
if((b === null) || (typeof b == "undefined")) {
return 0;
}
else {
return 1;
}
}
else if((b === null) || (typeof b == "undefined")) {
return -1;
}
if(a.constructor == String) {
a = a.toLowerCase();
}
if(b.constructor == String) {
b = b.toLowerCase();
}
if(a < b) {
}
else if (a > b) {
}
else {
return 0;
}
}
};
var //getClassName = Y.ClassNameManager.getClassName,
//DATATABLE = "datatable",
ASC = "asc",
DESC = "desc",
//CLASS_ASC = getClassName(DATATABLE, "asc"),
//CLASS_DESC = getClassName(DATATABLE, "desc"),
//CLASS_SORTABLE = getClassName(DATATABLE, "sortable"),
TEMPLATE_TH_LINK = '<a class="{link_class}" title="{link_title}" href="{link_href}">{value}</a>';
}
Y.mix(RecordsetSort, {
NS: "sort",
NAME: "recordsetSort",
ATTRS: {
dt: {
},
if(sorted === 0) {
}
else {
return sorted;
}
}
}
}
});
initializer: function(config) {
},
destructor: function(config) {
},
_defSortFn: function(e) {
},
},
custom: function() {
alert("sort custom");
},
// force asc
asc: function() {
alert("sort asc");
},
// force desc
desc: function() {
alert("sort desc");
},
// force reverse
reverse: function() {
alert("sort reverse");
}
});
function DataTableSort() {
}
Y.mix(DataTableSort, {
NS: "sort",
NAME: "dataTableSort",
ATTRS: {
sortedBy: {
value: null
}
}
});
initializer: function(config) {
//this.doBefore("_getThNodeMarkup", this._beforeGetThNodeMarkup);
// Attach click handlers
// Attach UI hooks
});
alert('ok');
});
//TODO
//dt.after("recordset:mutation", function() {//reset sortedBy});
//TODO
//add Column sortFn ATTR
},
/*_beforeGetThNodeMarkup: function(o, column) {
if(column.get("sortable")) {
o.link_class = "foo";
o.link_title = "bar";
o.link_href = "bat";
o.value = Y.substitute(this.thLinkTemplate, o);
}
},*/
_onEventSortColumn: function(e) {
e.halt();
dir = (prevSortedBy &&
}
});