mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-11-01 11:50:07 +00:00
re-did ids, fixed sorting...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
6aa31daf70
commit
80c6d525ce
@ -433,7 +433,8 @@ jQuery.fn.sortChildren = function(func){
|
|||||||
function getImageOrder(img){
|
function getImageOrder(img){
|
||||||
// XXX HACK need to parseInt this because '13' is less than '2'...
|
// XXX HACK need to parseInt this because '13' is less than '2'...
|
||||||
// ...figure a way out of this!!!
|
// ...figure a way out of this!!!
|
||||||
return parseInt($(img).attr('id'))
|
//return parseInt($(img).attr('id'))
|
||||||
|
return $(img).attr('id')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -447,6 +448,14 @@ function cmpImageOrder(a, b){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function cmpImagePaths(a, b){
|
||||||
|
a = getURL($(a).attr('id'))
|
||||||
|
b = getURL($(b).attr('id'))
|
||||||
|
return a > b ? 1 : a < b ? -1 : 0
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// NOTE: don't understand why am I the one who has to write this...
|
// NOTE: don't understand why am I the one who has to write this...
|
||||||
var SPECIAL_KEYS = {
|
var SPECIAL_KEYS = {
|
||||||
9: 'Tab',
|
9: 'Tab',
|
||||||
@ -1383,13 +1392,14 @@ function loadJSON(data, position, set_order){
|
|||||||
for(var j in images){
|
for(var j in images){
|
||||||
var image = images[j]
|
var image = images[j]
|
||||||
// update index...
|
// update index...
|
||||||
new_images[order] = image
|
//new_images[order] = image
|
||||||
// create image...
|
// create image...
|
||||||
makeImage(order, set_order)
|
//makeImage(order, set_order)
|
||||||
|
makeImage(j, set_order)
|
||||||
.appendTo(ribbon)
|
.appendTo(ribbon)
|
||||||
order++
|
order++
|
||||||
}
|
}
|
||||||
ribbons[i] = new_images
|
//ribbons[i] = new_images
|
||||||
}
|
}
|
||||||
console.log('loaded: ', order)
|
console.log('loaded: ', order)
|
||||||
if(position != null && $('#' + position).length != 0){
|
if(position != null && $('#' + position).length != 0){
|
||||||
@ -2182,11 +2192,8 @@ ImageGrid.GROUP('Image manipulation',
|
|||||||
display: false,
|
display: false,
|
||||||
},
|
},
|
||||||
function sortImagesVia(cmp){
|
function sortImagesVia(cmp){
|
||||||
// reverse ID order...
|
$('.ribbon').sortChildren(cmp)
|
||||||
$($('.image').get().sort(cmp))
|
updateRibbonImages($('.current.image').click())
|
||||||
.each(function(i, e){e.id = i})})
|
|
||||||
// resort the images...
|
|
||||||
ImageGrid.sortImages()
|
|
||||||
}),
|
}),
|
||||||
ImageGrid.ACTION({
|
ImageGrid.ACTION({
|
||||||
title: 'Sort images',
|
title: 'Sort images',
|
||||||
@ -2194,9 +2201,12 @@ ImageGrid.GROUP('Image manipulation',
|
|||||||
'NOTE: this will only realign three ribbons.'
|
'NOTE: this will only realign three ribbons.'
|
||||||
},
|
},
|
||||||
function sortImages(){
|
function sortImages(){
|
||||||
|
/* XXX this is broken: need a good default...
|
||||||
$('.ribbon').sortChildren(cmpImageOrder)
|
$('.ribbon').sortChildren(cmpImageOrder)
|
||||||
// compensate for offset cange...
|
// compensate for offset cange...
|
||||||
$('.current.image').click()
|
updateRibbonImages($('.current.image').click())
|
||||||
|
*/
|
||||||
|
return ImageGrid.sortImagesByPath()
|
||||||
}),
|
}),
|
||||||
ImageGrid.ACTION({
|
ImageGrid.ACTION({
|
||||||
title: 'Reverse order of images',
|
title: 'Reverse order of images',
|
||||||
@ -2204,18 +2214,14 @@ ImageGrid.GROUP('Image manipulation',
|
|||||||
},
|
},
|
||||||
function reverseImageOrder(){
|
function reverseImageOrder(){
|
||||||
// this is done by reversing their id attr
|
// this is done by reversing their id attr
|
||||||
ImageGrid.sortImagesVia(function(a, b){return cmpImageOrder(b, a)})
|
ImageGrid.sortImagesVia(function(a, b){return cmpImagePaths(b, a)})
|
||||||
}),
|
}),
|
||||||
ImageGrid.ACTION({
|
ImageGrid.ACTION({
|
||||||
title: 'Sort images by their full path',
|
title: 'Sort images by their full path',
|
||||||
},
|
},
|
||||||
// XXX this should use a normalized path...
|
// XXX this should use a normalized path...
|
||||||
function sortImagesByPath(){
|
function sortImagesByPath(){
|
||||||
ImageGrid.sortImagesVia(function(a, b){
|
ImageGrid.sortImagesVia(cmpImagePaths)
|
||||||
a = getURL($(a).attr('id'))
|
|
||||||
b = getURL($(b).attr('id'))
|
|
||||||
return a > b ? 1 : a < b ? -1 : 0
|
|
||||||
})
|
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user