1
2
3
4
5
6
7
8
|
/*
YUI 3.17.2 (build 9c3c78e)
Copyright 2014 Yahoo! Inc. All rights reserved.
Licensed under the BSD License.
http://yuilibrary.com/license/
*/
YUI.add("tree-sortable",function(e,t){function r(){}function i(){}var n="sort";r.prototype={sortReverse:!1,initializer:function(t){this.nodeExtensions=this.nodeExtensions.concat(e.Tree.Node.Sortable),t&&(t.sortComparator&&(this.sortComparator=t.sortComparator),"sortReverse"in t&&(this.sortReverse=t.sortReverse))},sort:function(t){return this.sortNode(this.rootNode,e.merge(t,{deep:!0}))},sortComparator:function(e){return e.index()},sortNode:function(t,r){if(!t.children.length)return this;r||(r={});if(r.deep){r=e.merge(r,{deep:!1});var i=this;return this.traverseNode(t,function(e){i.sortNode(e,r)}),this}var s=this._getSortComparator(t,r),o;return"sortReverse"in r?o=t.sortReverse=r.sortReverse:"sortReverse"in t?o=t.sortReverse:o=this.sortReverse,t.children.sort(e.rbind(this._sort,this,s,o)),t._isIndexStale=!0,r.silent||this.fire(n,{node:t,reverse:!!o,src:r.src}),this},_compare:function(e,t){return e<t?-1:e>t?1:0},_compareReverse:function(e,t){return t<e?-1:t>e?1:0},_getDefaultNodeIndex:function(e,t){var n=e.children,i=this._getSortComparator(e),s=n.length,o=0,u="sortReverse"in e?e.sortReverse:this.sortReverse;if(!s)return s;if(i._unboundComparator===r.prototype.sortComparator)return u?0:s;var a=u?this._compareReverse:this._compare,f=i(t),l;while(o<s)l=o+s>>1,a(i(n[l]),f)<0?o=l+1:s=l;return o},_getSortComparator:function(e,t){var n,r,i;return t&&t.sortComparator?r=e.sortComparator=t.sortComparator:e.sortComparator?(r=e.sortComparator,i=e):(r=this.sortComparator,i=this),n=function(){return r.apply(i,arguments)},n._unboundComparator=r,n},_sort:function(e,t,n,r){return this[r?"_compareReverse":"_compare"](n(e),n(t))}},e.Tree.Sortable=r,i.prototype={sort:function(e){return this.tree.sortNode(this,e),this}},e.Tree.Node.Sortable=i},"3.17.2",{requires:["tree"]});
|