diff --git a/ui/crop.js b/ui/crop.js index ba8400e2..e2e8a304 100755 --- a/ui/crop.js +++ b/ui/crop.js @@ -78,7 +78,7 @@ function makeCroppedData(gids, keep_ribbons, keep_unloaded_gids){ function cropDataTo(gids, keep_ribbons, keep_unloaded_gids){ var prev_state = DATA var cur = DATA.current - var r = getRibbonIndex() + var r = keep_ribbons ? getRibbonIndex() : 0 var new_data = makeCroppedData(gids, keep_ribbons, keep_unloaded_gids) @@ -91,8 +91,8 @@ function cropDataTo(gids, keep_ribbons, keep_unloaded_gids){ CROP_STACK.push(prev_state) DATA = new_data - cur = getGIDBefore(cur, keep_ribbons ? r : 0) - cur = cur == null ? gids[0] : cur + cur = getGIDBefore(cur, r) + cur = cur == null ? DATA.ribbons[r][0] : cur DATA.current = cur reloadViewer() diff --git a/ui/data.js b/ui/data.js index 089cd336..85bac83d 100755 --- a/ui/data.js +++ b/ui/data.js @@ -1387,15 +1387,16 @@ function getCommonSubArray(L1, L2){ } +// Load count images around a given image/gid into the given ribbon. +// function loadImagesAround(count, gid, ribbon, data){ // default values... data = data == null ? DATA : data - gid = gid == null ? getImageGID() : gid ribbon = ribbon == null ? getRibbonIndex() : ribbon ribbon = typeof(ribbon) != typeof(123) ? getRibbonIndex(ribbon) : ribbon count = count == null ? Math.round(LOAD_SCREENS * getScreenWidthInImages()) : count // get a gid that exists in the current ribbon... - gid = data.ribbons[ribbon].indexOf(gid) < 0 ? getGIDBefore(gid, ribbon, null, data) : gid + gid = getGIDBefore(gid, ribbon, null, data) var ribbon_elem = getRibbon(ribbon) @@ -1655,7 +1656,7 @@ function reloadViewer(images_per_screen){ // ...if the image is not loaded the focusingImage event handlers // will mess things up... // XXX need to call these when and only when current image is loaded... - focusImage($('.image').filter('[gid="'+JSON.stringify(current)+'"]')) + focusImage(getImage(current)) fitNImages(w) centerRibbons('css') diff --git a/ui/ribbons.js b/ui/ribbons.js index 97b677bc..c64c45fe 100755 --- a/ui/ribbons.js +++ b/ui/ribbons.js @@ -480,6 +480,8 @@ function rollRibbon(n, ribbon, extend, no_compensate_shift){ */ function focusImage(image){ + image = typeof(image) == typeof('str') ? getImage(image) : image + image.closest('.viewer').find('.current.image').removeClass('current') image.addClass('current') $('.viewer').trigger('focusingImage', [image])