mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 10:20:08 +00:00
some changes to client.js and added .focusRibbon(..) to data.js
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
9b2f6e39b0
commit
cf6273fbe4
@ -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('',
|
||||
|
||||
@ -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???
|
||||
|
||||
@ -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 =
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user