diff --git a/ui (gen4)/features/all.js b/ui (gen4)/features/all.js index 02b7ae29..0e44d680 100755 --- a/ui (gen4)/features/all.js +++ b/ui (gen4)/features/all.js @@ -11,6 +11,7 @@ var core = require('features/core') require('features/base') +require('features/collections') require('features/sort') require('features/tags') require('features/marks') diff --git a/ui (gen4)/features/collections.js b/ui (gen4)/features/collections.js new file mode 100755 index 00000000..ac224fc6 --- /dev/null +++ b/ui (gen4)/features/collections.js @@ -0,0 +1,122 @@ +/********************************************************************** +* +* +* +**********************************************************************/ +((typeof define)[0]=='u'?function(f){module.exports=f(require)}:define) +(function(require){ var module={} // make module AMD/node compatible... +/*********************************************************************/ + +var actions = require('lib/actions') +var features = require('lib/features') + +var core = require('features/core') + + + +/*********************************************************************/ + +// XXX things we need to do to collections: +// - add images from current state +// - remove images (from collection) +// - check what collections is image in... +var CollectionActions = actions.Actions({ + + collections: null, + + get collection(){ + return this.location.collection }, + + + // XXX might be a good idea to make collection loading part of the + // .load(..) protocol... + // ...this could be done via a url suffix, as a shorthand. + // something like: + // /path/to/index:collection + // -> /path/to/index/sub/path/.ImageGrid/collections/collection + // XXX loading collections by direct path would require us to look + // in the containing index for missing parts (*images.json, ...) + // XXX saving a local collection would require us to save to two + // locations: + // - collection specific stuff (data) to collection path + // - global stuff (images, tags, ...) to base index... + // XXX need to .reload() here... + loadCollection: ['-Collections/', + function(collection){ + if(collection == null + || this.collections == null + || !(collection in this.collections)){ + return + } + + this.crop(this.collections[collection].data) + + // XXX need to clear this when exiting crop... + this.location.collection = collection + }], + saveCollection: ['- Collections/Save collection', + core.doc`Save current state to collection`, + function(collection){ + collection = collection || this.location.collection + + // XXX should there be a default??? + if(collection == null){ + return + } + + var collections = this.collections = this.collections || {} + + collections[collection] = { + title: collection, + + data: this.data.clone(), + } + }], + + + inCollections: ['- Image/', + core.doc`Get list of collections containing item`, + function(gid){ + }], + toCollection: ['- Collections/', + core.doc`Add items to collection`, + function(gids, collection){ + var that = this + + gids = gids instanceof Array ? gids : [gids] + gids = gids + .map(function(gid){ + return gid in that.data.ribbons ? + // when adding a ribbon gid expand to images... + that.data.ribbons[gid].compact() + : [gid] }) + .reduce(function(a, b){ return a.concat(b) }, []) + + console.log('>>>', gids) + + // XXX + }], + + +}) + +var Collection = +module.Collection = core.ImageGridFeatures.Feature({ + title: '', + doc: '', + + tag: 'collections', + depends: [ + 'base', + 'crop', + ], + + actions: CollectionActions, + + handlers: [], +}) + + + +/********************************************************************** +* vim:set ts=4 sw=4 : */ return module }) diff --git a/ui (gen4)/features/meta.js b/ui (gen4)/features/meta.js index 8e925d88..52bcc5ab 100755 --- a/ui (gen4)/features/meta.js +++ b/ui (gen4)/features/meta.js @@ -33,6 +33,7 @@ core.ImageGridFeatures.Feature('viewer-commandline', [ core.ImageGridFeatures.Feature('viewer-minimal', [ 'lifecycle', 'base-full', + 'collections', 'peer',