svn commit: r563892 - /lenya/trunk/src/modules/editors/resources/javascript/disablebackspace.js

[email protected]
Newsgroups gmane.comp.cms.lenya.cvs
Message-ID <[email protected]>
Author: rfrovarp
Date: Wed Aug  8 07:17:29 2007
New Revision: 563892

URL: http://svn.apache.org/viewvc?view=rev&rev=563892
Log:
Fixes issue with the script eating backspaces in the editing area. Thanks to Jörn for reporting.

Modified:
    lenya/trunk/src/modules/editors/resources/javascript/disablebackspace.js

Modified: lenya/trunk/src/modules/editors/resources/javascript/disablebackspace.js
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/editors/resources/javascript/disablebackspace.js?view=diff&rev=563892&r1=563891&r2=563892
==============================================================================
--- lenya/trunk/src/modules/editors/resources/javascript/disablebackspace.js (original)
+++ lenya/trunk/src/modules/editors/resources/javascript/disablebackspace.js Wed Aug  8 07:17:29 2007
@@ -23,15 +23,24 @@
 {
   // Mozilla style code for Opera and Safari as well
   // For Opera 9 under Windows to work properly, the Mozilla test must be first.
-  if(typeof document.addEventListener != 'undefined' && e.which == 8) {
-    e.preventDefault();
-    e.stopPropagation();
-    return false;
+  if(typeof document.addEventListener != 'undefined') {
+    var src = e.target.type;
+    var key = e.which;
+//alert(src);
+    if( key == 8 && (src != 'text' && src != 'textarea')) {
+      e.preventDefault();
+      e.stopPropagation();
+      return false;
+    }
   }
   // IE style code for IE 6 and IE 7. Should work on IE 5.5+
-  else if(typeof document.attachEvent != 'undefined' && window.event && window.event.keyCode == 8) {
-    window.event.cancelBubble = true;
-    return false;
+  else if(typeof document.attachEvent != 'undefined' && window.event) {
+    var src = event.srcElement.type;
+    var key = window.event.keyCode;
+    if(key == 8 && (src != 'text' && src != 'textarea')) {
+      window.event.cancelBubble = true;
+      return false;
+    }
   }
   return true;
 }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.