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