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 * 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/...) * Extension API (CEF/PhoneGap/...)
@ -920,6 +950,12 @@ function setupDataBindings(viewer){
}) })
centerView(null, 'css') centerView(null, 'css')
if(toggleSingleImageMode('?') == 'on'){
SETTINGS['screen-images-single-image-mode'] = n
} else {
SETTINGS['screen-images-ribbon-mode'] = n
}
// update previews... // update previews...
// XXX make this update only what needs updating... // XXX make this update only what needs updating...
updateImages() updateImages()

View File

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

View File

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

View File

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