<?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">

	<panel jsml-class="menu_context_table" jsml-base="floatmenu">

		<panel jsml-base="rtemenuitem" command="mergecells" imagename="mrgcell" htmlcode="@MERGECELLS" />
		<panel jsml-base="rtemenuitem" command="splitcells" imagename="spltcell" htmlcode="@SPLITCELLS" />
		<panel jsml-base="rtemenuspliter" />
		<panel jsml-base="rtemenuitem" command="deleterow" htmlcode="@DELETEROW" imagename="delrow"  />
		<panel jsml-base="rtemenuitem" command="deletecolumn" htmlcode="@DELETECOLUMN" imagename="delcol"  />
		<panel jsml-base="rtemenuitem" command="insertrowtop" htmlcode="@INSERTROWTOP" imagename="insrow_t"  />
		<panel jsml-base="rtemenuitem" command="insertrowbottom" htmlcode="@INSERTROWBOTTOM" imagename="insrow_b"  />
		<panel jsml-base="rtemenuspliter" />
		<panel jsml-base="rtemenuitem" command="insertcolumnleft" htmlcode="@INSERTCOLUMNLEFT" imagename="inscol_l"  />
		<panel jsml-base="rtemenuitem" command="insertcolumnright" htmlcode="@INSERTCOLUMNRIGHT" imagename="inscol_r" />

	</panel>

	<panel jsml-class="menu_context_taglist" jsml-base="floatmenu">
		<initialize>
			<![CDATA[
			var node=editor.GetSelectionRoot();
			for(;node&&node.GetNameLower()!="body";node=node.GetParent())
			{
				if(node.nodeType!=1)continue;
				
				var item=self.createitem(node);
				self.append_child(item);
			}
			]]>
		</initialize>
		<method name="createitem" arguments="node">
			<![CDATA[
			var item=jsml.class_create_instance("rtemenuitem");
			item.set_arrow(true);
			item.set_xmlfile("menu_tagitem.xml");
			item._floatboxClass="floatmenu";
			item.initoption=function(newoption)
			{
				newoption.node=node;
				newoption.buttonClick=function()
				{
					item.invoke_event("click");
				}
			}
			item.attach_event("click",function()
			{
				editor.ShowPropertiesDialog(node);
			});
			item.set_text(node.GetName());
			return item;
			]]>
		</method>
	</panel>


	<panel jsml-base="rtemenuitem" command="mergecells" imagename="mrgcell" htmlcode="@MERGECELLS">
		<initialize>
			if(!editor.CanExecCommand("mergecells"))self.set_visible(false);
		</initialize>
	</panel>

	<panel jsml-base="rtemenuitem" command="selectall" imagename="selectall" htmlcode="@SELECTALL" />

	<panel jsml-base="rtemenuitem" command="undo" imagename="undo" htmlcode="@UNDO" />

	<panel jsml-base="rtemenuspliter" />

	<panel jsml-base="rtemenuitem" command="cut" imagename="cut" htmlcode="@CUT">
		<attach name="mousehover">self._ResetFCButton();</attach>
	</panel>
	<panel jsml-base="rtemenuitem" command="copy" imagename="copy" htmlcode="@COPY">
		<attach name="mousehover">self._ResetFCButton();</attach>
	</panel>

	<panel jsml-base="rtemenuitem" command="delete" imagename="delete" htmlcode="@DELETE" />

	<panel jsml-base="rtemenuspliter" />



	<panel jsml-base="rtemenuopener" menuclass="menu_context_taglist" htmlcode="@TAGLIST">
		<initialize>
			<![CDATA[
			var node=editor.GetSelectionRoot();
			var count=0;
			for(;node&&node.GetNameLower()!="body";node=node.GetParent())
			{
				if(node.nodeType==1)count++;
			}
			if(count==0)self.set_disabled(true);
			]]>
		</initialize>
	</panel>

	<panel jsml-base="rtemenuopener" menuclass="menu_context_table" htmlcode="@TABLE">
		<initialize>
			var table=editor.IsIncludedByTag("table");
			if(table==null)return self.set_visible(false);
		</initialize>
	</panel>

	<panel jsml-base="rtemenuitem" htmlcode="@IMAGEEDITOR" imagename="imageeditor">
		<initialize>
			<![CDATA[
			var node=editor.GetSelectionRoot();
			if(!node||node.GetNameLower()!="img")self.set_visible(false);
			self.set_disabled(true);
			editor.FindStorage(["Gallery","Image"],node.GetAttribute("src"),function(storage,fileitem)
			{
				if(!storage)return;
				self.imgnode=node;
				self.storage=storage;
				self.fileitem=fileitem;
				self.set_disabled(false);
			});
			]]>
		</initialize>
		<attach name="click">
			if(!self.storage)return;
			editor.ShowImageEditor(self.imgnode,self.storage,self.fileitem);
		</attach>
	</panel>

	<panel jsml-base="rtemenuitem" htmlcode="@INSERTIMAGEMAP" imagename="imagemap">
		<initialize>
			<![CDATA[
				var node=editor.GetSelectionRoot();
				if(!node||node.GetNameLower()!="img")self.set_visible(false);
				self.imgnode=node;
				]]>
		</initialize>
		<attach name="click">
			editor.ExecInsertImageMap(null,self.imgnode);
		</attach>
	</panel>


	<panel jsml-base="rtemenuitem" imagename="link" htmlcode="@EDIT| |@LINK">
		<initialize>
			var link=editor.IsIncludedByTag("a");
			if(link==null)return self.set_visible(false);
		</initialize>
		<attach name="click">
			var link=editor.IsIncludedByTag("a");
			if(link)editor.ShowPropertiesDialog(link);
		</attach>
	</panel>
	<panel jsml-base="rtemenuitem" imagename="unlink" htmlcode="@REMOVE| |@LINK">
		<initialize>
			var link=editor.IsIncludedByTag("a");
			if(link==null)return self.set_visible(false);
		</initialize>
		<attach name="click">
			var link=editor.IsIncludedByTag("a");
			if(link)link.RemoveNode(false);
		</attach>
	</panel>
	
	<panel jsml-base="rtemenuitem" htmlcode="@STYLES" imagename="properties">
		<initialize>
			<![CDATA[
				var node=editor.GetSelectionRoot();
				if(!node||!node.IsControl())
				{
					self.set_visible(false);
					return;
				}
				self.set_arrow(true);
				self.set_xmlfile("menu_styles.xml");
				self._floatboxClass="floatmenu";
				self.initoption=function(newoption)
				{
					newoption.node=node;
					newoption.buttonClick=function()
					{
						self.invoke_event("click");
					}
				}
				]]>
		</initialize>
		<attach name="click">
			editor.ShowPropertiesDialog(editor.GetSelectionRoot(),{styletab:"text"})
		</attach>
	</panel>
	<panel jsml-base="rtemenuitem" htmlcode="@PROPERTIES" imagename="properties">
		<initialize>
			var node=editor.GetSelectionRoot();
			if(!node||!node.IsControl())self.set_visible(false);
		</initialize>
		<attach name="click">
			editor.ShowPropertiesDialog(editor.GetSelectionRoot())
		</attach>
	</panel>


</jsml>
