diff --git a/editor.js b/editor.js
index f60148a..61c9329 100755
--- a/editor.js
+++ b/editor.js
@@ -211,27 +211,26 @@ function removePage(page){
/*********************************************************************/
// XXX this needs revision...
-// XXX need better separation between full screen and ribbon modes...
// XXX need to split this into more generic parts...
// XXX STUB
-// XXX setCurrentPage after each action...
-function _finalize(direction, n){
+function _finalize(n){
refreshInlineEditor()
- setCurrentPage(direction == 'before'? n : n+1)
+ setCurrentPage(n)
removeOverlay()
}
function addPage(direction){
var n = getPageNumber()
+ n = direction == 'before'? n : n+1
return function(){
showInOverlay($(
'
'))
}
}
diff --git a/index.html b/index.html
index b8e1c44..938846f 100755
--- a/index.html
+++ b/index.html
@@ -143,11 +143,13 @@ function showInfo(){
''))
}
-var keyboard_config = {
+var KEYBOARD_CONFIG = {
'.overlay': {
title: 'Overlay mode.',
doc: '',
+ ignore: '*',
+
Esc: function(){
removeOverlay()
return false
@@ -255,7 +257,7 @@ $(document).ready(function(){
// keyboard...
$(document)
- .keydown(makeKeyboardHandler(keyboard_config,
+ .keydown(makeKeyboardHandler(KEYBOARD_CONFIG,
function(k){console.log(k)}))
window.MagazineScroller = makeScrollHandler($('.viewer'), {
diff --git a/lib/keyboard.js b/lib/keyboard.js
index b35c39f..2ba21aa 100755
--- a/lib/keyboard.js
+++ b/lib/keyboard.js
@@ -84,40 +84,61 @@ function toKeyCode(c){
// if set to false the event handlers will always return false...
var KEYBOARD_HANDLER_PROPAGATE = true
-/* Basic key format:
+/* Basic key binding format:
*
- * : ,
+ * {
+ * : {
+ * // meta-data used to generate user docs/help/config
+ * title: ,
+ * doc: ,
*
- * : {
- * 'default': ,
- * // a modifier can be any single modifier, like shift or a
- * // combination of modifers like 'ctrl+shift', given in order
- * // of priority.
- * // supported modifiers are (in order of priority):
- * // - ctrl
- * // - alt
- * // - shift
- * : [...]
+ * // this defines the list of keys to ignore by the handler.
+ * // NOTE: use "*" to ignore all keys other than explicitly
+ * // defined in the current section.
+ * ignore:
+ *
+ * : ,
+ *
+ * : {
+ * 'default': ,
+ * // a modifier can be any single modifier, like shift or a
+ * // combination of modifers like 'ctrl+shift', given in order
+ * // of priority.
+ * // supported modifiers are (in order of priority):
+ * // - ctrl
+ * // - alt
+ * // - shift
+ * : [...],
+ * ...
+ * },
+ *
+ * : [
+ * // this can be any type of handler except for an alias...
+ * ,
+ *
+ * ],
+ *
+ * // alias...
+ * : ,
+ *
+ * ...
* },
*
- * : [
- * // this can be any type of handler except for an alias...
- * ,
- *
- * ],
- *
- * // alias...
- * : ,
+ * ...
+ * }
*
* can be:
* - explicit key code
* - key name, if present in _SPECIAL_KEYS)
* - key char (uppercase), as is returned by String.fromCharCode(...)
*
- *
+ * NOTE: all fields are optional.
* NOTE: if a handler explicitly returns false then that will break the
* event propagation chain and exit the handler.
* i.e. no other matching handlers will be called.
+ * NOTE: a is used as a predicate to select a section to
+ * use. if multiple selectors match something then multiple sections
+ * will be resolved in order of occurance.
*
* XXX might need to add meta information to generate sensible help...
*/
@@ -135,13 +156,6 @@ function makeKeyboardHandler(keybindings, unhandled){
var key = evt.keyCode
var chr = toKeyName(evt.keyCode)
- if(bindings.ignore == '*'
- || bindings.ignore != null && bindings.ignore.indexOf(key) != -1){
- // return true
- res = res == null ? true : res
- did_handling = true
- continue
- }
// XXX ugly...
var modifers = evt.ctrlKey ? 'ctrl' : ''
modifers += evt.altKey ? (modifers != '' ? '+alt' : 'alt') : ''
@@ -166,6 +180,14 @@ function makeKeyboardHandler(keybindings, unhandled){
}
// no handler...
if(handler == null){
+ // if something is ignored then just breakout and stop handling...
+ if(bindings.ignore == '*'
+ || bindings.ignore != null && bindings.ignore.indexOf(key) != -1){
+ res = res == null ? true : res
+ did_handling = true
+ // ignoring a key will stop processing it...
+ break
+ }
continue
}
// Array, lisp style with docs...
@@ -192,6 +214,7 @@ function makeKeyboardHandler(keybindings, unhandled){
// if the handler explicitly returned false break out...
if(res === false){
// XXX is this corrent???
+ // XXX should we just break here instead of return...
return KEYBOARD_HANDLER_PROPAGATE ? res : null
}
did_handling = true