From 8e4bbfa9701c035129d65821a675dc721c166ca1 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Tue, 25 Nov 2014 03:34:46 +0300 Subject: [PATCH] added reference support to image.flipImage(..) Signed-off-by: Alex A. Naanou --- ui (gen4)/data.js | 8 ++++++-- ui (gen4)/images.js | 15 +++++++++++---- ui (gen4)/ribbons.js | 7 +++---- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/ui (gen4)/data.js b/ui (gen4)/data.js index 0038a04b..13120ac7 100755 --- a/ui (gen4)/data.js +++ b/ui (gen4)/data.js @@ -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]) diff --git a/ui (gen4)/images.js b/ui (gen4)/images.js index bc1ace03..fb8b06d6 100755 --- a/ui (gen4)/images.js +++ b/ui (gen4)/images.js @@ -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 diff --git a/ui (gen4)/ribbons.js b/ui (gen4)/ribbons.js index 7967b447..0c7e2876 100755 --- a/ui (gen4)/ribbons.js +++ b/ui (gen4)/ribbons.js @@ -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)