Skip to content

Instantly share code, notes, and snippets.

@riffm
Created July 16, 2009 14:56
Show Gist options
  • Save riffm/148453 to your computer and use it in GitHub Desktop.
Save riffm/148453 to your computer and use it in GitHub Desktop.
var Key = new Class({
initialize:function(symbol, handler){
this.symbol = symbol;
this.handler = handler;
},
render:function(){
return new Element('a',{
'href':'#',
'text':this.symbol,
});
}
});
var KeyBoard = new Class({
initialize:function(panelID){
//this.panel = $(panelID);
this.chars = ['й','ц','у','к','е','н','г','ш','щ','з','х','ъ'];
this.body = new Element('div', {
'id':'keyboard',
'class':'keyboard',
'text':''
});
},
initKeys:function(){
this.chars.each(function(item, index){
this.keys.push(new Key(item, this.typeHandler.bind(this)));
});
},
typeHandler:function(e){
e.stop();
console.log(e.target.symbol);
},
render:function(){
this.keys.each(function(item, index){
item.render().inject(this.body);
});
this.body.inject(document.body);
}
});
window.addEvent('domready', function(){
var keyBoard = new KeyBoard('panel');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment