Skip to content

Commit 4e31438

Browse files
committed
Select All improved
1 parent 2c4c5e0 commit 4e31438

File tree

8 files changed

+188
-218
lines changed

8 files changed

+188
-218
lines changed

Blogifier.Web/Views/Blogifier/Admin/Packages/Themes.cshtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
<!-- Toolbar -->
99
<div class="bf-toolbar d-flex">
1010
<label class="custom-control custom-checkbox my-auto mr-3">
11-
<input class="custom-control-input item-checkbox" type="checkbox" id="selectAll" name="selectAll">
11+
<input class="custom-control-input" type="checkbox" id="selectAll" name="selectAll">
1212
<span class="item-control custom-control-indicator"></span>
1313
</label>
14-
<div id="postActionButtons" class="btn-group mr-3">
14+
<div id="multiActionBtns" class="btn-group mr-3">
1515
<a asp-controller="Packages" asp-action="Widgets" class="btn btn-outline-secondary btn-sm btn-rounded" style="padding: 0 20px">
1616
<i class="fa fa-arrow-left"></i> &nbsp; Back
1717
</a>

Blogifier.Web/Views/Blogifier/Admin/Packages/Widgets.cshtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
<!-- Toolbar -->
99
<div class="bf-toolbar d-flex">
1010
<label class="custom-control custom-checkbox my-auto mr-3" data-tooltip title="Select All">
11-
<input class="custom-control-input item-checkbox" type="checkbox" id="selectAll" name="selectAll">
11+
<input class="custom-control-input" type="checkbox" id="selectAll" name="selectAll">
1212
<span class="item-control custom-control-indicator"></span>
1313
</label>
1414
<a asp-controller="Packages" asp-action="Widgets" class="btn btn-outline-secondary btn-sm btn-rounded" style="padding: 0 20px; margin-right: 20px">
1515
<i class="fa fa-arrow-left mr-2"></i> Back
1616
</a>
17-
<div id="postActionButtons" class="btn-group mr-3">
17+
<div id="multiActionBtns" class="btn-group mr-3">
1818
<button type="button" class="btn btn-outline-secondary btn-icon btn-sm btn-rounded" disabled="disabled" data-tooltip onclick="return packagesController.enable()" title="Enable"><i class="fa fa-check"></i></button>
1919
<button type="button" class="btn btn-outline-secondary btn-icon btn-sm btn-rounded" disabled="disabled" data-tooltip onclick="return packagesController.disable()" title="Disable"><i class="fa fa-minus"></i></button>
2020
</div>

Blogifier.Web/Views/Blogifier/Admin/Posts/Index.cshtml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@
5353

5454
<!-- Toolbar -->
5555
<div class="bf-toolbar d-flex">
56-
<label class="custom-control custom-checkbox my-auto mr-3" data-tooltip title="Select All"><input class="custom-control-input item-checkbox" type="checkbox" name="selectAll"><span class="item-control custom-control-indicator"></span></label>
57-
<div id="postActionButtons" class="btn-group mr-3">
56+
<label class="custom-control custom-checkbox my-auto mr-3" data-tooltip title="Select All"><input id="selectAll" class="custom-control-input" type="checkbox" name="selectAll"><span class="item-control custom-control-indicator"></span></label>
57+
<div id="multiActionBtns" class="btn-group mr-3">
5858
<button type="button" class="btn btn-outline-secondary btn-icon btn-sm btn-rounded" disabled="disabled" data-tooltip onclick="return postsController.removePost()" title="Delete"><i class="fa fa-trash"></i></button>
5959
<button type="button" class="btn btn-outline-secondary btn-icon btn-sm btn-rounded" disabled="disabled" data-tooltip onclick="return postsController.unpublish()" title="Unpublish"><i class="fa fa-archive"></i></button>
6060
<button type="button" class="btn btn-outline-secondary btn-icon btn-sm btn-rounded" disabled="disabled" data-tooltip onclick="return postsController.publish()" title="Publish"><i class="fa fa-check"></i></button>
@@ -94,7 +94,7 @@
9494
var postStatus = item.Published == DateTime.MinValue ? "draft" : "published";
9595
if (curPost == 0) { curPost = item.BlogPostId; }
9696
<li class="bf-list-item d-flex align-items-center">
97-
<label class="bf-list-item-select custom-control custom-checkbox mr-3" data-tooltip title="Select"><input type="checkbox" id="@item.BlogPostId" class="item-checkbox custom-control-input"><span class="item-control custom-control-indicator"></span></label>
97+
<label class="bf-list-item-select custom-control custom-checkbox mr-3"><input type="checkbox" id="@item.BlogPostId" class="item-checkbox custom-control-input"><span class="item-control custom-control-indicator"></span></label>
9898
<a class="bf-list-item-link" href="~/admin/posts/editor/@item.BlogPostId?user=@user">@item.Title</a>
9999
<span class="bf-list-item-status bf-list-item-status-@postStatus ml-auto" data-tooltip title="@postStatus"><i class="fa fa-circle"></i></span>
100100
<span class="bf-list-item-date ml-3 d-none d-lg-block">@publishedLbl</span>
@@ -123,7 +123,7 @@
123123
<div class="post-grid-item">
124124
<a class="item-link" href="~/admin/posts/editor/@item.BlogPostId?user=@user" style="background-image:url(@item.Image);"><div class="item-title mt-auto">@item.Title</div></a>
125125
<div class="item-info d-flex">
126-
<label class="item-select custom-control custom-checkbox mr-3 my-auto" data-tooltip title="Select"><input type="checkbox" id="@item.BlogPostId" class="item-checkbox custom-control-input"><span class="item-control custom-control-indicator"></span></label>
126+
<label class="item-select custom-control custom-checkbox mr-3 my-auto"><input type="checkbox" id="@item.BlogPostId" class="item-checkbox custom-control-input"><span class="item-control custom-control-indicator"></span></label>
127127
<span class="item-date my-auto">@publishedLbl</span>
128128
<span class="item-status item-status-@postStatus my-auto ml-auto" data-tooltip title="@postStatus"><i class="fa fa-circle"></i></span>
129129
@if (Model.Profile.IsAdmin)

Blogifier.Web/Views/Blogifier/Admin/Settings/Users.cshtml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@
1212
}
1313
<div class="bf-settings">
1414
<div class="bf-toolbar d-flex">
15-
<label class="custom-control custom-checkbox my-auto mr-3"><input class="custom-control-input item-checkbox" type="checkbox" name="selectAll"><span class="item-control custom-control-indicator"></span></label>
15+
<label class="custom-control custom-checkbox my-auto mr-3"><input class="custom-control-input" id="selectAll" type="checkbox" name="selectAll"><span class="item-control custom-control-indicator"></span></label>
1616
<button type="button" class="btn btn-primary btn-rounded btn-sm mr-3" data-toggle="modal" data-target="#createUserModal">Create User</button>
17-
<button type="button" id="userActionButtons" class="btn btn-outline-secondary btn-rounded btn-sm btn-icon mr-3" disabled="disabled" data-tooltip onclick="return usersController.removeUser()" title="Delete"><i class="fa fa-trash"></i></button>
17+
<div id="multiActionBtns" class="mr-3">
18+
<button type="button" class="btn btn-outline-secondary btn-rounded btn-sm btn-icon" disabled="disabled" data-tooltip onclick="return usersController.removeUser()" title="Delete"><i class="fa fa-trash"></i></button>
19+
</div>
1820
<div class="loading loading-sm"><div class="loading-dot-1"></div><div class="loading-dot-2"></div><div class="loading-dot-3"></div></div>
1921
</div>
2022
<ul class="bf-list bf-users d-block" aria-label="posts">

Blogifier.Web/wwwroot/admin/js/app/app.js

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,36 @@
1-
// Toastr Options
1+
// Select All --------
2+
var selectAllCheckbox = $('#selectAll');
3+
var actionBtns = $('#multiActionBtns .btn');
4+
var itemCheckbox = '.item-checkbox';
5+
6+
$(selectAllCheckbox).change(function() { //"select all" change
7+
$(".item-checkbox").not(":hidden").prop('checked', $(this).prop("checked")); //change all ".item-checkbox" checked status
8+
toggleActionBtns();
9+
10+
});
11+
12+
$(itemCheckbox).on('change', function() { //".item-checkbox" change
13+
//uncheck "select all", if one of the listed checkbox item is unchecked
14+
if (false == $(this).prop("checked")) { //if this item is unchecked
15+
$(selectAllCheckbox).prop('checked', false); //change "select all" checked status to false
16+
}
17+
18+
if ($(itemCheckbox + ':checked').not(":hidden").length == $(itemCheckbox).not(":hidden").length) { //check "select all" if all checkbox items are checked
19+
$(selectAllCheckbox).prop('checked', true);
20+
}
21+
toggleActionBtns();
22+
});
23+
24+
function toggleActionBtns() {
25+
var bxs = $(itemCheckbox + ':checked').length;
26+
if (bxs && bxs > 0) {
27+
$(actionBtns).removeAttr('disabled');
28+
} else {
29+
$(actionBtns).attr('disabled', 'disabled');
30+
}
31+
}
32+
33+
 // Toastr Options --------
234
toastr.options.positionClass = 'toast-bottom-right';
335
toastr.options.backgroundpositionClass = 'toast-bottom-right';
436

Blogifier.Web/wwwroot/admin/js/app/packagesController.js

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -33,22 +33,3 @@ var packagesController = function (dataService) {
3333
disable: disable
3434
}
3535
}(DataService);
36-
37-
$(":checkbox").on("click", function () {
38-
if (this.id == "selectAll") {
39-
var selected = this.checked;
40-
$("input:checkbox.item-checkbox").each(function () {
41-
$(this).prop('checked', selected);
42-
});
43-
}
44-
toggleActionBtns();
45-
});
46-
47-
function toggleActionBtns() {
48-
if ($("input:checkbox.item-checkbox:checked").length > 0) {
49-
$('#postActionButtons > button').prop('disabled', false);
50-
}
51-
else {
52-
$('#postActionButtons > button').prop('disabled', true);
53-
}
54-
}

0 commit comments

Comments
 (0)