fixed a bug in cropDataTo(..) that prevented the correct image getting focused if the current image was not in the crop and before the first in the first cropped ribbon (i.e. getGIDBefore(..) returned null)...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2013-11-25 03:01:56 +04:00
parent caa856be79
commit 73f99faa23
3 changed files with 9 additions and 6 deletions

View File

@ -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()

View File

@ -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')

View File

@ -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])