datatable-sort-min.js revision 8947d1099a91880ec4e5be929041b1cebb9a3a55
YUI.add("datatable-sort",function(G){var A=G.ArraySort.compare,C="asc",B="desc",H=G.ClassNameManager.getClassName("datatable","sortable"),E='<a class="{link_class}" title="{link_title}" href="{link_href}">{value}</a>';function F(I,J,K){F.superclass.constructor.apply(this,arguments);}G.mix(F,{NS:"sort",NAME:"recordsetSort",ATTRS:{dt:{},defaultSorter:{value:function(K,I,L,M){var J=A(K.getValue(L),I.getValue(L),M);if(J===0){return A(K.get("id"),I.get("id"),M);}else{return J;}}}}});G.extend(F,G.Plugin.Base,{initializer:function(I){this.addTarget(this.get("dt"));this.publish("sort",{defaultFn:G.bind("_defSortFn",this)});},destructor:function(I){},_defSortFn:function(I){this.get("host").get("records").sort(function(K,J){return(I.sorter)(K,J,I.field,I.desc);});},sort:function(I,J,K){this.fire("sort",{field:I,desc:J,sorter:K||this.get("defaultSorter")});},custom:function(){alert("sort custom");},asc:function(){alert("sort asc");},desc:function(){alert("sort desc");},reverse:function(){alert("sort reverse");}});G.namespace("Plugin").RecordsetSort=F;function D(){D.superclass.constructor.apply(this,arguments);}G.mix(D,{NS:"sort",NAME:"dataTableSort",ATTRS:{sortedBy:{value:null}}});G.extend(D,G.Plugin.Base,{thLinkTemplate:E,initializer:function(I){var J=this.get("host");J.get("recordset").plug(F,{dt:J});this.doBefore("_getTheadThMarkup",this._beforeGetTheadThMarkup);J.on("addTheadTh",function(K){K.th.addClass(H);});J.on("theadCellClick",this._onEventSortColumn);J.after("recordsetSort:sort",function(){J._uiSetRecordset(J.get("recordset"));});J.after("sortedByChangeEvent",function(){alert("ok");});if(J.get("rendered")){J._uiSetColumnset(J.get("columnset"));}},_beforeGetTheadThMarkup:function(J,I){if(I.get("sortable")){J.value=G.substitute(this.thLinkTemplate,{link_class:"foo",link_title:"bar",link_href:"bat",value:J.value});}},_onEventSortColumn:function(M){M.halt();var K=this.get("columnset").get("hash")[M.currentTarget.get("id")],L=K.get("field"),J=this.get("sortedBy"),I=(J&&J.field===L&&J.dir===C)?B:C,N=K.get("sortFn");if(K.get("sortable")){this.get("recordset").sort.sort(L,I===B,N);this.set("sortedBy",{field:L,dir:I});}}});G.namespace("Plugin").DataTableSort=D;},"@VERSION@",{lang:["en"],requires:["plugin","datatable-base"]});