[livejournal] r18774: LJSV-1426: Incorrect behavior when sendi...
Committer: pkornilov
LJSV-1426: Incorrect behavior when sending private messageU trunk/htdocs/js/jquery_fn.js
Modified: trunk/htdocs/js/jquery_fn.js
===================================================================
--- trunk/htdocs/js/jquery_fn.js 2011-04-01 10:09:11 UTC (rev 18773)
+++ trunk/htdocs/js/jquery_fn.js 2011-04-04 03:13:47 UTC (rev 18774)
@@ -168,6 +168,21 @@
: this.trigger("input");
}
+// ctrl+enter send form
+jQuery.fn.disableEnterSubmit = function() {
+ this.bind("keypress", function(e) {
+ // keyCode == 10 in IE with ctrlKey
+ if ((e.which === 13 || e.which === 10) && e.target && e.target.form) {
+ if (e.target.tagName === "TEXTAREA" && e.ctrlKey && !jQuery(":submit", e.target.form).attr("disabled")) {
+ e.target.form.submit();
+ } else if (e.target.type === "text" && !e.ctrlKey) { // for input:text
+ e.preventDefault();
+ }
+ }
+ });
+ return this;
+};
+
/* function based on markup:
tab links: ul>li>a
current tab: ul>li.current
