diff --git a/ui (gen4)/features/base.js b/ui (gen4)/features/base.js index 678ba2ee..bff6ce50 100755 --- a/ui (gen4)/features/base.js +++ b/ui (gen4)/features/base.js @@ -624,12 +624,20 @@ module.SortActions = actions.Actions({ // // Sort using a specific method(s): // .sortImages() + // .sortImages(, ) + // + // .sortImages(' ..') + // .sortImages(' ..', ) + // // .sortImages([, ..]) + // .sortImages([, ..], ) // NOTE: can either be one of: // 1) method name (key) from .config['sort-methods'] // 2) a space separated string of methods or attribute paths // as in .config['sort-methods']'s values. // for more info se doc for: .config['sort-methods'] + // NOTE: if it is needed to reverse the method by default just + // add 'reverse' to it's string. // // Update current sort order: // .sortImages('update') @@ -638,6 +646,9 @@ module.SortActions = actions.Actions({ // NOTE: this is designed to facilitate manual sorting of // .data.order // + // Reverse image order: + // .sortImages('reverse') + // // // NOTE: reverse is calculated by oddity -- if an odd number indicated // then the result is reversed, otherwise it is not. @@ -654,7 +665,7 @@ module.SortActions = actions.Actions({ var that = this if(method == 'reverse'){ - method = null + method = [] reverse = true } @@ -662,54 +673,68 @@ module.SortActions = actions.Actions({ : reverse == 'reverse' || reverse + // special case: 'update' method = method == 'update' ? [] : method + + // defaults... method = method || this.config['sort-methods'][this.config['default-sort']] || this.config['default-sort'] || 'birthtime' - method = this.config['sort-methods'][method] || method - // handle multiple methods.... + + // expand method names... + // XXX should this be recursive??? + method = typeof(method) == typeof('str') ? + method + .split(/ +/g) + .map(function(m){ + return that.config['sort-methods'][m] || m }) + .join(' ') + : method method = typeof(method) == typeof('str') ? method.split(/ +/g) : method method = method instanceof Array ? method : [method] - // get the reverse... + // get the reverse arity... var i = method.indexOf('reverse') while(i >=0){ reverse = !reverse - method.splice(i, 1) + method.splice(i, 1) i = method.indexOf('reverse') } // build the compare routine... - method = method.map(function(m){ - return SortActions.__sort_methods__[m] - || (that.__sort_methods__ && that.__sort_methods__[m]) - // sort by attr path... - || (function(){ - var p = m.split(/\./g) - var _get = function(obj){ - for(var i=0; i