mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-11-02 04:10:11 +00:00
more refactoring...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
4c64a041e3
commit
7b0a68b99f
@ -5,7 +5,11 @@
|
|||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
|
|
||||||
//var DEBUG = DEBUG != null ? DEBUG : true
|
//var DEBUG = DEBUG != null ? DEBUG : true
|
||||||
//
|
|
||||||
|
var LOAD_SCREENS = 2
|
||||||
|
var LOAD_THRESHOLD = 1
|
||||||
|
var DEFAULT_SCREEN_IMAGES = 5
|
||||||
|
|
||||||
// XXX STUB
|
// XXX STUB
|
||||||
// Data format...
|
// Data format...
|
||||||
var DATA = {
|
var DATA = {
|
||||||
@ -168,11 +172,6 @@ function getGIDBefore(gid, ribbon, search){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
|
||||||
* Loaders
|
|
||||||
*/
|
|
||||||
|
|
||||||
// NOTE: count can be either negative or positive, this will indicate
|
// NOTE: count can be either negative or positive, this will indicate
|
||||||
// load direction...
|
// load direction...
|
||||||
// NOTE: this will not include the 'from' GID in the resulting list...
|
// 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){
|
function updateImage(image, gid, size){
|
||||||
image = $(image)
|
image = $(image)
|
||||||
if(gid == null){
|
if(gid == null){
|
||||||
@ -255,12 +259,12 @@ function updateImage(image, gid, size){
|
|||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// XXX STUB
|
// XXX STUB
|
||||||
//image.text(image.text() + ' ('+ s +'px)')
|
//image.text(image.text() + ' ('+ s +'px)')
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// shorthand...
|
// shorthand...
|
||||||
function updateImages(size){
|
function updateImages(size){
|
||||||
size = size == null ? getVisibleImageSize() : size
|
size = size == null ? getVisibleImageSize() : size
|
||||||
@ -322,6 +326,7 @@ function loadImages(ref_gid, count, ribbon){
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// XXX here for testing...
|
// XXX here for testing...
|
||||||
function loadImagesAround(ref_gid, count, ribbon){
|
function loadImagesAround(ref_gid, count, ribbon){
|
||||||
var ribbon_i = getRibbonIndex(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 is signature-compatible with rollRibbon...
|
||||||
// NOTE: this will load data ONLY if it is available, otherwise this
|
// NOTE: this will load data ONLY if it is available, otherwise this
|
||||||
// will have no effect...
|
// 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
|
* Setup
|
||||||
|
|||||||
@ -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
|
* Helpers
|
||||||
@ -646,14 +656,6 @@ function clickHandler(evt){
|
|||||||
* User actions
|
* 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...
|
// basic navigation actions...
|
||||||
function nextImage(n, mode){
|
function nextImage(n, mode){
|
||||||
mode = mode == null ? NAV_DEFAULT : 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(){
|
function zoomIn(){
|
||||||
var w = getScreenWidthInImages()
|
var w = getScreenWidthInImages()
|
||||||
if(w > 1){
|
if(w > 1){
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user