fixed crop bug -- turned out to be a dependency leak in getGIDBefore(...) that got the current ribbon form DOM, implicitly requering DOM and data to be in sync which is conceptually wrong...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2013-09-13 23:13:16 +04:00
parent ab976b256c
commit 62fe751973
2 changed files with 18 additions and 2 deletions

View File

@ -132,6 +132,7 @@ function getRibbon(image){
}
// XXX make this not depend on DOM... a-la getImageBefore vs. getGIDBefore
// NOTE: elem is optional and if given can be an image or a ribbon...
function getRibbonIndex(elem){
if(elem == null){

View File

@ -521,14 +521,29 @@ function normalizePath(url, base, mode){
}
// like getRibbonIndex but get the index only via DATA...
function getDataRibbonIndex(gid, data){
gid = gid == null ? getImageGID() : gid
data = data == null ? DATA : data
for(var i=0; i < data.ribbons.length; i++){
if(data.ribbons[i].indexOf(gid) >= 0){
return i
}
}
return -1
}
// Same as getImageBefore(...), but uses gids and searches in DATA...
//
// NOTE: this uses it's own predicate...
function getGIDBefore(gid, ribbon, search, data){
gid = gid == null ? getImageGID() : gid
ribbon = ribbon == null ? getRibbonIndex() : ribbon
search = search == null ? binSearch : search
data = data == null ? DATA : data
// XXX get a ribbon without getting into DOM...
// ...dependency leek...
ribbon = ribbon == null ? getDataRibbonIndex(gid, data) : ribbon
search = search == null ? binSearch : search
//search = search == null ? match2(linSearch, binSearch) : search
ribbon = data.ribbons[ribbon]
var order = data.order