From ca9c39293df9794b9f7a30543d0863822dc83ce7 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Sat, 9 Dec 2017 01:39:06 +0300 Subject: [PATCH] several fixes and tweaks... Signed-off-by: Alex A. Naanou --- ui (gen4)/features/core.js | 3 +- ui (gen4)/features/examples.js | 136 ++++++++++++++----------------- ui (gen4)/features/keyboard.js | 10 ++- ui (gen4)/features/ui-chrome.js | 2 +- ui (gen4)/features/ui-status.js | 1 + ui (gen4)/features/ui-widgets.js | 19 +++++ ui (gen4)/features/ui.js | 2 +- 7 files changed, 92 insertions(+), 81 deletions(-) diff --git a/ui (gen4)/features/core.js b/ui (gen4)/features/core.js index edcf3625..e15c1671 100755 --- a/ui (gen4)/features/core.js +++ b/ui (gen4)/features/core.js @@ -1272,7 +1272,8 @@ var SelfTestActions = actions.Actions({ tests.forEach(function(action){ that[action]() - logger.emit('done', action) + logger + && logger.emit('done', action) }) })], }) diff --git a/ui (gen4)/features/examples.js b/ui (gen4)/features/examples.js index 213cf77b..42b374b8 100755 --- a/ui (gen4)/features/examples.js +++ b/ui (gen4)/features/examples.js @@ -657,10 +657,10 @@ var ExampleUIActions = actions.Actions({ }], + // XXX BUG: right limit indicator can get covered by the scrollbar... // XXX migrate to the dialog framework... // XXX use this.dom as base... - // XXX BUG: when using this.dom as base some actions leak - // between the two viewers... + // XXX BUG: this breaks keyboard handling when closed... showTaggedInDrawer: ['- Test/Show tagged in drawer', function(tag){ tag = tag || 'bookmark' @@ -672,10 +672,12 @@ var ExampleUIActions = actions.Actions({ height: H, background: 'black', }) + .attr('tabindex', '0') // XXX use this.dom as base... // XXX when using viewer zoom and other stuff get leaked... var widget = drawer.Drawer($('body'), $('
') + .addClass('image-list-widget') .css({ position: 'relative', height: H, @@ -684,95 +686,75 @@ var ExampleUIActions = actions.Actions({ { focusable: true, }) + .on('close', function(){ + that.nested.stop() + + //delete that.nested + }) + var data = this.data.crop(this.data.getTaggedByAll(tag), true) - var b = new core.ImageGrid() - - // used switch experimental actions on (set to true) or off (unset or false)... - //a.experimental = true - - // setup actions... - core.ImageGridFeatures.setup(b, [ - 'viewer-testing', - ]) - // setup the viewer... - // XXX for some reason if we load this with data and images - // the images will not show up... - b.load({ - viewer: viewer, - }) + this.nested = core.ImageGridFeatures + // setup actions... + // XXX prune the features a bit better... + .setup([ + 'viewer-testing', - // load some testing data... - // NOTE: we can (and do) load this in parts... - b + // NOTE: this if not disabled will create a feedback loop... + '-ui-url-hash', + + '-ui-single-image', + '-ui-chrome', + ]) + .run(function(){ + this.close = function(){ widget.close() } + + this.config['keyboard-event-source'] = viewer + + // XXX hack -- need a better way to set this (a setter?)... + this.__keyboard_config = { + 'Basic Control': { + pattern: '*', + + Home: 'firstImage!', + End: 'lastImage!', + Left: 'prevImage!', + ctrl_Left: 'prevScreen!', + meta_Left: 'prevScreen!', + PgUp: 'prevScreen!', + PgDown: 'nextScreen!', + Right: 'nextImage!', + ctrl_Right: 'nextScreen!', + meta_Right: 'nextScreen!', + + Esc: 'close!', + }, + } + }) + // load some testing data... .load({ + viewer: viewer, data: data, images: this.images, }) - // this is needed when loading legacy sources that do not have tags - // synced... - // do not do for actual data... - //.syncTags() .fitImage(1) - + // XXX for some reason this is not called... + .refresh() // link navigation... .on('focusImage', function(){ - that.focusImage(this.current) - }) + that.focusImage(this.current) }) + // start things up... + .start() + .focusImage() - // XXX setup keyboard... - var keyboard = require('lib/keyboard') + // XXX need to focus widget -- use a real trigger event instead of timer... + setTimeout(function(){ + that.nested.dom.focus() + }, 200) - /*/ XXX update this to use .keyboard - // XXX move this to the .config... - var kb = { - 'Basic Control': { - pattern: '*', - - Home: { - default: 'firstImage!', - }, - End: { - default: 'lastImage!', - }, - Left: { - default: 'prevImage!', - ctrl: 'prevScreen!', - // XXX need to prevent default on mac + browser... - meta: 'prevScreen!', - }, - PgUp: 'prevScreen!', - PgDown: 'nextScreen!', - Right: { - default: 'nextImage!', - ctrl: 'nextScreen!', - // XXX need to prevent default on mac + browser... - meta: 'nextScreen!', - }, - } - } - - widget.dom - // XXX - .keydown( - keyboard.dropRepeatingkeys( - keyboard.makeKeyboardHandler( - kb, - function(k){ - window.DEBUG && console.log(k) - }, - b), - function(){ - return that.config['max-key-repeat-rate'] - })) - //*/ - - // XXX STUB - window.b = b - - return b + return this.nested }], showBookmarkedInDrawer: ['Test/Show bookmarked in drawer', function(){ this.showTaggedInDrawer('bookmark') }], diff --git a/ui (gen4)/features/keyboard.js b/ui (gen4)/features/keyboard.js index 83891e78..fef112d3 100755 --- a/ui (gen4)/features/keyboard.js +++ b/ui (gen4)/features/keyboard.js @@ -516,12 +516,16 @@ var KeyboardActions = actions.Actions({ } var a = keyboard.parseActionCall(code, that) - var doc = a.doc || that.getDocTitle(a.action) || null + var doc = a.doc + || (that.getDocTitle && that.getDocTitle(a.action)) + || null // check if we have no doc... if(doc == null || doc == ''){ console.warn('Action has no doc: "' + a.action +'" at: "'+ code +'"') + // XXX ??? + return } // see if two actions have the same doc... @@ -845,6 +849,10 @@ module.Keyboard = core.ImageGridFeatures.Feature({ this.toggleKeyboardHandling('on') }], + + ['stop', + function(){ + this.toggleKeyboardHandling('off') }], // pause keyboard repeat... ['shiftImageUp.pre shiftImageDown.pre', diff --git a/ui (gen4)/features/ui-chrome.js b/ui (gen4)/features/ui-chrome.js index e2aae49e..eb7a200b 100755 --- a/ui (gen4)/features/ui-chrome.js +++ b/ui (gen4)/features/ui-chrome.js @@ -354,7 +354,7 @@ module.CurrentImageIndicator = core.ImageGridFeatures.Feature({ // XXX is it a good idea to used the same timers for all instances??? var makeIndicatorHiderOnFastAction = function(hide_timeout){ return function(){ - if(this.toggleSingleImage('?') == 'on'){ + if(this.toggleSingleImage && this.toggleSingleImage('?') == 'on'){ return } diff --git a/ui (gen4)/features/ui-status.js b/ui (gen4)/features/ui-status.js index c23ccad4..d431036b 100755 --- a/ui (gen4)/features/ui-status.js +++ b/ui (gen4)/features/ui-status.js @@ -671,6 +671,7 @@ module.StatusBar = core.ImageGridFeatures.Feature({ tag: 'ui-status-bar', depends: [ 'ui', + 'ui-chrome', // XXX this is here to enable context menu // see: StatusBarActions.__statusbar_elements__.mark(..) diff --git a/ui (gen4)/features/ui-widgets.js b/ui (gen4)/features/ui-widgets.js index 1ef3a44c..aabfc502 100755 --- a/ui (gen4)/features/ui-widgets.js +++ b/ui (gen4)/features/ui-widgets.js @@ -485,6 +485,8 @@ var makeDrawer = function(direction){ }) } + + //--------------------------------------------------------------------- // Higher level dialog action constructors... @@ -569,6 +571,21 @@ function makeConfigListEditorDialog(path, options){ +//--------------------------------------------------------------------- + +var Chrome = +module.Chrome = core.ImageGridFeatures.Feature({ + title: '', + doc: '', + + tag: 'ui-chrome', + depends: [ + 'ui', + ], +}) + + + //--------------------------------------------------------------------- var DialogsActions = actions.Actions({ @@ -852,6 +869,7 @@ module.Dialogs = core.ImageGridFeatures.Feature({ tag: 'ui-dialogs', depends: [ 'ui', + 'ui-chrome', ], actions: DialogsActions, @@ -2052,6 +2070,7 @@ module.Buttons = core.ImageGridFeatures.Feature({ tag: 'ui-buttons', depends: [ 'ui', + 'ui-chrome' ], suggested: [ // needed for reporting info in .makeButtonControls(..) diff --git a/ui (gen4)/features/ui.js b/ui (gen4)/features/ui.js index 6855d1a0..a3d25e28 100755 --- a/ui (gen4)/features/ui.js +++ b/ui (gen4)/features/ui.js @@ -993,7 +993,7 @@ module.URLHash = core.ImageGridFeatures.Feature({ ['stop', function(){ this.__hashchange_handler - && $(window).on('hashchange', this.__hashchange_handler) + && $(window).off('hashchange', this.__hashchange_handler) }], // store/restore hash when we focus images... ['focusImage',