fixed bug -- now marks/tags/bookmarks are maintained in correct order while shifting images left/right...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2014-01-15 06:19:21 +04:00
parent a402e4671a
commit 6869baef54
6 changed files with 57 additions and 6 deletions

View File

@ -162,6 +162,11 @@ function setupBookmarks(viewer){
BOOKMARKS = fastSortGIDsByOrder(BOOKMARKS) BOOKMARKS = fastSortGIDsByOrder(BOOKMARKS)
bookmarksUpdated() bookmarksUpdated()
}) })
.on('horizontalShiftedImage', function(evt, gid, direction){
if(shiftGIDToOrderInList(gid, direction, BOOKMARKS)){
bookmarksUpdated()
}
})
} }
SETUP_BINDINGS.push(setupBookmarks) SETUP_BINDINGS.push(setupBookmarks)

View File

@ -1230,11 +1230,11 @@ button:hover {
} }
.small.viewer:not(.single-image-mode) .mark:after, .small.viewer:not(.single-image-mode) .mark:after,
.small.viewer:not(.single-image-mode) .marked.image:after { .small.viewer:not(.single-image-mode) .marked.image:after {
-webkit-transform: rotate(0deg) scaleY(1.8) scaleX(1.8); -webkit-transform: rotate(0deg) scaleY(1.5) scaleX(1.5);
-moz-transform: rotate(0deg) scaleY(1.8) scaleX(1.8); -moz-transform: rotate(0deg) scaleY(1.5) scaleX(1.5);
-o-transform: rotate(0deg) scaleY(1.8) scaleX(1.8); -o-transform: rotate(0deg) scaleY(1.5) scaleX(1.5);
-ms-transform: rotate(0deg) scaleY(1.8) scaleX(1.8); -ms-transform: rotate(0deg) scaleY(1.5) scaleX(1.5);
transform: rotate(0deg) scaleY(1.8) scaleX(1.8); transform: rotate(0deg) scaleY(1.5) scaleX(1.5);
} }
/********************************************************* Overlay ***/ /********************************************************* Overlay ***/
.overlay-block { .overlay-block {

View File

@ -1283,7 +1283,7 @@ button:hover {
.small.viewer:not(.single-image-mode) .mark:after, .small.viewer:not(.single-image-mode) .mark:after,
.small.viewer:not(.single-image-mode) .marked.image:after { .small.viewer:not(.single-image-mode) .marked.image:after {
.scale(1.8); .scale(1.5);
} }

View File

@ -728,6 +728,12 @@ function makeDeferredsQ(first){
/**************************************************** JS utilities ***/ /**************************************************** JS utilities ***/
// return 1, -1, or 0 depending on sign of x
function sign(x){
return (x > 0) - (x < 0)
}
String.prototype.capitalize = function(){ String.prototype.capitalize = function(){
return this[0].toUpperCase() + this.slice(1) return this[0].toUpperCase() + this.slice(1)
} }

View File

@ -235,6 +235,30 @@ function makeMarkUpdater(img_class, mark_class, test){
} }
// NOTE: this supports only shifts by one position...
function shiftGIDToOrderInList(gid, direction, list){
var gid_o = DATA.order.indexOf(gid)
var gid_m = list.indexOf(gid)
var a_m = gid_m + (direction == 'next' ? 1 : -1)
if(a_m < 0 || a_m >= list.length){
return false
}
var a_gid = list[a_m]
var a_o = DATA.order.indexOf(a_gid)
// if relative positions of cur and adjacent gids in list
// are different to that in DATA.order, then replace the gids
// in list...
if(sign(a_m - gid_m) != sign(a_o - gid_o)){
list[a_m] = gid
list[gid_m] = a_gid
return true
}
return false
}
/********************************************************************** /**********************************************************************
* *
@ -742,6 +766,11 @@ function setupMarks(viewer){
MARKED = fastSortGIDsByOrder(MARKED) MARKED = fastSortGIDsByOrder(MARKED)
marksUpdated() marksUpdated()
}) })
.on('horizontalShiftedImage', function(evt, gid, direction){
if(shiftGIDToOrderInList(gid, direction, MARKED)){
marksUpdated()
}
})
.on('baseURLChanged', function(){ .on('baseURLChanged', function(){
invalidateMarksCache() invalidateMarksCache()
}) })

View File

@ -537,6 +537,17 @@ function setupUnsortedTagHandler(viewer){
} }
tagsUpdated() tagsUpdated()
}) })
.on('horizontalShiftedImage', function(evt, gid, direction){
var updated = false
for(var tag in TAGS){
if(TAGS[tag].indexOf(gid) >= 0){
updated = shiftGIDToOrderInList(gid, direction, TAGS[tag])
}
}
if(updated){
tagsUpdated()
}
})
} }
SETUP_BINDINGS.push(setupUnsortedTagHandler) SETUP_BINDINGS.push(setupUnsortedTagHandler)