Created
January 17, 2009 05:18
-
-
Save gcr/48269 to your computer and use it in GitHub Desktop.
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 is a VERY heavily abridged part of my code for event | |
handlers and editable DIVs. | |
The full code can be found here: http://github.com/hotdog003/gutenborg/tree/master */ | |
function gbDocument(docname) { | |
// This creates a new document then subscribes us to it. | |
this.jqedit = $("<div class='gb-editor'></div>"); // Our jQuery text editor | |
// ... | |
this.enable_editing = function() { | |
this.jqedit.attr("contentEditable", true); | |
// Save the document object | |
doc = this; | |
this.jqedit.keypress(function(event) { | |
doc.keyevent(event); | |
}); | |
// FILTHY IE workaround | |
if ($.browser.msie) { | |
this.jqedit.keydown(function(event) { | |
if (event.which == 8 || event.which == 46) { | |
doc.keyevent(event); | |
} | |
}); | |
} | |
} | |
this.keyevent = function(event) { | |
// What to do when we get a keypress | |
alert(event.which); | |
event.preventDefault(); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment