mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-28 18:00:09 +00:00
added .sortAsCollection(..)...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
1c200f0129
commit
32bc16c9da
@ -2444,6 +2444,7 @@ var UICollectionActions = actions.Actions({
|
||||
.unique()))
|
||||
|
||||
// main collection...
|
||||
// XXX add option to force show this...
|
||||
!action
|
||||
&& collections.indexOf(MAIN_COLLECTION_TITLE) < 0
|
||||
&& make([
|
||||
@ -2476,6 +2477,9 @@ var UICollectionActions = actions.Actions({
|
||||
{
|
||||
new_item: new_message ?
|
||||
new_message
|
||||
// explicitly disabled new item...
|
||||
: (new_message === false || new_message === null) ?
|
||||
false
|
||||
: action ?
|
||||
'$New...'
|
||||
: '$New from current state...',
|
||||
@ -2498,7 +2502,9 @@ var UICollectionActions = actions.Actions({
|
||||
that.newCollection(title)
|
||||
: that.saveCollection(title) },
|
||||
|
||||
disabled: action ? [MAIN_COLLECTION_TITLE] : false,
|
||||
disabled: action ?
|
||||
[MAIN_COLLECTION_TITLE]
|
||||
: false,
|
||||
|
||||
update_merge: 'merge',
|
||||
|
||||
@ -2527,8 +2533,8 @@ var UICollectionActions = actions.Actions({
|
||||
.close(function(){
|
||||
that.collection_order = collections
|
||||
to_remove
|
||||
.forEach(function(title){ that.removeCollection(title) }) })
|
||||
})],
|
||||
.forEach(function(title){
|
||||
that.removeCollection(title) }) }) })],
|
||||
// XXX should this be able to add new collections???
|
||||
browseImageCollections: ['Collections|Image/Image $collections...',
|
||||
widgets.makeUIDialog(function(gid){
|
||||
@ -2742,6 +2748,18 @@ var UICollectionActions = actions.Actions({
|
||||
make.EditableList(this.collection_order)
|
||||
}],
|
||||
//*/
|
||||
|
||||
// XXX need to show MAIN_COLLECTION_TITLE...
|
||||
// XXX do we need to have an option/shorthand to .sortAs(..) and .inplaceSortAs(..) ???
|
||||
sortAsCollection: ['Collections/Sort as collection...',
|
||||
{sortMethod: true,
|
||||
mode: function(){
|
||||
return this.collections_length > 0 || 'disabled' }, },
|
||||
mixedModeCollectionAction(function(title){
|
||||
this.ensureCollection(title)
|
||||
.then(function(collection){
|
||||
this.data.order.inplaceSortAs(collection.data.order)
|
||||
this.sortImages('update') }) })],
|
||||
})
|
||||
|
||||
var UICollection =
|
||||
|
||||
@ -43,6 +43,7 @@ core.ImageGridFeatures.Feature('imagegrid-ui-minimal', [
|
||||
'keyboard',
|
||||
'ui-cursor',
|
||||
'ui-control',
|
||||
'ui-copy-image',
|
||||
'ui-drag-n-drop',
|
||||
|
||||
// XXX use one...
|
||||
|
||||
@ -721,6 +721,7 @@ var MetadataUIActions = actions.Actions({
|
||||
})],
|
||||
|
||||
|
||||
// shorthands...
|
||||
cropRatingsAsRibbons: ['Ribbon|Crop/Split ratings to ribbons (crop)',
|
||||
'ratingToRibbons: "crop"'],
|
||||
splitRatingsAsRibbons: ['Ribbon/Split ratings to ribbons (in-place)',
|
||||
|
||||
@ -490,8 +490,7 @@ module.SortActions = actions.Actions({
|
||||
|
||||
// can't sort if we know nothing about .images
|
||||
if(method && method.length > 0 && (!this.images || this.images.length == 0)){
|
||||
return
|
||||
}
|
||||
return }
|
||||
|
||||
// build the compare routine...
|
||||
method = method
|
||||
@ -544,11 +543,8 @@ module.SortActions = actions.Actions({
|
||||
for(var i=0; i < method.length; i++){
|
||||
res = method[i].call(that, a, b)
|
||||
if(res != 0){
|
||||
return res
|
||||
}
|
||||
}
|
||||
return res
|
||||
}
|
||||
return res } }
|
||||
return res }
|
||||
|
||||
// do the sort (in place)...
|
||||
if(method && method.length > 0 && this.images){
|
||||
@ -561,8 +557,7 @@ module.SortActions = actions.Actions({
|
||||
this.data.order.reverse()
|
||||
}
|
||||
|
||||
this.data.updateImagePositions()
|
||||
}],
|
||||
this.data.updateImagePositions() }],
|
||||
|
||||
// XXX should we merge manual order handling with .sortImages(..)???
|
||||
// XXX currently this will not toggle past 'none'
|
||||
@ -801,6 +796,7 @@ var SortUIActions = actions.Actions({
|
||||
Show sort method doc with flat method list...
|
||||
.showSortMethodDoc(method, false)
|
||||
|
||||
This will add actions with .sortMethod attribute as sort methods...
|
||||
`,
|
||||
widgets.makeUIDialog(function(method, expand, indent){
|
||||
var that = this
|
||||
@ -845,8 +841,7 @@ var SortUIActions = actions.Actions({
|
||||
// ignore the first item as we mention
|
||||
// it in the title...
|
||||
.slice(1)
|
||||
.join('\n'))))
|
||||
})],
|
||||
.join('\n')))) })],
|
||||
|
||||
// XXX should we be able to edit modes???
|
||||
// XXX should this be a toggler???
|
||||
@ -857,6 +852,16 @@ var SortUIActions = actions.Actions({
|
||||
|
||||
var dfl = this.config['default-sort']
|
||||
|
||||
var sort_actions = new Map(
|
||||
that.actions
|
||||
.filter(function(e){
|
||||
return that.getActionAttr(e, 'sortMethod') })
|
||||
.map(function(e){
|
||||
return [
|
||||
(that.getActionAttr(e, 'doc') || e).split(/[\\\/:]/).pop(),
|
||||
e,
|
||||
] }))
|
||||
|
||||
// XXX might be a good idea to make this generic...
|
||||
var _makeTogglHandler = function(toggler){
|
||||
return function(){
|
||||
@ -865,33 +870,40 @@ var SortUIActions = actions.Actions({
|
||||
o.update()
|
||||
.then(function(){ o.select(txt) })
|
||||
that.toggleSlideshow('?') == 'on'
|
||||
&& o.parent.close()
|
||||
}
|
||||
}
|
||||
&& o.parent.close() } }
|
||||
|
||||
var o = browse.makeLister(null, function(path, make){
|
||||
var lister = this
|
||||
var cur = that.toggleImageSort('?')
|
||||
|
||||
that.toggleImageSort('??').forEach(function(mode){
|
||||
// skip 'none'...
|
||||
if(mode == 'none'){
|
||||
return
|
||||
}
|
||||
make(mode, {
|
||||
cls: [
|
||||
(mode == cur ? 'highlighted selected' : ''),
|
||||
(mode == dfl ? 'default' : ''),
|
||||
].join(' '),
|
||||
// show only modes starting with upper case...
|
||||
hidden: mode[0].toUpperCase() != mode[0],
|
||||
})
|
||||
// normal sort methods...
|
||||
that.toggleImageSort('??')
|
||||
.forEach(function(mode){
|
||||
// skip 'none'...
|
||||
if(mode == 'none'){
|
||||
return }
|
||||
make(mode, {
|
||||
cls: [
|
||||
(mode == cur ? 'highlighted selected' : ''),
|
||||
(mode == dfl ? 'default' : ''),
|
||||
].join(' '),
|
||||
// show only modes starting with upper case...
|
||||
hidden: mode[0].toUpperCase() != mode[0],
|
||||
})
|
||||
.on('open', function(){
|
||||
that.toggleImageSort(null, mode,
|
||||
that.config['default-sort-order'] == 'reverse')
|
||||
lister.parent.close()
|
||||
})
|
||||
})
|
||||
lister.parent.close() }) })
|
||||
// action sort methods...
|
||||
if(sort_actions.size > 0){
|
||||
;[...sort_actions.entries()]
|
||||
.forEach(function([n, a]){
|
||||
make(n, {
|
||||
disabled: that.getActionMode(a) == 'disabled',
|
||||
})
|
||||
.on('open', function(){
|
||||
that[a]()
|
||||
make.dialog.close() }) }) }
|
||||
|
||||
// Commands...
|
||||
make('---')
|
||||
@ -899,8 +911,7 @@ var SortUIActions = actions.Actions({
|
||||
make('$Reverse images')
|
||||
.on('open', function(){
|
||||
that.reverseImages()
|
||||
lister.parent.close()
|
||||
})
|
||||
lister.parent.close() })
|
||||
|
||||
// Settings...
|
||||
make('---')
|
||||
@ -913,15 +924,19 @@ var SortUIActions = actions.Actions({
|
||||
// handle '?' button to browse path...
|
||||
this.showDoc = function(){
|
||||
var method = this.select('!').text()
|
||||
method
|
||||
&& method in that.config['sort-methods']
|
||||
&& that.showSortMethodDoc(method)
|
||||
}
|
||||
method = sort_actions.get(method) || method
|
||||
|
||||
// normal sort method...
|
||||
if(method in that.config['sort-methods']){
|
||||
that.showSortMethodDoc(method)
|
||||
|
||||
// sort action...
|
||||
} else if(method in that){
|
||||
that.showDoc(method) } }
|
||||
this.keyboard.handler('General', '?', 'showDoc')
|
||||
})
|
||||
|
||||
return o
|
||||
})]
|
||||
return o })],
|
||||
})
|
||||
|
||||
var SortUI =
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user