added mark-based shifting up/down...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2013-06-02 23:57:30 +04:00
parent e7ea183597
commit c6257a335a
2 changed files with 80 additions and 7 deletions

View File

@ -1433,7 +1433,7 @@ function sortImagesByName(reverse){
}
// shifting images...
// Ordering images...
// NOTE: this a bit more complicated than simply shifting an image
// left/right the DATA.order, we have to put it before or after
// the prev/next image...
@ -1481,6 +1481,81 @@ function shiftImageRight(image){
}
// XXX move to marks.js
// XXX need to account for empty ribbons...
function shiftMarkedImages(direction, mode, new_ribbon){
mode = mode == null ? 'ribbon' : mode
var cur = getRibbonIndex()
// ribbon only...
if(mode == 'ribbon'){
var ribbon = DATA.ribbons[cur]
// remove all the marked images form current ribbon...
var marked = $.map(MARKED, function(e){
var i = ribbon.indexOf(e)
if(i >= 0){
ribbon.splice(i, 1)
return e
}
return null
})
// shift all marked images...
} else {
var marked = MARKED.slice()
// remove all the marked images form all the ribbons...
$.each(DATA.ribbons, function(ribbon){
$.each(marked, function(e){
var i = ribbon.indexOf(e)
i >= 0 ? ribbon.splice(i, 1) : null
})
})
}
// if we are at the top or bottom ribbons we need to create a new
// ribbon regardless...
if((cur == 0 && direction == 'prev')
|| (cur == DATA.ribbons.length-1 && direction == 'next')){
new_ribbon = true
}
// add marked to new ribbon...
if(new_ribbon){
cur += direction == 'next' ? 1 : 0
DATA.ribbons.splice(cur, 0, marked)
// add marked to existing ribbon...
} else {
cur += direction == 'next' ? 1 : -1
DATA.ribbons[cur] = DATA.ribbons[cur].concat(marked).sort(cmp)
}
// remove empty ribbons...
DATA.ribbons = DATA.ribbons.filter(function(e){ return e.length > 0 ? true : false })
updateRibbonOrder()
}
function shiftMarkedImagesUp(mode, new_ribbon){
return shiftMarkedImages('prev', mode, new_ribbon)
}
function shiftMarkedImagesDown(mode, new_ribbon){
return shiftMarkedImages('next', mode, new_ribbon)
}
// XXX these are ribbon wise only (???)
// XXX this on first step this must pack all marked images
function horizontalShiftMarkedImages(direction){
}
function shiftMarkedImagesLeft(){
return shiftMarkedImages('prev')
}
function shiftMarkedImagesRight(){
return shiftMarkedImages('next')
}
/**********************************************************************
* vim:set ts=4 sw=4 spell : */

View File

@ -305,11 +305,10 @@ var KEYBOARD_CONFIG = {
shiftImageUpNewRibbon(null, DIRECTION)
centerRibbons()
}),
// XXX
alt: doc('Shift marked images up',
function(){
// XXX
toggleMarkesView('on')
shiftMarkedImagesUp()
}),
'alt+shift': doc('Shift marked images up to empty ribbon',
function(){
@ -335,11 +334,10 @@ var KEYBOARD_CONFIG = {
shiftImageDownNewRibbon(null, DIRECTION)
centerRibbons()
}),
// XXX
alt: doc('Shift marked images down',
function(){
// XXX
toggleMarkesView('on')
shiftMarkedImagesDown()
}),
'alt+shift': doc('Shift marked images down to empty ribbon',
function(){