Author: max
Date: 2007-11-15 14:39:20 -0800 (Thu, 15 Nov 2007)
New Revision: 7295

Modified:
   openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzInputTextSprite.js
   openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzKeyboardKernel.js
   openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzMouseKernel.js
   openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzSprite.js
   openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzTextSprite.js
   openlaszlo/trunk/lps/includes/source/LzMousewheelKernel.js
Log:
Change 20071115-maxcarlson-R by [EMAIL PROTECTED] on 2007-11-15 10:34:26 PST
    in /Users/maxcarlson/openlaszlo/trunk
    for http://svn.openlaszlo.org/openlaszlo/trunk

Summary: Use Lz.attachEventHandler() instead of binding directly to window and 
document events

New Features:

Bugs Fixed: LPP-4715 - Include a method for attaching event handlers in the 
platform javascript

Technical Reviewer: promanik
QA Reviewer: jcrowley
Doc Reviewer: (pending)

Documentation:

Release Notes:

Details: LzKeyboardKernel.js - Add comments.

LzSprite.js - Use single function to dispatch sprite mouse events.  Remove 
obsolete cleanup in  __cleanUpForIE().

LzTextSprite.js - Refactor text/inputtext selection to LzInputTextSprite.js.

LzMouseKernel.js - Use Lz.attachEventHandler() for event bindings, except for 
oncontextmenu.

LzInputTextSprite.js - Improve comments, unify text/inputtext selection control.

LzMousewheelKernel.js - Use Lz.attachEventHandler() to listen for mousewheel 
events.
    

Tests: Tested LzPix, Amazon and the components sampler in IE 6 and 7, Safari 3 
OS X, and Firefox 2 OS x.  Tested with IE 6 and drip detector to confirm there 
are no memory leaks.  



Modified: openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzInputTextSprite.js
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzInputTextSprite.js  
2007-11-15 22:30:42 UTC (rev 7294)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzInputTextSprite.js  
2007-11-15 22:39:20 UTC (rev 7295)
@@ -119,7 +119,8 @@
         this.__LZinputclickdiv.appendChild(this.__LzInputDiv);
     }
     //Debug.write('show');
-    // turn on selection in IE
+    // turn on text selection in IE
+    // can't use Lz.attachEventHandler because we need to cancel events 
selectively
     document.onselectstart = null;
 }
 
@@ -181,7 +182,8 @@
     }
     this.__LZdiv.appendChild(this.__LzInputDiv);
     //Debug.write('hide');
-    // turn off selection in IE
+    // turn off text selection in IE
+    // can't use Lz.attachEventHandler because we need to cancel events 
selectively
     document.onselectstart = LzTextSprite.prototype.__cancelhandler;
 }
 
@@ -427,3 +429,8 @@
     }    
     return h;
 }
+
+// prevent text selection in IE
+// can't use Lz.attachEventHandler because we need to cancel events
+document.onselectstart = LzTextSprite.prototype.__cancelhandler;
+document.ondrag =  LzTextSprite.prototype.__cancelhandler;

Modified: openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzKeyboardKernel.js
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzKeyboardKernel.js   
2007-11-15 22:30:42 UTC (rev 7294)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzKeyboardKernel.js   
2007-11-15 22:39:20 UTC (rev 7295)
@@ -80,6 +80,7 @@
         this.__scope = scope;
         this.__callback = keyboardcallback;
         if (lzOptions.dhtmlKeyboardControl != false) {
+            // can't use Lz.attachEventHandler because we need to cancel 
events selectively
             document.onkeydown = LzKeyboardKernel.__keyboardEvent;
             document.onkeyup = LzKeyboardKernel.__keyboardEvent;
             document.onkeypress = LzKeyboardKernel.__keyboardEvent;

Modified: openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzMouseKernel.js
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzMouseKernel.js      
2007-11-15 22:30:42 UTC (rev 7294)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzMouseKernel.js      
2007-11-15 22:39:20 UTC (rev 7295)
@@ -64,9 +64,10 @@
         this.__scope = scope;
         this.__callback = funcname;
 
-        document.onmousemove = LzMouseKernel.__mouseEvent;
-        document.onmousedown = LzMouseKernel.__mouseEvent;
-        document.onmouseup = LzMouseKernel.__mouseEvent;
+        Lz.attachEventHandler(document, 'mousemove', LzMouseKernel, 
'__mouseEvent');
+        Lz.attachEventHandler(document, 'mousedown', LzMouseKernel, 
'__mouseEvent');
+        Lz.attachEventHandler(document, 'mouseup', LzMouseKernel, 
'__mouseEvent');
+        // Prevent context menus in Firefox 1.5 - see LPP-2678
         document.oncontextmenu = LzMouseKernel.__mouseEvent;
     }    
     ,__showhand: 'pointer'

Modified: openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzSprite.js
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzSprite.js   2007-11-15 
22:30:42 UTC (rev 7294)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzSprite.js   2007-11-15 
22:39:20 UTC (rev 7295)
@@ -623,15 +623,16 @@
     if (who._clickable == c) return;
     who._clickable = c;
     if (c) {
+        var f = LzSprite.prototype.__clickDispatcher;
         // must capture the owner in a closure... this is bad for IE 6
-        who.onclick = function (e) { this.owner.__mouseEvent(e); return false;}
-        who.onmouseover = function (e) { this.owner.__mouseEvent(e); return 
false;}
-        who.onmouseout = function (e) { this.owner.__mouseEvent(e); return 
false;}
+        who.onclick = f;
+        who.onmouseover = f;
+        who.onmouseout = f;
         // Prevent context menus in Firefox 1.5 - see LPP-2678
-        who.onmousedown = function (e) { this.owner.__mouseEvent(e); return 
false;}
-        who.onmouseup = function (e) { this.owner.__mouseEvent(e); return 
false;}
+        who.onmousedown = f;
+        who.onmouseup = f;
         if (this.quirks.fix_ie_clickable) {
-            who.ondrag = function (e) { return false; }
+            who.ondrag = f;
         }
     } else {
         who.onclick = null;
@@ -647,9 +648,19 @@
 
 /**
   * @access private
+  * dispatches click events
   */
+LzSprite.prototype.__clickDispatcher = function(e) {
+    // capture events in IE
+    if (!e) e = window.event;
+    this.owner.__mouseEvent(e);
+    return false;
+}
+
+/**
+  * @access private
+  */
 LzSprite.prototype.__mouseEvent = function ( e ){
-    if (!e) e = window.event;
     if (LzKeyboardKernel && LzKeyboardKernel['__keyboardEvent']) 
LzKeyboardKernel.__keyboardEvent(e);
     var skipevent = false;
     var eventname = 'on' + e.type;
@@ -1584,16 +1595,6 @@
             obj[i] = null;
         }
         LzSprite.prototype.__sprites = {};
-
-        document.onmousemove = null;
-        document.onmousedown = null;
-        document.onmouseup = null;
-        document.oncontextmenu = null;
-        document.onkeydown = null;
-        document.onkeyup = null;
-        document.onkeypress = null;
-        document.onmousewheel = null;
-        Lz.removeEventHandler(window, 'resize', LzScreenKernel, 
'__resizeEvent');
     }
     Lz.attachEventHandler(window, 'beforeunload', window, '__cleanUpForIE');
 }

Modified: openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzTextSprite.js
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzTextSprite.js       
2007-11-15 22:30:42 UTC (rev 7294)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzTextSprite.js       
2007-11-15 22:39:20 UTC (rev 7295)
@@ -425,7 +425,3 @@
     this.__setHeight(h);
     if (this.multiline) this._styledirty = true;
 }
-
-// prevent text selection in IE
-document.onselectstart = function(){return false;}
-document.ondrag = function(){return false;}

Modified: openlaszlo/trunk/lps/includes/source/LzMousewheelKernel.js
===================================================================
--- openlaszlo/trunk/lps/includes/source/LzMousewheelKernel.js  2007-11-15 
22:30:42 UTC (rev 7294)
+++ openlaszlo/trunk/lps/includes/source/LzMousewheelKernel.js  2007-11-15 
22:39:20 UTC (rev 7295)
@@ -26,9 +26,10 @@
     ,setCallback: function (scope, mousewheelcallback) {
         if (LzMousewheelKernel.__callbacks.length == 0 && 
lzOptions.dhtmlKeyboardControl != false) {
             if (window.addEventListener) {
-                window.addEventListener('DOMMouseScroll', 
LzMousewheelKernel.__mousewheelEvent, false);
+                Lz.attachEventHandler(window, 'DOMMouseScroll', 
LzMousewheelKernel, '__mousewheelEvent');
+            } else {
+                Lz.attachEventHandler(document, 'mousewheel', 
LzMousewheelKernel, '__mousewheelEvent');
             }
-            document.onmousewheel = LzMousewheelKernel.__mousewheelEvent;
         }
         LzMousewheelKernel.__callbacks.push(scope, mousewheelcallback);
         //console.log('setCallback', LzMousewheelKernel.__callbacks);


_______________________________________________
Laszlo-checkins mailing list
[email protected]
http://www.openlaszlo.org/mailman/listinfo/laszlo-checkins

Reply via email to