mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-11-01 03:40:09 +00:00
added basic sorting (still not bound to user controls)...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
5cb2ebcfa2
commit
d48de6be00
49
ui/data.js
49
ui/data.js
@ -189,11 +189,11 @@ function imageDateCmp(a, b, get, data){
|
|||||||
function imageNameCmp(a, b, get, data){
|
function imageNameCmp(a, b, get, data){
|
||||||
data = data == null ? IMAGES : data
|
data = data == null ? IMAGES : data
|
||||||
if(get == null){
|
if(get == null){
|
||||||
a = data[b].path.split('/').pop()
|
a = data[a].path.split('/').pop()
|
||||||
b = data[a].path.split('/').pop()
|
b = data[b].path.split('/').pop()
|
||||||
} else {
|
} else {
|
||||||
a = data[get(b)].path.split('/').pop()
|
a = data[get(a)].path.split('/').pop()
|
||||||
b = data[get(a)].path.split('/').pop()
|
b = data[get(b)].path.split('/').pop()
|
||||||
}
|
}
|
||||||
if(a == b){
|
if(a == b){
|
||||||
return 0
|
return 0
|
||||||
@ -485,6 +485,18 @@ function getBestPreview(gid, size){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Resort the ribbons by DATA.order and re-render...
|
||||||
|
//
|
||||||
|
// NOTE: due to how the format is structured, to sort the images one
|
||||||
|
// only needs to sort DATA.order and call this.
|
||||||
|
function updateRibbonOrder(){
|
||||||
|
for(var i=0; i < DATA.ribbons.length; i++){
|
||||||
|
DATA.ribbons[i].sort(imageOrderCmp)
|
||||||
|
}
|
||||||
|
loadData()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* Constructors
|
* Constructors
|
||||||
@ -953,16 +965,33 @@ function loadSettings(){
|
|||||||
* Actions...
|
* Actions...
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// XXX revise...
|
function reverseImageOrder(){
|
||||||
function reverseImages(){
|
|
||||||
DATA.order.reverse()
|
DATA.order.reverse()
|
||||||
for(var i=0; i < DATA.ribbons.length; i++){
|
updateRibbonOrder()
|
||||||
DATA.ribbons[i].reverse()
|
|
||||||
}
|
|
||||||
loadData()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// NOTE: using imageOrderCmp as a cmp function here will yield odd
|
||||||
|
// results -- in-place sorting a list based on relative element
|
||||||
|
// positions within itself is fun ;)
|
||||||
|
function sortImages(cmp, reverse){
|
||||||
|
cmp = cmp == null ? imageDateCmp : cmp
|
||||||
|
DATA.order.sort(cmp)
|
||||||
|
if(reverse){
|
||||||
|
DATA.order.reverse()
|
||||||
|
}
|
||||||
|
updateRibbonOrder()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// shirt-hands...
|
||||||
|
function sortImagesByDate(reverse){
|
||||||
|
return sortImages(reverse)
|
||||||
|
}
|
||||||
|
function sortImagesByName(reverse){
|
||||||
|
return sortImages(imageNameCmp, reverse)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
|
|||||||
@ -276,7 +276,7 @@ var KEYBOARD_CONFIG = {
|
|||||||
default: doc('Rotate image right',
|
default: doc('Rotate image right',
|
||||||
function(){ rotateRight() }),
|
function(){ rotateRight() }),
|
||||||
ctrl: doc('Reverse image order',
|
ctrl: doc('Reverse image order',
|
||||||
function(){ reverseImages() }),
|
function(){ reverseImageOrder() }),
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user