several fixes and tweaks...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2017-12-09 01:39:06 +03:00
parent 80f579e31c
commit ca9c39293d
7 changed files with 92 additions and 81 deletions

View File

@ -1272,7 +1272,8 @@ var SelfTestActions = actions.Actions({
tests.forEach(function(action){ tests.forEach(function(action){
that[action]() that[action]()
logger.emit('done', action) logger
&& logger.emit('done', action)
}) })
})], })],
}) })

View File

@ -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 migrate to the dialog framework...
// XXX use this.dom as base... // XXX use this.dom as base...
// XXX BUG: when using this.dom as base some actions leak // XXX BUG: this breaks keyboard handling when closed...
// between the two viewers...
showTaggedInDrawer: ['- Test/Show tagged in drawer', showTaggedInDrawer: ['- Test/Show tagged in drawer',
function(tag){ function(tag){
tag = tag || 'bookmark' tag = tag || 'bookmark'
@ -672,10 +672,12 @@ var ExampleUIActions = actions.Actions({
height: H, height: H,
background: 'black', background: 'black',
}) })
.attr('tabindex', '0')
// XXX use this.dom as base... // XXX use this.dom as base...
// XXX when using viewer zoom and other stuff get leaked... // XXX when using viewer zoom and other stuff get leaked...
var widget = drawer.Drawer($('body'), var widget = drawer.Drawer($('body'),
$('<div>') $('<div>')
.addClass('image-list-widget')
.css({ .css({
position: 'relative', position: 'relative',
height: H, height: H,
@ -684,95 +686,75 @@ var ExampleUIActions = actions.Actions({
{ {
focusable: true, focusable: true,
}) })
.on('close', function(){
that.nested.stop()
//delete that.nested
})
var data = this.data.crop(this.data.getTaggedByAll(tag), true) 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... // setup the viewer...
// XXX for some reason if we load this with data and images this.nested = core.ImageGridFeatures
// the images will not show up... // setup actions...
b.load({ // XXX prune the features a bit better...
viewer: viewer, .setup([
}) 'viewer-testing',
// load some testing data... // NOTE: this if not disabled will create a feedback loop...
// NOTE: we can (and do) load this in parts... '-ui-url-hash',
b
'-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({ .load({
viewer: viewer,
data: data, data: data,
images: this.images, 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) .fitImage(1)
// XXX for some reason this is not called...
.refresh()
// link navigation... // link navigation...
.on('focusImage', function(){ .on('focusImage', function(){
that.focusImage(this.current) that.focusImage(this.current) })
}) // start things up...
.start()
.focusImage()
// XXX setup keyboard... // XXX need to focus widget -- use a real trigger event instead of timer...
var keyboard = require('lib/keyboard') setTimeout(function(){
that.nested.dom.focus()
}, 200)
/*/ XXX update this to use .keyboard return this.nested
// 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
}], }],
showBookmarkedInDrawer: ['Test/Show bookmarked in drawer', showBookmarkedInDrawer: ['Test/Show bookmarked in drawer',
function(){ this.showTaggedInDrawer('bookmark') }], function(){ this.showTaggedInDrawer('bookmark') }],

View File

@ -516,12 +516,16 @@ var KeyboardActions = actions.Actions({
} }
var a = keyboard.parseActionCall(code, that) 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... // check if we have no doc...
if(doc == null || doc == ''){ if(doc == null || doc == ''){
console.warn('Action has no doc: "' console.warn('Action has no doc: "'
+ a.action +'" at: "'+ code +'"') + a.action +'" at: "'+ code +'"')
// XXX ???
return
} }
// see if two actions have the same doc... // see if two actions have the same doc...
@ -845,6 +849,10 @@ module.Keyboard = core.ImageGridFeatures.Feature({
this.toggleKeyboardHandling('on') this.toggleKeyboardHandling('on')
}], }],
['stop',
function(){
this.toggleKeyboardHandling('off') }],
// pause keyboard repeat... // pause keyboard repeat...
['shiftImageUp.pre shiftImageDown.pre', ['shiftImageUp.pre shiftImageDown.pre',

View File

@ -354,7 +354,7 @@ module.CurrentImageIndicator = core.ImageGridFeatures.Feature({
// XXX is it a good idea to used the same timers for all instances??? // XXX is it a good idea to used the same timers for all instances???
var makeIndicatorHiderOnFastAction = function(hide_timeout){ var makeIndicatorHiderOnFastAction = function(hide_timeout){
return function(){ return function(){
if(this.toggleSingleImage('?') == 'on'){ if(this.toggleSingleImage && this.toggleSingleImage('?') == 'on'){
return return
} }

View File

@ -671,6 +671,7 @@ module.StatusBar = core.ImageGridFeatures.Feature({
tag: 'ui-status-bar', tag: 'ui-status-bar',
depends: [ depends: [
'ui', 'ui',
'ui-chrome',
// XXX this is here to enable context menu // XXX this is here to enable context menu
// see: StatusBarActions.__statusbar_elements__.mark(..) // see: StatusBarActions.__statusbar_elements__.mark(..)

View File

@ -485,6 +485,8 @@ var makeDrawer = function(direction){
}) })
} }
//--------------------------------------------------------------------- //---------------------------------------------------------------------
// Higher level dialog action constructors... // 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({ var DialogsActions = actions.Actions({
@ -852,6 +869,7 @@ module.Dialogs = core.ImageGridFeatures.Feature({
tag: 'ui-dialogs', tag: 'ui-dialogs',
depends: [ depends: [
'ui', 'ui',
'ui-chrome',
], ],
actions: DialogsActions, actions: DialogsActions,
@ -2052,6 +2070,7 @@ module.Buttons = core.ImageGridFeatures.Feature({
tag: 'ui-buttons', tag: 'ui-buttons',
depends: [ depends: [
'ui', 'ui',
'ui-chrome'
], ],
suggested: [ suggested: [
// needed for reporting info in .makeButtonControls(..) // needed for reporting info in .makeButtonControls(..)

View File

@ -993,7 +993,7 @@ module.URLHash = core.ImageGridFeatures.Feature({
['stop', ['stop',
function(){ function(){
this.__hashchange_handler this.__hashchange_handler
&& $(window).on('hashchange', this.__hashchange_handler) && $(window).off('hashchange', this.__hashchange_handler)
}], }],
// store/restore hash when we focus images... // store/restore hash when we focus images...
['focusImage', ['focusImage',