refactoring....

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2016-11-20 00:57:26 +03:00
parent f0f597e5f2
commit e468ed35e4
2 changed files with 25 additions and 15 deletions

View File

@ -362,6 +362,7 @@ module.makeWorkspaceConfigWriter = function(keys, callback){
// XXX should this delete a prop if it's not in the loading workspace???
// XXX only replace a prop if it has changed???
// XXX handle defaults -- when a workspace was just created...
var makeWorkspaceConfigLoader =
module.makeWorkspaceConfigLoader = function(keys, callback){
return function(workspace){
@ -390,6 +391,7 @@ module.makeWorkspaceConfigLoader = function(keys, callback){
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// XXX need a way to handle defaults...
var WorkspaceActions = actions.Actions({
config: {
'load-workspace': 'default',

View File

@ -104,10 +104,13 @@ var SingleImageActions = actions.Actions({
// NOTE: setting this to null or to -1 will disable the feature...
'single-image-proportions-threshold': 2,
// Sets ribbon align mode in single image mode...
// Config defaults to set on first init of single image mode...
//
// NOTE: if this is null use the workspace value.
'single-image-ribbon-focus-mode': 'order',
// NOTE: the keys set here will be handled by the 'single-image'
// workspace...
'single-image-config-defaults': {
'ribbon-focus-mode': 'order',
},
},
updateImageProportions: ['- Interface/',
@ -243,6 +246,14 @@ var SingleImageActions = actions.Actions({
if(this.workspaces['single-image'] == null){
this.loadWorkspace('ui-chrome-hidden')
// setup defaults...
var that = this
var defaults = this.config['single-image-config-defaults'] || {}
Object.keys(defaults)
.forEach(function(key){
that.config[key] = JSON.parse(JSON.stringify(defaults[key])) })
this.saveWorkspace('single-image')
}
@ -424,20 +435,17 @@ module.SingleImageView = core.ImageGridFeatures.Feature({
// Workspace...
// ...set ribbon focus mode to order (default) in single image mode...
['saveWorkspace',
core.makeWorkspaceConfigWriter(['ribbon-focus-mode'])],
core.makeWorkspaceConfigWriter(
Object.keys(SingleImageActions.config['single-image-config-defaults']))],
['loadWorkspace',
core.makeWorkspaceConfigLoader(
['ribbon-focus-mode'],
Object.keys(SingleImageActions.config['single-image-config-defaults']),
// NOTE: considering that 'ribbon-focus-mode' is handled
// by a toggler that can have things bound to it,
// active is the way to go here...
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'])
}
'ribbon-focus-mode' in workspace
&& this.toggleRibbonFocusMode(workspace['ribbon-focus-mode'])
})],
],
})