From 0ce58772ee533bb512e5c39fa74798cc360e315e Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Sat, 22 Mar 2014 18:10:22 +0400 Subject: [PATCH] added more shorthand methods... Signed-off-by: Alex A. Naanou --- ui/data4.js | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/ui/data4.js b/ui/data4.js index bbcd6574..16e78037 100755 --- a/ui/data4.js +++ b/ui/data4.js @@ -647,6 +647,23 @@ var DataPrototype = { return this }, + // Shorthand methods... + // + // XXX should these be here??? + focusImageOffset: function(offset){ + return this.focusImage('current', offset) + }, + nextImage: function(){ return this.focusImageOffset(1) }, + prevImage: function(){ return this.focusImageOffset(-1) }, + focusRibbonOffset: function(offset){ + var c = this.getRibbonOrder() + var t = c+offset + t = Math.max(0, Math.min(this.ribbon_order.length-1, t)) + return this.focusImage('current', (t < c ? 'after' : 'before'), t) + }, + nextRibbon: function(){ return this.focusRibbonOffset(1) }, + prevRibbon: function(){ return this.focusRibbonOffset(-1) }, + // Set base ribbon... // // This is signature compatible with .getRibbon(..), see it for more @@ -788,8 +805,7 @@ var DataPrototype = { // normalize the target... // XXX is this the correct way to go??? - target = Math.max(0, target) - target = Math.min(this.ribbon_order.length-1, target) + target = Math.max(0, Math.min(this.ribbon_order.length-1, target) var ribbon = this.ribbon_order[target] @@ -845,7 +861,7 @@ var DataPrototype = { // // NOTE: shiftImageUp/shiftImageDown will create new ribbons when // shifting from first/last ribbons respectively. - // NOTE: non of these change .current + // NOTE: none of these change .current // // XXX should this be here?? shiftImageLeft: function(gid){ return this.shiftImage(gid, -1, 'offset') },