|
|
|
@ -1,4 +1,6 @@
|
|
|
|
|
using Microsoft.AspNetCore.Razor.TagHelpers;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using Microsoft.AspNetCore.Razor.TagHelpers;
|
|
|
|
|
|
|
|
|
|
namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Tooltip
|
|
|
|
|
{
|
|
|
|
@ -6,19 +8,40 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Tooltip
|
|
|
|
|
{
|
|
|
|
|
public override void Process(TagHelperContext context, TagHelperOutput output)
|
|
|
|
|
{
|
|
|
|
|
if (IsButtonDisabled(context, output))
|
|
|
|
|
{
|
|
|
|
|
SetParentElementWithTooltip(context, output);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SetDataToggle(context, output);
|
|
|
|
|
SetDataPlacement(context, output);
|
|
|
|
|
SetTooltipTitle(context, output);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected virtual void SetParentElementWithTooltip(TagHelperContext context, TagHelperOutput output)
|
|
|
|
|
{
|
|
|
|
|
var directory = GetDirectory() != TooltipDirectory.Default ? GetDirectory() : TooltipDirectory.Top;
|
|
|
|
|
output.Attributes.Add("data-placement", directory.ToString().ToLowerInvariant());
|
|
|
|
|
|
|
|
|
|
output.PreElement.SetHtmlContent(
|
|
|
|
|
"<span class=\"d-inline-block\" tabindex=\"0\" data-toggle=\"tooltip\" " +
|
|
|
|
|
"data-placement=\"" + directory.ToString().ToLowerInvariant() +
|
|
|
|
|
"\" title=\"" + GetTitle() + "\">" + Environment.NewLine);
|
|
|
|
|
|
|
|
|
|
output.PostElement.SetHtmlContent(Environment.NewLine + "</span>");
|
|
|
|
|
|
|
|
|
|
output.Attributes.Add("style", "pointer-events: none;");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected virtual void SetDataToggle(TagHelperContext context, TagHelperOutput output)
|
|
|
|
|
{
|
|
|
|
|
output.Attributes.Add("data-toggle","tooltip");
|
|
|
|
|
output.Attributes.Add("data-toggle", "tooltip");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected virtual void SetDataPlacement(TagHelperContext context, TagHelperOutput output)
|
|
|
|
|
{
|
|
|
|
|
var directory = GetDirectory() != TooltipDirectory.Default ? GetDirectory() : TooltipDirectory.Bottom;
|
|
|
|
|
var directory = GetDirectory() != TooltipDirectory.Default ? GetDirectory() : TooltipDirectory.Top;
|
|
|
|
|
output.Attributes.Add("data-placement", directory.ToString().ToLowerInvariant());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -65,5 +88,10 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Tooltip
|
|
|
|
|
|
|
|
|
|
return TooltipDirectory.Default;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected virtual bool IsButtonDisabled(TagHelperContext context, TagHelperOutput output)
|
|
|
|
|
{
|
|
|
|
|
return output.Attributes.Any(a => a.Name == "disabled");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|