added reference support to image.flipImage(..)

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2014-11-25 03:34:46 +03:00
parent d0e2887ec1
commit 8e4bbfa970
3 changed files with 20 additions and 10 deletions

View File

@ -1755,18 +1755,22 @@ var DataPrototype = {
return this
},
// XXX if the group is collapsed there will be problems with uncropping...
// Croup current group...
//
cropGroup: function(target){
var target = this.getImage(target)
var group = this.getGroup(target)
// not a group...
if(group == null){
return
}
if(target == group){
// group is expanded -- all the images we need are loaded...
if(target != group){
var res = this.crop(this.groups[group])
// group collapsed -- need to get the elements manually...
} else {
var r = this.getRibbon(target)
var res = this.crop(this.groups[group])

View File

@ -549,24 +549,31 @@ module.ImagesPrototype = {
// .flipImage(target, 'vertical')
// -> images
//
// XXX add reference support...
flipImage: function(gids, direction, reference){
gids = gids.constructor !== Array ? [gids] : gids
reference = reference || 'image'
reference = reference || 'view'
var that = this
gids.forEach(function(key){
var img = that[key]
var o = img.orientation
var d = direction
// flip relative to
if(reference == 'view' && (o == 90 || o == 270)){
d = d == 'horizontal' ? 'vertical' : 'horizontal'
}
if(img == null){
img = that[key] = {}
}
var state = img.flipped
state = state == null ? [] : state
// toggle the specific state...
var i = state.indexOf(direction)
var i = state.indexOf(d)
if(i >= 0){
state.splice(i, 1)
} else {
state.push(direction)
state.push(d)
}
if(state.length == 0){
delete img.flipped

View File

@ -1619,7 +1619,7 @@ var RibbonsPrototype = {
// it's original orientation by default...
// ...this makes things consistent both visually and internally
flipImage: function(target, direction, reference){
reference = reference || 'image'
reference = reference || 'view'
target = target == null || target.constructor !== Array ? [target] : target
var set_state = direction.constructor === Array ? direction : null
@ -1630,10 +1630,9 @@ var RibbonsPrototype = {
// update existing state...
if(set_state == null){
var d = direction
if(reference == 'view' && [90, 270].indexOf(that.getImageRotation(img)) > -1){
var d = direction == 'vertical' ? 'horizontal' : 'vertical'
} else {
var d = direction
d = direction == 'vertical' ? 'horizontal' : 'vertical'
}
var state = img.attr('flipped')
state = (state == null ? '' : state)