From 051cba3082558038ad83ee1c28b4711a0e41ab17 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Sat, 26 Nov 2016 14:29:11 +0300 Subject: [PATCH] updated core.makeConfigToggler(..) to support bool states + single image mode tweaks... Signed-off-by: Alex A. Naanou --- ui (gen4)/features/base.js | 11 +++++++---- ui (gen4)/features/core.js | 11 +++++++++-- ui (gen4)/features/ui-single-image.js | 2 ++ ui (gen4)/features/ui.js | 1 + 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/ui (gen4)/features/base.js b/ui (gen4)/features/base.js index 5a8fe73c..6182b885 100755 --- a/ui (gen4)/features/base.js +++ b/ui (gen4)/features/base.js @@ -69,7 +69,7 @@ actions.Actions({ // If true, shift up/down will count as a left/right move... // // see .direction for details... - 'shifts-affect-direction': true, + 'shifts-affect-direction': 'on', // Determines the image selection mode when focusing or moving // between ribbons... @@ -140,7 +140,7 @@ actions.Actions({ // Sets the number of steps to change direction (N) // // 'shifts-affect-direction' - // If true, add last direction change before vertical shift to + // If 'on', add last direction change before vertical shift to // direction counter (N) // This makes the direction change after several shifts up/down // "backwards" a bit faster. @@ -449,7 +449,7 @@ actions.Actions({ this.data.shiftImageUp(cur) this.focusImage(next) - this.config['shifts-affect-direction'] && (this.direction = '!') + this.config['shifts-affect-direction'] == 'on' && (this.direction = '!') // if a specific target is given, just shift it... } else { @@ -473,7 +473,7 @@ actions.Actions({ this.data.shiftImageDown(cur) this.focusImage(next) - this.config['shifts-affect-direction'] && (this.direction = '!') + this.config['shifts-affect-direction'] == 'on' && (this.direction = '!') // if a specific target is given, just shift it... } else { @@ -507,6 +507,9 @@ actions.Actions({ this.focusImage() }], + toggleShiftsAffectDirection: ['Interface/Shifts affect direction', + core.makeConfigToggler('shifts-affect-direction', ['off', 'on'])], + shiftRibbonUp: ['Ribbon|Edit|Sort/Shift ribbon up', function(target){ this.data.shiftRibbonUp(target) diff --git a/ui (gen4)/features/core.js b/ui (gen4)/features/core.js index a930dadc..b6ebc704 100755 --- a/ui (gen4)/features/core.js +++ b/ui (gen4)/features/core.js @@ -39,10 +39,12 @@ module.protocol = function(protocol, func){ // NOTE: if no toggler state is set this assumes that the first state // is the default... +// NOTE: default states is [false, true] var makeConfigToggler = module.makeConfigToggler = function(attr, states, a, b){ + states = states || [false, true] var pre = a // XXX is this a good default??? //var post = b || function(action){ action != null && this.focusImage() } @@ -50,10 +52,15 @@ function(attr, states, a, b){ return toggler.Toggler(null, function(_, action){ - var lst = states.constructor === Array ? states : states.call(this) + var lst = states.constructor === Array ? states + : states instanceof Function ? states.call(this) + : states if(action == null){ - return this.config[attr] || lst[lst.indexOf('none')] || lst[0] + var cfg = this.config[attr] + return cfg == null ? + (lst[lst.indexOf('none')] || lst[0]) + : cfg } else { this.config[attr] = action diff --git a/ui (gen4)/features/ui-single-image.js b/ui (gen4)/features/ui-single-image.js index 1358f453..59af2174 100755 --- a/ui (gen4)/features/ui-single-image.js +++ b/ui (gen4)/features/ui-single-image.js @@ -110,9 +110,11 @@ var SingleImageActions = actions.Actions({ // workspace... 'single-image-config-defaults': { 'ribbon-focus-mode': 'order', + 'shifts-affect-direction': 'off', }, }, + // XXX make this accept args for debuging... updateImageProportions: ['- Interface/', function(){ var that = this diff --git a/ui (gen4)/features/ui.js b/ui (gen4)/features/ui.js index 9ff3637a..8230d64a 100755 --- a/ui (gen4)/features/ui.js +++ b/ui (gen4)/features/ui.js @@ -860,6 +860,7 @@ module.ViewerActions = actions.Actions({ // ribbon rotation... + // ribbonRotation: ['- Interface/', function(a){ if(arguments.length > 0){