From ed68854c805f514c7123e5e2370781dd0e51dd49 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Wed, 29 Mar 2017 18:10:31 +0300 Subject: [PATCH] cleanup + fixes... Signed-off-by: Alex A. Naanou --- ui (gen4)/features/ui-marks.js | 27 ++++++++++++++++++++++----- ui (gen4)/features/ui.js | 27 ++++++++++----------------- 2 files changed, 32 insertions(+), 22 deletions(-) diff --git a/ui (gen4)/features/ui-marks.js b/ui (gen4)/features/ui-marks.js index 4f6a5420..0e82958f 100755 --- a/ui (gen4)/features/ui-marks.js +++ b/ui (gen4)/features/ui-marks.js @@ -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({ diff --git a/ui (gen4)/features/ui.js b/ui (gen4)/features/ui.js index 4e8355fd..9adb489e 100755 --- a/ui (gen4)/features/ui.js +++ b/ui (gen4)/features/ui.js @@ -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: [