linkdialog.lzx
<library>
<class name="linkdialog" width="${parent.toolbar.width}" height="${parent.toolbar.height}" bgcolor="0xD4D7E6" visible="false">
<attribute name="editor" value="${grte}"/>
<attribute name="ystart" value="110
"/>
<attribute name="ssel" value="0
"/>
<attribute name="esel" value="0
"/>
<animator name="_animShow" attribute="y" to="0" from="${-parent.height}" duration="500" start="false" onstart="parent.setAttribute('visible', true)"/>
<animator name="_animHide" attribute="y" from="0" to="${-parent.height}" duration="200" start="false" onstop="parent.setAttribute('visible', false)"/>
<method name="show">
this.ssel = this.editor._ssel;
this.esel = this.editor._esel;
this.urlfield.setAttribute('text', "http://");
var ntextlength = this.urlfield.text.length;
this.urlfield.setSelection(ntextlength,ntextlength);
this._animShow.doStart();
</method>
<method name="hide">
this._animHide.doStart();
</method>
<method name="makelink">
if (this.ssel == this.esel) {
// it doesn't make sense to make a link to an empty selection, so,
// let's see if the editor has a more useful selection.
this.ssel = this.editor._ssel;
this.esel = this.editor._esel;
}
var url = this.urlfield.text;
var fmt = this.editor.getTextFormat(this.ssel, this.esel);
fmt.url = url;
fmt.color = 0x0000FF;
fmt.target = "_new";
fmt.underline = true;
this.editor.setTextFormat(fmt, this.ssel, this.esel);
var ncaratinsertpoint = this.editor._esel;
// make sure that next onfocus, which will be triggered by doing setSelection here, is ignored by editor.
this.editor._ignorenextfocus = true;
this.editor.setSelection(ncaratinsertpoint,ncaratinsertpoint);
this.hide();
</method>
<text name="linktolabel" y="4" x="5" fgcolor="0x40408B" font="Verdana, Arial, sans" fontsize="11" resize="true">Link to URL:</text>
<borderinput name="urlfield" width="${parent.width-150}" y="3"/>
<view y="4" x="${parent.width-145}">
<stylishbutton onclick="classroot.makelink()" width="70" text="Link">
<tooltip>Make a link to this location</tooltip>
</stylishbutton>
<stylishbutton onclick="classroot.hide()" x="80" width="60" text="Cancel">
<tooltip>Don't make a link</tooltip>
</stylishbutton>
</view>
</class>
</library>