added meta-features...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2014-12-09 16:34:14 +03:00
parent 88e6bd6c5b
commit 61791ebb1d
3 changed files with 94 additions and 24 deletions

View File

@ -28,6 +28,10 @@ console.log('>>> features')
// features with higher priority will be setup first,
// features with the same priority will be run in order of
// occurrence.
// .suggested - list of optional suggested features, these are not
// required but setup if available.
// This is useful for defining meta features but without
// making each sub-feature a strict dependency.
// .depends - feature dependencies -- tags of features that must setup
// before the feature (list | null)
// .exclusive - feature exclusivity tags (list | null)
@ -148,6 +152,9 @@ function Feature(feature_set, obj){
obj = feature_set
// XXX is this a good default???
feature_set = Features
} else if(feature_set == null){
feature_set = Features
}
obj.__proto__ = FeatureProto
@ -162,6 +169,20 @@ Feature.prototype = FeatureProto
Feature.prototype.constructor = Feature
var MetaFeature
module.MetaFeature = function(feature_set, tag, list){
if(list == null){
list = tag
tag = feature_set
feature_set = null
}
return Feature(feature_set, {
tag: tag,
suggested: list,
})
}
var FeatureSet =
module.FeatureSet = {
// Build feature list...
@ -267,6 +288,17 @@ module.FeatureSet = {
return res
}
// expand optional "suggested" features...
var res = []
lst.forEach(function(n){
var e = that[n]
if(e != null && e.suggested != null){
res = res.concat(e.suggested)
}
res.push(n)
})
lst = res
// expand and sort dependencies...
// 2+ times untill depth is 0 or length stabelizes...
var missing = {}

View File

@ -212,30 +212,7 @@ $(function(){
a.setEmptyMsg('Loading...')
viewer.ImageGridFeatures.setup(a, [
// features...
'ui-ribbon-align-to-order',
'ui-single-image-view',
'ui-partial-ribbons',
'image-marks',
'image-bookmarks',
'fs-loader',
'app-control',
// chrome...
'ui-animation',
'ui-bounds-indicators',
'ui-current-image-indicator',
// NOTE: only one of these can be set...
'ui-current-image-indicator-hide-on-fast-screen-nav',
//'ui-current-image-indicator-hide-on-screen-nav',
'ui-image-state-indicator',
'ui-global-state-indicator',
// experimental and optional features...
//'auto-single-image',
'viewer-testing',
// XXX this is not for production...
'experiments',

View File

@ -2379,6 +2379,67 @@ module.FileSystemLoader = features.Feature(ImageGridFeatures, {
//---------------------------------------------------------------------
// Meta features...
//
// XXX need to make a set of basic configurations:
// - commandline - everything but no UI
// - viewer-minimal - basic browser compatible viewer
// - viewer - full viewer
// - editor - editing capability
//
features.MetaFeature(ImageGridFeatures, 'viewer-testing', [
// features...
'ui-ribbon-align-to-order',
'ui-single-image-view',
'ui-partial-ribbons',
'image-marks',
'image-bookmarks',
'fs-loader',
'app-control',
// chrome...
'ui-animation',
'ui-bounds-indicators',
'ui-current-image-indicator',
// NOTE: only one of these can be set...
'ui-current-image-indicator-hide-on-fast-screen-nav',
//'ui-current-image-indicator-hide-on-screen-nav',
'ui-image-state-indicator',
'ui-global-state-indicator',
// experimental and optional features...
//'auto-single-image',
])
features.MetaFeature(ImageGridFeatures, 'commandline', [
'image-marks',
'image-bookmarks',
])
features.MetaFeature(ImageGridFeatures, 'viewer-minimal', [
'ui-ribbon-align-to-order',
'ui-animation',
'ui-bounds-indicators',
'ui-current-image-indicator',
'ui-current-image-indicator-hide-on-fast-screen-nav',
//'ui-current-image-indicator-hide-on-screen-nav',
])
features.MetaFeature(ImageGridFeatures, 'viewer', [
'viewer-minimal',
])
features.MetaFeature(ImageGridFeatures, 'viewer-partial', [
'viewer',
'ui-partial-ribbons',
])
//---------------------------------------------------------------------
var ExperimentActions = actions.Actions({