diff --git a/ui (gen4)/features/base.js b/ui (gen4)/features/base.js index a1919031..c566682a 100755 --- a/ui (gen4)/features/base.js +++ b/ui (gen4)/features/base.js @@ -79,6 +79,8 @@ actions.Actions({ 'last', // select last image ], 'ribbon-focus-mode': 'order', + + 'defeault-sort': 'birthtime ctime', }, @@ -512,15 +514,90 @@ actions.Actions({ // XXX align to ribbon... + // Custom sort modes... + // + // Format: + // { + // : function(a, b){ ... }, + // ... + // } + // + // NOTE: the cmp function is called in the actions context. + __sort_modes__: { + }, // XXX this also requires images... // XXX cache order??? - sortImages: ['Sort/', - function(method){ - if(this.images){ - // select method... - this.data.order = this.images.sortImages().reverse() + sortImages: ['- Edit|Sort/Sort images', + function(method, reverse){ + var that = this + + if(method == 'reverse'){ + method = null + reverse = true + } + + reverse = reverse == null + || reverse == 'reverse' + || reverse + + method = method + || this.config['defeault-sort'] + || 'birthtime' + // handle multiple methods.... + method = typeof(method) == typeof('str') ? method.split(/ +/g) : method + method = method instanceof Array ? method : [method] + method = method.map(function(m){ + return BaseActions.__sort_modes__[m] + || (that.__sort_modes__ && that.__sort_modes__[m]) + // sort by attr path... + || (function(){ + var p = m.split(/\./g) + var _get = function(obj){ + for(var i=0; i