diff options
Diffstat (limited to 'input-focus.js')
-rw-r--r-- | input-focus.js | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/input-focus.js b/input-focus.js new file mode 100644 index 0000000..323efd0 --- /dev/null +++ b/input-focus.js @@ -0,0 +1,29 @@ +/* + (c) 2009 by Leon Winter + (c) 2009 by Hannes Schueller + see LICENSE file +*/ + +function vimprobable_v(e, y) { + t = e.nodeName.toLowerCase(); + if((t == 'input' && /^(text|password|checkbox|radio)$/.test(e.type)) + || /^(select|textarea)$/.test(t) + || e.contentEditable == 'true') + console.log('insertmode_'+(y=='focus'?'on':'off')); +} + +if(document.activeElement) + vimprobable_v(document.activeElement,'focus'); + +vimprobable_m=['focus','blur']; + +if (document.getElementsByTagName("body")[0] !== null && typeof(document.getElementsByTagName("body")[0]) == "object") { + for(i in vimprobable_m) + document.getElementsByTagName('body')[0].addEventListener(vimprobable_m[i], function(x) { + vimprobable_v(x.target,x.type); + }, true); +} + +self.onunload = function() { + vimprobable_v(document.activeElement, ''); +}; |