some tweaking to the widget framework, still not really a framework, but rather an API ;)

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2015-09-12 03:10:42 +03:00
parent 57ecfb8391
commit 6b009137c5
3 changed files with 44 additions and 11 deletions

View File

@ -146,7 +146,7 @@ var BrowserPrototype = {
'select',
'deselect',
'keydown',
//'keydown',
],
},
@ -1842,7 +1842,6 @@ PathListPrototype.options = {
// setup handlers...
if(!star && data !== keys && kp.length == 0 && data[k] != null){
//console.log('>>> "'+ cur +'" -> "'+ k +'"')
e.on('open', function(){
return that.options.data[k].apply(this, arguments)
})

View File

@ -9,6 +9,7 @@ console.log('>>> overlay')
//var DEBUG = DEBUG != null ? DEBUG : true
var keyboard = require('../keyboard')
var object = require('../../object')
var widget = require('./widget')
@ -37,13 +38,23 @@ var OverlayClassPrototype = {
var OverlayPrototype = {
dom: null,
client: null,
options: {
nonPropagatedEvents: [
'clik',
//'keydown',
'click',
'keydown',
],
},
keyboard: {
General: {
pattern: '.browse-widget',
Esc: 'close',
},
},
// XXX triggering events from here and from jQuery/dom has a
// different effect...
trigger: widget.triggerEventWithSource,
@ -78,12 +89,14 @@ var OverlayPrototype = {
parent = this.parent = $(parent || 'body')
options = options || {}
this.client = client
// merge options...
var opts = Object.create(this.options)
Object.keys(options).forEach(function(n){ opts[n] = options[n] })
options = this.options = opts
var dom = this.dom = this.constructor.make(client, options)
var dom = this.dom = this.constructor.make(client.dom || client, options)
.click(function(){
that.close()
})
@ -92,6 +105,18 @@ var OverlayPrototype = {
.addClass('blur')
.append(dom)
// add keyboard handler...
dom.keydown(
keyboard.makeKeyboardHandler(
this.keyboard,
options.logKeys,
this))
// focus the client...
if(client.focus){
client.focus()
}
return this
},
}

View File

@ -236,27 +236,36 @@ $(function(){
window.browse = browse
window.overlay = overlay
actionCategoryOrder = [
'File',
'Edit',
'Navigate',
]
var makeActionLister = function(list, filter){
return function(){
var paths = a.getPath()
var actions = {}
// pre-order the main categories...
actionCategoryOrder.forEach(function(k){
actions[k] = null
})
// build the action list...
Object.keys(paths).forEach(function(k){
var n = paths[k][0]
var k = filter ? filter(k) : k
actions[k] = function(){
console.log('>>>>', n, k)
return a[n]()
}
})
var b = L = list(null, actions)
var o = overlay.Overlay($('body'), b.dom)
var o = overlay.Overlay($('body'),
list(null, actions)
.open(function(){ o.close() }))
b.open(function(){ o.close() })
b.focus()
L = o.client
}
}