diff --git a/ui (gen4)/client.js b/ui (gen4)/client.js index e35ef4c1..8a5a60ec 100755 --- a/ui (gen4)/client.js +++ b/ui (gen4)/client.js @@ -34,27 +34,8 @@ var CLIENT_ACTIONS = { focusImage: doc('Focus Image', proxy('data', 'focusImage')), - - // target can be: - // - current - // - base - // - before - // - after - // - // XXX should this be implemented here on in data.js???? focusRibbon: doc('Focus ribbon', - function(target){ - var cur = this.data.getRibbonIndex() - var ribbon = this.data.getRibbon(target) - var t = this.data.getRibbonIndex(ribbon) - - // XXX revise this... - var direction = t < cur ? 'before' : 'after' - - return this.focusImage( - this.data.getImage(ribbon, direction)) - }), - + proxy('data', 'focusRibbon')), firstImage: doc('', proxy('data', 'firstImage')), lastImage: doc('', diff --git a/ui (gen4)/data.js b/ui (gen4)/data.js index 4125b7d3..405e813e 100755 --- a/ui (gen4)/data.js +++ b/ui (gen4)/data.js @@ -650,8 +650,8 @@ module.DataPrototype = { target = target == null ? this.current : target if(target == 'before' || target == 'after'){ - target = this.current offset = target + target = 'current' } offset = offset == null ? 0 : offset @@ -721,6 +721,32 @@ module.DataPrototype = { return this }, + focusRibbon: function(target){ + var cur = this.getRibbonOrder() + var ribbon = this.getRibbon(target) + + // nothing to do... + if(target == null || ribbon == null){ + return this + } + + var t = this.getRibbonOrder(ribbon) + + // XXX revise this... + var direction = t < cur ? 'before' : 'after' + + var img = this.getImage(ribbon, direction) + + if(img == null){ + img = direction == 'before' + ? this.getImage('first', ribbon) + : this.getImage('last', ribbon) + } + + return this.focusImage(img) + }, + + // Shorthand methods... // // XXX should these be here??? diff --git a/ui (gen4)/testing.js b/ui (gen4)/testing.js index 6e02f109..33814191 100755 --- a/ui (gen4)/testing.js +++ b/ui (gen4)/testing.js @@ -47,7 +47,7 @@ module.mock_data = { }, } Object.keys(mock_data.ribbons).forEach(function(k){ - mock_data.order = mock_data.order.concat(mock_data.order[k]) + mock_data.order = mock_data.order.concat(mock_data.ribbons[k]) }) var test_data =