some refactoring and fixes...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2014-03-22 17:58:13 +04:00
parent ba266f594b
commit cee7ebb590

View File

@ -661,18 +661,18 @@ var DataPrototype = {
// Create empty ribbon... // Create empty ribbon...
// //
// XXX above/below/at... // If mode is 'below' this will create a new ribbon below the target,
// XXX do we remove ribbons and how... // otherwise the new ribbon will be created above.
// XXX test
newRibbon: function(target, mode){ newRibbon: function(target, mode){
var gid = this.newGid('R') var gid = this.newGid('R')
var i = this.getRibbonOrder(target) var i = this.getRibbonOrder(target)
i = mode == 'below' ? i+1 : i
this.ribbon_order.splice(i, 0, gid) this.ribbon_order.splice(i, 0, gid)
this.ribbons[gid] = [] this.ribbons[gid] = []
// XXX should we return this or gid??? return gid
return this
}, },
// Merge ribbons // Merge ribbons
@ -789,7 +789,7 @@ var DataPrototype = {
// normalize the target... // normalize the target...
// XXX is this the correct way to go??? // XXX is this the correct way to go???
target = Math.max(0, target) target = Math.max(0, target)
target = Math.min(this.ribbon_order-1, target) target = Math.min(this.ribbon_order.length-1, target)
var ribbon = this.ribbon_order[target] var ribbon = this.ribbon_order[target]
@ -841,11 +841,29 @@ var DataPrototype = {
return this return this
}, },
// XXX shorthand actions... // Shorthand actions...
shiftImageUp: function(gid){ return this.shiftImage(gid, this.getRibbonIndex(gid)-1) }, //
shiftImageDown: function(gid){ return this.shiftImage(gid, this.getRibbonIndex(gid)+1) }, // NOTE: shiftImageUp/shiftImageDown will create new ribbons when
// shifting from first/last ribbons respectively.
// NOTE: non of these change .current
//
// XXX should this 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') },
shiftImageUp: function(gid){
// check if we need to create a ribbon here...
if(this.getRibbonOrder(gid) == 0){
this.newRibbon(gid)
}
return this.shiftImage(gid, this.getRibbonOrder(gid)-1)
},
shiftImageDown: function(gid){
// check if we need to create a ribbon here...
if(this.getRibbonOrder(gid) == this.ribbon_order.length-1){
this.newRibbon(gid, 'below')
}
return this.shiftImage(gid, this.getRibbonOrder(gid)+1)
},