saving and restoring settings now works...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2013-05-24 00:32:42 +04:00
parent 6df9184afe
commit 9c3962df81
4 changed files with 45 additions and 1 deletions

View File

@ -577,6 +577,20 @@ function convertDataGen1(data, cmp){
}
function loadSettings(){
toggleTheme(SETTINGS['theme'])
if(toggleSingleImageMode('?') == 'on'){
var w = SETTINGS['screen-images-single-image-mode']
var p = SETTINGS['single-image-mode-proportions']
toggleImageProportions(p)
} else {
var w = SETTINGS['screen-images-ribbon-mode']
}
fitNImages(w)
}
/**********************************************************************
* localStorage
@ -653,6 +667,22 @@ function saveLocalStorageMarks(attr){
}
function loadLocalStorageSettings(attr){
attr = attr == null ? DATA_ATTR : attr
attr += '_SETTINGS'
SETTINGS = JSON.parse(localStorage[attr])
loadSettings()
}
function saveLocalStorageSettings(attr){
attr = attr == null ? DATA_ATTR : attr
attr += '_SETTINGS'
localStorage[attr] = JSON.stringify(SETTINGS)
}
/**********************************************************************
* Extension API (CEF/PhoneGap/...)
@ -920,6 +950,12 @@ function setupDataBindings(viewer){
})
centerView(null, 'css')
if(toggleSingleImageMode('?') == 'on'){
SETTINGS['screen-images-single-image-mode'] = n
} else {
SETTINGS['screen-images-ribbon-mode'] = n
}
// update previews...
// XXX make this update only what needs updating...
updateImages()

View File

@ -487,9 +487,12 @@ $(function(){
loadLocalStorageMarks()
}
loadLocalStorageSettings()
// XXX stub...
//centerView(focusImage($('.image').first()), 'css')
updateImages()
})
})

View File

@ -202,6 +202,8 @@ var KEYBOARD_CONFIG = {
//saveLocalStorage()
saveLocalStorageData()
saveLocalStorageMarks()
saveLocalStorageSettings()
})
},
Z: {

View File

@ -55,7 +55,10 @@ var toggleTheme = createCSSClassToggler('.viewer',
'gray',
'dark',
'light'
])
],
function(action){
SETTINGS['theme'] = action
})
// NOTE: this confirmsto the css toggler protocol, but is not implemented