mirror of
https://gitlab.com/buildfeed/BuildFeed.git
synced 2024-03-22 21:10:34 +08:00
e04ab6fdbd
Mostly some #5, some tweaks to #4
57 lines
2.1 KiB
Plaintext
57 lines
2.1 KiB
Plaintext
@using BuildFeed.Code
|
|
@using System.Web.Mvc
|
|
@using System.Web.Mvc.Html
|
|
@using System.Web.Routing
|
|
|
|
@helper PaginationBlock(int currentPage, int totalPages, string view, RouteValueDictionary rd)
|
|
{
|
|
string multiView = view + "Page";
|
|
if (totalPages > 1)
|
|
{
|
|
<div class="text-center">
|
|
<ul class="pagination">
|
|
@if (currentPage == 2)
|
|
{
|
|
RouteValueDictionary rvd = new RouteValueDictionary(rd);
|
|
rvd.Remove("page");
|
|
<li>@MvcIntrinsics.Html.ActionLink(HttpUtility.HtmlDecode("«"), view, rvd)</li>
|
|
}
|
|
else if (currentPage > 2)
|
|
{
|
|
RouteValueDictionary rvd = new RouteValueDictionary(rd);
|
|
rvd["page"] = currentPage - 1;
|
|
<li>@MvcIntrinsics.Html.ActionLink(HttpUtility.HtmlDecode("«"), multiView, rvd)</li>
|
|
}
|
|
else
|
|
{
|
|
<li class="disabled"><span>«</span></li>
|
|
}
|
|
|
|
|
|
@{
|
|
RouteValueDictionary rvdIndex = new RouteValueDictionary(rd);
|
|
rvdIndex.Remove("page");
|
|
}
|
|
<li @((1 == currentPage) ? "class=active" : "")>@MvcIntrinsics.Html.ActionLink("1", view)</li>
|
|
@for (int i = 2; i <= totalPages; i++)
|
|
{
|
|
RouteValueDictionary rvd = new RouteValueDictionary(rd);
|
|
rvd["page"] = i;
|
|
<li @((i == currentPage) ? "class=active" : "")>@MvcIntrinsics.Html.ActionLink(i.ToString(), multiView, rvd)</li>
|
|
}
|
|
|
|
|
|
@if (currentPage < totalPages)
|
|
{
|
|
RouteValueDictionary rvd = new RouteValueDictionary(rd);
|
|
rvd["page"] = currentPage + 1;
|
|
<li>@MvcIntrinsics.Html.ActionLink(HttpUtility.HtmlDecode("»"), multiView, rvd)</li>
|
|
}
|
|
else
|
|
{
|
|
<li class="disabled"><span>»</span></li>
|
|
}
|
|
</ul>
|
|
</div>
|
|
}
|
|
} |