added marked image list, now persistent over dynamically loaded data...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2013-05-14 18:10:33 +04:00
parent 8b34dfed42
commit 9c2ceb95ae
4 changed files with 49 additions and 9 deletions

View File

@ -59,6 +59,20 @@ function getRibbon(image){
} }
function getImage(gid){
if(e == null){
return $('.current.image')
}
// XXX do a proper check...
// gid...
return $('.image[gid='+ JSON.stringify(gid) +']')
// order...
// XXX
//return $('.image[order='+ JSON.stringify(gid) +']')
}
// NOTE: elem is optional and if given can be an image or a ribbon... // NOTE: elem is optional and if given can be an image or a ribbon...
function getRibbonIndex(elem){ function getRibbonIndex(elem){
if(elem == null){ if(elem == null){
@ -844,7 +858,10 @@ function shiftImageDownNewRibbon(image, moving){
// XXX if this unmarks an image in marked-only mode no visible image is // XXX if this unmarks an image in marked-only mode no visible image is
// going to be current... // going to be current...
var toggleImageMark = createCSSClassToggler('.current.image', 'marked') var toggleImageMark = createCSSClassToggler('.current.image', 'marked',
function(action){
$('.viewer').trigger('togglingMark', [$('.current.image'), action])
})
// mode can be: // mode can be:

View File

@ -41,6 +41,8 @@ var DATA = {
} }
} }
var MARKS = []
/********************************************************************** /**********************************************************************
@ -228,11 +230,16 @@ function updateImage(image, gid, size){
// update classes and other indicators... // update classes and other indicators...
image image
.attr({ .attr({
//order: JSON.stringify(DATA.order.indexOf(gid)),
order: JSON.stringify(gid) order: JSON.stringify(gid)
// XXX update other attrs...
}) })
// setup marks...
if(MARKS.indexOf(gid) != -1){
image.addClass('marked')
} else {
image.removeClass('marked')
}
// XXX STUB // XXX STUB
image.text(gid) image.text(gid)
@ -257,11 +264,6 @@ function updateImage(image, gid, size){
image.css({ image.css({
'background-image': url, 'background-image': url,
}) })
// XXX STUB
//image.text(image.text() + ' ('+ s +'px)')
} }
@ -537,6 +539,20 @@ function setupDataBindings(viewer){
.on('focusingImage', function(evt, image){ .on('focusingImage', function(evt, image){
DATA.current = getImageGID($(image)) DATA.current = getImageGID($(image))
}) })
.on('togglingMark', function(evt, img, action){
var gid = getImageGID(img)
// add marked image to list...
if(action == 'on'){
MARKS.push(gid)
// remove marked image from list...
} else {
MARKS.splice(MARKS.indexOf(gid), 1)
}
})
} }

View File

@ -260,7 +260,6 @@ $(function(){
centerView(focusImage($('.image').first()), 'css') centerView(focusImage($('.image').first()), 'css')
updateImages() updateImages()
}) })

View File

@ -1,3 +1,11 @@
/**********************************************************************
*
*
*
**********************************************************************/
//var DEBUG = DEBUG != null ? DEBUG : true
/*********************************************************************/ /*********************************************************************/
/*********************************************************************/ /*********************************************************************/