almost finished the keyboard help/setup ui...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2012-08-19 23:18:11 +04:00
parent 3e861147e7
commit b121a6327e

View File

@ -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 = {} if(actions[group] == null){
for(var k in keybindings){ actions[group] = []
var n = [toKeyName(k)] }
// get the action name... actions[group].push([
// XXX need a name here... ImageGrid[a].title!=null?ImageGrid[a].title:a,
var v = keybindings[k] a
// alias... ])
while(typeof(v) == typeof(3)){ }
// XXX skip for now... // sort things...
// ...later we will need to accumolate all the keys in a list... groups.sort()
for(var g in actions){
actions[g].sort(function(a, b){
a = a[0]
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 continue
} }
// function... if(group == null){
if(typeof(v) == typeof(function(){})){ group = $('<div class="group"/>')
// XXX title... .append($('<div class="title"/>').text(g!=null?g:'Other'))
// XXX name... }
// XXX ??? var option
// Array... group.append(
} else if(typeof(v) == typeof([]) && v.constructor.name == 'Array'){ option = $('<div class="option"/>').append($([
// XXX get the second arg... $('<div class="title"/>').text(actions[g][i][0])[0],
// object... $('<div class="doc"/>').html(
} else if(typeof(v) == typeof({})){ action.doc?action.doc.replace(/\n/g, '<br>'):'')[0],
// XXX get all the handlers and accumolate the keys... // XXX keys...
// XXX unknown... $('<div class="value"/>').text('KEY')[0],
])))
if(action.display == false){
option.addClass('disabled')
} else { } else {
// XXX err... // XXX handler...
} }
} }
var res = {} if(group != null){
ui.append(group)
}
}
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',
}, },