mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 10:20:08 +00:00
a bit more work on workspaces...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
35077407c1
commit
01797476e4
@ -213,12 +213,57 @@ module.LifeCycle = ImageGridFeatures.Feature({
|
||||
//
|
||||
//
|
||||
|
||||
|
||||
// Helpers...
|
||||
var makeWorkspaceConfigWriter =
|
||||
module.makeWorkspaceConfigWriter = function(keys, callback){
|
||||
return function(workspace){
|
||||
var that = this
|
||||
|
||||
keys = typeof(keys) == typeof(function(){}) ? keys() : keys
|
||||
|
||||
// store statusbar data...
|
||||
keys.forEach(function(key){
|
||||
workspace[key] = JSON.parse(JSON.stringify(that.config[key]))
|
||||
})
|
||||
|
||||
callback && callback.call(this, workspace)
|
||||
}
|
||||
}
|
||||
|
||||
// XXX should this delete a prop if it's not in the loading workspace???
|
||||
var makeWorkspaceConfigLoader =
|
||||
module.makeWorkspaceConfigLoader = function(keys, callback){
|
||||
return function(workspace){
|
||||
var that = this
|
||||
|
||||
keys = typeof(keys) == typeof(function(){}) ? keys() : keys
|
||||
|
||||
// load statusbar data...
|
||||
keys.forEach(function(key){
|
||||
// the key exists...
|
||||
if(key in workspace){
|
||||
that.config[key] = JSON.parse(JSON.stringify(workspace[key]))
|
||||
|
||||
// no key set...
|
||||
// XXX is this the right way to go???
|
||||
} else {
|
||||
delete that.config[key]
|
||||
}
|
||||
})
|
||||
|
||||
callback && callback.call(this, workspace)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
var WorkspaceActions = actions.Actions({
|
||||
config: {
|
||||
'workspace': 'default',
|
||||
'chrome-visible': 'on',
|
||||
|
||||
'saved-workspaces': {},
|
||||
'workspaces': {},
|
||||
},
|
||||
|
||||
get workspace(){
|
||||
@ -228,6 +273,11 @@ var WorkspaceActions = actions.Actions({
|
||||
this.loadWorkspace(value)
|
||||
},
|
||||
|
||||
get workspaces(){
|
||||
return this.config.workspaces
|
||||
},
|
||||
|
||||
|
||||
getWorkspace: ['- Workspace/',
|
||||
function(){ return this.saveWorkspace(null) }],
|
||||
|
||||
@ -242,12 +292,12 @@ var WorkspaceActions = actions.Actions({
|
||||
// XXX for some reason this does not trigger a .config save...
|
||||
saveWorkspace: ['Workspace/Save Workspace',
|
||||
function(name){
|
||||
this.config['saved-workspaces'] = this.config['saved-workspaces']
|
||||
this.config['workspaces'] = this.config['workspaces']
|
||||
|
||||
var res = {}
|
||||
|
||||
if(name !== null){
|
||||
this.config['saved-workspaces'][name || this.config.workspace] = res
|
||||
this.config['workspaces'][name || this.config.workspace] = res
|
||||
}
|
||||
|
||||
return res
|
||||
@ -257,14 +307,21 @@ var WorkspaceActions = actions.Actions({
|
||||
// specific way to do stuff...
|
||||
loadWorkspace: ['Workspace/Load Workspace',
|
||||
function(name){
|
||||
this.config.workspace = name
|
||||
// get a workspace by name and load it...
|
||||
if(typeof(name) == typeof('str')){
|
||||
this.config.workspace = name
|
||||
|
||||
return this.config['saved-workspaces'][name] || {}
|
||||
return this.config['workspaces'][name || this.config.workspace] || {}
|
||||
|
||||
// we got the workspace object...
|
||||
} else {
|
||||
return name
|
||||
}
|
||||
}],
|
||||
|
||||
toggleWorkspace: ['Workspace/Toggle Workspace',
|
||||
makeConfigToggler('workspace',
|
||||
function(){ return Object.keys(this.config['saved-workspaces']) },
|
||||
function(){ return Object.keys(this.config['workspaces']) },
|
||||
function(state){ this.loadWorkspace(state) })],
|
||||
})
|
||||
|
||||
|
||||
@ -71,7 +71,8 @@ var SlideshowActions = actions.Actions({
|
||||
core.makeConfigToggler('ui-slideshow-direction', ['forward', 'reverse'])],
|
||||
toggleSlideshowLooping: ['Slideshow/Looping',
|
||||
core.makeConfigToggler('ui-slideshow-looping', ['on', 'off'])],
|
||||
// XXX need to save/load state...
|
||||
|
||||
// XXX should this save/load a tmp workspace or a dedicated slideshow workspace???
|
||||
toggleSlideshow: ['Slideshow/Start',
|
||||
toggler.CSSClassToggler(
|
||||
function(){ return this.ribbons.viewer },
|
||||
@ -90,14 +91,22 @@ var SlideshowActions = actions.Actions({
|
||||
|
||||
// prepare for the slideshow...
|
||||
} else {
|
||||
// XXX get state before setting/hiding things...
|
||||
// XXX
|
||||
// save current workspace...
|
||||
this.__pre_slideshow_workspace = this.workspace
|
||||
this.saveWorkspace()
|
||||
|
||||
// construct the slideshow workspace if it does not exist...
|
||||
if(this.workspaces['slideshow'] == null){
|
||||
this.toggleChrome('off')
|
||||
this.saveWorkspace('slideshow')
|
||||
|
||||
// load the slideshow workspace...
|
||||
} else {
|
||||
this.loadWorkspace('slideshow')
|
||||
}
|
||||
|
||||
// single image mode...
|
||||
this.toggleSingleImage('on')
|
||||
|
||||
// XXX hide all marks...
|
||||
// XXX
|
||||
}
|
||||
|
||||
// start the timer...
|
||||
@ -122,12 +131,14 @@ var SlideshowActions = actions.Actions({
|
||||
// stop...
|
||||
} else {
|
||||
// stop timer...
|
||||
clearTimeout(this.__slideshouw_timer)
|
||||
this.__slideshouw_timer
|
||||
&& clearTimeout(this.__slideshouw_timer)
|
||||
delete this.__slideshouw_timer
|
||||
|
||||
// XXX restore state...
|
||||
// XXX
|
||||
|
||||
// XXX should this be a dedicated slideshow workspace??
|
||||
this.__pre_slideshow_workspace &&
|
||||
this.loadWorkspace(this.__pre_slideshow_workspace)
|
||||
delete this.__pre_slideshow_workspace
|
||||
}
|
||||
})],
|
||||
resetSlideshowTimer: ['- Slideshow/Restart slideshow timer',
|
||||
@ -144,11 +155,17 @@ module.Slideshow = core.ImageGridFeatures.Feature({
|
||||
|
||||
tag: 'ui-slideshow',
|
||||
depends: [
|
||||
'workspace',
|
||||
'ui',
|
||||
'ui-single-image-view',
|
||||
],
|
||||
|
||||
actions: SlideshowActions,
|
||||
|
||||
handlers: [
|
||||
['stop',
|
||||
function(){ this.toggleSlideshow('off') }]
|
||||
],
|
||||
})
|
||||
|
||||
|
||||
|
||||
@ -419,6 +419,7 @@ module.StatusBar = core.ImageGridFeatures.Feature({
|
||||
|
||||
tag: 'ui-status-bar',
|
||||
depends: [
|
||||
'workspace',
|
||||
'ui',
|
||||
|
||||
// XXX this is here to enable context menu
|
||||
@ -450,6 +451,19 @@ module.StatusBar = core.ImageGridFeatures.Feature({
|
||||
this.updateStatusBar()
|
||||
}
|
||||
}],
|
||||
|
||||
// Workspace...
|
||||
// XXX is storing all the config a bit too much???
|
||||
['saveWorkspace',
|
||||
core.makeWorkspaceConfigWriter(
|
||||
function(){ return Object.keys(StatusBar.config) })],
|
||||
['loadWorkspace',
|
||||
core.makeWorkspaceConfigLoader(
|
||||
function(){ return Object.keys(StatusBar.config) },
|
||||
function(workspace){
|
||||
'status-bar-mode' in workspace
|
||||
&& this.toggleStatusBar(workspace['status-bar-mode'])
|
||||
})],
|
||||
],
|
||||
})
|
||||
|
||||
|
||||
@ -162,6 +162,9 @@ module.ViewerActions = actions.Actions({
|
||||
'last', // select last image
|
||||
],
|
||||
'ribbon-focus-mode': 'visual',
|
||||
|
||||
|
||||
'chrome-visible': 'on',
|
||||
},
|
||||
|
||||
// Images...
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user