Created
October 22, 2012 22:02
-
-
Save Iheartweb/3934854 to your computer and use it in GitHub Desktop.
Keyboard Manager
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| This maps the 'body' to a Lu component. you can also write a pattern like | |
| $('[data-lu~=KeyManager]'). Abstract is our EventProvider - it is modeled | |
| after and proxies jQuery events. | |
| */ | |
| Map.add( $( 'body' ), 'Abstract', function( $body ){ | |
| //A few things are available in this scope | |
| //The settings that will be used | |
| this.settings.foo = 'bar'; | |
| //this is the key to be used when passing configuration in data-lu-config | |
| //so providing data-lu-config="{ foo: { bar: true } }" will pass the foo object to | |
| //this instance before instantiation | |
| this.key = 'foo'; | |
| //every component has a deferral .ready is a shortcut into it's resolution | |
| this.ready( function( Abstract ){ | |
| //this line gets translated to $body.trigger( 'lu:keypress', ['foo','bar'] ); | |
| Abstract.trigger( 'keypress', ['foo', 'bar'] ); | |
| //This is where all of the key management code should live for now. | |
| $body.keypress( function(){ | |
| //... | |
| } ); | |
| } ); | |
| } ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment