[Laszlo-checkins] r14404 - openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml

max@openlaszlo.org max at openlaszlo.org
Wed Jul 29 11:29:46 PDT 2009


Author: max
Date: 2009-07-29 11:29:44 -0700 (Wed, 29 Jul 2009)
New Revision: 14404

Modified:
   openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzSprite.js
Log:
Change 20090724-maxcarlson-S by maxcarlson at Bank on 2009-07-24 15:55:40 PDT
    in /Users/maxcarlson/openlaszlo/trunk-clean
    for http://svn.openlaszlo.org/openlaszlo/trunk

Summary: Fix selection issues in Firefox and Safari, word wrapping in IE

Bugs Fixed: LPP-6374 - Add option to make DHTML text wrapping match swf, LPP-8311 - Amazon (dhtml): double click may display images as selected, LPP-8349 - dhtml: dragging in background allows selection in Safari

Technical Reviewer: ptw
QA Reviewer: hminsky

Details: Add separate style 'lzimg' and use it for img tags.  Move background-repeat style there, and add -moz-user-select: none to prevent selection in Firefox.  Correct CSS hyphenation routine to hyphenate more than one CamelCase letter, e.g. MozUserSelect and MsWordBreak.  This fixed word wrapping in IE DHTML.  Turn on prevent_selection quirk for Safari.  Use 'lzimg' style for img tags - except in alphaimageloaders which are only used for sizing.

Tests: See testcase from LPP-6374 in IE DHTML, testcases for LPP-8311 in Firefox and LPP-8349 in Safari.



Modified: openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzSprite.js
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzSprite.js	2009-07-29 18:20:45 UTC (rev 14403)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzSprite.js	2009-07-29 18:29:44 UTC (rev 14404)
@@ -243,7 +243,6 @@
 LzSprite.prototype.__defaultStyles = {
     lzdiv: {
         position: 'absolute'
-        ,backgroundRepeat: 'no-repeat'
     },
     lzclickdiv: {
         position: 'absolute'
@@ -431,12 +430,17 @@
     lzcontext: {
         position: 'absolute'
     },
+    lzimg: {
+        position: 'absolute',
+        backgroundRepeat: 'no-repeat'
+    },
     writeCSS: function() {
         var rules = [];
         var css = '';
         for (var classname in this) {
             if (classname == 'writeCSS' || 
                 classname == 'hyphenate' || 
+                classname == '__replace' || 
                 classname == '__re') continue;
             css += classname.indexOf('#') == -1 ? '.' : '';
             css += classname + '{';
@@ -448,14 +452,12 @@
         }
         document.write('<style type="text/css">' + css + '</style>');
     },
-    __re: new RegExp("[A-Z]"),
+    __re: new RegExp('[A-Z]', 'g'),
     hyphenate: function(n) {
-        var i = n.search(this.__re);
-        if (i != -1) {
-            var c = n.substring(i, i + 1);
-            n = n.substring(0, i) + '-' + c.toLowerCase() + n.substring(i + 1, n.length);
-        }
-        return n;
+        return n.replace(this.__re, this.__replace);
+    },
+    __replace: function(found) {
+        return '-' + found.toLowerCase();
     }
 }
 LzSprite.prototype.__defaultStyles['#lzcontextmenu div.separator'] = {
@@ -717,6 +719,7 @@
             
             // required as of 3.2.1 to get test/lztest/lztest-textheight.lzx to show multiline inputtext properly
             quirks['inputtext_strips_newlines'] = true;
+            quirks['prevent_selection'] = true;
         } else if (browser.isOpera) {
             // Fix bug in where if any parent of an image is hidden the size is 0
             quirks['invisible_parent_image_sizing_fix'] = true;
@@ -806,6 +809,15 @@
             LzSprite.prototype.inner_html_strips_newlines_re = RegExp('$', 'mg');
         }
 
+        // Turn off image selection - see LPP-8311
+        if (browser.isFirefox) {
+            defaultStyles.lzimg['MozUserSelect'] = 'none';
+        } else if (browser.isSafari) {
+            defaultStyles.lzimg['WebkitUserSelect'] = 'none';
+        } else {
+            defaultStyles.lzimg['UserSelect'] = 'none';
+        }
+
         LzSprite.prototype.br_to_newline_re = RegExp('<br/>', 'mg');
     }
 };
@@ -1047,7 +1059,7 @@
     if (this.stretches == null && this.__csssprite) {
         if (! this.__LZimg) {
             var im = document.createElement('img');
-            im.className = 'lzdiv';
+            im.className = 'lzimg';
             im.owner = this;
             im.src = lz.embed.options.serverroot + LzSprite.prototype.blankimage;
             this.__bindImage(im);
@@ -1907,7 +1919,7 @@
         }
     } else {
         var im = document.createElement('img');
-        im.className = 'lzdiv';
+        im.className = 'lzimg';
         // show again in onload
         if (! skiploader) im.style.display = 'none'
         if (this.owner && skiploader != true) {



More information about the Laszlo-checkins mailing list