30 lines
1.5 KiB
C#
30 lines
1.5 KiB
C#
using System.Text;
|
|
using System.Web.Mvc;
|
|
using Kreta.BusinessLogic.Utils;
|
|
|
|
namespace Kreta.Web.Helpers
|
|
{
|
|
public static class SwitchButtonExtension
|
|
{
|
|
public static MvcHtmlString KretaSwitchButton(this HtmlHelper helper, string name, bool state, int offstateText = 134, int onstateText = 133)
|
|
{
|
|
|
|
string kikapcsolt = (bool)state ? "" : "-off";
|
|
|
|
var sb = new StringBuilder();
|
|
|
|
sb.AppendFormat("<div class='onoffswitch' onclick='SwitchButtonHelper.switchButtonChange(\"my{0}\",\"hidden{0}\")'>", name);
|
|
sb.AppendFormat("<input type='checkbox' name='{0}' class='onoffswitch-checkbox' id='my{0}' {1} Value=\"{2}\" />", name, state ? "checked" : string.Empty, state);
|
|
sb.AppendFormat("<label class='onoffswitch-label' for='my{0}'>", name);
|
|
sb.AppendFormat("<span class='onoffswitch-inner onoffswitch-inner-before'><span>{0}</span></span>", StringResourcesUtils.GetString(onstateText));
|
|
sb.AppendFormat("<span class='onoffswitch-inner'></span>");
|
|
sb.AppendFormat("<span class='onoffswitch-inner onoffswitch-inner-after'><span>{0}</span></span>", StringResourcesUtils.GetString(offstateText));
|
|
sb.AppendFormat("<span class='onoffswitch-switch'></span>");
|
|
sb.Append("</label>");
|
|
sb.Append("</div>");
|
|
sb.AppendFormat("<input type='hidden' name='{0}' Value=\"{1}\" id='hidden{2}' style='visibility:\"collapse\"'/>", name, state, name);
|
|
|
|
return new MvcHtmlString(sb.ToString());
|
|
}
|
|
}
|
|
}
|