rte.lzx
<library>
<class name="rte" extends="html" scrollbars="false">
<doc>
<tag name="shortdesc"><text>Adds the capability to edit rich-text pages.</text></tag>
<text>
<p><tagname>rte</tagname> is a <sgmltag class="element" role="html"><html></sgmltag> that allows editing of rich-text pages.
The rte component uses the dijit.Editor from the dojo toolkit.</p>
<p>For best results in Flash (like the html component), set the wmode attribute to 'transparent' when embedding the application. See examples/extensions/html-swf.jsp for an example. See examples/extensions/rte.lzx for an example of embedding <tagname>rte</tagname> in a window.</p>
<example><programlisting class="code"> <canvas height="400">
<include href="extensions/rte.lzx"/>
<rte width="600" height="400">Initial contents that you can edit.</rte>
</canvas>
</programlisting></example>
<p><classname>rte</classname> extends <sgmltag class="element" role="html"><html></sgmltag>.</p>
</text>
</doc>
<event name="ontext"/>
<event name="oneditorready"/>
<attribute name="toolbar_order" type="string" value="undo,redo,|,cut,copy,paste,|,bold,italic,underline,strikethrough,|,insertOrderedList,insertUnorderedList,indent,outdent,|,justifyLeft,justifyRight,justifyCenter,justifyFull,|,foreColor,hiliteColor,|,createLink,unlink,insertImage,|,print,smiley,||,fontName,fontSize
"/>
<attribute name="extra_plugins" type="string" value="
"/>
<attribute name="dojo_root" type="string" value="
"/>
<attribute name="dojo_theme" type="string" value="tundra
"/>
<attribute name="dojo_locale" type="string" value="
"/>
<attribute name="dojo_js" type="string" value="dojo/dojo.js
"/>
<attribute name="dojo_css" type="string" value="dijit/themes/
"/>
<attribute name="wrapperfile" type="string" value="
"/>
<attribute name="text" type="html"/>
<setter name="text" args="t">
this.text = t;
// This can fire before the object is ready
if (this.editorready) {
this.callJavascript('lz.rte.manager.setText', null, t);
}
</setter>
<method name="setText" args="html">
this.$lzc$set_text(html)
</method>
<method name="getText" args="delegate">
this.callJavascript('lz.rte.manager.getText', delegate);
</method>
<attribute name="editorready" value="false
"/>
<method name="insertHtml" args="html">
this.callJavascript('lz.rte.manager.insertHtml', null, html);
</method>
<method name="execCommand" args="cmd, arg=''">
this.callJavascript('lz.rte.manager.execCommand', null, cmd, arg);
</method>
<method name="construct" args="parent, args">
super.construct( parent, args );
this.button_mapping = new LzInheritedHash()
</method>
<method name="addButton" args="attributes, delegate">
// Fix up relative paths. They are specified relative to where the
// application is stored but this won't work in the iframe.
for (var attr in attributes) {
if (attr == 'src') {
var src = attributes[attr];
if (src.length > 0 && !(src.indexOf('http') > -1 || src.charAt(0) == '/')) {
// Relative path
src = lz.Browser.getLoadURLAsLzURL().path + src;
attributes[attr] = src;
}
}
}
// Add tooltips if they weren't specified in the attributes.
// Depending on browser, the tooltip is 'alt' or 'title'. If both are
// missing, use the value of the element
var value = null;
if ('value' in attributes)
value = attributes['value'];
if ('alt' in attributes)
value = attributes['alt'];
if ('title' in attributes)
value = attributes['title'];
if (value) {
if (!('alt' in attributes))
attributes['alt'] = value;
if (!('title' in attributes))
attributes['title'] = value;
}
var id = this.callJavascript ('lz.rte.manager.addButton', null, attributes);
this.button_mapping[id] = delegate;
return id;
</method>
<handler name="onbuttonclick" args="id">
// One of the user buttons was clicked
var handler = this.button_mapping[id];
if (handler)
handler.execute (id);
</handler>
<handler name="onload">
// Change where dojo is found (if necessary)
if (this.dojo_root.length > 0) {
this.callJavascript('lz.rte.manager.setDojoPath', null, this.dojo_root, this.dojo_js, this.dojo_css);
}
// Set the locale
if (this.dojo_locale.length > 0)
this.callJavascript('lz.rte.manager.setDojoLocale', null, this.dojo_locale);
// Set the theme
if (this.dojo_theme.length > 0)
this.callJavascript('lz.rte.manager.setDojoTheme', null, this.dojo_theme);
// Set the extra plugins
if (this.extra_plugins.length > 0)
this.callJavascript('lz.rte.manager.setExtraPlugins', null, this.extra_plugins);
// Set the plugin list
if (this.toolbar_order.length > 0)
this.callJavascript('lz.rte.manager.setPlugins', null, this.toolbar_order);
// Create and start the editor
this.callJavascript('lz.rte.manager.create', null, 'rte', this.iframeid);
this.callJavascript('lz.rte.manager.rte_start', null, this.text);
</handler>
<event name="on_rte_loaded"/>
<event name="on_editorready"/>
<event name="on_text"/>
<handler name="on_editorready">
// The editor is ready.
this.editorready = true;
// Any settext calls are ignored until this point. Display the current html text.
if (this.text)
this.setAttribute('text', this.text);
// Fire any oneditorready events
if (this.oneditorready.ready) this.oneditorready.sendEvent(true);
</handler>
<handler name="on_text" args="txt">
this.text = txt;
if (this.ontext.ready) this.ontext.sendEvent(txt);
</handler>
<method name="loadsrc" args="root">
var wrapper = root + 'rtewrapper.html';
if (this.wrapperfile.length > 0) {
wrapper = lz.Browser.getLoadURLAsLzURL().path + this.wrapperfile;
}
this.setAttribute('src', wrapper);
this.setAttribute('visible', true);
</method>
<handler name="oninit">
// Get the server root.
// Use a callback because the object may not be ready yet
var obj = this;
lz.Browser.callJS('lz.embed.getServerRoot', function(root) { obj.loadsrc(root);});
</handler>
<method name="destroy_callback" args="txt">
if (txt != this.text)
this.ontext.sendEvent(txt);
if (this['iframeid']) {
this.callJavascript('lz.rte.manager.__destroy', null, this.iframeid);
}
super.destroy();
</method>
<method name="destroy">
this.getText(new LzDelegate(this, 'destroy_callback'));
</method>
</class>
</library>
Cross References
Classes
- <class name="rte" extends="html">