added ribbon focus mode to workspace...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2016-11-20 00:04:41 +03:00
parent 9d0679cda0
commit f0f597e5f2
3 changed files with 29 additions and 4 deletions

View File

@ -44,20 +44,19 @@ module.makeConfigToggler =
function(attr, states, a, b){ function(attr, states, a, b){
var pre = a var pre = a
var post = b || function(action){ action != null && this.focusImage() } // XXX is this a good default???
//var post = b || function(action){ action != null && this.focusImage() }
var post = b
return toggler.Toggler(null, return toggler.Toggler(null,
function(_, action){ function(_, action){
var lst = states.constructor === Array ? states : states.call(this) var lst = states.constructor === Array ? states : states.call(this)
//console.log('action', action)
if(action == null){ if(action == null){
return this.config[attr] || lst[lst.indexOf('none')] || lst[0] return this.config[attr] || lst[lst.indexOf('none')] || lst[0]
} else { } else {
this.config[attr] = action this.config[attr] = action
//this.focusImage()
} }
}, },
states, pre, post) states, pre, post)

View File

@ -103,6 +103,11 @@ var SingleImageActions = actions.Actions({
// //
// NOTE: setting this to null or to -1 will disable the feature... // NOTE: setting this to null or to -1 will disable the feature...
'single-image-proportions-threshold': 2, 'single-image-proportions-threshold': 2,
// Sets ribbon align mode in single image mode...
//
// NOTE: if this is null use the workspace value.
'single-image-ribbon-focus-mode': 'order',
}, },
updateImageProportions: ['- Interface/', updateImageProportions: ['- Interface/',
@ -415,6 +420,25 @@ module.SingleImageView = core.ImageGridFeatures.Feature({
} }
} }
}], }],
// Workspace...
// ...set ribbon focus mode to order (default) in single image mode...
['saveWorkspace',
core.makeWorkspaceConfigWriter(['ribbon-focus-mode'])],
['loadWorkspace',
core.makeWorkspaceConfigLoader(
['ribbon-focus-mode'],
function(workspace){
if(this.workspace == 'single-image'){
var mode = this.config['single-image-ribbon-focus-mode']
|| workspace['ribbon-focus-mode']
|| 'order'
this.toggleRibbonFocusMode(mode)
} else if('ribbon-focus-mode' in workspace) {
this.toggleRibbonFocusMode(workspace['ribbon-focus-mode'])
}
})],
], ],
}) })

View File

@ -130,6 +130,8 @@
// later is enough, but as strict mode is not stable enough (sometimes // later is enough, but as strict mode is not stable enough (sometimes
// works and sometimes does not), we can not reliably pass the element // works and sometimes does not), we can not reliably pass the element
// via 'this'. // via 'this'.
// XXX add .toString(..) to resulting function to print the source of all
// the handlers...
var Toggler = var Toggler =
module.Toggler = module.Toggler =
function(elem, state_accessor, states, callback_a, callback_b){ function(elem, state_accessor, states, callback_a, callback_b){