Skip to content

Commit

Permalink
Add checkboxes to tables, with button to allow to delete many rows
Browse files Browse the repository at this point in the history
Closes #23
  • Loading branch information
keshikashviligio committed Feb 1, 2017
1 parent a335041 commit 5fc3962
Show file tree
Hide file tree
Showing 26 changed files with 615 additions and 43 deletions.
183 changes: 183 additions & 0 deletions assets/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,186 @@
.togglebutton label input[type=checkbox]:checked + .toggle:active:after {
box-shadow: 0 1px 3px 1px rgba(0, 0, 0, 0.4), 0 0 0 15px rgba(60, 141, 188, 0.1);
}
.checkbox label,
.radio label,
label {
font-size: 16px;
line-height: 1.42857143;
font-weight: 400;
}
.checkbox input[type=checkbox] {
opacity: 0;
position: absolute;
margin: 0;
z-index: -1;
width: 0;
height: 0;
overflow: hidden;
left: 0;
pointer-events: none;
}
.checkbox .checkbox-material {
vertical-align: middle;
position: relative;
top: 3px;
}
.checkbox .checkbox-material .check {
position: relative;
display: inline-block;
width: 20px;
height: 20px;
border: 2px solid rgba(0, 0, 0, 0.54);
border-radius: 2px;
overflow: hidden;
z-index: 1;
}
.checkbox .checkbox-material .check:before {
position: absolute;
content: "";
transform: rotate(45deg);
-webkit-transform: rotate(45deg);
display: block;
margin-top: -4px;
margin-left: 6px;
width: 0;
height: 0;
animation: checkbox-off;
-webkit-animation: checkbox-off;
}
.checkbox .checkbox-material:before {
display: block;
position: absolute;
left: 0;
content: "";
background-color: rgba(0, 0, 0, 0.84);
height: 20px;
width: 20px;
border-radius: 100%;
z-index: 1;
opacity: 0;
margin: 0;
transform: scale3d(2.3, 2.3, 1);
-webkit-transform: scale3d(2.3, 2.3, 1);
}
.checkbox input[type=checkbox]:checked + .checkbox-material .check:before {
color: #009688;
box-shadow: 0 0 0 10px, 10px -10px 0 10px, 32px 0 0 20px, 0px 32px 0 20px, -5px 5px 0 10px, 20px -12px 0 11px;
animation: checkbox-on 0.3s forwards;
-webkit-animation: checkbox-on 0.3s forwards;
}
@keyframes checkbox-on {
0% {
box-shadow: 0 0 0 10px, 10px -10px 0 10px, 32px 0 0 20px, 0px 32px 0 20px, -5px 5px 0 10px, 15px 2px 0 11px;
}
50% {
box-shadow: 0 0 0 10px, 10px -10px 0 10px, 32px 0 0 20px, 0px 32px 0 20px, -5px 5px 0 10px, 20px 2px 0 11px;
}
100% {
box-shadow: 0 0 0 10px, 10px -10px 0 10px, 32px 0 0 20px, 0px 32px 0 20px, -5px 5px 0 10px, 20px -12px 0 11px;
}
}
@-webkit-keyframes checkbox-on {
0% {
box-shadow: 0 0 0 10px, 10px -10px 0 10px, 32px 0 0 20px, 0px 32px 0 20px, -5px 5px 0 10px, 15px 2px 0 11px;
}
50% {
box-shadow: 0 0 0 10px, 10px -10px 0 10px, 32px 0 0 20px, 0px 32px 0 20px, -5px 5px 0 10px, 20px 2px 0 11px;
}
100% {
box-shadow: 0 0 0 10px, 10px -10px 0 10px, 32px 0 0 20px, 0px 32px 0 20px, -5px 5px 0 10px, 20px -12px 0 11px;
}
}
@keyframes checkbox-off {
0% {
box-shadow: 0 0 0 10px, 10px -10px 0 10px, 32px 0 0 20px, 0px 32px 0 20px, -5px 5px 0 10px, 20px -12px 0 11px, 0 0 0 0 inset;
}
25% {
box-shadow: 0 0 0 10px, 10px -10px 0 10px, 32px 0 0 20px, 0px 32px 0 20px, -5px 5px 0 10px, 20px -12px 0 11px, 0 0 0 0 inset;
}
50% {
transform: rotate(45deg);
-webkit-transform: rotate(45deg);
margin-top: -4px;
margin-left: 6px;
width: 0;
height: 0;
box-shadow: 0 0 0 10px, 10px -10px 0 10px, 32px 0 0 20px, 0px 32px 0 20px, -5px 5px 0 10px, 15px 2px 0 11px, 0 0 0 0 inset;
}
51% {
transform: rotate(0deg);
-webkit-transform: rotate(0deg);
margin-top: -2px;
margin-left: -2px;
width: 20px;
height: 20px;
box-shadow: 0 0 0 0,
0 0 0 0,
0 0 0 0,
0 0 0 0,
0 0 0 0,
0 0 0 0,
0px 0 0 10px inset;
}
100% {
transform: rotate(0deg);
-webkit-transform: rotate(0deg);
margin-top: -2px;
margin-left: -2px;
width: 20px;
height: 20px;
box-shadow: 0 0 0 0,
0 0 0 0,
0 0 0 0,
0 0 0 0,
0 0 0 0,
0 0 0 0,
0px 0 0 0 inset;
}
}
@-webkit-keyframes checkbox-off {
0% {
box-shadow: 0 0 0 10px, 10px -10px 0 10px, 32px 0 0 20px, 0px 32px 0 20px, -5px 5px 0 10px, 20px -12px 0 11px, 0 0 0 0 inset;
}
25% {
box-shadow: 0 0 0 10px, 10px -10px 0 10px, 32px 0 0 20px, 0px 32px 0 20px, -5px 5px 0 10px, 20px -12px 0 11px, 0 0 0 0 inset;
}
50% {
transform: rotate(45deg);
-webkit-transform: rotate(45deg);
margin-top: -4px;
margin-left: 6px;
width: 0;
height: 0;
box-shadow: 0 0 0 10px, 10px -10px 0 10px, 32px 0 0 20px, 0px 32px 0 20px, -5px 5px 0 10px, 15px 2px 0 11px, 0 0 0 0 inset;
}
51% {
transform: rotate(0deg);
-webkit-transform: rotate(0deg);
margin-top: -2px;
margin-left: -2px;
width: 20px;
height: 20px;
box-shadow: 0 0 0 0,
0 0 0 0,
0 0 0 0,
0 0 0 0,
0 0 0 0,
0 0 0 0,
0px 0 0 10px inset;
}
100% {
transform: rotate(0deg);
-webkit-transform: rotate(0deg);
margin-top: -2px;
margin-left: -2px;
width: 20px;
height: 20px;
box-shadow: 0 0 0 0,
0 0 0 0,
0 0 0 0,
0 0 0 0,
0 0 0 0,
0 0 0 0,
0px 0 0 0 inset;
}
}
28 changes: 27 additions & 1 deletion assets/js/i18nContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
(function ($) {
var I18nContent = function () {
this.$toggleBtn = $('.togglebutton > label > input');

this.$greedView = $('.grid-view');
this.$multipleDeleteButton = $('.delete-multiple');
this.init();
};

Expand All @@ -13,6 +14,7 @@

init: function () {
this.toggleStatus();
this.onDeleteCheckedItems();
},


Expand All @@ -33,6 +35,29 @@
},


onDeleteCheckedItems: function () {
var me = this;
me.$multipleDeleteButton.on('click', function (e) {
e.preventDefault();
var $itemIds, conf, deleteUrl;
$itemIds = me.$greedView.yiiGridView('getSelectedRows');
if($itemIds.length < 1){
return;
}
conf = confirm('Are you sure you want to delete this/these item(s)?');
if(conf !== true) return;

deleteUrl = $(this).data('url') || 'delete';
me._post(deleteUrl, {id: $itemIds}).done(function (res) {
if(res.errorMsg){
alert(res.errorMsg);
}
//console.log(res);
});
});
},


_get: function (url, data) {
return $.ajax({
url: url,
Expand All @@ -42,6 +67,7 @@
});
},


_post: function (url, data) {
return $.ajax({
url: url,
Expand Down
Loading

0 comments on commit 5fc3962

Please sign in to comment.