minor bugfix...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2014-06-01 17:35:38 +04:00
parent 0515cf6fca
commit 60e7b695a7
3 changed files with 8 additions and 5 deletions

View File

@ -2275,6 +2275,7 @@ function setupData(viewer){
.on([ .on([
// ribbons.js API... // ribbons.js API...
'shiftedImage', 'shiftedImage',
'shiftedImages',
'createdRibbon', 'createdRibbon',
'removedRibbon', 'removedRibbon',
].join(' '), function(){ ].join(' '), function(){

View File

@ -286,6 +286,7 @@ var DataPrototype = {
// -> gid // -> gid
// -> null // -> null
// NOTE: null is returned if there is no image at given offset. // NOTE: null is returned if there is no image at given offset.
// NOTE: offset is calculated within the same ribbon...
// //
// //
// NOTE: If gid|order is not given, current image is assumed. // NOTE: If gid|order is not given, current image is assumed.
@ -366,11 +367,11 @@ var DataPrototype = {
mode = offset < 0 ? 'before' mode = offset < 0 ? 'before'
: offset > 0 ? 'after' : offset > 0 ? 'after'
: mode : mode
offset = Math.abs(offset)
} else { } else {
var offset = 0 var offset = 0
mode = mode == null ? 'before' : mode mode = mode == null ? 'before' : mode
} }
offset = Math.abs(offset)
var i = this.order.indexOf(target) var i = this.order.indexOf(target)
@ -814,7 +815,7 @@ var DataPrototype = {
// //
// order is expected to be ribbon order. // order is expected to be ribbon order.
// //
// from must be: // from must be one of:
// - a .getImage(..) compatible object. usually an image gid, order, // - a .getImage(..) compatible object. usually an image gid, order,
// or null, see .getImage(..) for more info. // or null, see .getImage(..) for more info.
// - a list of .getImage(..) compatible objects. // - a list of .getImage(..) compatible objects.
@ -835,7 +836,6 @@ var DataPrototype = {
// XXX when shifting groups of images we are using the first as a // XXX when shifting groups of images we are using the first as a
// base, should we use last as a base for right shifting??? // base, should we use last as a base for right shifting???
// ...another way to go could be using current as a reference // ...another way to go could be using current as a reference
// XXX process from as a list of gids...
// XXX test vertical.. // XXX test vertical..
shiftImage: function(from, target, mode){ shiftImage: function(from, target, mode){
from = from == null ? this.current : from from = from == null ? this.current : from
@ -850,7 +850,6 @@ var DataPrototype = {
// target is an offset... // target is an offset...
if(mode == 'offset'){ if(mode == 'offset'){
// XXX change check this...
// XXX check that we can place an elem at first and last positions... // XXX check that we can place an elem at first and last positions...
var t = this.getImageOrder(this.getImage(first, target)) var t = this.getImageOrder(this.getImage(first, target))
@ -922,7 +921,7 @@ var DataPrototype = {
// shifting from first/last ribbons respectively. // shifting from first/last ribbons respectively.
// NOTE: none of these change .current // NOTE: none of these change .current
// //
// XXX should this be here?? // XXX should these be here??
shiftImageLeft: function(gid){ return this.shiftImage(gid, -1, 'offset') }, shiftImageLeft: function(gid){ return this.shiftImage(gid, -1, 'offset') },
shiftImageRight: function(gid){ return this.shiftImage(gid, 1, 'offset') }, shiftImageRight: function(gid){ return this.shiftImage(gid, 1, 'offset') },
// XXX test... // XXX test...
@ -984,6 +983,7 @@ var DataPrototype = {
// Shorthand actions... // Shorthand actions...
// //
// XXX should these be here??
shiftRibbonUp: function(gid){ return this.shiftRibbon(gid, -1, 'offset') }, shiftRibbonUp: function(gid){ return this.shiftRibbon(gid, -1, 'offset') },
shiftRibbonDown: function(gid){ return this.shiftRibbon(gid, 1, 'offset') }, shiftRibbonDown: function(gid){ return this.shiftRibbon(gid, 1, 'offset') },

View File

@ -602,6 +602,8 @@ function shiftMarkedImages(direction, mode, new_ribbon){
DATA.ribbons[cur] = fastSortGIDsByOrder(DATA.ribbons[cur].concat(marked)) DATA.ribbons[cur] = fastSortGIDsByOrder(DATA.ribbons[cur].concat(marked))
} }
dataUpdated()
// remove empty ribbons and reload... // remove empty ribbons and reload...
dropEmptyRibbons() dropEmptyRibbons()
reloadViewer() reloadViewer()