Permalink
Browse files

Added post-load callback; and added "simple" layout.

--HG--
extra : rebase_source : 24b1c5ac0628ee615c08ebf3007b237960fad280
  • Loading branch information...
1 parent a7c178c commit 44f2c90623cca2f89ff8ce761c2c7bcf55c393ab @tomgidden tomgidden committed Mar 18, 2013
Showing with 61 additions and 6 deletions.
  1. +7 −6 jquery.osk.js
  2. +54 −0 layouts/simple.json
View
@@ -1,16 +1,17 @@
(function($) {
//create a keyboard
//layoutURL: URL for the keyboard layout
-//callback: each character generated by the keyboard will be passed to this function
-$.fn.loadLayout = function(layoutURL, callback) {
+//callback_keypress: each character generated by the keyboard will be passed to this function
+//callback_loaded: once the layout has loaded and the keyboard initialised, this function is called
+$.fn.loadLayout = function(layoutURL, callback_keypress, callback_loaded) {
var keyboard = new Keyboard($(this[0]));
- callback = callback || false;
+ if (callback_keypress)
+ keyboard.callback = callback_keypress;
$.getJSON(layoutURL, function(layout) {
addKeys(layout, keyboard);
draw(keyboard);
+ if(callback_loaded) callback_loaded.apply(this);
});
- if (callback)
- keyboard.callback = callback;
return this;
};
@@ -187,4 +188,4 @@ function modify(keyboard) {
for (var id in keyboard.keyIDs)
keyboard.keyIDs[id].modify(keyboard.modifiers);
}
-})(jQuery)
+})(jQuery)
View
@@ -0,0 +1,54 @@
+[
+ [
+ {"id": "key_1", "label": "1", "sLabel": "!"},
+ {"id": "key_2", "label": "2", "sLabel": "@"},
+ {"id": "key_3", "label": "3", "sLabel": "#"},
+ {"id": "key_4", "label": "4", "sLabel": "$"},
+ {"id": "key_5", "label": "5", "sLabel": "%"},
+ {"id": "key_6", "label": "6", "sLabel": "^"},
+ {"id": "key_7", "label": "7", "sLabel": "&"},
+ {"id": "key_8", "label": "8", "sLabel": "*"},
+ {"id": "key_9", "label": "9", "sLabel": "("},
+ {"id": "key_0", "label": "0", "sLabel": ")"},
+ {"id": "key_backspace", "label": "\u232b", "sLabel": "\u232b", "func": "backspace", "sFunc": "backspace"}
+ ],
+ [
+ {"id": "key_q", "label": "q"},
+ {"id": "key_w", "label": "w"},
+ {"id": "key_e", "label": "e"},
+ {"id": "key_r", "label": "r"},
+ {"id": "key_t", "label": "t"},
+ {"id": "key_y", "label": "y"},
+ {"id": "key_u", "label": "u"},
+ {"id": "key_i", "label": "i"},
+ {"id": "key_o", "label": "o"},
+ {"id": "key_p", "label": "p"},
+ {"id": "key_singlequote", "label": "’", "sLabel": "\""}
+ ],
+ [
+ {"id": "key_a", "label": "a"},
+ {"id": "key_s", "label": "s"},
+ {"id": "key_d", "label": "d"},
+ {"id": "key_f", "label": "f"},
+ {"id": "key_g", "label": "g"},
+ {"id": "key_h", "label": "h"},
+ {"id": "key_j", "label": "j"},
+ {"id": "key_k", "label": "k"},
+ {"id": "key_l", "label": "l"},
+ {"id": "key_enter", "label": "Enter", "sLabel": "Enter", "func": "enter", "sFunc": "enter"}
+ ],
+ [
+ {"id": "key_left", "label": "", "sLabel": "", "func": "left", "sFunc": "left"},
+ {"id": "key_z", "label": "z"},
+ {"id": "key_x", "label": "x"},
+ {"id": "key_c", "label": "c"},
+ {"id": "key_v", "label": "v"},
+ {"id": "key_b", "label": "b"},
+ {"id": "key_n", "label": "n"},
+ {"id": "key_m", "label": "m"},
+ {"id": "key_right", "label": "", "sLabel": "", "func": "right", "sFunc": "right"}
+ ],
+ [
+ {"id": "key_spacebar", "label": "Space", "sLabel": "Space", "func": "space", "sFunc": "space"}
+ ]
+]

0 comments on commit 44f2c90

Please sign in to comment.