From e2192aef8429b99fd5c817d13ace023a06cfbad1 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Thu, 2 May 2013 22:32:20 +0400 Subject: [PATCH] more code rearangement... Signed-off-by: Alex A. Naanou --- ui/ImageGrid.js | 112 ++++++++++++++++++++++++------------------------ 1 file changed, 56 insertions(+), 56 deletions(-) diff --git a/ui/ImageGrid.js b/ui/ImageGrid.js index 73ddb856..d1a713bf 100755 --- a/ui/ImageGrid.js +++ b/ui/ImageGrid.js @@ -18,62 +18,6 @@ **********************************************************************/ -/********************************************************************** -* Constructors -*/ - -// NOTE: to avoid state sync problems this should clone an image if -// one is available... -function createImage(n){ - if(n == null){ - if(window._n == null){ - window._n = 0 - } - n = _n - _n += 1 - } - var img = $('.image') - if(img.length > 0){ - return img.first().clone() - .attr({ - 'order': n, - // need to strip extra classes... - 'class': 'image' - }) - } else { - return $('
') - } -} - -// This will create a set of new images, reusing a list of existing -// elements if given. -// XXX do we need this??? -function createImages(need, have){ - have = have == null ? [] : have - - // we have enough elements in the cache... - if(have.length >= need){ - return $(have.splice(0, need)) - - // need to create additional elements... - } else { - return $(have.toArray().concat(new Array(need - have.length))) - .map(function(i, elem){ - if(elem != null){ - return elem - } - return createImage()[0] - }) - } -} - -function createRibbon(){ - return $('
') -} - - - - /********************************************************************** * Helpers */ @@ -163,6 +107,62 @@ function shiftImage(direction, image, force_create_ribbon){ +/********************************************************************** +* Constructors +*/ + +// NOTE: to avoid state sync problems this should clone an image if +// one is available... +function createImage(n){ + if(n == null){ + if(window._n == null){ + window._n = 0 + } + n = _n + _n += 1 + } + var img = $('.image') + if(img.length > 0){ + return img.first().clone() + .attr({ + 'order': n, + // need to strip extra classes... + 'class': 'image' + }) + } else { + return $('
') + } +} + +// This will create a set of new images, reusing a list of existing +// elements if given. +// XXX do we need this??? +function createImages(need, have){ + have = have == null ? [] : have + + // we have enough elements in the cache... + if(have.length >= need){ + return $(have.splice(0, need)) + + // need to create additional elements... + } else { + return $(have.toArray().concat(new Array(need - have.length))) + .map(function(i, elem){ + if(elem != null){ + return elem + } + return createImage()[0] + }) + } +} + +function createRibbon(){ + return $('
') +} + + + + /********************************************************************** * Modes */