using System;
using CMS.CMSHelper;
using CMS.GlobalHelper;
using CMS.PortalControls;
using CMS.PortalEngine;
public partial class CMSWebParts_General_TextHighlighter : CMSAbstractWebPart
{
#region "Public properties"
///
/// Gets or sets the class name of span which wrap the highlighted words.
///
public string CSSClassName
{
get
{
return ValidationHelper.GetString(GetValue("CSSClassName"), string.Empty);
}
set
{
SetValue("CSSClassName", value);
}
}
///
/// Gets or sets the text or regular expression which should be highlighted.
///
public string TextToHighlight
{
get
{
return ValidationHelper.GetString(GetValue("TextToHighlight"), string.Empty);
}
set
{
SetValue("TextToHighlight", value);
}
}
///
/// Indicates whether the text to highlight is regular expression or not.
///
public bool TextIsRegularExpression
{
get
{
return ValidationHelper.GetBoolean(GetValue("TextIsRegularExpression"), false);
}
set
{
SetValue("TextIsRegularExpression", value);
}
}
#endregion
#region "Page events"
protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
if (StopProcessing)
{
// Do nothing
}
else
{
if ((CMSContext.ViewMode == ViewModeEnum.LiveSite) || (CMSContext.ViewMode == ViewModeEnum.Preview))
{
ScriptHelper.RegisterJQueryHighLighter(Page);
ScriptHelper.RegisterStartupScript(Page, typeof(String), "highlighter" + ClientID, ScriptHelper.GetScript("jQuery(function(){jQuery('body').highlight(" + ScriptHelper.GetString(TextToHighlight) + ", " + ScriptHelper.GetString(CSSClassName) + ", " + ScriptHelper.GetString(TextIsRegularExpression.ToString()) + ")})"));
}
}
}
#endregion
}