minor refactoring + docs...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2016-06-21 02:45:45 +03:00
parent f5c35ebc7e
commit 6385660b09
3 changed files with 34 additions and 12 deletions

View File

@ -28,8 +28,9 @@ var drawer = require('lib/widget/drawer')
// helper...
function customScale(n){
return {
default: 'fitCustom: '+n,
'ctrl+shift': 'setCustomSize: '+n,
default: 'fitCustom: '+n+' -- Set cutom image size',
'alt': 'setCustomSize: '+n+' -- Set current image size as custom',
'ctrl+shift': 'setCustomSize: '+n+' null -- Clear custom image size',
}
}
@ -80,14 +81,18 @@ module.GLOBAL_KEYBOARD = {
'#0', '#1', '#2', '#3', '#4', '#5', '#6', '#7', '#8', '#9',
],
// zooming...
'#1': 'fitScreen',
'#2': {
default: 'fitNormal',
'ctrl+shift': 'setNormalScale',
'alt': 'setNormalScale',
'ctrl+shift': 'setNormalScale: null -- Reset normal size to default',
},
'#3': {
default: 'fitSmall',
'ctrl+shift': 'setSmallScale',
'alt': 'setSmallScale',
'ctrl+shift': 'setSmallScale: null -- Reset small size to default',
},
'#4': customScale(4),
'#5': customScale(5),

View File

@ -253,12 +253,16 @@ var SingleImageActions = actions.Actions({
// basic single image view sizing...
fitSmall: ['Zoom/Show small image',
function(){ this.screenfit = this.config['fit-small-scale'] || 4 }],
setSmallScale: ['Zoom/Set small size to current',
function(value){
this.config['fit-small-scale']
= value === null ? 4 : (value || this.screenfit) }],
fitNormal: ['Zoom/Show normal image',
function(){ this.screenfit = this.config['fit-normal-scale'] || 1.2 }],
setSmallScale: ['Zoom/Set small size to current',
function(){ this.config['fit-small-scale'] = this.screenfit }],
setNormalScale: ['Zoom/Set normal size to current',
function(){ this.config['fit-normal-scale'] = this.screenfit }],
function(value){
this.config['fit-normal-scale']
= value === null ? 1.2 : (value || this.screenfit) }],
fitCustom: ['- Zoom/Show cusotm size image',
function(n){
@ -275,16 +279,29 @@ var SingleImageActions = actions.Actions({
this.screenfit = s
}],
setCustomSize: ['- Zoom/Set image cusotm size',
function(n){
function(n, value){
if(n == null){
return
}
var sizes = this.config['fit-custom-scale'] || {}
sizes[n] = this.screenfit
var sizes = this.config['fit-custom-scale']
// reset...
if(value === null){
if(sizes && n in sizes){
delete sizes[n]
}
// set...
} else {
sizes = sizes && JSON.parse(JSON.stringify(sizes)) || {}
sizes[n] = value || this.screenfit
}
// NOTE: we are resetting this for it to be stored correctly...
this.config['fit-custom-scale'] = sizes
if(sizes){
this.config['fit-custom-scale'] = sizes
}
}],
})

View File

@ -249,7 +249,7 @@ function parseActionCall(txt){
// parse arguments...
var args = JSON.parse('['+(
((c[1] || '')
.match(/"[^"]*"|'[^']*'|\{[^\}]*\}|\[[^\]]*\]|\d+|\d+\.\d*/gm)
.match(/"[^"]*"|'[^']*'|\{[^\}]*\}|\[[^\]]*\]|\d+|\d+\.\d*|null/gm)
|| [])
.join(','))+']')