Author: rfrovarp
Date: Mon Jul 30 09:42:23 2007
New Revision: 561035
URL: http://svn.apache.org/viewvc?view=rev&rev=561035
Log:
New disable backspace code that registers itself merely by being loaded. Change FCK usecase to try to register itself as an event to onload. This would allow for multiple onload's to happen if necessary in the future.
Modified:
lenya/trunk/src/modules/editors/resources/javascript/disablebackspace.js
lenya/trunk/src/modules/fckeditor/usecases/fckeditor.jx
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=561035&r1=561034&r2=561035
==============================================================================
--- lenya/trunk/src/modules/editors/resources/javascript/disablebackspace.js (original)
+++ lenya/trunk/src/modules/editors/resources/javascript/disablebackspace.js Mon Jul 30 09:42:23 2007
@@ -15,16 +15,37 @@
* limitations under the License.
*/
-function checkBackspace(e)
+/*
+* Processes the event. Ordering is important for Opera 9 on Windows,
+* as it must use the Mozilla style code, but will match IE style code.
+*/
+function LenyaDisableBackspace(e)
{
- var key;
- if(window.event)
- key = window.event.keyCode;
- else
- key = e.which;
- if (key == 8) {
- alert("disablebackspace.js just ate a backspace event. Burp!");
- return false;
- } else
- return true;
+ // 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;
+ }
+ // 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;
+ }
+ return true;
}
+
+/*
+* Register event handler.
+* This does not need to wait for onload to fire.
+*/
+// Mozilla style for Opera and Safari as well
+if(typeof document.addEventListener != 'undefined') {
+ document.addEventListener('keypress',LenyaDisableBackspace,false);
+}
+// IE style code for IE 6 and IE 7. Should work on IE 5.5+
+else if(typeof document.attachEvent != 'undefined') {
+ document.attachEvent('onkeydown',LenyaDisableBackspace);
+}
+
Modified: lenya/trunk/src/modules/fckeditor/usecases/fckeditor.jx
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/fckeditor/usecases/fckeditor.jx?view=diff&rev=561035&r1=561034&r2=561035
==============================================================================
--- lenya/trunk/src/modules/fckeditor/usecases/fckeditor.jx (original)
+++ lenya/trunk/src/modules/fckeditor/usecases/fckeditor.jx Mon Jul 30 09:42:23 2007
@@ -30,10 +30,19 @@
<script type="text/javascript" src="/modules/editors/javascript/org.apache.lenya.editors.js"> </script>
<script type="text/javascript" src="/modules/fckeditor/javascript/fck_lenya_glue.js"> </script>
<script type="text/javascript">
- window.onload = function()
- {
+ function loadfckloader() {
fckloader('${usecase.getParameter('requesturi')}', '${request.getContextPath()}');
}
+
+ if(typeof window.addEventListener != 'undefined') {
+ window.addEventListener('load',loadfckloader,false);
+ }
+ else if(typeof window.attachEvent != 'undefined') {
+ window.attachEvent('onload',loadfckloader);
+ }
+ else {
+ window.onload = loadfckloader();
+ }
</script>
<page:title>FCKeditor - Sample</page:title>
@@ -45,7 +54,7 @@
</page:body>
</jx:when>
<jx:otherwise>
- <page:body onkeydown="return checkBackspace(event)" onkeypress="return checkBackspace(event)" >
+ <page:body>
<div class="lenya-box">
<div class="lenya-box-title">Information</div>
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.