mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-30 19:00: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',
|
'select',
|
||||||
'deselect',
|
'deselect',
|
||||||
|
|
||||||
'keydown',
|
//'keydown',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -1842,7 +1842,6 @@ PathListPrototype.options = {
|
|||||||
|
|
||||||
// setup handlers...
|
// setup handlers...
|
||||||
if(!star && data !== keys && kp.length == 0 && data[k] != null){
|
if(!star && data !== keys && kp.length == 0 && data[k] != null){
|
||||||
//console.log('>>> "'+ cur +'" -> "'+ k +'"')
|
|
||||||
e.on('open', function(){
|
e.on('open', function(){
|
||||||
return that.options.data[k].apply(this, arguments)
|
return that.options.data[k].apply(this, arguments)
|
||||||
})
|
})
|
||||||
|
|||||||
@ -9,6 +9,7 @@ console.log('>>> overlay')
|
|||||||
|
|
||||||
//var DEBUG = DEBUG != null ? DEBUG : true
|
//var DEBUG = DEBUG != null ? DEBUG : true
|
||||||
|
|
||||||
|
var keyboard = require('../keyboard')
|
||||||
var object = require('../../object')
|
var object = require('../../object')
|
||||||
var widget = require('./widget')
|
var widget = require('./widget')
|
||||||
|
|
||||||
@ -37,13 +38,23 @@ var OverlayClassPrototype = {
|
|||||||
|
|
||||||
var OverlayPrototype = {
|
var OverlayPrototype = {
|
||||||
dom: null,
|
dom: null,
|
||||||
|
client: null,
|
||||||
|
|
||||||
options: {
|
options: {
|
||||||
nonPropagatedEvents: [
|
nonPropagatedEvents: [
|
||||||
'clik',
|
'click',
|
||||||
//'keydown',
|
'keydown',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
||||||
|
keyboard: {
|
||||||
|
General: {
|
||||||
|
pattern: '.browse-widget',
|
||||||
|
|
||||||
|
Esc: 'close',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
// XXX triggering events from here and from jQuery/dom has a
|
// XXX triggering events from here and from jQuery/dom has a
|
||||||
// different effect...
|
// different effect...
|
||||||
trigger: widget.triggerEventWithSource,
|
trigger: widget.triggerEventWithSource,
|
||||||
@ -78,12 +89,14 @@ var OverlayPrototype = {
|
|||||||
parent = this.parent = $(parent || 'body')
|
parent = this.parent = $(parent || 'body')
|
||||||
options = options || {}
|
options = options || {}
|
||||||
|
|
||||||
|
this.client = client
|
||||||
|
|
||||||
// merge options...
|
// merge options...
|
||||||
var opts = Object.create(this.options)
|
var opts = Object.create(this.options)
|
||||||
Object.keys(options).forEach(function(n){ opts[n] = options[n] })
|
Object.keys(options).forEach(function(n){ opts[n] = options[n] })
|
||||||
options = this.options = opts
|
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(){
|
.click(function(){
|
||||||
that.close()
|
that.close()
|
||||||
})
|
})
|
||||||
@ -92,6 +105,18 @@ var OverlayPrototype = {
|
|||||||
.addClass('blur')
|
.addClass('blur')
|
||||||
.append(dom)
|
.append(dom)
|
||||||
|
|
||||||
|
// add keyboard handler...
|
||||||
|
dom.keydown(
|
||||||
|
keyboard.makeKeyboardHandler(
|
||||||
|
this.keyboard,
|
||||||
|
options.logKeys,
|
||||||
|
this))
|
||||||
|
|
||||||
|
// focus the client...
|
||||||
|
if(client.focus){
|
||||||
|
client.focus()
|
||||||
|
}
|
||||||
|
|
||||||
return this
|
return this
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@ -236,27 +236,36 @@ $(function(){
|
|||||||
window.browse = browse
|
window.browse = browse
|
||||||
window.overlay = overlay
|
window.overlay = overlay
|
||||||
|
|
||||||
|
actionCategoryOrder = [
|
||||||
|
'File',
|
||||||
|
'Edit',
|
||||||
|
'Navigate',
|
||||||
|
]
|
||||||
|
|
||||||
var makeActionLister = function(list, filter){
|
var makeActionLister = function(list, filter){
|
||||||
return function(){
|
return function(){
|
||||||
var paths = a.getPath()
|
var paths = a.getPath()
|
||||||
var actions = {}
|
var actions = {}
|
||||||
|
|
||||||
|
// pre-order the main categories...
|
||||||
|
actionCategoryOrder.forEach(function(k){
|
||||||
|
actions[k] = null
|
||||||
|
})
|
||||||
|
|
||||||
|
// build the action list...
|
||||||
Object.keys(paths).forEach(function(k){
|
Object.keys(paths).forEach(function(k){
|
||||||
var n = paths[k][0]
|
var n = paths[k][0]
|
||||||
var k = filter ? filter(k) : k
|
var k = filter ? filter(k) : k
|
||||||
actions[k] = function(){
|
actions[k] = function(){
|
||||||
console.log('>>>>', n, k)
|
|
||||||
return a[n]()
|
return a[n]()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
var b = L = list(null, actions)
|
var o = overlay.Overlay($('body'),
|
||||||
var o = overlay.Overlay($('body'), b.dom)
|
list(null, actions)
|
||||||
|
.open(function(){ o.close() }))
|
||||||
|
|
||||||
b.open(function(){ o.close() })
|
L = o.client
|
||||||
|
|
||||||
b.focus()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user