mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-28 18:00:09 +00:00
some minor fixes, docs and cleanup...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
de55a50e12
commit
121d9d7e8c
@ -624,12 +624,20 @@ module.SortActions = actions.Actions({
|
||||
//
|
||||
// Sort using a specific method(s):
|
||||
// .sortImages(<method>)
|
||||
// .sortImages(<method>, <reverse>)
|
||||
//
|
||||
// .sortImages('<method> ..')
|
||||
// .sortImages('<method> ..', <reverse>)
|
||||
//
|
||||
// .sortImages([<method>, ..])
|
||||
// .sortImages([<method>, ..], <reverse>)
|
||||
// NOTE: <method> 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,27 +673,41 @@ 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){
|
||||
method = method
|
||||
// remove duplicate methods...
|
||||
.unique()
|
||||
.map(function(m){
|
||||
return SortActions.__sort_methods__[m]
|
||||
|| (that.__sort_methods__ && that.__sort_methods__[m])
|
||||
// sort by attr path...
|
||||
@ -732,6 +757,10 @@ module.SortActions = actions.Actions({
|
||||
reverse ?
|
||||
this.data.order.sort(cmp.bind(this)).reverse()
|
||||
: this.data.order.sort(cmp.bind(this))
|
||||
|
||||
// just reverse...
|
||||
} else if(method.length <= 0 && reverse) {
|
||||
this.data.order.reverse()
|
||||
}
|
||||
|
||||
this.data.updateImagePositions()
|
||||
@ -740,7 +769,7 @@ module.SortActions = actions.Actions({
|
||||
// XXX should this be a dialog with ability to edit modes???
|
||||
// - toggle reverse sort
|
||||
// XXX currently this will not toggle past 'none'
|
||||
toggleImageSort: ['Edit|Sort/Sort images by',
|
||||
toggleImageSort: ['Edit|Sort/Toggle image sort method',
|
||||
toggler.Toggler(null,
|
||||
function(){ return this.data.sort_method || 'none' },
|
||||
function(){
|
||||
@ -763,7 +792,7 @@ module.SortActions = actions.Actions({
|
||||
this.sortImages('update')
|
||||
|
||||
} else {
|
||||
this.sortImages(this.config['sort-methods'][mode])
|
||||
this.sortImages(mode)
|
||||
}
|
||||
|
||||
this.data.sort_method = mode
|
||||
|
||||
@ -263,7 +263,8 @@ module.GLOBAL_KEYBOARD = {
|
||||
O: 'browsePath',
|
||||
S: {
|
||||
default: 'slideshowDialog',
|
||||
shift: 'sortImages: "birthtime ctime" -- Sort images by date',
|
||||
//shift: 'sortImages: "Date" -- Sort images by date',
|
||||
shift: 'sortImages -- Sort images',
|
||||
alt: 'browseActions: "/Sort/"',
|
||||
// XXX need to make this save to base_path if it exists and
|
||||
// ask the user if it does not... now it always asks.
|
||||
|
||||
@ -564,32 +564,6 @@ module.ImagesPrototype = {
|
||||
return gids
|
||||
},
|
||||
// Shorthands...
|
||||
// XXX default gids may include stray attributes...
|
||||
sortByDate: function(gids, reverse){
|
||||
gids = gids == null ? Object.keys(this) : gids
|
||||
return this.sortImages(gids, null, reverse)
|
||||
},
|
||||
sortByName: function(gids, reverse){
|
||||
gids = gids == null ? Object.keys(this) : gids
|
||||
return this.sortImages(gids, module.makeImageNameCmp(this), reverse)
|
||||
},
|
||||
sortBySeqOrName: function(gids, reverse){
|
||||
gids = gids == null ? Object.keys(this) : gids
|
||||
return this.sortImages(gids, module.makeImageSeqOrNameCmp(this), reverse)
|
||||
},
|
||||
sortByNameXPStyle: function(gids, reverse){
|
||||
gids = gids == null ? Object.keys(this) : gids
|
||||
return this.sortImages(gids,
|
||||
module.makeImageSeqOrNameCmp(this, null, this.getImageNameLeadingSeq),
|
||||
reverse)
|
||||
},
|
||||
sortByDateOrSeqOrName: function(gids, reverse){
|
||||
gids = gids == null ? Object.keys(this) : gids
|
||||
return this.sortImages(gids, [
|
||||
module.makeImageDateCmp(this),
|
||||
module.makeImageSeqOrNameCmp(this)
|
||||
], reverse)
|
||||
},
|
||||
// XXX
|
||||
sortedImagesByFileNameSeqWithOverflow: function(gids, reverse){
|
||||
gids = gids == null ? Object.keys(this) : gids
|
||||
|
||||
@ -457,7 +457,7 @@ function getKeyHandlers(key, modifiers, keybindings, modes, shifted_keys, action
|
||||
|
||||
// actions...
|
||||
} else if(handler in actions
|
||||
|| handler.split(/!?\s*:\s*|!/)[0].trim() in actions){
|
||||
|| handler.split(/!?\s*:\s*|!|--/)[0].trim() in actions){
|
||||
|
||||
var c = parseActionCall(handler)
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user