Hi Max,
There are a couple of issues with the changes.
- Destroying the rte object often generates an error in callJavascript
because the object has already been deleted. I created LPP-9327 and
assigned it to me since I ran into this issue in the past.
- There is a need for a rte.getText() method to query for the text.
There are cases where the dijit.Editor contents and the rte component
will have different values. For example, if you click on a plugin button
that modifies the text, no event is generated to tell the component
about the new value. This is why I call getText() when I want to change
the existing value of the component.
I can see where the asynchronous nature of calling getText() can be a
problem. One workaround is to listen for mouse events or add a timer to
look for changes in the text. Or maybe I can add a delegate to
getText(). I created LPP-9328 and assigned it to me.
- There is a small leak in your code (in swf)
lz.embed.iframemanager.__callbacks is an array that grows with every
callJavascript() call that uses a callback. The existing rte component
does not make much use of the callback (unless you create a lot of
buttons) so this is not a big issue right away.
Otherwise approved! (I don't think anyone will run into these issues
before they are resolved).
On Wed, Aug 25, 2010 at 7:27 PM, Max Carlson wrote:
Change maxcarlson-20100825-5k4 by maxcarl...@friendly on 2010-08-25
15:58:50 PDT
in /Users/maxcarlson/openlaszlo/trunk2
for http://svn.openlaszlo.org/openlaszlo/trunk
Summary: Add pmrpc cross-domain support for calling JS in loaded
iframes/html
Bugs Fixed: LPP-9324 - Add pmrpc to the html component
Technical Reviewer: promanik
QA Reviewer: hminsky
Details: This change makes it possible to call javascript inside and
send events from within iframes loaded from different domains. The
technology to do this (pmrpc) is completely callback based, which
forced some changes with the way callbacks work.
html.callJavascript() now requires a callback argument if you need the
return value for a given call.
credits - Add license from pmrpc.js
html - Include JSON library to serialize callJavascript retrun values.
Modify SWF __iframecallback() and callJavascript() to store callbacks
locally now that return values come back asynchonously.
rte.lzx - Use callbacks where callJavascript() return values are
required. Reorient towards updating the rte.text attribute whenever
text changes. Rework destroy() to finish only after rte.text is
updated one last time.
pmrpc - Include library
build - Add dependencies, build target for pmrpc
rtemanager - Rename destroy() -> __destroy(). addButton() expects a
second buttonid arg, which is echoed back. This allows the
asynchronous return value to associate the button ID with the correct
callback in rte.lzx.
iframemanager-library - Include pmrpc.js.
iframemanager - Shorten lookups, remove unneeded getIDFromWindow()
call, owner -> __owner. Rework asyncCallback() to pass through the
callback ID when needed, see html.lzx __iframecallback() in swf.
callJavascript() now uses pmrpc to call into the iframe. Leave older
direct iframe calling code intact. Register as a pmrpc server for
asyncCallback().
iframestub - Include pmrpc, register as a client for callJavascript()
calls and use iframemanager.asyncCallback(). Replace
parent.lz.embed.iframemanager.getIDFromWindow with window.name.
examples/extensions/html - Add test showing JS script injection
failing.
examples/extensions/html-test - Include iframestub to ensure
callJavascript() calls work properly.
examples/extensions/rte - Use this.text instead of getText().
Tests: examples/extensions/html.lzx and examples/extensions/rte.lzx
run as before.
Files:
A credits/pmrpc.txt
M lps/components/extensions/html.lzx
M lps/components/extensions/rte.lzx
A lps/includes/source/pmrpc.js
M lps/includes/source/build.xml
M lps/includes/source/rtemanager.js
M lps/includes/source/iframemanager-library.lzs
M lps/includes/source/iframemanager.js
M lps/includes/source/iframestub.js
M examples/extensions/html.lzx
M examples/extensions/html-test.html
M examples/extensions/rte.lzx
Changeset:
http://svn.openlaszlo.org/openlaszlo/patches/maxcarlson-20100825-5k4.tar