mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 18:30:09 +00:00
merged some almost identical functions...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
dadda5508a
commit
d440355b9f
@ -292,88 +292,60 @@ function createRibbonBelow(){
|
|||||||
// Modifiers...
|
// Modifiers...
|
||||||
|
|
||||||
// XXX sort elements correctly...
|
// XXX sort elements correctly...
|
||||||
function mergeRibbonsUp(){
|
function mergeRibbons(direction){
|
||||||
$('.current-ribbon')
|
$('.current-ribbon')[direction]('.ribbon')
|
||||||
.prev('.ribbon')
|
|
||||||
.children()
|
.children()
|
||||||
.detach()
|
.detach()
|
||||||
.insertAfter('.current-image')
|
.insertAfter('.current-image')
|
||||||
$('.current-ribbon')
|
$('.current-ribbon')[direction]('.ribbon')
|
||||||
.prev('.ribbon')
|
|
||||||
.slideUp(function(){
|
.slideUp(function(){
|
||||||
$(this).remove()
|
$(this).remove()
|
||||||
$('.current-image').click()
|
$('.current-image').click()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// XXX sort elements correctly...
|
// now the actual modifiers...
|
||||||
function mergeRibbonsDown(){
|
|
||||||
$('.current-ribbon')
|
function shiftImage(direction){
|
||||||
.next('.ribbon')
|
// XXX simplify this...
|
||||||
.children()
|
if(direction == 'prev'){
|
||||||
.detach()
|
var createRibbon = createRibbonAbove
|
||||||
.insertAfter('.current-image')
|
} else if (direction == 'next'){
|
||||||
$('.current-ribbon')
|
var createRibbon = createRibbonBelow
|
||||||
.next('.ribbon')
|
} else {
|
||||||
.slideUp(function(){
|
return false
|
||||||
$(this).remove()
|
}
|
||||||
$('.current-image').click()
|
|
||||||
})
|
if($('.current-ribbon')[direction]('.ribbon').length == 0){
|
||||||
|
createRibbon()
|
||||||
|
}
|
||||||
|
// XXX sort elements correctly...
|
||||||
|
if($('.current-ribbon').children('.image').length == 1){
|
||||||
|
// XXX this adds image to the head while the below portion adds it to the tail...
|
||||||
|
mergeRibbons(direction)
|
||||||
|
} else {
|
||||||
|
img = $('.current-image')
|
||||||
|
if(img.next('.image').length == 0){
|
||||||
|
prevImage()
|
||||||
|
} else {
|
||||||
|
nextImage()
|
||||||
|
}
|
||||||
|
img
|
||||||
|
.detach()
|
||||||
|
.appendTo($('.current-ribbon')[direction]('.ribbon'))
|
||||||
|
}
|
||||||
|
// XXX this has to know aout animations...
|
||||||
|
$('.current-image').click()
|
||||||
}
|
}
|
||||||
|
|
||||||
// XXX sort elements correctly...
|
|
||||||
// XXX do animations...
|
|
||||||
function promoteImage(){
|
function promoteImage(){
|
||||||
if($('.current-ribbon').next('.ribbon').length == 0){
|
return shiftImage('next')
|
||||||
createRibbonBelow()
|
|
||||||
}
|
|
||||||
// XXX sort elements correctly...
|
|
||||||
if($('.current-ribbon').children('.image').length == 1){
|
|
||||||
// XXX this adds image to the head while the below portion adds it to the tail...
|
|
||||||
mergeRibbonsDown()
|
|
||||||
} else {
|
|
||||||
img = $('.current-image')
|
|
||||||
if(img.next('.image').length == 0){
|
|
||||||
prevImage()
|
|
||||||
} else {
|
|
||||||
nextImage()
|
|
||||||
}
|
|
||||||
img
|
|
||||||
.detach()
|
|
||||||
.appendTo($('.current-ribbon').next('.ribbon'))
|
|
||||||
}
|
|
||||||
$('.current-image').click()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// XXX sort elements correctly...
|
// XXX this has problems, when creating a new ribbon this does not settle
|
||||||
// XXX do animations...
|
// into a correct spot...
|
||||||
// XXX BUG: when demoting first image (new ribbon created) it gets focused...
|
|
||||||
// REASON: .click() gets called in several places BEFORE the animation is done...
|
|
||||||
// NOTE: this bog does not affect promoteImage -- adding a lower element does not affect current positioning...
|
|
||||||
function demoteImage(){
|
function demoteImage(){
|
||||||
if($('.current-ribbon').prev('.ribbon').length == 0){
|
return shiftImage('prev')
|
||||||
var new_ribbon = createRibbonAbove()
|
|
||||||
}
|
|
||||||
// XXX sort elements correctly...
|
|
||||||
if($('.current-ribbon').children('.image').length == 1){
|
|
||||||
// XXX this adds image to the head while the below portion adds it to the tail...
|
|
||||||
mergeRibbonsUp()
|
|
||||||
} else {
|
|
||||||
img = $('.current-image')
|
|
||||||
if(img.next('.image').length == 0){
|
|
||||||
// XXX in case when we've just created an empty ribbon, the click in this fires BEFORE it is fully expanded...
|
|
||||||
prevImage()
|
|
||||||
} else {
|
|
||||||
// XXX in case when we've just created an empty ribbon, the click in this fires BEFORE it is fully expanded...
|
|
||||||
nextImage()
|
|
||||||
}
|
|
||||||
img
|
|
||||||
.detach()
|
|
||||||
.appendTo($('.current-ribbon').prev('.ribbon'))
|
|
||||||
}
|
|
||||||
// XXX in case when we've just created an empty ribbon, the click in this fires BEFORE it is fully expanded...
|
|
||||||
$('.current-image').click()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// vim:set ts=4 sw=4 nowrap :
|
// vim:set ts=4 sw=4 nowrap :
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user