mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-12-17 08:41:40 +00:00
almost finished the keyboard help/setup ui...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
3e861147e7
commit
b121a6327e
@ -81,7 +81,8 @@ var ImageGrid = {
|
|||||||
ImageGrid.GROUP('API',
|
ImageGrid.GROUP('API',
|
||||||
ImageGrid.ACTION({
|
ImageGrid.ACTION({
|
||||||
doc: 'Set option(s) value(s), calling apropriate callbacks.',
|
doc: 'Set option(s) value(s), calling apropriate callbacks.',
|
||||||
group: 'API'
|
group: 'API',
|
||||||
|
display: false,
|
||||||
},
|
},
|
||||||
function set(obj){
|
function set(obj){
|
||||||
for(var n in obj){
|
for(var n in obj){
|
||||||
@ -100,7 +101,8 @@ ImageGrid.GROUP('API',
|
|||||||
}),
|
}),
|
||||||
ImageGrid.ACTION({
|
ImageGrid.ACTION({
|
||||||
doc: 'Get documentation for name.',
|
doc: 'Get documentation for name.',
|
||||||
group: 'API'
|
group: 'API',
|
||||||
|
display: false,
|
||||||
},
|
},
|
||||||
function doc(name){
|
function doc(name){
|
||||||
return {
|
return {
|
||||||
@ -192,44 +194,67 @@ function toKeyName(code){
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// XXX merge this with showSetup as they are virtually identical...
|
||||||
function showKeyboardBindings(){
|
function showKeyboardBindings(){
|
||||||
// XXX get all the actions...
|
var actions = {}
|
||||||
// XXX get all the keys bound...
|
var groups = []
|
||||||
// XXX connect the two together, including:
|
// build the group/action structure...
|
||||||
// - unbound actions
|
for(var a in ImageGrid.actions){
|
||||||
// - undocumented keys
|
var group = ImageGrid[a].group
|
||||||
|
if(group.indexOf(groups) == -1){
|
||||||
|
groups.push(group)
|
||||||
// build an action indexed dict (effectively reverse keybindings)...
|
|
||||||
var res = {}
|
|
||||||
for(var k in keybindings){
|
|
||||||
var n = [toKeyName(k)]
|
|
||||||
// get the action name...
|
|
||||||
// XXX need a name here...
|
|
||||||
var v = keybindings[k]
|
|
||||||
// alias...
|
|
||||||
while(typeof(v) == typeof(3)){
|
|
||||||
// XXX skip for now...
|
|
||||||
// ...later we will need to accumolate all the keys in a list...
|
|
||||||
continue
|
|
||||||
}
|
}
|
||||||
// function...
|
if(actions[group] == null){
|
||||||
if(typeof(v) == typeof(function(){})){
|
actions[group] = []
|
||||||
// XXX title...
|
}
|
||||||
// XXX name...
|
actions[group].push([
|
||||||
// XXX ???
|
ImageGrid[a].title!=null?ImageGrid[a].title:a,
|
||||||
// Array...
|
a
|
||||||
} else if(typeof(v) == typeof([]) && v.constructor.name == 'Array'){
|
])
|
||||||
// XXX get the second arg...
|
}
|
||||||
// object...
|
// sort things...
|
||||||
} else if(typeof(v) == typeof({})){
|
groups.sort()
|
||||||
// XXX get all the handlers and accumolate the keys...
|
for(var g in actions){
|
||||||
// XXX unknown...
|
actions[g].sort(function(a, b){
|
||||||
} else {
|
a = a[0]
|
||||||
// XXX err...
|
b = b[0]
|
||||||
|
return a > b ? 1 : a < b ? -1 : 0
|
||||||
|
})
|
||||||
|
}
|
||||||
|
// build the HTML...
|
||||||
|
var ui = $('<div class="options"/>')
|
||||||
|
for(var g in actions){
|
||||||
|
var group = null
|
||||||
|
for(var i=0; i<actions[g].length; i++){
|
||||||
|
// get the action object...
|
||||||
|
var action = ImageGrid.actions[actions[g][i][1]]
|
||||||
|
if(!DEBUG && action.display == false){
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if(group == null){
|
||||||
|
group = $('<div class="group"/>')
|
||||||
|
.append($('<div class="title"/>').text(g!=null?g:'Other'))
|
||||||
|
}
|
||||||
|
var option
|
||||||
|
group.append(
|
||||||
|
option = $('<div class="option"/>').append($([
|
||||||
|
$('<div class="title"/>').text(actions[g][i][0])[0],
|
||||||
|
$('<div class="doc"/>').html(
|
||||||
|
action.doc?action.doc.replace(/\n/g, '<br>'):'')[0],
|
||||||
|
// XXX keys...
|
||||||
|
$('<div class="value"/>').text('KEY')[0],
|
||||||
|
])))
|
||||||
|
if(action.display == false){
|
||||||
|
option.addClass('disabled')
|
||||||
|
} else {
|
||||||
|
// XXX handler...
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(group != null){
|
||||||
|
ui.append(group)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var res = {}
|
showInOverlay(ui)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1073,7 +1098,7 @@ ImageGrid.GROUP('Mode: All',
|
|||||||
|
|
||||||
ImageGrid.ACTION({
|
ImageGrid.ACTION({
|
||||||
id: 'toggleControls',
|
id: 'toggleControls',
|
||||||
title: 'Keyboard-oriented interface',
|
title: 'Toggle keyboard-oriented interface',
|
||||||
doc: 'Toggle Touch/Keyboard UI controls.',
|
doc: 'Toggle Touch/Keyboard UI controls.',
|
||||||
type: 'toggle',
|
type: 'toggle',
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user