@*   Xafari Framework version : 17.2.3011.1336   *@

@using DevExpress.ExpressApp.Actions
@using DevExpress.ExpressApp.Templates
@using Xafari.Mvc
@using Xafari.Mvc.Templates

@model Xafari.Mvc.Templates.ActionContainers.NavigationHistoryActionContainer

@{
    this.Model.FrameTemplate.RegisterActionContainers(new IActionContainer[] { this.Model });
}

<span class="NavigationHistoryLinks" id="NavigationHistoryLinks_@(this.Model.GetHashCode().ToString())">
    @{
        if (((this.Model.HistorySingleChoiceAction != null) && (this.Model.HistorySingleChoiceAction.Active)) && (this.Model.HistorySingleChoiceAction.Items.Count > 1))
        {
            List<ChoiceActionItem> nonDuplicateItems = this.Model.GetNonDuplicateItems(this.Model.HistorySingleChoiceAction.Items);
            int index = nonDuplicateItems.IndexOf(this.Model.HistorySingleChoiceAction.SelectedItem);
            int num2 = index - (this.Model.VisibleItemCount/2);
            int visibleItemCount = index + (this.Model.VisibleItemCount - (this.Model.VisibleItemCount/2));
            if (visibleItemCount > (nonDuplicateItems.Count - 1))
            {
                visibleItemCount = nonDuplicateItems.Count - 1;
                num2 = (visibleItemCount - this.Model.VisibleItemCount) + 1;
            }
            if (num2 < 0)
            {
                num2 = 0;
                visibleItemCount = this.Model.VisibleItemCount;
                if (visibleItemCount > (nonDuplicateItems.Count - 1))
                {
                    visibleItemCount = nonDuplicateItems.Count - 1;
                }
            }

            for (int i = num2; i <= visibleItemCount; i++)
            {
                ChoiceActionItem navigationItem = nonDuplicateItems[i];

                var hrefAtt = string.Empty;
                var idAtt = "id=" + this.ViewData.Frame().ControlId("L" + i) + "";
                var onclickAtt = string.Empty;
                var classAtt = string.Empty;
                var disabledAtt = string.Empty;

                var disabled = !(navigationItem.Enabled && this.Model.HistorySingleChoiceAction.Enabled);
                if (!disabled)
                {
                    if (!this.Model.IsItemSelected(navigationItem))
                    {
                        var xafActionItemExecuteScript = this.Model.HistorySingleChoiceAction.GetXafActionExecuteScript(this.ViewData.Window(), this.Model.HistorySingleChoiceAction.ConfirmationMessage, navigationItem.GetItemPathIndex(this.Model.HistorySingleChoiceAction));
                        onclickAtt = "onclick=" + xafActionItemExecuteScript;
                        hrefAtt = "href=javascript:{}";
                    }
                    else
                    {
                        classAtt = "class=Current";
                    }
                }
                else
                {
                    disabledAtt = "disabled=disabled";
                }
                <text><a @(hrefAtt) @(idAtt) @(onclickAtt) @(classAtt) @(disabledAtt) style="white-space: nowrap;">@(this.Model.GetLinkText(navigationItem))</a>@(i != visibleItemCount ? this.Model.Delimiter : string.Empty)</text>
            }
        }

        this.Model.SendStateToClient();

    }
</span>

@{
    this.Model.FrameTemplate.UnregisterActionContainers(new IActionContainer[] { this.Model });
}