cleanup + fixes...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2017-03-29 18:10:31 +03:00
parent b5d11192ac
commit ed68854c80
2 changed files with 32 additions and 22 deletions

View File

@ -207,12 +207,29 @@ module.ImageMarks = core.ImageGridFeatures.Feature({
tag: 'image-marks',
depends: ['base'],
depends: [
'base'
],
suggested: [
'ui-image-marks',
],
actions: ImageMarkActions,
})
var ImageMarksUI =
module.ImageMarksUI = core.ImageGridFeatures.Feature({
title: '',
doc: '',
tag: 'ui-image-marks',
depends: [
'ui'
],
handlers: [
// obey the shiftImage protocol...
[[
'shiftMarkedUp.pre',
'shiftMarkedDown.pre',
@ -222,14 +239,14 @@ module.ImageMarks = core.ImageGridFeatures.Feature({
var marked = this.markedInRibbon(ribbon)
// need to shift focus...
// XXX this still results in odd alignment problems in some cases...
if(marked.indexOf(this.current) >= 0){
var l = this.ribbons.getRibbonLocator()
var direction = this.direction == 'right' ? 'next' : 'prev'
var getNext = function(direction){
var next = that.data.getImage(direction)
while(next != null && marked.indexOf(next) >= 0){
next = that.data.getImage(direction)
next = that.data.getImage(next, direction)
}
return next
}
@ -237,6 +254,7 @@ module.ImageMarks = core.ImageGridFeatures.Feature({
var next = getNext(direction)
|| getNext(direction == 'next' ? 'prev' : 'next')
var l = this.ribbons.getRibbonLocator()
next != null
&& this.ribbons.preventTransitions(l)
&& this.focusImage(next)
@ -261,7 +279,6 @@ module.ImageMarks = core.ImageGridFeatures.Feature({
})
//---------------------------------------------------------------------
var ImageBookmarkActions = actions.Actions({

View File

@ -89,11 +89,16 @@ function updateImagePosition(actions, target){
return function(){
actions.ribbons.preventTransitions(s)
var end = function(){
// XXX not sure why this does not work without a setTimeout(..)
//actions.ribbons.restoreTransitions(s, true)
setTimeout(function(){
actions.ribbons.restoreTransitions(s, true) }, 0) }
// XXX hack...
if(target.constructor === Array){
// XXX hack???
if(target instanceof Array){
actions.reload()
return
return end()
}
var target_ribbon = actions.data.getRibbon(target)
@ -101,7 +106,7 @@ function updateImagePosition(actions, target){
// nothing changed...
if(source_ribbon == target_ribbon
&& actions.data.getImageOrder(target) == source_order){
return
return end()
}
// place image at position...
@ -134,10 +139,7 @@ function updateImagePosition(actions, target){
actions.focusImage()
// XXX not sure why this does not work without a setTimeout(..)
//actions.ribbons.restoreTransitions(s, true)
setTimeout(function(){
actions.ribbons.restoreTransitions(s, true) }, 0)
return end()
}
}
@ -880,15 +882,6 @@ module.ViewerActions = actions.Actions({
fitScreen: ['Zoom/Fit image to screen',
function(){ this.screenfit = 1 }],
// NOTE: these work by getting the target position from .data...
/*
shiftImageTo: [
function(target){ return updateImagePosition(this, target) }],
shiftImageUp: [
function(target){ return updateImagePosition(this, target) }],
shiftImageDown: [
function(target){ return updateImagePosition(this, target) }],
//*/
shiftImageLeft: [
function(target){ this.ribbons.placeImage(target, -1) }],
shiftImageRight: [