From 1d649283cf61094098a054f64a78f85270841567 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Sun, 31 May 2020 17:53:14 +0300 Subject: [PATCH] refactoring... Signed-off-by: Alex A. Naanou --- ui (gen4)/features/app.js | 10 ++-- ui (gen4)/features/base.js | 2 +- ui (gen4)/features/collections.js | 2 +- ui (gen4)/features/location.js | 2 +- .../features/ui-partial-ribbons-precache.js | 4 +- ui (gen4)/features/ui-status.js | 4 +- ui (gen4)/features/ui-widgets.js | 46 ++++++++++++++----- ui (gen4)/features/ui.js | 30 ++++++------ 8 files changed, 62 insertions(+), 38 deletions(-) diff --git a/ui (gen4)/features/app.js b/ui (gen4)/features/app.js index 477f9f9e..3769dc2e 100755 --- a/ui (gen4)/features/app.js +++ b/ui (gen4)/features/app.js @@ -124,7 +124,7 @@ var NWHostActions = actions.Actions({ // XXX add ability to use devtools on background page (node context)... // XXX get the devtools stage... showDevTools: ['Interface|Development/Show Dev Tools', - {mode: 'toggleBrowseActionKeys'}, + {mode: 'advancedBrowseModeAction'}, function(action){ if(action == '?'){ // XXX get the devtools stage... @@ -145,7 +145,7 @@ var NWHostActions = actions.Actions({ }], toggleSplashScreen: ['Interface/', - {mode: 'toggleBrowseActionKeys'}, + {mode: 'advancedBrowseModeAction'}, function(){ }], }) @@ -246,7 +246,7 @@ var ElectronHostActions = actions.Actions({ // XXX should this be a toggler??? showDevTools: ['Interface|Development/Show Dev Tools', - {mode: 'toggleBrowseActionKeys'}, + {mode: 'advancedBrowseModeAction'}, function(action){ var w = electron.remote.getCurrentWindow() @@ -277,7 +277,7 @@ var ElectronHostActions = actions.Actions({ // XXX make this a real toggler... toggleSplashScreen: ['Interface/', - {mode: 'toggleBrowseActionKeys'}, + {mode: 'advancedBrowseModeAction'}, function(action){ var splash = this.splash = (!this.splash || this.splash.isDestroyed()) ? electron.remote.getGlobal('splash') @@ -560,7 +560,7 @@ var WindowedAppControlActions = actions.Actions({ }], toggleSplashScreenShowing: ['Interface/Splash screen on start', - {mode: 'toggleBrowseActionKeys'}, + {mode: 'advancedBrowseModeAction'}, core.makeConfigToggler('show-splash-screen', ['on', 'off'], function(action){ diff --git a/ui (gen4)/features/base.js b/ui (gen4)/features/base.js index adb66121..f9bc0100 100755 --- a/ui (gen4)/features/base.js +++ b/ui (gen4)/features/base.js @@ -832,7 +832,7 @@ actions.Actions({ // NOTE: resetting this option will clear the last direction... toggleShiftsAffectDirection: ['Interface/Shifts affect direction', - {mode: 'toggleBrowseActionKeys'}, + {mode: 'advancedBrowseModeAction'}, core.makeConfigToggler('shifts-affect-direction', ['off', 'on'], function(action){ diff --git a/ui (gen4)/features/collections.js b/ui (gen4)/features/collections.js index 3b385551..4925b8e3 100755 --- a/ui (gen4)/features/collections.js +++ b/ui (gen4)/features/collections.js @@ -1282,7 +1282,7 @@ var CollectionActions = actions.Actions({ // Config and interface stuff... // toggleCollectionCropRetention: ['Interface/Collection crop save mode', - {mode: 'toggleBrowseActionKeys'}, + {mode: 'advancedBrowseModeAction'}, core.makeConfigToggler( 'collection-save-crop-state', [ diff --git a/ui (gen4)/features/location.js b/ui (gen4)/features/location.js index 201f656a..33bbc92e 100755 --- a/ui (gen4)/features/location.js +++ b/ui (gen4)/features/location.js @@ -352,7 +352,7 @@ var LocationActions = actions.Actions({ core.doc`Toggle index synchronization method NOTE: this will not show disabled methods.`, - {mode: 'toggleBrowseActionKeys'}, + {mode: 'advancedBrowseModeAction'}, toggler.Toggler(null, function(_, state){ var dict = this.location_sync_methods diff --git a/ui (gen4)/features/ui-partial-ribbons-precache.js b/ui (gen4)/features/ui-partial-ribbons-precache.js index 1951db61..7c471669 100755 --- a/ui (gen4)/features/ui-partial-ribbons-precache.js +++ b/ui (gen4)/features/ui-partial-ribbons-precache.js @@ -28,7 +28,7 @@ var PreCacheActions = actions.Actions({ // NOTE: this will not work from chrome when loading from a local fs... // XXX experimental... startCacheWorker: ['Interface/', - {mode: 'toggleBrowseActionKeys'}, + {mode: 'advancedBrowseModeAction'}, function(){ // a worker is started already... if(this.cacheWorker != null){ @@ -63,7 +63,7 @@ var PreCacheActions = actions.Actions({ this.cacheWorker.url = url }], stopCacheWorker: ['Interface/', - {mode: 'toggleBrowseActionKeys'}, + {mode: 'advancedBrowseModeAction'}, function(){ if(this.cacheWorker){ this.cacheWorker.terminate() diff --git a/ui (gen4)/features/ui-status.js b/ui (gen4)/features/ui-status.js index fb1ad6e2..334d8952 100755 --- a/ui (gen4)/features/ui-status.js +++ b/ui (gen4)/features/ui-status.js @@ -893,12 +893,12 @@ var StatusLogActions = actions.Actions({ // XXX should this be here or in a separate feature??? statusLog: ['Interface/Show status log', - {mode: 'toggleBrowseActionKeys'}, + {mode: 'advancedBrowseModeAction'}, function(){ // XXX use list }], clearStatusLog: ['Interface/Clear status log', - {mode: 'toggleBrowseActionKeys'}, + {mode: 'advancedBrowseModeAction'}, function(){ delete this.__status_log }], diff --git a/ui (gen4)/features/ui-widgets.js b/ui (gen4)/features/ui-widgets.js index 22fc0923..540fcbc3 100755 --- a/ui (gen4)/features/ui-widgets.js +++ b/ui (gen4)/features/ui-widgets.js @@ -904,7 +904,7 @@ var DialogsActions = actions.Actions({ listDialogs: ['Interface|System/Dialog/Dialog list...', - {mode: 'toggleBrowseActionKeys'}, + {mode: 'advancedBrowseModeAction'}, makeUIDialog(function(){ var actions = this @@ -931,7 +931,7 @@ var DialogsActions = actions.Actions({ })], toggleOverlayBlur: ['Interface/Dialog overlay blur', - {mode: 'toggleBrowseActionKeys'}, + {mode: 'advancedBrowseModeAction'}, toggler.CSSClassToggler( function(){ return this.dom }, 'overlay-blur-enabled', @@ -2587,7 +2587,7 @@ var BrowseActionsActions = actions.Actions({ // ...this would help with the (global) search -- switch to // flat if searching in root mode... browseActions: ['Interface/Dialog/Actions...', - {mode: 'toggleBrowseActionKeys'}, + {mode: 'advancedBrowseModeAction'}, core.doc`Browse actions dialog... This uses action definition to build and present an action tree. @@ -2949,6 +2949,31 @@ var BrowseActionsActions = actions.Actions({ this.keyboard.handler('General', 'ctrl-a', 'toggleAdvanced') }) })], + // XXX revise... + advancedBrowseModeAction: ['- System/', + core.doc`Placeholder advanced action + + This is mainly used to indicate other actions as advanced mode only. + + Example: + someAction: ['Menu/Path/Some action', + // show up only in advanced browse mode... + {mode: 'advancedBrowseModeAction'}, + function(){ + ... + }], + `, + {mode: function(){ + return this.advancedBrowseModeAction() }}, + core.notUserCallable(function(){ + // Placeholder action, not for direct use... + // + // See doc for more info: + // .showDoc('advancedBrowseModeAction') + return this.config['browse-advanced-mode'] != 'on' + && 'hidden' + || 'visible' })], + toggleBrowseAdvanced: ['System|Interface/-99: Advanced menu items', core.doc`Toggle advanced menu items... @@ -2958,7 +2983,7 @@ var BrowseActionsActions = actions.Actions({ - return 'hidden' when needed or: - link to an action that behaves in a desired way: - {mode: 'toggleBrowseActionKeys',} + {mode: 'advancedBrowseModeAction',} See .toggleBrowseActionKeys(..) for an example. `, @@ -2967,8 +2992,7 @@ var BrowseActionsActions = actions.Actions({ ['off', 'on'])], toggleBrowseActionKeys: ['Interface/Show keys in menu', - {mode: function(){ - return this.config['browse-advanced-mode'] != 'on' && 'hidden' }}, + {mode: 'advancedBrowseModeAction'}, core.makeConfigToggler( 'browse-actions-keys', ['on', 'off'], @@ -3013,7 +3037,7 @@ module.ContextActionMenu = core.ImageGridFeatures.Feature({ actions: actions.Actions({ showContextMenu: ['Interface/Show context menu...', - {mode: 'toggleBrowseActionKeys'}, + {mode: 'advancedBrowseModeAction'}, uiDialog(function(){ return this.current ? this.browseActions('/Image/') @@ -3172,13 +3196,13 @@ var ButtonsActions = actions.Actions({ }, toggleMainButtons: ['Interface/Main buttons', - {mode: 'toggleBrowseActionKeys'}, + {mode: 'advancedBrowseModeAction'}, makeButtonControlsToggler('main-buttons')], toggleSecondaryButtons: ['Interface/Secondary buttons', - {mode: 'toggleBrowseActionKeys'}, + {mode: 'advancedBrowseModeAction'}, makeButtonControlsToggler('secondary-buttons')], toggleAppButtons: ['Interface/App buttons', - {mode: 'toggleBrowseActionKeys'}, + {mode: 'advancedBrowseModeAction'}, makeButtonControlsToggler('app-buttons')], toggleSideButtons: ['Interface/70: Touch buttons', @@ -3195,7 +3219,7 @@ var ButtonsActions = actions.Actions({ })()], toggleButtonHighlightColor: ['Interface/Theme/Button highlight color', - {mode: 'toggleBrowseActionKeys'}, + {mode: 'advancedBrowseModeAction'}, core.makeConfigToggler( 'button-highlight-color', function(){ return this.config['button-highlight-colors'] }, diff --git a/ui (gen4)/features/ui.js b/ui (gen4)/features/ui.js index a579ed85..2cba0626 100755 --- a/ui (gen4)/features/ui.js +++ b/ui (gen4)/features/ui.js @@ -361,7 +361,7 @@ module.ViewerActions = actions.Actions({ .centerImage(target) .centerRibbon(target) }], alignRibbons: ['Interface/Align ribbons', - {mode: 'toggleBrowseActionKeys'}, + {mode: 'advancedBrowseModeAction'}, function(target, scale, now){ if(target == 'now'){ now = true @@ -392,7 +392,7 @@ module.ViewerActions = actions.Actions({ // XXX skip off-screen ribbons (???) // XXX should the timeout be configurable??? alignByOrder: ['Interface/Align ribbons by image order', - {mode: 'toggleBrowseActionKeys'}, + {mode: 'advancedBrowseModeAction'}, function(target, scale, now){ if(target == 'now'){ now = true @@ -457,7 +457,7 @@ module.ViewerActions = actions.Actions({ } }], alignByFirst: ['Interface/Align ribbons except current to first image', - {mode: 'toggleBrowseActionKeys'}, + {mode: 'advancedBrowseModeAction'}, function(target){ target = target == 'now' ? null : target @@ -656,7 +656,7 @@ module.ViewerActions = actions.Actions({ // XXX make this play nice with crops... // ...should this be a crop??? toggleRibbonList: ['Interface|Ribbon/Ribbons as images view', - {mode: 'toggleBrowseActionKeys'}, + {mode: 'advancedBrowseModeAction'}, function(){ if(this._full_data == null){ // XXX do a better name here... @@ -697,7 +697,7 @@ module.ViewerActions = actions.Actions({ function(angle){ }], toggleImageRendering: ['Interface/Image rendering', - {mode: 'toggleBrowseActionKeys'}, + {mode: 'advancedBrowseModeAction'}, toggler.CSSClassToggler( function(){ return this.dom }, ['crisp-resize', 'default-resize'], @@ -936,7 +936,7 @@ module.Cursor = core.ImageGridFeatures.Feature({ actions: actions.Actions({ toggleHiddenCursor: ['Interface/Cursor hidden', - {mode: 'toggleBrowseActionKeys'}, + {mode: 'advancedBrowseModeAction'}, toggler.CSSClassToggler( function(){ return this.dom }, 'cursor-hidden', @@ -1011,7 +1011,7 @@ module.Cursor = core.ImageGridFeatures.Feature({ // .config['cursor-show-threshold'] // toggleAutoHideCursor: ['Interface/Cursor auto-hide', - {mode: 'toggleBrowseActionKeys'}, + {mode: 'advancedBrowseModeAction'}, toggler.CSSClassToggler( function(){ return this.dom }, 'cursor-autohide', @@ -1127,13 +1127,13 @@ module.Cursor = core.ImageGridFeatures.Feature({ })], toggleAutoHideCursorTimeout: ['Interface/Hide cursor on timeout', - {mode: 'toggleBrowseActionKeys'}, + {mode: 'advancedBrowseModeAction'}, core.makeConfigToggler('cursor-autohide-on-timeout', ['on', 'off'], function(){ this.toggleAutoHideCursor('!') })], toggleAutoHideCursorKeyboard: ['Interface/Hide cursor on keyboard', - {mode: 'toggleBrowseActionKeys'}, + {mode: 'advancedBrowseModeAction'}, core.makeConfigToggler('cursor-autohide-on-keyboard', ['on', 'off'], function(){ @@ -1224,7 +1224,7 @@ var ControlActions = actions.Actions({ from reaching the viewer. NOTE: this defines the focus/blur handlers on the window object.`, - {mode: 'toggleBrowseActionKeys'}, + {mode: 'advancedBrowseModeAction'}, core.makeConfigToggler('lock-unfocused', ['off', 'on'], function(state){ @@ -1378,7 +1378,7 @@ var ControlActions = actions.Actions({ // XXX depends on .ribbons... // XXX uses: .focusImage(..) toggleImageClickHandling: ['Interface/Image click handling', - {mode: 'toggleBrowseActionKeys'}, + {mode: 'advancedBrowseModeAction'}, toggler.Toggler(null, function(_, new_state){ return new_state ? @@ -1631,7 +1631,7 @@ var ControlActions = actions.Actions({ // XXX depends on .ribbons... // XXX uses: .focusImage(..) toggleRibbonPanHandling: ['Interface/Ribbon pan handling', - {mode: 'toggleBrowseActionKeys'}, + {mode: 'advancedBrowseModeAction'}, toggler.Toggler(null, function(_, new_state){ return new_state ? @@ -1871,7 +1871,7 @@ var ControlActions = actions.Actions({ // XXX depends on .ribbons... // XXX uses: .focusImage(..) toggleMouseWheelHandling: ['Interface/Mouse wheel handling', - {mode: 'toggleBrowseActionKeys'}, + {mode: 'advancedBrowseModeAction'}, toggler.Toggler(null, function(_, new_state){ return new_state ? @@ -1976,7 +1976,7 @@ var ControlActions = actions.Actions({ })], togglePinchHandling: ['Interface/Pinch zoom handling', - {mode: 'toggleBrowseActionKeys'}, + {mode: 'advancedBrowseModeAction'}, function(){ // XXX }], @@ -1986,7 +1986,7 @@ var ControlActions = actions.Actions({ // ...allow ui features to control this... // XXX depends on .ribbons... toggleSwipeHandling: ['Interface/Swipe handling', - //{mode: 'toggleBrowseActionKeys'}, + //{mode: 'advancedBrowseModeAction'}, toggler.Toggler(null, function(_, state){ return state ?