@* Generator: WebPagesHelper *@
@using Disco;
@using Disco.Models.Repository;
@using Disco.Services;
@using Disco.Services.Web;
@using Disco.Web;
@using System.Web.Mvc
@using System.Web.Mvc.Html;

@helper FriendlyDate(DateTime d, string ElementId = null, bool WithoutSuffix = false)
{<span @(ElementId == null ? null : new HtmlString(string.Format("id=\"{0}\" ", ElementId))) title="@d.ToFullDateTime()" data-livestamp="@d.ToUnixEpoc()" data-isodate="@d.ToISO8601()" class="date nowrap@(WithoutSuffix ? " noMomentSuffix" : null)">@d.ToFullDateTime()</span>}
@helper FriendlyDate(DateTime? d, string NullValue = "n/a", string ElementId = null, bool WithoutSuffix = false)
{<span @(ElementId == null ? null : new HtmlString(string.Format("id=\"{0}\" ", ElementId))) title="@d.ToFullDateTime(NullValue)" data-livestamp="@d.ToUnixEpoc()" data-isodate="@d.ToISO8601()" class="date nowrap@(WithoutSuffix ? " noMomentSuffix" : null)">@d.ToFullDateTime(NullValue)</span>}
@helper FriendlyDateAndUser(DateTime? d, User u, string DateNullValue = "n/a", bool WithoutSuffix = false)
{
    @FriendlyDate(d, DateNullValue, WithoutSuffix: WithoutSuffix);
    @FriendlyUser(u, null, " by");
}
@helper FriendlyDateAndUser(DateTime d, User u, bool WithoutSuffix = false)
{
    @FriendlyDate(d, WithoutSuffix: WithoutSuffix);
    @FriendlyUser(u, null, " by");
}
@helper FriendlyDateAndUser(DateTime? d, string UserId, string DateNullValue = "n/a", bool WithoutSuffix = false)
{
    @FriendlyDate(d, DateNullValue, WithoutSuffix: WithoutSuffix);
    @FriendlyUser(UserId, null, " by");
}
@helper FriendlyDateAndUser(DateTime d, string UserId, bool WithoutSuffix = false)
{
    @FriendlyDate(d, WithoutSuffix: WithoutSuffix);
    @FriendlyUser(UserId, null, " by");
}
@helper FriendlyDateAndTitleUser(DateTime? d, User u, string DateNullValue = "n/a", bool WithoutSuffix = false)
{
    <span title="@d.ToFullDateTime(DateNullValue) by @u" data-livestamp="@d.ToUnixEpoc()" class="date nowrap@(WithoutSuffix ? " noMomentSuffix" : null)">@d.ToFullDateTime(DateNullValue)</span>
}
@helper FriendlyDateAndTitleUser(DateTime d, User u, bool WithoutSuffix = false)
{
    <span title="@d.ToFullDateTime() by @u" data-livestamp="@d.ToUnixEpoc()" class="date nowrap@(WithoutSuffix ? " noMomentSuffix" : null)">@d.ToFullDateTime()</span>
}
@helper FriendlyUser(User u, string nullValue = null, string prepend = null)
{
    if (u != null)
    {
        @prepend <span title="@u">@u.FriendlyId()</span>
    }
    else
    {
        <span>@nullValue</span>
    }
}
@helper FriendlyUser(string UserId, string nullValue = null, string prepend = null)
{
    if (UserId != null)
    {
        @prepend <span>@Disco.Services.Interop.ActiveDirectory.ActiveDirectory.FriendlyAccountId(UserId)</span>
    }
    else
    {
        <span>@nullValue</span>
    }
}


@helper RadioButtonList(string id, List<System.Web.Mvc.SelectListItem> items, int columns = 1)
{
    @ItemList(null, "radio", id, items, columns)
}
@helper RadioButtonList(string containerName, string id, List<System.Web.Mvc.SelectListItem> items, int columns = 1)
{
    @ItemList(containerName, "radio", id, items, columns)
}
@helper CheckBoxList(string id, List<System.Web.Mvc.SelectListItem> items, int columns = 1, bool alignEven = true, int? forceUniqueIds = null, bool htmlEncodeText = true)
{
    @ItemList(null, "checkbox", id, items, columns, alignEven, forceUniqueIds, htmlEncodeText)
}
@helper CheckBoxList(string containerName, string id, List<System.Web.Mvc.SelectListItem> items, int columns = 1, bool alignEven = true, int? forceUniqueIds = null, bool htmlEncodeText = true)
{
    @ItemList(containerName, "checkbox", id, items, columns, alignEven, forceUniqueIds, htmlEncodeText)
}
@helper CheckboxBulkSelect(string BulkSelectContainerId, string ParentJQuerySelector = null)
{Html.GetPageHelper().BundleDeferred("~/ClientScripts/Modules/Disco-jQueryExtensions");
    <span id="@BulkSelectContainerId" class="checkboxBulkSelectContainer">
        @if (string.IsNullOrWhiteSpace(ParentJQuerySelector))
        {
            <script type="text/javascript">$(function () { $('#@(BulkSelectContainerId)').checkboxBulkSelect(); });</script>
        }
        else
        {
            <script type="text/javascript">$(function () { $('#@(BulkSelectContainerId)').checkboxBulkSelect({ parentSelector: '@(ParentJQuerySelector)' }); });</script>
        }
    </span>
}
@helper ItemList(string containerId, string inputType, string id, List<System.Web.Mvc.SelectListItem> items, int columns = 1, bool alignEven = true, int? forceUniqueIds = null, bool htmlEncodeText = true)
{
    int itemsPerColumn = items.Count / columns;
    int columnWidth = (100 / columns);
    var itemNextId = 0;
    <table id="@containerId" class="none">
        <tr>
            @for (int i = 0; i < columns; i++)
            {
                <td @(alignEven ? new HtmlString(string.Format(" style=\"width: {0}%\"", columnWidth)) : new HtmlString(string.Empty))>
                    <ul class="none">
                        @{
                            int itemsForThisColumn = itemsPerColumn + (items.Count % columns > i ? 1 : 0);
                            for (int i2 = 0; i2 < itemsForThisColumn && itemNextId < items.Count; i2++)
                            {
                                var item = items[itemNextId];
                                itemNextId++;
                                var itemId = forceUniqueIds.HasValue ? string.Format("{0}_{1}_{2}", id, item.Value, forceUniqueIds++) : string.Format("{0}_{1}", id, item.Value);
                                <li>
                                    <input id="@itemId" name="@id" value="@item.Value" type="@inputType" @(item.Selected ? new HtmlString("checked=\"checked\" ") : null) /><label for="@itemId">
                                        @if (htmlEncodeText)
                                        {@item.Text }
                                    else
                                    { @(new HtmlString(item.Text))}
                                    </label>
                                </li>
                            }
                        }
                    </ul>
                </td>
            }
        </tr>
    </table>
}


@helper Breadcrumbs(List<Tuple<string, ActionResult>> BreadCrumbs)
{
    for (int index = 0; index < BreadCrumbs.Count; index++)
    {
        var breadCrumb = BreadCrumbs[index];
        if (index != 0)
        {
            <span>&gt;</span>
        }
        if (breadCrumb.Item2 == null)
        {
            <span title="@breadCrumb.Item1">@breadCrumb.Item1</span>
        }
        else
        {
            @Html.GetPageHelper().ActionLink(breadCrumb.Item1, breadCrumb.Item2)
        }
    }
}
@helper Breadcrumbs(string Title)
{
    @Title
}
@helper BreadcrumbsTitle(List<Tuple<string, ActionResult>> BreadCrumbs)
{
    for (int index = 0; index < BreadCrumbs.Count; index++)
    {
        var breadCrumb = BreadCrumbs[index];
        if (index != 0)
        {
            @(new HtmlString(" > "))
        }
        @breadCrumb.Item1
    }
}
@helper BreadcrumbsTitle(string Title)
{
    @Title
}