<?xml version="1.0" encoding="utf-8" ?>
<jsml xmlns="http://cutesoft.net/jsml"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://cutesoft.net/jsml ../core/jsml.xsd">

	<include src="{folder}dialogs/browsedialogbase.xml?{timems}" />

	<execute>
		dialog.set_back_color("#F9F9F9");
		dialog.set_title(editor.GetLangText("HOTSPOT"));
	</execute>


	<!-- # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 
			class insertimagemaplinkdialog
	 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # -->
	<panel jsml-class="insertimagemaplinkdialog" dock="fill" margin="3">

		<panel dock="bottom" margin="3" padding="6" overflow="visible">

			<panel dock="right" margin="3" overflow="visible">
				<initialize>
					if(!option.nestedmode)self.set_visible(false);
				</initialize>
				<button dock="left" width="82" height="24"  text="@CLOSE">
					<attach name="click">
						dialog.close();
					</attach>
				</button>
			</panel>

			<panel dock="right" margin="3" overflow="visible">
				<initialize>
					if(option.nestedmode)self.set_visible(false);
				</initialize>
				<button dock="left" width="82" height="24"  text="@OK" margin="0,12,0,0">
					<initialize>
						if(option.oktext)self.set_text(option.oktext);
					</initialize>
					<attach name="click">
						if(!option.targetnode.GetAttribute("href"))return;
						dialog.result=true;
						dialog.close();
					</attach>
				</button>
				<button dock="left" width="82" height="24"  text="@CANCEL">
					<attach name="click">
						dialog.close();
					</attach>
				</button>
			</panel>

		</panel>


		<groupbox text="@HOTSPOT" dock="top" overflow="visible" margin="3" padding="12,12,12,2">


			<panel margin="7,3,1,3" height="18" dock="top" >
				<label dock="left" vertical_align="middle" text="Url:" text_align="right" width="50"/>

				<panel jsml-base="rteproptextbox" dock="left" propname="href" width="240" jsml-local="tbhref">
					<attach name="change,loadvalue,attach_dom">
						<![CDATA[
						instance.syncurltotext();
						var ddltext=ddltype.get_text();
						var href=self.get_text();
						if(ddltext&&href.substring(0,ddltext.length)==ddltext)return;
						for(var i=0;i<ddltype._items.length;i++)
						{
							ddltext=ddltype._items[i].get_value();
							if(href.substring(0,ddltext.length)!=ddltext)
								continue;
							ddltype.set_text(ddltext);
							break;
						}
						]]>
					</attach>
				</panel>

				<image jsml-base="imagebutton" dock="left" width="20" tooltip="@INTERNALLINK" src="{folder}images/node-tree.png" padding="-1,1,1,-1" margin="0,1,0,1">
					<attach name="click">
						instance.showfindurl(self);
					</attach>
				</image>
				<panel dock="left" width="3" />
				<button dock="left" width="82" height="24"  text="@BROWSE|..">
					<attach name="click">
						instance.showuploadfile(self);
					</attach>
				</button>
			</panel>

			<panel margin="7,3,1,3" height="18" dock="top">
				<label dock="left" vertical_align="middle" text="@TYPE|:" text_align="right" width="50"/>
				<dropdown dock="left" jsml-local="ddltype" border_color="#cccccc">
					<attach name="change">
						tbhref.set_text(self.get_text());
						tbhref.invoke_event("change");
					</attach>
					<listitem text="http://" value="http://" />
					<listitem text="https://" value="https://" />
					<listitem text="news://" value="news://" />
					<listitem text="ftp://" value="ftp://" />
					<listitem text="mailto:" value="mailto:" />
					<listitem text="@OTHER" value="" />
				</dropdown>
				<panel dock="left" width="12" />
				<label dock="left" vertical_align="middle" text="@ATTR_TARGET|:" text_align="right" width="50"/>
				<panel dock="left" jsml-base="rtepropdropdown" propname="target">
					<listitem value="" text="@NOTSET" />
					<listitem value="_blank" text="@ATTR_TARGETBLANK" />
					<listitem value="_parent" text="@ATTR_TARGETPARENT" />
				</panel>

			</panel>

			<panel margin="7,3,1,3" height="18" dock="top" >
				<label dock="left" vertical_align="middle" text="@TOOLTIP|:" text_align="right" width="50"/>
				<panel jsml-base="rteproptextbox" dock="left" propname="title" width="320" jsml-local="tbtext"/>
			</panel>

		</groupbox>


		<!-- # # # # # # # # # # # # # # # # 
			dialog code
		 # # # # # # # # # # # # # # # # -->


		<initialize>
			<![CDATA[

			self._rtenode=option.targetnode;

			]]>
		</initialize>
		
		<initialize>
			self.setDelegateTimeout(self.delegate(self.initsynctext),100);
		</initialize>
		<method name="stopsynctext">
			self.initsynctext();
		</method>
		<method name="initsynctext">
			<![CDATA[
			self._synctotext=false;
			var text=tbtext.get_ctrl_value();
			if(!text||text==editor._config.default_link_text)
				self._synctotext=true;
			else if(text==option.targetnode.GetAttribute("href"))
				self._synctotext=true;
			]]>
		</method>
		<method name="syncurltotext">
			<![CDATA[
			if(!self._synctotext)return;
			option.targetnode.SetAttribute("title",option.targetnode.GetAttribute("href")||"")
			tbtext.invoke_event("loadvalue");
			]]>
		</method>
		
		<method name="showfindurl" arguments="ctrl">
			<![CDATA[
			var newoption={};
			newoption.control=ctrl
			newoption.handlehref=function(href)
			{
				tbhref.set_text(href);
				tbhref.invoke_event("change");
			}
			editor.ShowXmlFloatBox(editor.BuildDialogUrl("insertlink_findurl.xml"),newoption);
			]]>
		</method>
		<method name="showuploadfile" arguments="anchor">
			<![CDATA[
			var newoption={width:640,height:420,targetnode:option.targetnode};
			newoption.nestedmode=true;
			newoption.callback=function()
			{
				self.invoke_recursive("loadvalue");
			}
			editor.ShowXmlDialog(editor.BuildDialogUrl("insertdocument.xml"),newoption);
			]]>
		</method>

	</panel>

	<panel jsml-base="insertimagemaplinkdialog" />

</jsml>
