+String url = "/trunk-clean/laszlo-explorer/explore-nav.lzx?"+ qParams
+ "&lzr=" + runtime +
"&lzt=html&lzusemastersprite=true&lzwmode=transparent";
Obviously you don't want "trunk-clean" here.
var lzr = global['lzr'];
if (lzr && lzr == 'dhtml') {
- Debug.info("gonna use dhtml nav.");
+ if ($debug) Debug.info("gonna use dhtml nav.");
That should be: var lzr = lz.Browser.getInitArg("navset");
+ <radiobutton value="'dhtml'">dhtml</radiobutton>
+ <radiobutton value="'swf8'">swf8</radiobutton>
+ <radiobutton value="'swf10'">swf10</radiobutton>
"value" defaults to "text" if not specified, so this can be written more
compact as:
<radiobutton text="dhtml"/>
<radiobutton text="swf8"/>
<radiobutton text="swf10"/>
+ var url = lz.Browser.callJS('eval', null, 'window.location');
Shouldn't it be possible to use lz.Browser.getLoadURL{AsLzURL}() instead?
---
I've also worked on some laszlo-explorer changes, mainly to enable the
bookmarking feature for swf9+ and some other code clean-ups. My current
work is attached, some changes are identical to your changeset, others
are meant to improve readability, for example the use of
formatToString(..) in the doaction() method.
On 4/2/2010 12:25 AM, Max Carlson wrote:
Change 20100401-maxcarlson-j by maxcarl...@bank on 2010-04-01 15:12:44 PDT
in /Users/maxcarlson/openlaszlo/trunk-clean
for http://svn.openlaszlo.org/openlaszlo/trunk
Summary: Modernize laszlo-explorer
Bugs Fixed: LPP-8875 - laszlo-explorer should be a self-contained application
capable of changing runtimes dynamically
Technical Reviewer: hminsky
QA Reviewer: ptw
Details: index.jsp - Redirect to a standalone version of the application
explore-nav - Add history support so refreshing the page restores back to the same
location. Add radio button to select runtime. Use<html/> instead of a
frameset to load HTML content.
Tests: laszlo-explorer/ works across all runtimes and when the runtime is
changed restores to the current location.
Files:
M laszlo-explorer/index.jsp
M laszlo-explorer/explore-nav.lzx
Changeset:
http://svn.openlaszlo.org/openlaszlo/patches/20100401-maxcarlson-j.tar
<canvas width="200" height="605" bgcolor="0xeaeaea" debug="true">
<!-- Datasets -->
<dataset name="navdata"/>
<!-- Included Libraries -->
<include href="base/basetree.lzx" />
<include href="resources.lzx" />
<handler name="oninit"><![CDATA[
var navset = lz.Browser.getInitArg("navset");
if (navset == null) {
if ($dhtml) {
navset = "nav_dhtml.xml";
} else {
navset = "nav.xml";
}
}
canvas.navdata.setAttribute("src", navset);
canvas.navdata.doRequest();
]]></handler>
<!-- CLASSES -->
<!-- Animator group classes to be instantiated when needed -->
<class name="openanimator" extends="animatorgroup" process="sequential"
start="false">
<attribute name="item" value="null"/>
<animator target="$once{parent.item}" attribute="width" to="$once{160 +
7*(parent.item.level+1)}"
duration="100" relative="false"/>
<animatorgroup name="open" process="simultaneous" duration="250"
start="false"
onstop="parent.item.onopendone.sendEvent()">
<!-- note the spacing & inset to -6, since the shadow is 6 pixels high
-->
<animator attribute="inset" to="-6"
start="false" relative="false"/>
<animator attribute="spacing" to="-6"
start="false" relative="false"/>
</animatorgroup>
</class>
<class name="closeanimator" extends="animatorgroup" process="sequential"
start="false">
<attribute name="item" value="null"/>
<animatorgroup name="items" process="simultaneous" duration="200"
start="false"
onstop="parent.item.children.setAttribute('visible', false);">
<!-- note the spacing & inset from -6, since the shadow is 6 pixels
high -->
<animator attribute="spacing" to="${-parent.parent.parent.hgt}"
from="-6"
start="false"
relative="false"/>
<animator attribute="inset" to="${-parent.parent.parent.hgt}" from="-6"
start="false"/>
</animatorgroup>
<animator target="$once{parent.item}" attribute="width" to="$once{160 +
7*parent.item.level}"
duration="100" relative="false"/>
</class>
<!-- NavButton Class parent of all item buttons -->
<class name="menubutton" extends="basetree" xindent="0"
yindent="${this.item.height}"
closechildren="true" closesiblings="true" layout="class:null">
<attribute name="level" type="number"/>
<attribute name="defaultplacement" value="itemlist" type="string"/>
<event name="onopendone"/>
<datapath xpath="*">
<attribute name="doneDel" value="null"/>
<handler name="onclones">
var lastclone = clones[ clones.length - 1 ];
if ( !this.doneDel ){
this.doneDel = new LzDelegate( this, 'replicationDone');
} else {
this.doneDel.unregisterAll();
}
this.doneDel.register( lastclone , "oninit" );
</handler>
<method name="replicationDone" args="v">
var mb = this.parent;
mb.dataBound();
</method>
</datapath>
<handler name="oninit">
this.children.sendToBack();
</handler>
<handler name="ondata">
this.setAttribute("isleaf", !this.datapath.p.hasChildNodes());
if( !this['clonenumber'] || this.clonenumber == 0) {
var mb = this.parent;
if (mb instanceof lz.menubutton) {
mb.dataBound();
}
}
</handler>
<attribute name="deferOpen" value="false"/>
<method name="_setOpen" args="o"><![CDATA[
if (_initcomplete && this.isleaf) {
this.open = false;
return;
}
if (o && this.itemlist.subviews.length == 0) {
this.deferOpen = true;
new lz.navbutton(this, { level: this.level + 1 });
} else {
super._setOpen(o);
}
]]></method>
<method name="dataBound"><![CDATA[
if (this.deferOpen) {
this.deferOpen = false;
this.setAttribute('open', true);
}
if (this['nextOpenList']) {
var nol = this.nextOpenList;
var no = this.searchSubnodes("title", nol[0]);
if (no != null) {
no.openSequence(nol);
} else if ($debug) {
Debug.warn("invalid element in open sequence %w\n", nol[0]);
}
}
]]></method>
<method name="openChildren" args="o">
if (this.itemlist.subviews.length > 0) {
// Debug.write('doOpenChildren', this, o, this.itemlist.subviews);
var item_hgt = this.item.height;
var layout = this.itemlist.childlayout;
layout.setAttribute('hgt', item_hgt);
if (o) {
layout.setAttribute('spacing', -item_hgt);
layout.setAttribute('inset', -item_hgt);
this.children.setAttribute('visible', true);
layout.doOpen();
} else {
layout.doClose();
}
}
</method>
<method name="openSequence" args="seq">
if (seq[0] == this.title) {
// first, open self
this.header.open();
if (seq.length > 1) {
this.nextOpenList = seq.splice(1);
}
}
</method>
<view name="itemlist" width="${classroot.width}" placement="children" >
<simplelayout name="childlayout" spacing="-20">
<attribute name="hgt" value="0" />
<attribute name="animateOpen" value="null"/>
<attribute name="animateClose" value="null"/>
<method name="doOpen">
if (this.animateOpen == null) {
this.animateOpen = new lz.openanimator(this, { item:
classroot });
}
this.animateOpen.doStart();
</method>
<method name="doClose">
if (this.animateClose == null) {
this.animateClose = new lz.closeanimator(this, { item:
classroot });
}
this.animateClose.doStart();
</method>
</simplelayout>
</view>
<itembutton name="header" level="$once{classroot.level}"
text="$once{classroot.title}" width="${classroot.width}"/>
</class>
<!-- ItemButton class the visible portion of navButtons -->
<class name="itembutton" placement="item" datapath="."
onmouseover="background.setAttribute('frame', 2)"
onmouseout="showUp()"
onmousedown="background.setAttribute('frame', 3)"
onmouseup="showUp()" clickable="true">
<attribute name="level" type="number"/>
<attribute name="text" type="string"/>
<attribute name="isleaf" value="false"/>
<event name="onopendone"/>
<method name="largetext">
icon.setAttribute("y", 9);
label.setAttribute("fgcolor", 0xffffff);
label.setAttribute("fontsize", 13);
</method>
<method name="smalltext">
icon.setAttribute("y", 5);
label.setAttribute("fgcolor", 0xd4dcec);
label.setAttribute("fontsize", 11);
</method>
<handler name="ondata">
var dp = this.datapath;
this.setAttribute("isleaf", !dp.p.hasChildNodes());
var tagtype = dp.xpathQuery("name()");
this.background.setAttribute('resource', tagtype + "_btn");
if (tagtype == 'subitem') {
this.smalltext();
} else {
this.largetext();
}
var action = dp.xpathQuery("@action");
if (action == 'popup' || action == 'source' || action ==
'popupexternal') {
icon.setAttribute('frame', 4);
}
</handler>
<handler name="onopen" reference="classroot" method="doaction"/>
<method name="doaction" args="v=null"><![CDATA[
var dp = this.datapath;
var autoselect = dp.xpathQuery("@autoselect");
if (autoselect == "true") {
var firstitem = classroot.itemlist.subviews[0];
if (firstitem is lz.menubutton) {
firstitem.header.open();
}
} else {
var action = dp.xpathQuery("@action");
var runtime = dp.xpathQuery("@runtime") || $runtime;
var src = dp.xpathQuery("@src");
var tagline = dp.xpathQuery("@text");
var title = dp.xpathQuery("@title");
if (action == 'popup') {
var popup = dp.xpathQuery("@popup");
var target = dp.xpathQuery("@target");
var popwidth = dp.xpathQuery("@width") || 860;
var popheight = dp.xpathQuery("@height") || 600;
if (target == null) target = escape(popup + runtime);
var url =
label.formatToString("loading.jsp?src=%s&lzr=%s&lzt=html", popup, runtime);
var features =
label.formatToString("scrollbars=yes,width=%s,height=%s", popwidth, popheight);
if ($runtime == 'dhtml') {
lz.Browser.loadURL(url, target, features);
} else {
var js = label.formatToString("window.open('%s', '%s',
'%s')", url, target, features);
lz.Browser.loadJS(js);
}
if (src != null){
var url =
label.formatToString("content.jsp?src=%s&tag=%s&title=%s&lzr=%s", src, tagline,
title, runtime);
lz.Browser.loadURL(url, 'content');
}
} else if (action =='popupexternal') {
var features =
label.formatToString("scrollbars=yes,resizable=yes,toolbar=yes,location=yes,menubar=yes,width=%s,height=%s",
popwidth, popheight);
var js = label.formatToString("window.open('%s', '%s', '%s')",
src, target, features);
lz.Browser.loadJS(js);
} else {
if (title == null) {
title = classroot.title;
}
var url =
label.formatToString("content.jsp?src=%s&tag=%s&title=%s&action=%s&lzr=%s",
src, tagline, title, action, runtime);
lz.Browser.loadURL(url, (action == 'source') ? 'source' :
'content');
}
}
]]></method>
<handler name="onclick" method="open"/>
<method name="open" args="v=null"><![CDATA[
classroot.changeFocus(null);
// only open subitems if there are
if (! this.isleaf) {
// only open menu if not already opened ( i.e don't toggle like before )
// if ( !classroot.open ) -- this did not completely work, so just
always open
classroot.setAttribute("open", true);
}
this.doaction();
]]></method>
<handler name="onopen" reference="classroot" method="showUp"/>
<method name="showUp" args="v=null">
background.setAttribute('frame', classroot.open ? 4 : 1);
// Only toggle arrow if there are subnodes
if (this.datapath.getNodeCount()) {
icon.setAttribute('frame', classroot.open ? 2 : 1);
}
</method>
<view name="background" width="${classroot.width}"
x="${classroot.width-200}" />
<view name="icon" resource="icon" y="9" stretches="both" width="11"
height="11"
x="${classroot.width - this.width - 6 }" />
<defaulttext name="label" x="${6 + classroot.level*7}" valign="middle"
fontstyle="bold" fontsize="13"
width="${parent.width-x}" text="${classroot.text}"/>
</class>
<class name="defaulttext" extends="text" font="helvetica,sans-serif"
fgcolor="#ffffff"/>
<class name="navbutton" extends="menubutton" width="${immediateparent.width}">
<attribute name="title" value="$path{'@name'}"/>
</class>
<!-- APPLICATION -->
<!-- navigation bar and classes -->
<view width="200" height="$once{canvas.height}" >
<view x="-15" resource="navbg"/>
<basebutton resource="logobtn" x="2" y="6"
onclick="lz.Browser.loadURL('http://www.openlaszlo.org', '_blank')"/>
<view x="10" y="570" layout="axis:y" >
<defaulttext resize="true" fontsize="10" text="${'Version: ' +
canvas.version + ' (' + canvas.runtime + ')'}" />
<view>
<defaulttext fontsize="10" text="${'Build: ' + canvas.lpsbuild}"/>
<simplelayout axis="x"/>
</view>
</view>
</view>
<view width="200" y="42" height="${menu.height +4}">
<basetree name="menu" datapath="navdata:/menu"
showroot="false" x="2" y="2"
layout="spacing:-6">
<!-- note spacing is -6, since the shadow is 6 pixels high -->
<method name="dataBound">
// this is how we restore the state of the app from an incoming URL,
// this is always provided by the JSP wrappers
var bookmark = lz.Browser.getInitArg('bookmark');
if (bookmark != null) {
var restore = bookmark.split('|');
if (restore.length > 0) {
var no = this.searchSubnodes("title", restore[0]);
if (no != null) no.openSequence(restore);
}
}
</method>
<navbutton width="160" level="0">
</navbutton>
</basetree>
</view>
</canvas>
<!-- * X_LZ_COPYRIGHT_BEGIN ***************************************************
* Copyright 2001-2008 Laszlo Systems, Inc. All Rights Reserved. *
* Use is subject to license terms. *
* X_LZ_COPYRIGHT_END ****************************************************** -->
<!-- @LZX_VERSION@ -->