added ability to disable features...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2016-05-11 05:00:40 +03:00
parent 8009e55246
commit df378430c1
7 changed files with 41 additions and 3 deletions

View File

@ -123,6 +123,8 @@ core.ImageGridFeatures.Feature('viewer-testing', [
'fail-safe-devtools', 'fail-safe-devtools',
'-experiments',
]) ])
/* /*

View File

@ -474,6 +474,7 @@ module.SortUI = core.ImageGridFeatures.Feature({
tag: 'ui-sort', tag: 'ui-sort',
depends: [ depends: [
'ui', 'ui',
'sort',
], ],
actions: SortUIActions, actions: SortUIActions,

View File

@ -1922,7 +1922,9 @@ var ControlActions = actions.Actions({
// on... // on...
if(state == 'on'){ if(state == 'on'){
this.off('updateRibbon', handler)
this.on('updateRibbon', handler) this.on('updateRibbon', handler)
this.data.ribbon_order.forEach(function(gid){ this.data.ribbon_order.forEach(function(gid){
handler.call(that, null, gid) handler.call(that, null, gid)
}) })

View File

@ -710,7 +710,7 @@ module.MetaActions = {
mode = mode[1] mode = mode[1]
// get the handlers... // get the handlers...
var h = that._action_handlers[action] var h = that._action_handlers[action] || []
// remove explicit handler... // remove explicit handler...
if(typeof(handler) == 'function'){ if(typeof(handler) == 'function'){

View File

@ -47,6 +47,9 @@ var actions = require('lib/actions')
// and mixed out on .remove() // and mixed out on .remove()
// .config - feature configuration, will be merged with base // .config - feature configuration, will be merged with base
// object's .config // object's .config
// NOTE: the final .config is an empty object with
// .__proto__ set to the merged configuration
// data...
// .handlers - feature event handlers (list | null) // .handlers - feature event handlers (list | null)
// //
// //
@ -273,6 +276,14 @@ module.FeatureSet = {
// breaking either the dependency or priority ordering. // breaking either the dependency or priority ordering.
// //
// //
// Forcing a feature disabled:
//
// If a feature is indicated with a leading '-' then it is forced
// disabled and will not load.
// Disabled features are treated in the same way as inaplicable
// features.
//
//
// Dependency sorting: // Dependency sorting:
// //
// These are order dependencies, i.e. for a dependency to be // These are order dependencies, i.e. for a dependency to be
@ -451,6 +462,15 @@ module.FeatureSet = {
// NOTE: this will not resolve all the conflicts... // NOTE: this will not resolve all the conflicts...
lst = _sortDep(lst, missing, depth).unique() lst = _sortDep(lst, missing, depth).unique()
// get disabled features...
var disabled = []
Object.keys(missing).forEach(function(n){
if(n[0] == '-'){
delete missing[n]
disabled.push(n.slice(1))
}
})
// clasify features... // clasify features...
var unapplicable = [] var unapplicable = []
var conflicts = {} var conflicts = {}
@ -461,6 +481,11 @@ module.FeatureSet = {
return true return true
} }
// disabled...
if(disabled.indexOf(n) >= 0){
return false
}
// check applicability... // check applicability...
if(!e.isApplicable.call(that, obj)){ if(!e.isApplicable.call(that, obj)){
unapplicable.push(n) unapplicable.push(n)
@ -472,11 +497,13 @@ module.FeatureSet = {
return true return true
} }
// mark feature unapplicable if it depends on an unapplicable... // mark feature unapplicable if it depends on an unapplicable
// or a disabled...
// NOTE: we need to do this once as features at this point // NOTE: we need to do this once as features at this point
// are sorted by dependencies... // are sorted by dependencies...
if(e.depends.filter(function(dep){ if(e.depends.filter(function(dep){
return unapplicable.indexOf(dep) > -1 return unapplicable.indexOf(dep) > -1
|| disabled.indexOf(dep) > -1
}).length > 0){ }).length > 0){
unapplicable.push(n) unapplicable.push(n)
return false return false
@ -533,6 +560,7 @@ module.FeatureSet = {
return { return {
features: lst, features: lst,
disabled: disabled,
excluded: excluded, excluded: excluded,
missing: missing, missing: missing,
conflicts: conflicts, conflicts: conflicts,

View File

@ -89,7 +89,8 @@ module.QueueActions = actions.Actions({
taskFailed: ['', function(){}], taskFailed: ['', function(){}],
taskDone: ['', function(){}], taskDone: ['', function(){}],
done: ['', function(){}], done: ['', function(func){
func && this.on('done', func) }],
// Task manipulation actions... // Task manipulation actions...

View File

@ -75,6 +75,10 @@ $(function(){
&& console.warn('Features excluded (%d):', && console.warn('Features excluded (%d):',
a.features.excluded.length, a.features.excluded.length,
a.features.excluded) a.features.excluded)
a.features.disabled.length > 0
&& console.log('Features disabled (%d):',
a.features.disabled.length,
a.features.disabled)
console.log('Features not applicable (%d):', console.log('Features not applicable (%d):',
a.features.unapplicable.length, a.features.unapplicable.length,
a.features.unapplicable) a.features.unapplicable)