some refactoring...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2013-07-03 20:18:00 +04:00
parent 583d196c87
commit dacfdf6192
4 changed files with 27 additions and 22 deletions

View File

@ -109,12 +109,13 @@ var IMAGES_CREATED = false
var MARKED = []
// NOTE: these are named: <mode>-<feature>
var SETTINGS = {
'theme': null,
'screen-images-ribbon-mode': null,
'screen-images-single-image-mode': null,
'global-theme': null,
'ribbon-mode-screen-images': null,
'single-image-mode-screen-images': null,
'single-image-mode-proportions': null,
'image-info-ribbon-mode': 'off',
'ribbon-mode-image-info': 'off',
}
var BASE_URL = '.'
@ -1030,17 +1031,17 @@ function reloadViewer(images_per_screen){
// Apply the current SETTINGS to current viewer
function loadSettings(){
toggleTheme(SETTINGS['theme'])
toggleTheme(SETTINGS['global-theme'])
if(toggleSingleImageMode('?') == 'on'){
var w = SETTINGS['screen-images-single-image-mode']
var w = SETTINGS['single-image-mode-screen-images']
if(window.PROPORTIONS_RATIO_THRESHOLD == null){
var p = SETTINGS['single-image-mode-proportions']
toggleImageProportions(p)
}
} else {
var w = SETTINGS['screen-images-ribbon-mode']
toggleImageInfo(SETTINGS['image-info-ribbon-mode'] == 'on' ? 'on' : 'off')
var w = SETTINGS['ribbon-mode-screen-images']
toggleImageInfo(SETTINGS['ribbon-mode-image-info'] == 'on' ? 'on' : 'off')
}
fitNImages(w)
}

View File

@ -133,11 +133,11 @@ var toggleSingleImageMode = createCSSClassToggler(
TRANSITION_MODE_DEFAULT = 'css'
// save things...
SETTINGS['screen-images-ribbon-mode'] = w
SETTINGS['image-info-ribbon-mode'] = toggleImageInfo('?')
SETTINGS['ribbon-mode-screen-images'] = w
SETTINGS['ribbon-mode-image-info'] = toggleImageInfo('?')
// load things...
w = SETTINGS['screen-images-single-image-mode']
w = SETTINGS['single-image-mode-screen-images']
w = w == null ? 1 : w
var p = SETTINGS['single-image-mode-proportions']
p = p == null ? 'square' : p
@ -152,18 +152,18 @@ var toggleSingleImageMode = createCSSClassToggler(
TRANSITION_MODE_DEFAULT = 'animate'
// save things...
SETTINGS['screen-images-single-image-mode'] = w
SETTINGS['single-image-mode-screen-images'] = w
SETTINGS['single-image-mode-proportions'] = toggleImageProportions('?')
// load things...
w = SETTINGS['screen-images-ribbon-mode']
w = SETTINGS['ribbon-mode-screen-images']
w = w == null ? DEFAULT_SCREEN_IMAGES : w
toggleImageProportions('none')
fitNImages(w)
var i = SETTINGS['image-info-ribbon-mode'] == 'on' ? 'on' : 'off'
var i = SETTINGS['ribbon-mode-image-info'] == 'on' ? 'on' : 'off'
toggleImageInfo(i)
SETTINGS['image-info-ribbon-mode'] = i
SETTINGS['ribbon-mode-image-info'] = i
centerRibbons()
}
@ -287,7 +287,7 @@ var toggleTheme = createCSSClassToggler(
],
// XXX does this get called for default state (gray)???
function(action){
SETTINGS['theme'] = action
SETTINGS['global-theme'] = action
})
@ -296,7 +296,7 @@ var toggleImageInfo = createCSSClassToggler(
'.image-info-visible',
function(action){
if(toggleSingleImageMode('?') == 'off'){
SETTINGS['image-info-ribbon-mode'] = action
SETTINGS['ribbon-mode-image-info'] = action
}
})

View File

@ -180,9 +180,9 @@ function setupDataBindings(viewer){
// update settings...
if(toggleSingleImageMode('?') == 'on'){
SETTINGS['screen-images-single-image-mode'] = n
SETTINGS['single-image-mode-screen-images'] = n
} else {
SETTINGS['screen-images-ribbon-mode'] = n
SETTINGS['ribbon-mode-screen-images'] = n
}
// update proportions...

View File

@ -584,6 +584,7 @@ function formDialog(root, message, config, btn, cls){
// get the tooltip...
if(/[^\\]\|/.test(t)){
// XXX do we need to cut the spaces off here???
var tip = t.split(/\s*\|\s*/)
text = tip[0]
tip = tip[1]
@ -660,6 +661,12 @@ function formDialog(root, message, config, btn, cls){
/************************************************ Standard dialogs ***/
// NOTE: these return a deferred that will reflect the state of the
// dialog, and the progress of the operations that it riggers...
//
// XXX might be a good idea to be able to block the ui (overlay + progress
// bar?) until some long/critical operations finish, to prevent the
// user from breaking things while the ui is inconsistent...
var _alert = alert
function alert(){
@ -742,15 +749,12 @@ function exportPreviewsDialog(state, dfl){
normalizePath(data[keys[2]]),
data[keys[0]],
data[keys[1]])
// XXX do real reporting...
showStatusQ('Copying data...')
res.resolve(data[''])
})
.fail(function(){
showStatusQ('Export: canceled.')
res.reject()
})