Commit f3307c90 authored by Viet Hoang's avatar Viet Hoang

Merge branch 'ImageCoordinatePicker_v1.1.0' into 'master'

Image coordinate picker v1.1.0

See merge request !14
parents be72963b e55e6f33
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<controlSources>
<source mode="on" namespace="Vhs.ImageCoordinatePickerField.Fields"
assembly="Vhs.ImageCoordinatePickerField" prefix="vhs" />
</controlSources>
<settings>
<setting name="Vhs.ImageCoordinatePickerField.DialogWidth" value="800"/>
<setting name="Vhs.ImageCoordinatePickerField.DialogHeight" value="600"/>
......
......@@ -7,7 +7,7 @@
namespace Vhs.ImageCoordinatePickerField.Fields
{
public class ImageCoordinateField : Text, IContentField
public class ImageCoordinatePicker : Text, IContentField
{
public string GetValue()
{
......@@ -23,8 +23,10 @@ public override void HandleMessage(Message message)
{
base.HandleMessage(message);
if (!message.Name.Equals("vhs:PickCoordinate"))
if (!message.Name.Equals("vhs:PickCoordinate") || message["id"] != this.ID)
{
return;
}
// manage to get the container id (Sitecore item id) of this field
// onFocus attribute's value will be like this
......
......@@ -88,7 +88,7 @@
<ItemGroup>
<Compile Include="Constants\QueryStringKeys.cs" />
<Compile Include="Dialogs\ImageCoordinatePickerDialog.cs" />
<Compile Include="Fields\ImageCoordinatePickerField.cs" />
<Compile Include="Fields\ImageCoordinatePicker.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Services\ConfigurationService.cs" />
</ItemGroup>
......
using System.Collections.Specialized;
using Sitecore.Shell.Applications.ContentEditor;
using Sitecore.Web.UI.Sheer;
using Vhs.ImageCoordinatePickerField2.Constants;
using Vhs.ImageCoordinatePickerField2.Services;
using SC = Sitecore;
namespace Vhs.ImageCoordinatePickerField2.Fields
{
public class ImageCoordinatePicker : Text, IContentField
{
public string GetValue()
{
return this.Value;
}
public void SetValue(string value)
{
this.Value = value;
}
public override void HandleMessage(Message message)
{
base.HandleMessage(message);
if (!message.Name.Equals("vhs:PickCoordinate2") || message["id"] != this.ID)
{
return;
}
// manage to get the container id (Sitecore item id) of this field
// onFocus attribute's value will be like this
// javascript:return scContent.activate(this,event,'sitecore://master/{6DB97A83-480E-4F51-A9D5-B6C688C651B3}?lang=en&ver=1&fld={AA29FFC7-DEA0-4053-87A3-967C198AB652}&ctl=FIELD313682656')
// in this case, container id = 6DB97A83-480E-4F51-A9D5-B6C688C651B3
var onFocus = this.Attributes["onfocus"];
var containerId = onFocus.Split('?')[0].Split('{')[1].Replace("}", string.Empty);
SC.Context.ClientPage.Start(
this,
"PickCoordinate",
new NameValueCollection { { QueryStringKeys.ContainerId, containerId } });
}
protected void PickCoordinate(ClientPipelineArgs args)
{
if (args.IsPostBack)
{
if (args.HasResult && args.Result != this.Value)
{
this.SetModified();
this.SetValue(args.Result);
}
}
else
{
var uri = string.Format(
"{0}&{1}={2}&{3}={4}",
SC.UIUtil.GetUri("control:ImageCoordinatePickerDialog2"),
QueryStringKeys.Value,
this.GetValue(),
QueryStringKeys.ContainerId,
args.Parameters[QueryStringKeys.ContainerId]);
SheerResponse.ShowModalDialog(uri, ConfigurationService.DialogWidth, ConfigurationService.DialogHeight,
string.Empty, true);
args.WaitForPostBack();
}
}
}
}
\ No newline at end of file
......@@ -89,6 +89,7 @@
<Compile Include="Constants\QueryStringKeys.cs" />
<Compile Include="Dialogs\ImageCoordinatePickerDialog.cs" />
<Compile Include="Fields\ImageCoordinatePickerField.cs" />
<Compile Include="Fields\ImageCoordinatePicker.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Services\ConfigurationService.cs" />
</ItemGroup>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment