more refactoring...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2013-05-13 02:31:09 +04:00
parent 4c64a041e3
commit 7b0a68b99f
2 changed files with 49 additions and 49 deletions

View File

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

View File

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