mirror of
https://gitlab.com/buildfeed/BuildFeed.git
synced 2024-03-22 21:10:34 +08:00
104 lines
3.2 KiB
Plaintext
104 lines
3.2 KiB
Plaintext
@using System.Web.Mvc.Html
|
|
@using System.Web.Routing
|
|
@using BuildFeed.Code
|
|
@helper PaginationBlock(int currentPage, int totalPages, string view, RouteValueDictionary rd)
|
|
{
|
|
string multiView = view + "Page";
|
|
|
|
if (totalPages > 1)
|
|
{
|
|
<ul class="pagination">
|
|
@if (currentPage == 2)
|
|
{
|
|
RouteValueDictionary rvd = new RouteValueDictionary(rd);
|
|
rvd.Remove("page");
|
|
<li><a href="@MvcIntrinsics.Url.Action(view, rvd)"><i class="fa fa-angle-double-left"></i></a></li>
|
|
<li><a href="@MvcIntrinsics.Url.Action(view, rvd)"><i class="fa fa-angle-left"></i></a></li>
|
|
}
|
|
else if (currentPage > 2)
|
|
{
|
|
RouteValueDictionary firstRvd = new RouteValueDictionary(rd);
|
|
firstRvd.Remove("page");
|
|
<li><a href="@MvcIntrinsics.Url.Action(view, firstRvd)"><i class="fa fa-angle-double-left"></i></a></li>
|
|
|
|
RouteValueDictionary rvd = new RouteValueDictionary(rd)
|
|
{
|
|
["page"] = currentPage - 1
|
|
};
|
|
<li><a href="@MvcIntrinsics.Url.Action(multiView, rvd)"><i class="fa fa-angle-left"></i></a></li>
|
|
}
|
|
else
|
|
{
|
|
<li class="disabled">
|
|
<span><i class="fa fa-angle-double-left"></i></span>
|
|
</li>
|
|
<li class="disabled">
|
|
<span><i class="fa fa-angle-left"></i></span>
|
|
</li>
|
|
}
|
|
|
|
|
|
@{
|
|
RouteValueDictionary rvdIndex = new RouteValueDictionary(rd);
|
|
rvdIndex.Remove("page");
|
|
IEnumerable<int> pages;
|
|
}
|
|
|
|
@if (totalPages <= 7)
|
|
{
|
|
pages = Enumerable.Range(1, totalPages);
|
|
}
|
|
else if (currentPage <= 4)
|
|
{
|
|
pages = Enumerable.Range(1, 7);
|
|
}
|
|
else if (currentPage >= totalPages - 2)
|
|
{
|
|
pages = Enumerable.Range(totalPages - 6, 7);
|
|
}
|
|
else
|
|
{
|
|
pages = Enumerable.Range(currentPage - 3, 7);
|
|
}
|
|
|
|
@foreach (int i in pages)
|
|
{
|
|
RouteValueDictionary rvd = new RouteValueDictionary(rd)
|
|
{
|
|
["page"] = i
|
|
};
|
|
|
|
<li @( i == currentPage
|
|
? "class=active"
|
|
: "")>
|
|
@MvcIntrinsics.Html.ActionLink(i.ToString(), multiView, rvd)</li>
|
|
}
|
|
|
|
|
|
@if (currentPage < totalPages)
|
|
{
|
|
RouteValueDictionary rvd = new RouteValueDictionary(rd)
|
|
{
|
|
["page"] = currentPage + 1
|
|
};
|
|
|
|
<li><a href="@MvcIntrinsics.Url.Action(multiView, rvd)"><i class="fa fa-angle-right"></i></a></li>
|
|
|
|
RouteValueDictionary lastRvd = new RouteValueDictionary(rd)
|
|
{
|
|
["page"] = totalPages
|
|
};
|
|
<li><a href="@MvcIntrinsics.Url.Action(multiView, lastRvd)"><i class="fa fa-angle-double-right"></i></a></li>
|
|
}
|
|
else
|
|
{
|
|
<li class="disabled">
|
|
<span><i class="fa fa-angle-right"></i></span>
|
|
</li>
|
|
<li class="disabled">
|
|
<span><i class="fa fa-angle-double-right"></i></span>
|
|
</li>
|
|
}
|
|
</ul>
|
|
}
|
|
} |