[Laszlo-checkins] r8600 - in openlaszlo/trunk: WEB-INF/lps/lfc/kernel WEB-INF/lps/lfc/kernel/dhtml WEB-INF/lps/lfc/views WEB-INF/lps/lfc/views/platform lps/components/extensions
hqm@openlaszlo.org
hqm at openlaszlo.org
Wed Apr 9 07:35:25 PDT 2008
Author: hqm
Date: 2008-04-09 07:35:20 -0700 (Wed, 09 Apr 2008)
New Revision: 8600
Modified:
openlaszlo/trunk/WEB-INF/lps/lfc/kernel/LzUtils.lzs
openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzInputTextSprite.js
openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzSprite.js
openlaszlo/trunk/WEB-INF/lps/lfc/views/LaszloCanvas.lzs
openlaszlo/trunk/WEB-INF/lps/lfc/views/platform/LzPlatform.lzs
openlaszlo/trunk/lps/components/extensions/drawview.lzx
Log:
Change 20080408-hqm-B by hqm at badtzmaru.local on 2008-04-08 23:58:08 EDT
in /Users/hqm/openlaszlo/trunk4
for http://svn.openlaszlo.org/openlaszlo/trunk
Summary: convert LzUtils and LzPlatform to real classes
New Features:
Bugs Fixed:
Technical Reviewer: max
QA Reviewer: (pending)
Doc Reviewer: (pending)
Documentation:
Release Notes:
Details:
+ converted LzUtils to a class. Removed the "two level" scheme where people
called LzUtils.color.inttohex, etc, and just replaced it with
regular methods. Updated all callers of LzUtils that I could find in the
LFC or lps/components directory.
+ converted LzPlatform to a class
Tests:
smoke
calendar
amazon
Modified: openlaszlo/trunk/WEB-INF/lps/lfc/kernel/LzUtils.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/kernel/LzUtils.lzs 2008-04-09 12:00:09 UTC (rev 8599)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/kernel/LzUtils.lzs 2008-04-09 14:35:20 UTC (rev 8600)
@@ -1,7 +1,7 @@
/**
- * LzUtils.js
+ * LzUtils.lzs
*
- * @copyright Copyright 2007 Laszlo Systems, Inc. All Rights Reserved.
+ * @copyright Copyright 2007-2008 Laszlo Systems, Inc. All Rights Reserved.
* Use is subject to license terms.
*
* @topic Kernel
@@ -9,53 +9,59 @@
* @author Max Carlson <max at openlaszlo.org>
*/
-var LzUtils = {
+class LzUtils {
+ // ***** callback *****
// Provides weak links for global callbacks
- callback: {
- __scopeid: 0
- ,__scopes: []
+ static var __scopeid:* = 0;
+ static var __scopes:* = [];
+
/**
* Returns a callback as a string, suitable for setTimeout
*/
- ,getcallbackstr: function(scope, name) {
- var sc = LzUtils.callback.__scopeid++;
+ public static function getcallbackstr(scope:*, name:*) {
+ var sc = LzUtils.__scopeid++;
if (scope.__callbacks == null) {
scope.__callbacks = {sc: sc}
} else {
scope.__callbacks[sc] = sc;
}
- LzUtils.callback.__scopes[sc] = scope;
- return 'if (LzUtils.callback.__scopes[' + sc + ']) LzUtils.callback.__scopes[' + sc + '].' + name + '.apply(LzUtils.callback.__scopes[' + sc + '], [])';
+ LzUtils.__scopes[sc] = scope;
+ return 'if (LzUtils.__scopes[' + sc + ']) LzUtils.__scopes[' + sc + '].' + name + '.apply(LzUtils.__scopes[' + sc + '], [])';
}
/**
* Returns a callback function
*/
- ,getcallbackfunc: function(scope, name, args) {
- var sc = LzUtils.callback.__scopeid++;
+ public static function getcallbackfunc(scope, name, args) {
+ var sc = LzUtils.__scopeid++;
if (scope.__callbacks == null) {
scope.__callbacks = {sc: sc}
} else {
scope.__callbacks[sc] = sc;
}
- LzUtils.callback.__scopes[sc] = scope;
+ LzUtils.__scopes[sc] = scope;
+//TODO pbr
+ return null;
+/*
return function () {
- var s = LzUtils.callback.__scopes[sc];
+ var s = LzUtils.__scopes[sc];
if (s) return s[name].apply(s, args);
}
+*/
}
- ,remove: function(scope) {
+ public static function removecallback(scope) {
if (scope.__callbacks != null) {
for (var i in scope.__callbacks) {
var sc = scope.__callbacks[i]
//Debug.write('removing', sc);
- delete LzUtils.callback.__scopes[sc];
+ delete LzUtils.__scopes[sc];
}
delete scope.__callbacks;
}
}
- }
- ,dectohex: function(c, p) {
+
+
+ public static function dectohex(c:*, p:*) {
if (typeof c == 'number') {
// convert from decimal to hex
var hex = c.toString(16);
@@ -69,8 +75,9 @@
return c;
}
}
- ,color: {
- hextoint: function(value) {
+
+ // ***** color *****
+ public static function hextoint(value:*) {
if (typeof value != 'string') return value;
if (value.charAt(0) == '#') {
var n = parseInt(value.slice(1), 16);
@@ -85,15 +92,16 @@
}
}
}
- if (typeof eval(value) == 'number') {
- return eval(value);
- }
+ //TODO pbr Need a workaround for eval
+// if (typeof eval(value) == 'number') {
+// return eval(value);
+// }
if ($debug) {
Debug.warn('unknown color format: ' + value);
}
return 0;
}
- ,inttohex: function(c) {
+ public static function inttohex(c:*) {
if (typeof c == 'string') {
c = c * 1;
}
@@ -104,8 +112,8 @@
}
return c;
}
- ,torgb: function(s) {
- if (typeof s == 'number') s = this.inttohex(s);
+ public static function torgb(s:*) {
+ if (typeof s == 'number') s = LzUtils.inttohex(s);
if (typeof s != 'string') return s;
if (s.length < 6) {
// expand #036 or #0369
@@ -121,5 +129,4 @@
(s.length > 7 ? ',' + parseInt(s.substring(7, 9), 16) : '') +
')';
}
- }
}
Modified: openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzInputTextSprite.js
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzInputTextSprite.js 2008-04-09 12:00:09 UTC (rev 8599)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzInputTextSprite.js 2008-04-09 14:35:20 UTC (rev 8600)
@@ -785,7 +785,7 @@
LzInputTextSprite.prototype.setColor = function (c) {
if (this.color == c) return;
this.color = c;
- this.__LzInputDiv.style.color = LzUtils.color.inttohex(c);
+ this.__LzInputDiv.style.color = LzUtils.inttohex(c);
}
LzInputTextSprite.prototype.getText = function () {
Modified: openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzSprite.js
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzSprite.js 2008-04-09 12:00:09 UTC (rev 8599)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzSprite.js 2008-04-09 14:35:20 UTC (rev 8600)
@@ -834,13 +834,13 @@
LzSprite.prototype.setColor = function ( c ){
if (this.color == c) return;
this.color = c;
- this.__LZdiv.style.color = LzUtils.color.inttohex(c);
+ this.__LZdiv.style.color = LzUtils.inttohex(c);
}
LzSprite.prototype.setBGColor = function ( c ){
if (this.bgcolor == c) return;
this.bgcolor = c;
- this.__LZdiv.style.backgroundColor = c == null ? 'transparent' : LzUtils.color.inttohex(c);
+ this.__LZdiv.style.backgroundColor = c == null ? 'transparent' : LzUtils.inttohex(c);
if (this.quirks.fix_ie_background_height) {
if (this.height != null && this.height < 2) {
this.setSource(LzSprite.prototype.blankimage, true);
@@ -1056,7 +1056,7 @@
clearTimeout(img.owner.__imgtimoutid);
img.owner.__imgtimoutid = null;
}
- LzUtils.callback.remove(img.owner);
+ LzUtils.removecallback(img.owner);
}
if (LzSprite.prototype.quirks.ie_alpha_image_loader && img.sizer) {
if (img.sizer.tId) clearTimeout(img.sizer.tId);
@@ -1113,7 +1113,7 @@
im.sizer.onloadforeal = function() {
im.owner.__imgonload(im.sizer);
}
- var callback = LzUtils.callback.getcallbackstr(this.owner, '__imgontimeout');
+ var callback = LzUtils.getcallbackstr(this.owner, '__imgontimeout');
this.owner.__imgtimoutid = setTimeout(callback, canvas.medialoadtimeout);
im.sizer.src = url;
}
@@ -1128,9 +1128,9 @@
if (this.owner && skiploader + '' != 'true') {
//Debug.info('sizer', skiploader == true, skiploader != true, skiploader);
im.owner = this.owner;
- im.onload = LzUtils.callback.getcallbackfunc(this.owner, '__imgonload', [im]);
- im.onerror = LzUtils.callback.getcallbackfunc(this.owner, '__imgonerror', [im]);
- var callback = LzUtils.callback.getcallbackstr(this.owner, '__imgontimeout');
+ im.onload = LzUtils.getcallbackfunc(this.owner, '__imgonload', [im]);
+ im.onerror = LzUtils.getcallbackfunc(this.owner, '__imgonerror', [im]);
+ var callback = LzUtils.getcallbackstr(this.owner, '__imgontimeout');
this.owner.__imgtimoutid = setTimeout(callback, canvas.medialoadtimeout);
}
Modified: openlaszlo/trunk/WEB-INF/lps/lfc/views/LaszloCanvas.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/views/LaszloCanvas.lzs 2008-04-09 12:00:09 UTC (rev 8599)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/views/LaszloCanvas.lzs 2008-04-09 14:35:20 UTC (rev 8600)
@@ -173,7 +173,7 @@
}
if (this.sprite.capabilities.readcanvassizefromsprite == true) {
- this.bgcolor = LzUtils.color.hextoint(args.bgcolor);
+ this.bgcolor = LzUtils.hextoint(args.bgcolor);
} else {
this.bgcolor = args.bgcolor;
}
Modified: openlaszlo/trunk/WEB-INF/lps/lfc/views/platform/LzPlatform.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/views/platform/LzPlatform.lzs 2008-04-09 12:00:09 UTC (rev 8599)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/views/platform/LzPlatform.lzs 2008-04-09 14:35:20 UTC (rev 8600)
@@ -1,6 +1,6 @@
/**
*
- * @copyright Copyright 2001-2007 Laszlo Systems, Inc. All Rights Reserved.
+ * @copyright Copyright 2001-2008 Laszlo Systems, Inc. All Rights Reserved.
* Use is subject to license terms.
*
* @access private
@@ -13,62 +13,64 @@
Platform-specific definitions
*/
-var LzPlatform = new Object ();
+public class LzPlatformClass {
+ public function initCanvas (canvasobj) {
+ LzPlatform.buildDefaultMenu(canvasobj);
+ }
-LzPlatform.initCanvas = function (canvasobj) {
- LzPlatform.buildDefaultMenu(canvasobj);
-}
+ /**
+ * @access private
+ */
+ function __LZdefaultMenuItemHandler (obj, item) {
+ // load a url
+ LzBrowser.loadURL("http://www.openlaszlo.org", "lz_about");
+ }
-/**
- * @access private
- */
-LzPlatform.__LZdefaultMenuItemHandler = function (obj, item) {
- // load a url
- LzBrowser.loadURL("http://www.openlaszlo.org", "lz_about");
-}
-
-/**
- * @access private
- */
-LzPlatform.__LZviewSourceMenuItemHandler = function (obj, item) {
- // view source for this app
- // /examples/components/edittext_example.lzx
- var url = LzBrowser.getBaseURL();
- if (canvas.proxied) {
- url = url.toString() + "?lzt=source";
- } else {
- // SOLO app named foo.lzx looks for a source zipfile named foo.lzx.zip
- url = url.toString() + ".zip";
+ /**
+ * @access private
+ */
+ function __LZviewSourceMenuItemHandler (obj, item) {
+ // view source for this app
+ // /examples/components/edittext_example.lzx
+ var url = LzBrowser.getBaseURL();
+ if (canvas.proxied) {
+ url = url.toString() + "?lzt=source";
+ } else {
+ // SOLO app named foo.lzx looks for a source zipfile named foo.lzx.zip
+ url = url.toString() + ".zip";
+ }
+ LzBrowser.loadURL(url, "lz_source");
}
- LzBrowser.loadURL(url, "lz_source");
-}
-/**
- * Build the default righ-click menu object
- * @access private
- */
-LzPlatform.buildDefaultMenu = function (canvas) {
- canvas.__LZDefaultCanvasMenu = new LzContextMenu();
- canvas.__LZdefaultMenuItem = new LzContextMenuItem("About OpenLaszlo...",
- new LzDelegate(LzPlatform, '__LZdefaultMenuItemHandler'));
+ /**
+ * Build the default righ-click menu object
+ * @access private
+ */
+ function buildDefaultMenu (canvas) {
+ canvas.__LZDefaultCanvasMenu = new LzContextMenu();
+ canvas.__LZdefaultMenuItem = new LzContextMenuItem("About OpenLaszlo...",
+ new LzDelegate(LzPlatform, '__LZdefaultMenuItemHandler'));
- canvas.__LZviewSourceMenuItem = new LzContextMenuItem("View Source",
- new LzDelegate(LzPlatform, '__LZviewSourceMenuItemHandler'));
+ canvas.__LZviewSourceMenuItem = new LzContextMenuItem("View Source",
+ new LzDelegate(LzPlatform, '__LZviewSourceMenuItemHandler'));
- canvas.__LZDefaultCanvasMenu.hideBuiltInItems();
- canvas.__LZDefaultCanvasMenu.addItem(canvas.__LZdefaultMenuItem);
- if (canvas.proxied) {
- canvas.__LZDefaultCanvasMenu.addItem(canvas.__LZviewSourceMenuItem);
- }
+ canvas.__LZDefaultCanvasMenu.hideBuiltInItems();
+ canvas.__LZDefaultCanvasMenu.addItem(canvas.__LZdefaultMenuItem);
+ if (canvas.proxied) {
+ canvas.__LZDefaultCanvasMenu.addItem(canvas.__LZviewSourceMenuItem);
+ }
- // Install the default menu onto MovieClip, so it shows up everywhere by default
- if (canvas.__LZDefaultCanvasMenu) {
- canvas.setDefaultContextMenu(canvas.__LZDefaultCanvasMenu);
+ // Install the default menu onto MovieClip, so it shows up everywhere by default
+ if (canvas.__LZDefaultCanvasMenu) {
+ canvas.setDefaultContextMenu(canvas.__LZDefaultCanvasMenu);
+ }
}
}
+var LzPlatform:LzPlatformClass = new LzPlatformClass();
+
Modified: openlaszlo/trunk/lps/components/extensions/drawview.lzx
===================================================================
--- openlaszlo/trunk/lps/components/extensions/drawview.lzx 2008-04-09 12:00:09 UTC (rev 8599)
+++ openlaszlo/trunk/lps/components/extensions/drawview.lzx 2008-04-09 14:35:20 UTC (rev 8600)
@@ -367,12 +367,12 @@
if (this.tId) clearTimeout(this.tId);
this.setAttribute('context', this.__LZcanvas.getContext("2d"));
} else {
- var callback = LzUtils.callback.getcallbackstr(this, '__initie');
+ var callback = LzUtils.getcallbackstr(this, '__initie');
this.tId = setTimeout(callback, 50);
}
} catch (e) {
if (this.maxTries-- > 0) {
- var callback = LzUtils.callback.getcallbackstr(this, '__initie');
+ var callback = LzUtils.getcallbackstr(this, '__initie');
this.tId = setTimeout(callback, 50);
}
}
@@ -444,7 +444,7 @@
var ccache = lz.drawview._colorcache;
var fillStyleColor = ccache[this.fillStyle];
if (fillStyleColor == null) {
- fillStyleColor = LzUtils.color.torgb(this.fillStyle);
+ fillStyleColor = LzUtils.torgb(this.fillStyle);
ccache[this.fillStyle] = fillStyleColor;
}
this.context.fillStyle = fillStyleColor;
@@ -456,7 +456,7 @@
var ccache = lz.drawview._colorcache;
var strokeStyleColor = ccache[this.strokeStyle];
if (strokeStyleColor == null) {
- strokeStyleColor = LzUtils.color.torgb(this.strokeStyle);
+ strokeStyleColor = LzUtils.torgb(this.strokeStyle);
ccache[this.strokeStyle] = strokeStyleColor;
}
this.context.strokeStyle = strokeStyleColor;
@@ -541,7 +541,7 @@
var ccache = lz.drawview._colorcache;
var cstopColor = ccache[c];
if (cstopColor == null) {
- cstopColor = LzUtils.color.torgb(c);
+ cstopColor = LzUtils.torgb(c);
ccache[c] = cstopColor;
}
this._g.addColorStop(o, cstopColor);
@@ -754,7 +754,7 @@
var ccache = lz.drawview._colorcache;
var fillStyleColor = ccache[this.fillStyle];
if (fillStyleColor == null) {
- fillStyleColor = LzUtils.color.hextoint(this.fillStyle);
+ fillStyleColor = LzUtils.hextoint(this.fillStyle);
ccache[this.fillStyle] = fillStyleColor;
}
this.context.beginFill(fillStyleColor, this.globalAlpha * 100);
@@ -806,7 +806,7 @@
var ccache = lz.drawview._colorcache;
var strokeStyleColor = ccache[this.strokeStyle];
if (strokeStyleColor == null) {
- strokeStyleColor = LzUtils.color.hextoint(this.strokeStyle);
+ strokeStyleColor = LzUtils.hextoint(this.strokeStyle);
ccache[this.strokeStyle] = strokeStyleColor;
}
this.context.lineStyle(this.lineWidth, strokeStyleColor, this.globalAlpha * 100);
@@ -885,7 +885,7 @@
var ccache = lz.drawview._colorcache;
var cstopColor = ccache[c];
if (cstopColor == null) {
- cstopColor = LzUtils.color.hextoint(c);
+ cstopColor = LzUtils.hextoint(c);
ccache[c] = cstopColor;
}
this._c[this._c.length] = cstopColor;
More information about the Laszlo-checkins
mailing list