From 7b0a68b99f4826bc02ad717fd5cb933446c39d1e Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Mon, 13 May 2013 02:31:09 +0400 Subject: [PATCH] more refactoring... Signed-off-by: Alex A. Naanou --- ui/ImageGrid.data.js | 77 ++++++++++++++++++++++---------------------- ui/ImageGrid.js | 21 ++++++------ 2 files changed, 49 insertions(+), 49 deletions(-) diff --git a/ui/ImageGrid.data.js b/ui/ImageGrid.data.js index 86080400..da765b82 100755 --- a/ui/ImageGrid.data.js +++ b/ui/ImageGrid.data.js @@ -5,7 +5,11 @@ **********************************************************************/ //var DEBUG = DEBUG != null ? DEBUG : true -// + +var LOAD_SCREENS = 2 +var LOAD_THRESHOLD = 1 +var DEFAULT_SCREEN_IMAGES = 5 + // XXX STUB // Data format... var DATA = { @@ -168,11 +172,6 @@ function getGIDBefore(gid, ribbon, search){ } - -/********************************************************************** -* Loaders -*/ - // NOTE: count can be either negative or positive, this will indicate // load direction... // NOTE: this will not include the 'from' GID in the resulting list... @@ -212,6 +211,11 @@ function getImageGIDs(from, count, ribbon, inclusive){ } + +/********************************************************************** +* Loaders +*/ + function updateImage(image, gid, size){ image = $(image) if(gid == null){ @@ -254,13 +258,13 @@ function updateImage(image, gid, size){ 'background-image': url, }) - // XXX STUB //image.text(image.text() + ' ('+ s +'px)') } + // shorthand... function updateImages(size){ size = size == null ? getVisibleImageSize() : size @@ -322,6 +326,7 @@ function loadImages(ref_gid, count, ribbon){ }) } + // XXX here for testing... function loadImagesAround(ref_gid, count, ribbon){ var ribbon_i = getRibbonIndex(ribbon) @@ -330,37 +335,6 @@ function loadImagesAround(ref_gid, count, ribbon){ } -var LOAD_SCREENS = 2 -var LOAD_THRESHOLD = 1 -var DEFAULT_SCREEN_IMAGES = 5 - -function loadData(data, images_per_screen){ - var ribbons_set = $('.ribbon-set') - var current = data.current - // if no width is given, use the current or default... - var w = images_per_screen == null ? getScreenWidthInImages() : images_per_screen - w = w > MAX_SCREEN_IMAGES ? DEFAULT_SCREEN_IMAGES : w - - // clear data... - $('.ribbon').remove() - - // create ribbons... - $.each(data.ribbons, function(i, e){ - createRibbon().appendTo(ribbons_set) - }) - - // create images... - $('.ribbon').each(function(i, e){ - loadImages(current, Math.min(w * LOAD_SCREENS * 1.5, data.ribbons[i].length), $(this)) - }) - - focusImage($('.image').filter('[gid='+JSON.stringify(current)+']')) - - fitNImages(w) - centerRibbons('css') -} - - // NOTE: this is signature-compatible with rollRibbon... // NOTE: this will load data ONLY if it is available, otherwise this // will have no effect... @@ -399,6 +373,33 @@ function rollImages(n, ribbon, extend){ } +function loadData(data, images_per_screen){ + var ribbons_set = $('.ribbon-set') + var current = data.current + // if no width is given, use the current or default... + var w = images_per_screen == null ? getScreenWidthInImages() : images_per_screen + w = w > MAX_SCREEN_IMAGES ? DEFAULT_SCREEN_IMAGES : w + + // clear data... + $('.ribbon').remove() + + // create ribbons... + $.each(data.ribbons, function(i, e){ + createRibbon().appendTo(ribbons_set) + }) + + // create images... + $('.ribbon').each(function(i, e){ + loadImages(current, Math.min(w * LOAD_SCREENS * 1.5, data.ribbons[i].length), $(this)) + }) + + focusImage($('.image').filter('[gid='+JSON.stringify(current)+']')) + + fitNImages(w) + centerRibbons('css') +} + + /********************************************************************** * Setup diff --git a/ui/ImageGrid.js b/ui/ImageGrid.js index 855055d7..513f0623 100755 --- a/ui/ImageGrid.js +++ b/ui/ImageGrid.js @@ -20,6 +20,16 @@ * **********************************************************************/ +// NOTE: NAV_ALL might not be practical... +var NAV_ALL = '*' +var NAV_VISIBLE = ':visible' +var NAV_MARKED = '.marked:visible' +var NAV_DEFAULT = NAV_VISIBLE + +var MAX_SCREEN_IMAGES = 12 +var ZOOM_SCALE = 1.2 + + /********************************************************************** * Helpers @@ -646,14 +656,6 @@ function clickHandler(evt){ * User actions */ -// NOTE: NAV_ALL might not be practical... -var NAV_ALL = '*' -var NAV_VISIBLE = ':visible' -var NAV_MARKED = '.marked:visible' - -var NAV_DEFAULT = NAV_VISIBLE - - // basic navigation actions... function nextImage(n, mode){ mode = mode == null ? NAV_DEFAULT : mode @@ -780,9 +782,6 @@ function fitNImages(n){ } -var MAX_SCREEN_IMAGES = 12 -var ZOOM_SCALE = 1.2 - function zoomIn(){ var w = getScreenWidthInImages() if(w > 1){