mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-12-17 08:41:40 +00:00
added feature applicability test...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
96a2eab041
commit
67b7d2f6a6
@ -215,6 +215,7 @@ $(function(){
|
||||
'ui-partial-ribbons',
|
||||
'ui-ribbon-align-to-order',
|
||||
'ui-single-image-view',
|
||||
'fs-loader',
|
||||
|
||||
// ui elements...
|
||||
'image-marks',
|
||||
|
||||
@ -1185,6 +1185,10 @@ var FeatureProto =
|
||||
module.FeatureProto = {
|
||||
tag: null,
|
||||
|
||||
isApplicable: function(actions){
|
||||
return true
|
||||
},
|
||||
|
||||
getPriority: function(){
|
||||
var res = this.priority || 0
|
||||
return res == 'high' ? 99
|
||||
@ -1282,10 +1286,9 @@ Feature.prototype.constructor = Feature
|
||||
// XXX if this works out might be a good idea to organize everything as
|
||||
// a feature... including the Client and Viewer
|
||||
// ...needs more thought...
|
||||
// XXX add a standard doc set...
|
||||
var FeatureSet =
|
||||
module.FeatureSet = {
|
||||
buildFeatureList: function(lst){
|
||||
buildFeatureList: function(obj, lst){
|
||||
lst = lst.constructor !== Array ? [lst] : lst
|
||||
|
||||
var that = this
|
||||
@ -1298,12 +1301,25 @@ module.FeatureSet = {
|
||||
})
|
||||
|
||||
// sort features via dependencies...
|
||||
var unapplicable = []
|
||||
var conflicts = {}
|
||||
lst = lst.filter(function(n, i){
|
||||
var e = that[n]
|
||||
if(e == null || e.depends == null ){
|
||||
if(e == null){
|
||||
return true
|
||||
}
|
||||
|
||||
// check applicability...
|
||||
if(!e.isApplicable(obj)){
|
||||
unapplicable.push(n)
|
||||
return false
|
||||
}
|
||||
|
||||
// no dependencies...
|
||||
if(e.depends == null ){
|
||||
return true
|
||||
}
|
||||
|
||||
// keep only conflicting...
|
||||
var deps = e.depends.filter(function(dep){
|
||||
dep = lst.indexOf(dep)
|
||||
@ -1350,13 +1366,14 @@ module.FeatureSet = {
|
||||
return {
|
||||
features: lst,
|
||||
excluded: excluded,
|
||||
conflicts: conflicts
|
||||
conflicts: conflicts,
|
||||
unapplicable: unapplicable,
|
||||
}
|
||||
},
|
||||
|
||||
setup: function(obj, lst){
|
||||
lst = lst.constructor !== Array ? [lst] : lst
|
||||
var features = this.buildFeatureList(lst)
|
||||
var features = this.buildFeatureList(obj, lst)
|
||||
lst = features.features
|
||||
|
||||
// check for conflicts...
|
||||
@ -1377,6 +1394,12 @@ module.FeatureSet = {
|
||||
features.excluded.join(', '))
|
||||
}
|
||||
|
||||
// report unapplicable features...
|
||||
if(features.unapplicable.length > 0){
|
||||
console.log('Features not applicable in current context:',
|
||||
features.unapplicable.join(', '))
|
||||
}
|
||||
|
||||
// do the setup...
|
||||
var that = this
|
||||
var setup = FeatureProto.setup
|
||||
@ -2434,6 +2457,21 @@ module.ImageBookmarks = Feature({
|
||||
|
||||
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
var FileSystemLoader =
|
||||
module.FileSystemLoader = Feature({
|
||||
title: '',
|
||||
doc: '',
|
||||
|
||||
tag: 'fs-loader',
|
||||
|
||||
isApplicable: function(){
|
||||
return window.nodejs != null
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* vim:set ts=4 sw=4 : */
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user