using System;
using System.Text;
using System.Web;
using System.Web.UI;
using CMS.ExtendedControls;
using CMS.GlobalHelper;
public partial class CMSInlineControls_ImageControl : InlineUserControl
{
#region "Properties"
///
/// Gets or sets the value which determines whether to use the control in special mode (icon of the filetype with hovereffect).
///
public bool ShowFileIcons
{
get
{
return ValidationHelper.GetBoolean(GetValue("ShowFileIcons"), false);
}
set
{
SetValue("ShowFileIcons", value);
}
}
///
/// URL of the image media.
///
public string URL
{
get
{
return ValidationHelper.GetString(GetValue("URL"), null);
}
set
{
SetValue("URL", value);
}
}
///
/// Gets or sets the value which determines whether to append size parameters to URL ot not.
///
public bool SizeToURL
{
get
{
return ValidationHelper.GetBoolean(GetValue("SizeToURL"), true);
}
set
{
SetValue("SizeToURL", value);
}
}
///
/// Image extension.
///
public string Extension
{
get
{
return ValidationHelper.GetString(GetValue("Extension"), null);
}
set
{
SetValue("Extension", value);
}
}
///
/// Image alternative text.
///
public string Alt
{
get
{
return ValidationHelper.GetString(GetValue("Alt"), null);
}
set
{
SetValue("Alt", value);
}
}
///
/// Image width.
///
public int Width
{
get
{
return ValidationHelper.GetInteger(GetValue("Width"), -1);
}
set
{
SetValue("Width", value);
}
}
///
/// Image height.
///
public int Height
{
get
{
return ValidationHelper.GetInteger(GetValue("Height"), -1);
}
set
{
SetValue("Height", value);
}
}
///
/// Image border width.
///
public int BorderWidth
{
get
{
return ValidationHelper.GetInteger(GetValue("BorderWidth"), -1);
}
set
{
SetValue("BorderWidth", value);
}
}
///
/// Image border color.
///
public string BorderColor
{
get
{
return ValidationHelper.GetString(GetValue("BorderColor"), null);
}
set
{
SetValue("BorderColor", value);
}
}
///
/// Image horizontal space.
///
public int HSpace
{
get
{
return ValidationHelper.GetInteger(GetValue("HSpace"), -1);
}
set
{
SetValue("HSpace", value);
}
}
///
/// Image vertical space.
///
public int VSpace
{
get
{
return ValidationHelper.GetInteger(GetValue("VSpace"), -1);
}
set
{
SetValue("VSpace", value);
}
}
///
/// Image align.
///
public string Align
{
get
{
return ValidationHelper.GetString(GetValue("Align"), null);
}
set
{
SetValue("Align", value);
}
}
///
/// Image ID.
///
public string ImageID
{
get
{
return ValidationHelper.GetString(GetValue("Id"), null);
}
set
{
SetValue("Id", value);
}
}
///
/// Image tooltip text.
///
public string Tooltip
{
get
{
return ValidationHelper.GetString(GetValue("Tooltip"), null);
}
set
{
SetValue("Tooltip", value);
}
}
///
/// Image css class.
///
public string Class
{
get
{
return ValidationHelper.GetString(GetValue("Class"), null);
}
set
{
SetValue("Class", value);
}
}
///
/// Image inline style.
///
public string Style
{
get
{
return ValidationHelper.GetString(GetValue("Style"), null);
}
set
{
SetValue("Style", value);
}
}
///
/// Image link destination.
///
public string Link
{
get
{
return ValidationHelper.GetString(GetValue("Link"), null);
}
set
{
SetValue("Link", value);
}
}
///
/// Image link target (_blank/_self/_parent/_top)
///
public string Target
{
get
{
return ValidationHelper.GetString(GetValue("Target"), null);
}
set
{
SetValue("Target", value);
}
}
///
/// Image behavior.
///
public string Behavior
{
get
{
return ValidationHelper.GetString(GetValue("Behavior"), null);
}
set
{
SetValue("Behavior", value);
}
}
///
/// Width of the thumbnail image which is displayed when mouse is moved over the image.
///
public int MouseOverWidth
{
get
{
return ValidationHelper.GetInteger(GetValue("MouseOverWidth"), 0);
}
set
{
SetValue("MouseOverWidth", value);
}
}
///
/// Height of the thumbnail image which is displayed when mouse is moved over the image.
///
public int MouseOverHeight
{
get
{
return ValidationHelper.GetInteger(GetValue("MouseOverHeight"), 0);
}
set
{
SetValue("MouseOverHeight", value);
}
}
///
/// Control parameter.
///
public override string Parameter
{
get
{
return URL;
}
set
{
URL = value;
}
}
#endregion
#region "Page events"
protected void Page_PreRender(object sender, EventArgs e)
{
if (Behavior == "hover")
{
StringBuilder sb = new StringBuilder();
// If jQuery not loaded
sb.AppendFormat(@"
if (typeof jQuery == 'undefined') {{
var jQueryCore=document.createElement('script');
jQueryCore.setAttribute('type','text/javascript');
jQueryCore.setAttribute('src', '{0}');
setTimeout('document.body.appendChild(jQueryCore)',100);
setTimeout('loadTooltip()',200);
}}", ScriptHelper.GetScriptUrl("~/CMSScripts/jquery/jquery-core.js"));
// If jQuery tooltip plugin not loaded
sb.AppendFormat(@"
var jQueryTooltips=document.createElement('script');
function loadTooltip() {{
if (typeof jQuery == 'undefined') {{ setTimeout('loadTooltip()',200); return;}}
if (typeof jQuery.fn.tooltip == 'undefined') {{
jQueryTooltips.setAttribute('type','text/javascript');
jQueryTooltips.setAttribute('src', '{0}');
setTimeout('document.body.appendChild(jQueryTooltips)',100);
}}
}}", ScriptHelper.GetScriptUrl("~/CMSScripts/jquery/jquery-tooltips.js"));
string rtlDefinition = null;
if (((IsLiveSite) && (CultureHelper.IsPreferredCultureRTL())) || (CultureHelper.IsUICultureRTL()))
{
rtlDefinition = "positionLeft: true,left: -15,";
}
sb.AppendFormat(@"
function hover(imgID, width, height, sizeInUrl) {{
if ((typeof jQuery == 'undefined')||(typeof jQuery.fn.tooltip == 'undefined')) {{
var imgIDForTimeOut = imgID.replace(/\\/gi,""\\\\"").replace(/'/gi,""\\'"");
setTimeout(""loadTooltip();hover('""+imgIDForTimeOut+""',""+width+"",""+height+"",""+sizeInUrl+"")"",100); return;
}}
jQuery('img[id='+imgID+']').tooltip({{
delay: 0,
track: true,
showBody: "" - "",
showBody: "" - "",
extraClass: ""ImageExtraClass"",
showURL: false,
{0}
bodyHandler: function() {{
var hidden = jQuery(""#"" + imgID + ""_src"");
var source = this.src;
if (hidden[0] != null) {{
source = hidden[0].value;
}}
var hoverDiv = jQuery(""