]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - include/javascript/yui3/build/recordset/recordset-sort-min.js
Release 6.5.0
[Github/sugarcrm.git] / include / javascript / yui3 / build / recordset / recordset-sort-min.js
1 /*
2 Copyright (c) 2010, Yahoo! Inc. All rights reserved.
3 Code licensed under the BSD License:
4 http://developer.yahoo.com/yui/license.html
5 version: 3.3.0
6 build: 3167
7 */
8 YUI.add("recordset-sort",function(D){var A=D.ArraySort.compare,C=D.Lang.isValue;function B(E,F,G){B.superclass.constructor.apply(this,arguments);}D.mix(B,{NS:"sort",NAME:"recordsetSort",ATTRS:{lastSortProperties:{value:{field:undefined,desc:true,sorter:undefined},validator:function(E){return(C(E.field)&&C(E.desc)&&C(E.sorter));}},defaultSorter:{value:function(G,E,H,I){var F=A(G.getValue(H),E.getValue(H),I);if(F===0){return A(G.get("id"),E.get("id"),I);}else{return F;}}},isSorted:{value:false}}});D.extend(B,D.Plugin.Base,{initializer:function(F){var E=this,G=this.get("host");this.publish("sort",{defaultFn:D.bind("_defSortFn",this)});this.on("sort",function(){E.set("isSorted",true);});this.onHostEvent("add",function(){E.set("isSorted",false);},G);this.onHostEvent("update",function(){E.set("isSorted",false);},G);},destructor:function(E){},_defSortFn:function(E){this.get("host")._items.sort(function(G,F){return(E.sorter)(G,F,E.field,E.desc);});this.set("lastSortProperties",E);},sort:function(E,F,G){this.fire("sort",{field:E,desc:F,sorter:G||this.get("defaultSorter")});},resort:function(){var E=this.get("lastSortProperties");this.fire("sort",{field:E.field,desc:E.desc,sorter:E.sorter||this.get("defaultSorter")});},reverse:function(){this.get("host")._items.reverse();},flip:function(){var E=this.get("lastSortProperties");if(C(E.field)){this.fire("sort",{field:E.field,desc:!E.desc,sorter:E.sorter||this.get("defaultSorter")});}else{}}});D.namespace("Plugin").RecordsetSort=B;},"3.3.0",{requires:["arraysort","recordset-base","plugin"]});