mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-30 02:40:08 +00:00
added descriptor support to action's mixin/out methods...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
7b7070c8b1
commit
40dda16421
@ -530,7 +530,11 @@ module.MetaActions = {
|
|||||||
// otherwise only mixin local actions...
|
// otherwise only mixin local actions...
|
||||||
//
|
//
|
||||||
// XXX test
|
// XXX test
|
||||||
mixin: function(from, all, all_attr_types){
|
mixin: function(from, all, descriptors, all_attr_types){
|
||||||
|
// defaults...
|
||||||
|
descriptors = descriptors || true
|
||||||
|
all_attr_types = all_attr_types || false
|
||||||
|
|
||||||
if(all){
|
if(all){
|
||||||
var keys = []
|
var keys = []
|
||||||
for(var k in from){
|
for(var k in from){
|
||||||
@ -542,9 +546,19 @@ module.MetaActions = {
|
|||||||
|
|
||||||
var that = this
|
var that = this
|
||||||
keys.forEach(function(k){
|
keys.forEach(function(k){
|
||||||
var attr = from[k]
|
// properties....
|
||||||
if(all_attr_types || attr instanceof Action){
|
var prop = Object.getOwnPropertyDescriptor(from, k)
|
||||||
that[k] = attr
|
if(descriptors && prop.get != null){
|
||||||
|
// NOTE: so as to be able to delete this on mixout...
|
||||||
|
prop.configurable = true
|
||||||
|
Object.defineProperty(that, k, prop)
|
||||||
|
|
||||||
|
// actions and other attributes...
|
||||||
|
} else {
|
||||||
|
var attr = from[k]
|
||||||
|
if(all_attr_types || attr instanceof Action){
|
||||||
|
that[k] = attr
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -569,6 +583,10 @@ module.MetaActions = {
|
|||||||
// XXX not sure about these...
|
// XXX not sure about these...
|
||||||
// XXX test
|
// XXX test
|
||||||
mixout: function(from, all, all_attr_types){
|
mixout: function(from, all, all_attr_types){
|
||||||
|
// defaults...
|
||||||
|
descriptors = descriptors || true
|
||||||
|
all_attr_types = all_attr_types || false
|
||||||
|
|
||||||
if(all){
|
if(all){
|
||||||
var keys = []
|
var keys = []
|
||||||
for(var k in from){
|
for(var k in from){
|
||||||
@ -581,11 +599,22 @@ module.MetaActions = {
|
|||||||
var locals = Object.keys(this)
|
var locals = Object.keys(this)
|
||||||
var that = this
|
var that = this
|
||||||
keys.forEach(function(k){
|
keys.forEach(function(k){
|
||||||
var attr = from[k]
|
var prop = Object.getOwnPropertyDescriptor(from, k)
|
||||||
if((all_attr_types || attr instanceof Action)
|
|
||||||
// remove only local attrs...
|
// descriptor...
|
||||||
&& locals.indexOf(k) >= 0){
|
if(descriptors && prop.get != null){
|
||||||
delete that[k]
|
if(prop.get === Object.getOwnPropertyDescriptor(that, k).get){
|
||||||
|
delete that[k]
|
||||||
|
}
|
||||||
|
|
||||||
|
// actions and other attrs...
|
||||||
|
} else {
|
||||||
|
var attr = from[k]
|
||||||
|
if((all_attr_types || attr instanceof Action)
|
||||||
|
// remove only local attrs...
|
||||||
|
&& locals.indexOf(k) >= 0){
|
||||||
|
delete that[k]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@ -183,7 +183,7 @@ module.GLOBAL_KEYBOARD = {
|
|||||||
|
|
||||||
B: {
|
B: {
|
||||||
default: 'toggleBookmark',
|
default: 'toggleBookmark',
|
||||||
ctrl: 'toggleTheme',
|
ctrl: 'toggleTheme!',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1163,9 +1163,10 @@ var PartialRibbonsActions = actions.Actions({
|
|||||||
var pl = this.ribbons.getImage(target).prevAll('.image:not(.clone)').length
|
var pl = this.ribbons.getImage(target).prevAll('.image:not(.clone)').length
|
||||||
|
|
||||||
// next/prev available...
|
// next/prev available...
|
||||||
var na = this.data.getImages(target, size/2, 'after').length - 1
|
// NOTE: we subtract 1 to remove the current and make these
|
||||||
var pa = this.data.getImages(target, size/2, 'before').length - 1
|
// compatible with: nl, pl
|
||||||
|
var na = this.data.getImages(target, size, 'after').length - 1
|
||||||
|
var pa = this.data.getImages(target, size, 'before').length - 1
|
||||||
|
|
||||||
// do the update...
|
// do the update...
|
||||||
// loaded more than we need (crop?)...
|
// loaded more than we need (crop?)...
|
||||||
@ -1767,6 +1768,8 @@ module.GlobalStateIndicator = Feature({
|
|||||||
|
|
||||||
//---------------------------------------------------------------------
|
//---------------------------------------------------------------------
|
||||||
|
|
||||||
|
// XXX should we rename this to "select"???
|
||||||
|
|
||||||
// target can be:
|
// target can be:
|
||||||
// 'all'
|
// 'all'
|
||||||
// 'loaded'
|
// 'loaded'
|
||||||
@ -1807,8 +1810,33 @@ function makeTagTogglerAction(tag){
|
|||||||
|
|
||||||
// XXX add image updater...
|
// XXX add image updater...
|
||||||
var ImageMarkActions = actions.Actions({
|
var ImageMarkActions = actions.Actions({
|
||||||
|
|
||||||
|
// NOTE: this will return a copy...
|
||||||
|
get marked(){
|
||||||
|
if(this.data == null
|
||||||
|
|| this.data.tags == null
|
||||||
|
|| !('selected' in this.data.tags)){
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
return this.data.tags['selected'].slice()
|
||||||
|
},
|
||||||
|
|
||||||
|
// Common use-cases:
|
||||||
|
// Toggle mark on current image
|
||||||
|
// .toggleMark()
|
||||||
|
//
|
||||||
|
// Mark current ribbon
|
||||||
|
// .toggleMark('ribbon', 'on')
|
||||||
|
//
|
||||||
|
// Unmark all loaded images
|
||||||
|
// .toggleMark('loaded', 'off')
|
||||||
|
//
|
||||||
|
// Invert marks on current ribbon
|
||||||
|
// .toggleMark('ribbon')
|
||||||
|
//
|
||||||
toggleMark: ['Toggle image mark',
|
toggleMark: ['Toggle image mark',
|
||||||
makeTagTogglerAction('selected')],
|
makeTagTogglerAction('selected')],
|
||||||
|
// XXX
|
||||||
toggleMarkBlock: ['Toggle block marks',
|
toggleMarkBlock: ['Toggle block marks',
|
||||||
'A block is a set of adjacent images either marked on unmarked '
|
'A block is a set of adjacent images either marked on unmarked '
|
||||||
+'in the same way',
|
+'in the same way',
|
||||||
@ -1848,12 +1876,27 @@ module.ImageMarks = Feature({
|
|||||||
tag: 'image-marks',
|
tag: 'image-marks',
|
||||||
|
|
||||||
actions: ImageMarkActions,
|
actions: ImageMarkActions,
|
||||||
|
|
||||||
|
// XXX image update...
|
||||||
|
handlers: [
|
||||||
|
],
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------
|
//---------------------------------------------------------------------
|
||||||
var ImageBookmarkActions = actions.Actions({
|
var ImageBookmarkActions = actions.Actions({
|
||||||
|
|
||||||
|
// NOTE: this will return a copy...
|
||||||
|
get bookmarked(){
|
||||||
|
if(this.data == null
|
||||||
|
|| this.data.tags == null
|
||||||
|
|| !('bookmark' in this.data.tags)){
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
return this.data.tags['bookmark'].slice()
|
||||||
|
},
|
||||||
|
|
||||||
toggleBookmark: ['',
|
toggleBookmark: ['',
|
||||||
makeTagTogglerAction('bookmark')],
|
makeTagTogglerAction('bookmark')],
|
||||||
// action can be:
|
// action can be:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user