mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 18:30:09 +00:00
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:
parent
57ecfb8391
commit
6b009137c5
@ -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)
|
||||
})
|
||||
|
||||
@ -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
|
||||
},
|
||||
}
|
||||
|
||||
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user