diff --git a/ui/bookmarks.js b/ui/bookmarks.js index d566461a..f8ea6ea8 100755 --- a/ui/bookmarks.js +++ b/ui/bookmarks.js @@ -53,8 +53,8 @@ function getBookmarkedGIDBefore(gid){ /*********************************************************************/ -function cropBookmarkedImages(cmp, keep_ribbons, no_cleanout_marks){ - cropDataTo(BOOKMARKS.slice(), keep_ribbons, no_cleanout_marks) +function cropBookmarkedImages(cmp, keep_ribbons, keep_unloaded_gids){ + cropDataTo(BOOKMARKS.slice(), keep_ribbons, keep_unloaded_gids) return DATA } diff --git a/ui/compatibility.js b/ui/compatibility.js index 7ab0ac31..c7c9f2c1 100755 --- a/ui/compatibility.js +++ b/ui/compatibility.js @@ -251,9 +251,7 @@ if(window.CEF_dumpJSON != null){ // add the preview to the image object... img.preview[size+'px'] = './' + CACHE_DIR +'/'+ preview_path.split(CACHE_DIR).pop() // mark image dirty... - if(IMAGES_UPDATED.indexOf(gid) < 0){ - IMAGES_UPDATED.push(gid) - } + imageUpdated(gid) } //console.log('>>> Preview:', name, '('+size+'): Exists.') deferred.notify(gid, size, 'exists') @@ -324,9 +322,7 @@ if(window.CEF_dumpJSON != null){ } img.preview[size+'px'] = './' + CACHE_DIR +'/'+ preview_path.split(CACHE_DIR).pop() // mark image dirty... - if(IMAGES_UPDATED.indexOf(gid) < 0){ - IMAGES_UPDATED.push(gid) - } + imageUpdated(gid) // we are done... deferred.resolve() } diff --git a/ui/data.js b/ui/data.js index 9524e47f..096f5e2c 100755 --- a/ui/data.js +++ b/ui/data.js @@ -695,6 +695,16 @@ function orientationExif2ImageGrid(orientation){ } +// mark an image as updated... +// +function imageUpdated(gid){ + gid = gid == null ? getImageGID(): gid + if(IMAGES_UPDATED.indexOf(gid) == -1){ + IMAGES_UPDATED.push(gid) + } +} + + /********************************************************************** * Constructors and general data manipulation diff --git a/ui/files.js b/ui/files.js index 901887bf..f85e7e37 100755 --- a/ui/files.js +++ b/ui/files.js @@ -753,9 +753,8 @@ function readImageOrientation(gid, no_update_loaded){ img.flipped = o.flipped // mark image dirty... - if((o_o != o.orientation || o_f != o.flipped ) - && IMAGES_UPDATED.indexOf(gid) < 0){ - IMAGES_UPDATED.push(gid) + if(o_o != o.orientation || o_f != o.flipped){ + imageUpdated(gid) } // update image if loaded... @@ -811,7 +810,7 @@ function readImagesDates(images){ return $.when.apply(null, $.map(images, function(_, gid){ return readImageDate(gid, images) .done(function(){ - IMAGES_UPDATED.push(gid) + imageUpdated(gid) }) })) } @@ -823,7 +822,7 @@ function readImagesDatesQ(images){ $.each(images, function(gid, img){ queue.enqueue(readImageDate, gid, images) .always(function(){ - IMAGES_UPDATED.push(gid) + imageUpdated(gid) queue.notify(gid, 'done') }) }) @@ -844,7 +843,7 @@ function updateImageGID(gid, images, data){ // images... images[gid] = images[key] delete images[key] - IMAGES_UPDATED.push(gid) + imageUpdated(gid) // data... if(data != null){ diff --git a/ui/marks.js b/ui/marks.js index b0861940..8f736762 100755 --- a/ui/marks.js +++ b/ui/marks.js @@ -144,12 +144,11 @@ var updateSelectedImageMark = makeMarkUpdater( // NOTE: MARKED may contain both gids that are not loaded and that do // not exist, as there is no way to distinguish between the two // situations the cleanup is optional... -function cropMarkedImages(cmp, keep_ribbons, no_cleanout_marks){ +function cropMarkedImages(cmp, keep_ribbons, keep_unloaded_gids){ cmp = cmp == null ? imageOrderCmp : cmp - var cur = DATA.current var marked = MARKED.slice().sort(cmp) - cropDataTo(marked, keep_ribbons, no_cleanout_marks) + cropDataTo(marked, keep_ribbons, keep_unloaded_gids) return DATA } diff --git a/ui/setup.js b/ui/setup.js index 2304e28c..bc8dfea4 100755 --- a/ui/setup.js +++ b/ui/setup.js @@ -290,9 +290,7 @@ function setupDataBindings(viewer){ // change the image orientation status and add to // updated list... IMAGES[gid].orientation = orientation - if(IMAGES_UPDATED.indexOf(gid) == -1){ - IMAGES_UPDATED.push(gid) - } + imageUpdated(gid) }) }) .on('flippingVertical flippingHorizontal', function(evt, image){ @@ -302,9 +300,7 @@ function setupDataBindings(viewer){ var flip = getImageFlipState(img) IMAGES[gid].flipped = flip - if(IMAGES_UPDATED.indexOf(gid) == -1){ - IMAGES_UPDATED.push(gid) - } + imageUpdated(gid) }) }) .on('resetToOriginalImage', function(evt, image){ @@ -315,9 +311,7 @@ function setupDataBindings(viewer){ IMAGES[gid].flipped = null IMAGES[gid].orientation = 0 - if(IMAGES_UPDATED.indexOf(gid) == -1){ - IMAGES_UPDATED.push(gid) - } + imageUpdated(gid) }) }) diff --git a/ui/tags.js b/ui/tags.js index 3efbe06f..3766a924 100755 --- a/ui/tags.js +++ b/ui/tags.js @@ -10,9 +10,7 @@ // ... // } // -TAGS = { - -} +var TAGS = {} @@ -72,8 +70,8 @@ function addTag(tags, gid, tagset, images){ set = [] tagset[tag] = set } - if(set.indexOf(tag) < 0){ - set.push(tag) + if(set.indexOf(gid) < 0){ + set.push(gid) set.sort() } @@ -84,8 +82,7 @@ function addTag(tags, gid, tagset, images){ if(updated){ img.tags = img_tags - // XXX hardcoded and not customizable... - IMAGES_UPDATED.push(gid) + imageUpdated(gid) } } @@ -121,8 +118,7 @@ function removeTag(tags, gid, tagset, images){ } if(updated){ - // XXX hardcoded and not customizable... - IMAGES_UPDATED.push(gid) + imageUpdated(gid) } } @@ -203,6 +199,49 @@ function getRelatedTags(){ } */ +/*********************************************************************/ + +function tagMarked(tags){ + MARKED.forEach(function(gid){ + addTag(tags, gid) + }) + return MARKED +} +function untagMarked(tags){ + MARKED.forEach(function(gid){ + removeTag(tags, gid) + }) + return MARKED +} + + +function markTagged(tags){ + MARKED = selectByTags(tags) + updateImages() + return MARKED +} +function unmarkTagged(tags){ + var set = selectByTags(tags) + set.forEach(function(gid){ + var i = MARKED.indexOf(gid) + if(i > -1){ + MARKED.splice(i, 1) + } + }) + updateImages() + return set +} + + +function cropTagged(tags, cmp, keep_ribbons, keep_unloaded_gids){ + cmp = cmp == null ? imageOrderCmp : cmp + var set = selectByTags(tags).sort(cmp) + + cropDataTo(set, keep_ribbons, keep_unloaded_gids) + + return DATA +} + /********************************************************************** diff --git a/ui/ui.js b/ui/ui.js index fbcae805..61831153 100755 --- a/ui/ui.js +++ b/ui/ui.js @@ -1246,7 +1246,7 @@ function showImageInfo(){ } else { data.comment = ncomment } - IMAGES_UPDATED.push(gid) + imageUpdated(gid) } // tags...