mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-30 10:50:08 +00:00
refactoring...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
ebf92c5acf
commit
ec490e56e9
@ -80,7 +80,6 @@ function(attr, states, callback){
|
|||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
|
|
||||||
// XXX split this into read and write actions...
|
// XXX split this into read and write actions...
|
||||||
// XXX check if align by position is relevant here...
|
|
||||||
var BaseActions =
|
var BaseActions =
|
||||||
module.BaseActions =
|
module.BaseActions =
|
||||||
actions.Actions({
|
actions.Actions({
|
||||||
@ -239,12 +238,7 @@ actions.Actions({
|
|||||||
function(mode){
|
function(mode){
|
||||||
var res = {}
|
var res = {}
|
||||||
for(var k in this){
|
for(var k in this){
|
||||||
// dump the base crop state...
|
if(this[k] != null && this[k].dumpJSON != null){
|
||||||
if(k == 'data' && this.crop_stack && this.crop_stack.length > 0){
|
|
||||||
res[k] = this.crop_stack[0].dumpJSON()
|
|
||||||
|
|
||||||
// dump current state...
|
|
||||||
} else if(this[k] != null && this[k].dumpJSON != null){
|
|
||||||
res[k] = this[k].dumpJSON()
|
res[k] = this[k].dumpJSON()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -551,8 +545,25 @@ actions.Actions({
|
|||||||
function(target){
|
function(target){
|
||||||
this.images
|
this.images
|
||||||
&& this.images.flipImage(this.data.getImage(target), 'horizontal') }],
|
&& this.images.flipImage(this.data.getImage(target), 'horizontal') }],
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
var Base =
|
||||||
|
module.Base = core.ImageGridFeatures.Feature({
|
||||||
|
title: 'ImageGrid base',
|
||||||
|
|
||||||
|
tag: 'base',
|
||||||
|
|
||||||
|
actions: BaseActions,
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------
|
||||||
|
// Tags...
|
||||||
|
|
||||||
|
var TagsActions =
|
||||||
|
module.TagsActions = actions.Actions({
|
||||||
// tags...
|
// tags...
|
||||||
//
|
//
|
||||||
// XXX mark updated...
|
// XXX mark updated...
|
||||||
@ -651,8 +662,68 @@ actions.Actions({
|
|||||||
this.data.tagsFromImages(images, mode)
|
this.data.tagsFromImages(images, mode)
|
||||||
}
|
}
|
||||||
}],
|
}],
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
var Tags =
|
||||||
|
module.Tags = core.ImageGridFeatures.Feature({
|
||||||
|
title: '',
|
||||||
|
|
||||||
|
tag: 'tags',
|
||||||
|
depends: [
|
||||||
|
'base',
|
||||||
|
],
|
||||||
|
|
||||||
|
actions: TagsActions,
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------
|
||||||
|
// Crop...
|
||||||
|
|
||||||
|
var CropActions =
|
||||||
|
module.CropActions = actions.Actions({
|
||||||
|
|
||||||
|
crop_stack: null,
|
||||||
|
|
||||||
|
// load the crop stack if present...
|
||||||
|
load: [function(data){
|
||||||
|
if(data.crop_stack){
|
||||||
|
this.crop_stack = data.crop_stack.map(function(j){
|
||||||
|
return data.Data(j)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}],
|
||||||
|
|
||||||
|
// store the root crop state instead of the current view...
|
||||||
|
//
|
||||||
|
// modes supported:
|
||||||
|
// - current - store the current state/view
|
||||||
|
// - base - store the base state/view
|
||||||
|
// - full - store the crop stack
|
||||||
|
//
|
||||||
|
// XXX might need to revise the mode approach...
|
||||||
|
// XXX add support to loading the states...
|
||||||
|
json: [function(mode){
|
||||||
|
mode = mode || 'current'
|
||||||
|
|
||||||
|
return function(res){
|
||||||
|
if(mode == 'base'
|
||||||
|
&& this.crop_stack
|
||||||
|
&& this.crop_stack.length > 0){
|
||||||
|
res.data = this.crop_stack[0].dumpJSON()
|
||||||
|
}
|
||||||
|
if(mode == 'full'
|
||||||
|
&& this.crop_stack
|
||||||
|
&& this.crop_stack.length > 0){
|
||||||
|
res.crop_stack = this.crop_stack.map(function(c){
|
||||||
|
return c.dumpJSON()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}],
|
||||||
|
|
||||||
// crop...
|
// crop...
|
||||||
//
|
//
|
||||||
crop: ['- Crop/Crop image list',
|
crop: ['- Crop/Crop image list',
|
||||||
@ -762,8 +833,28 @@ actions.Actions({
|
|||||||
var selector = mode == 'any' ? 'getTaggedByAny' : 'getTaggedByAll'
|
var selector = mode == 'any' ? 'getTaggedByAny' : 'getTaggedByAll'
|
||||||
this.crop(this.data[selector](tags), flatten)
|
this.crop(this.data[selector](tags), flatten)
|
||||||
}],
|
}],
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
var Crop =
|
||||||
|
module.Crop = core.ImageGridFeatures.Feature({
|
||||||
|
title: '',
|
||||||
|
|
||||||
|
tag: 'crop',
|
||||||
|
depends: [
|
||||||
|
'base',
|
||||||
|
],
|
||||||
|
|
||||||
|
actions: CropActions,
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------
|
||||||
|
// Image Group...
|
||||||
|
|
||||||
|
var ImageGroupActions =
|
||||||
|
module.ImageGroupActions = actions.Actions({
|
||||||
// grouping...
|
// grouping...
|
||||||
// XXX need to tell .images about this...
|
// XXX need to tell .images about this...
|
||||||
group: ['- Group|Edit/Group images',
|
group: ['- Group|Edit/Group images',
|
||||||
@ -813,17 +904,32 @@ actions.Actions({
|
|||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
var Base =
|
var ImageGroup =
|
||||||
module.Base = core.ImageGridFeatures.Feature({
|
module.ImageGroup = core.ImageGridFeatures.Feature({
|
||||||
title: 'ImageGrid base',
|
title: '',
|
||||||
|
|
||||||
tag: 'base',
|
tag: 'image-group',
|
||||||
|
depends: [
|
||||||
|
'base',
|
||||||
|
],
|
||||||
|
|
||||||
actions: BaseActions,
|
actions: ImageGroupActions,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------
|
||||||
|
// Meta base features...
|
||||||
|
|
||||||
|
// full features base...
|
||||||
|
core.ImageGridFeatures.Feature('base-full', [
|
||||||
|
'base',
|
||||||
|
'tags',
|
||||||
|
'crop',
|
||||||
|
'image-group',
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* vim:set ts=4 sw=4 : */
|
* vim:set ts=4 sw=4 : */
|
||||||
|
|||||||
@ -27,7 +27,7 @@ var core = require('features/core')
|
|||||||
|
|
||||||
core.ImageGridFeatures.Feature('viewer-testing', [
|
core.ImageGridFeatures.Feature('viewer-testing', [
|
||||||
'lifecycle',
|
'lifecycle',
|
||||||
'base',
|
'base-full',
|
||||||
'ui',
|
'ui',
|
||||||
|
|
||||||
// features...
|
// features...
|
||||||
|
|||||||
@ -101,6 +101,7 @@ module.FeatureProto = {
|
|||||||
|
|
||||||
// merge config...
|
// merge config...
|
||||||
// XXX should this use inheritance???
|
// XXX should this use inheritance???
|
||||||
|
// XXX do we need to clone .config?
|
||||||
if(this.config != null
|
if(this.config != null
|
||||||
|| (this.actions != null
|
|| (this.actions != null
|
||||||
&& this.actions.config != null)){
|
&& this.actions.config != null)){
|
||||||
@ -110,12 +111,6 @@ module.FeatureProto = {
|
|||||||
actions.config = {}
|
actions.config = {}
|
||||||
}
|
}
|
||||||
Object.keys(config).forEach(function(n){
|
Object.keys(config).forEach(function(n){
|
||||||
/*
|
|
||||||
// keep existing keys...
|
|
||||||
if(actions.config[n] === undefined){
|
|
||||||
actions.config[n] = config[n]
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
// NOTE: this will overwrite existing values...
|
// NOTE: this will overwrite existing values...
|
||||||
actions.config[n] = config[n]
|
actions.config[n] = config[n]
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user