Skip to content

Commit

Permalink
Fix an issue to support bootstrap 4.1+. Also create an example for Bo…
Browse files Browse the repository at this point in the history
…otstrap 4.1+
  • Loading branch information
MikeAlhayek committed Jan 10, 2019
1 parent 0c4863e commit 4a33367
Show file tree
Hide file tree
Showing 434 changed files with 81,512 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace X.PagedList.Mvc.Example.Core.Controllers
{
public class Bootstrap41Controller : HomeController
{

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public IActionResult Error()
return View();
}

private IPagedList<string> GetPagedNames(int? page)
protected IPagedList<string> GetPagedNames(int? page)
{
// return a 404 if user browses to before the first page
if (page.HasValue && page < 1)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@{
ViewBag.Title = "Product Listing";
}

@using X.PagedList; @*import this so we can cast our list to IPagedList (only necessary because ViewBag is dynamic)*@

<!-- loop through each of your products and display it however you want. we're just printing the name here -->
<h2>List of Products</h2>
<div id="nameListContainer">
@Html.Partial("_NameListPartial", (IPagedList<string>)ViewBag.Names)
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
@{
Layout = "~/Views/Shared/_Layout-41.cshtml";
ViewBag.Title = "Product Listing";
}

@using X.PagedList.Mvc.Core; @*import this so we get our HTML Helper*@
@using X.PagedList; @*import this so we can cast our list to IPagedList (only necessary because ViewBag is dynamic)*@

<!-- import the included stylesheet for some (very basic) default styling -->
<link href="/Content/PagedList.css" rel="stylesheet" type="text/css" />

<!-- loop through each of your products and display it however you want. we're just printing the name here -->
<section class="mt-4">
<h2>List of Products</h2>
<ul>
@foreach (var name in ViewBag.Names)
{
<li>@name</li>
}
</ul>
</section>

<!-- output a paging control that lets the user navigation to the previous page, next page, etc -->
@Html.PagedListPager((IPagedList)ViewBag.Names, page => Url.Action("Index", new { page }), new X.PagedList.Mvc.Common.PagedListRenderOptionsBase
{
DisplayItemSliceAndTotal = true,
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
@*use this for the fake AjaxOptions since ajax helpers were dropped in .net core*@
@model IPagedList<string>

@*import this so we get our HTML Helper*@
@using X.PagedList.Mvc.Core;

@*import this so we can cast our list to IPagedList (only necessary because ViewBag is dynamic)*@
@using X.PagedList;
@using X.PagedList.Mvc.Common

<ul>
@foreach (var name in Model)
{
<li>@name</li>
}
</ul>

@Html.PagedListPager((IPagedList<string>)ViewBag.Names, page => Url.Action("GetOnePageOfNames", new { page }), PagedListRenderOptions.EnableUnobtrusiveAjaxReplacing(new PagedListRenderOptions { MaximumPageNumbersToDisplay = 5, DisplayPageCountAndCurrentLocation = true, UlElementClasses = new[] { "pagination" }, ContainerDivClasses = new[] { "pagination-container" } }, new AjaxOptions() { HttpMethod = "GET", UpdateTargetId = "nameListContainer" }))
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>@ViewData["Title"] - X.PagedList.Mvc.Example.Core</title>

<environment names="Development">
<link rel="stylesheet" href="~/lib/bootstrap-modern/dist/css/bootstrap.css" />
<link rel="stylesheet" href="~/css/site.css" />
<link rel="stylesheet" href="~/css/PagedList.css" />
</environment>
<environment names="Staging,Production">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"
asp-fallback-href="~/lib/bootstrap-modern/dist/css/bootstrap.css"
asp-fallback-test-class="sr-only" asp-fallback-test-property="position" asp-fallback-test-value="absolute" />
<link rel="stylesheet" href="~/css/site.min.css" asp-append-version="true" />
</environment>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark fixed-top">
<div class="container">
<a asp-area="" asp-controller="Home" asp-action="Index" class="navbar-brand">X.PagedList.Mvc.Example.Core</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarHeader" aria-controls="navbarHeader" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>

<div class="collapse navbar-collapse" id="navbarHeader">
<ul class="navbar-nav mr-auto">
<li class="nav-item"><a class="nav-link" asp-area="" asp-controller="Home" asp-action="Index">Traditional Paging</a></li>
<li class="nav-item"><a class="nav-link" asp-area="" asp-controller="Home" asp-action="AjaxIndex">AJAX Paging</a></li>
<li class="nav-item"><a class="nav-link" asp-area="" asp-controller="Bootstrap41" asp-action="Index">Traditional Paging (Bootstrap 4.1+)</a></li>
<li class="nav-item"><a class="nav-link" asp-area="" asp-controller="Bootstrap41" asp-action="AjaxIndex">AJAX Paging (Bootstrap 4.1+)</a></li>
</ul>

</div>
</div>
</nav>

<div class="container body-content">
@RenderBody()
<hr />
<footer>
<p>&copy; 2017 - X.PagedList.Mvc.Example.Core</p>
</footer>
</div>

<environment names="Development">
<script src="~/lib/jquery/dist/jquery.js"></script>
<script src="~/lib/bootstrap-modern/dist/js/bootstrap.js"></script>
<script src="~/lib/jquery-ajax-unobtrusive/jquery.unobtrusive-ajax.js"></script>
<script src="~/js/site.js" asp-append-version="true"></script>
</environment>
<environment names="Staging,Production">
<script src="https://ajax.aspnetcdn.com/ajax/jquery/jquery-2.2.0.min.js"
asp-fallback-src="~/lib/jquery/dist/jquery.min.js"
asp-fallback-test="window.jQuery"
crossorigin="anonymous"
integrity="sha384-K+ctZQ+LL8q6tP7I94W+qzQsfRV2a+AfHIi9k8z8l9ggpc8X+Ytst4yBo/hH+8Fk">
</script>
<script src="~/lib/jquery-ajax-unobtrusive/jquery.unobtrusive-ajax.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"
asp-fallback-src="~/lib/bootstrap-modern/dist/js/bootstrap.js"
asp-fallback-test="window.jQuery && window.jQuery.fn && window.jQuery.fn.modal"
crossorigin="anonymous"
integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy">
</script>
<script src="~/js/site.min.js" asp-append-version="true"></script>
</environment>

@RenderSection("Scripts", required: false)
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li><a asp-area="" asp-controller="Home" asp-action="Index">Traditional Paging</a></li>
<li><a asp-area="" asp-controller="Home" asp-action="AjaxIndex">AJAX Paging</a></li>
<li><a asp-area="" asp-controller="Home" asp-action="Index">Traditional Paging</a></li>
<li><a asp-area="" asp-controller="Home" asp-action="AjaxIndex">AJAX Paging</a></li>
<li><a asp-area="" asp-controller="Bootstrap41" asp-action="Index">Traditional Paging (Bootstrap 4.1+)</a></li>
<li><a asp-area="" asp-controller="Bootstrap41" asp-action="AjaxIndex">AJAX Paging (Bootstrap 4.1+)</a></li>
</ul>
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions examples/X.PagedList.Mvc.Example.Core/bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"private": true,
"dependencies": {
"bootstrap": "3.3.7",
"bootstrap-modern": "bootstrap#4.1.3",
"jquery": "2.2.0",
"jquery-validation": "1.14.0",
"jquery-validation-unobtrusive": "3.2.6",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module.exports = {
presets: [
[
'@babel/env',
{
loose: true,
modules: false,
exclude: ['transform-typeof-symbol']
}
]
],
plugins: [
'@babel/proposal-object-rest-spread'
],
env: {
test: {
plugins: [ 'istanbul' ]
}
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "bootstrap",
"homepage": "https://github.com/twbs/bootstrap",
"version": "4.1.3",
"_release": "4.1.3",
"_resolution": {
"type": "version",
"tag": "v4.1.3",
"commit": "3b558734382ce58b51e5fc676453bfd53bba9201"
},
"_source": "https://github.com/twbs/bootstrap.git",
"_target": "4.1.3",
"_originalSource": "bootstrap"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# https://github.com/browserslist/browserslist#readme

>= 1%
last 1 major version
not dead
Chrome >= 45
Firefox >= 38
Edge >= 12
Explorer >= 10
iOS >= 9
Safari >= 9
Android >= 4.4
Opera >= 30
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# editorconfig.org

root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
**/*.min.js
**/dist/
**/vendor/
/_gh_pages/
/package.js
Loading

0 comments on commit 4a33367

Please sign in to comment.