mirror of
https://github.com/DanielnetoDotCom/YouPHPTube
synced 2025-10-06 03:50:04 +02:00
Updates
This commit is contained in:
parent
2f2fdc4923
commit
cb718ebaee
4 changed files with 93 additions and 12 deletions
|
@ -10,6 +10,9 @@
|
||||||
<?php
|
<?php
|
||||||
echo AVideoPlugin::getUserNotificationButton();
|
echo AVideoPlugin::getUserNotificationButton();
|
||||||
?>
|
?>
|
||||||
|
</div>
|
||||||
|
<div id="userNotificationsFilterButtons">
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="list-group">
|
<div class="list-group">
|
||||||
<?php
|
<?php
|
||||||
|
|
|
@ -22,7 +22,7 @@ function getTemplateFromArray(itemsArray) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function addTemplateFromArray(itemsArray) {
|
function addTemplateFromArray(itemsArray) {
|
||||||
if(typeof itemsArray === 'function'){
|
if (typeof itemsArray === 'function') {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//console.log('addTemplateFromArray', itemsArray);
|
//console.log('addTemplateFromArray', itemsArray);
|
||||||
|
@ -32,13 +32,13 @@ function addTemplateFromArray(itemsArray) {
|
||||||
var template = getTemplateFromArray(itemsArray);
|
var template = getTemplateFromArray(itemsArray);
|
||||||
|
|
||||||
var priority = 6;
|
var priority = 6;
|
||||||
if(!isNaN(itemsArray.priority)){
|
if (!isNaN(itemsArray.priority)) {
|
||||||
priority = itemsArray.priority;
|
priority = itemsArray.priority;
|
||||||
}
|
}
|
||||||
if(empty(priority)){
|
if (empty(priority)) {
|
||||||
priority = 6;
|
priority = 6;
|
||||||
}
|
}
|
||||||
var selector = '#topMenuUserNotifications ul .list-group .priority'+priority;
|
var selector = '#topMenuUserNotifications ul .list-group .priority' + priority;
|
||||||
console.log('addTemplateFromArray prepend', selector);
|
console.log('addTemplateFromArray prepend', selector);
|
||||||
$(selector).prepend(template);
|
$(selector).prepend(template);
|
||||||
return true;
|
return true;
|
||||||
|
@ -123,6 +123,7 @@ function updateUserNotificationCount() {
|
||||||
countToOrRevesrse(selector, total);
|
countToOrRevesrse(selector, total);
|
||||||
$(selector).show();
|
$(selector).show();
|
||||||
}, 1);
|
}, 1);
|
||||||
|
createFilterButtons();
|
||||||
}
|
}
|
||||||
}, 500);
|
}, 500);
|
||||||
}
|
}
|
||||||
|
@ -138,7 +139,7 @@ async function getUserNotification() {
|
||||||
} else {
|
} else {
|
||||||
for (var item in response.notifications) {
|
for (var item in response.notifications) {
|
||||||
var itemsArray = response.notifications[item];
|
var itemsArray = response.notifications[item];
|
||||||
if(typeof itemsArray === 'function'){
|
if (typeof itemsArray === 'function') {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
addTemplateFromArray(itemsArray);
|
addTemplateFromArray(itemsArray);
|
||||||
|
@ -164,16 +165,86 @@ function deleteUserNotification(id, t) {
|
||||||
avideoAlertError(response.msg);
|
avideoAlertError(response.msg);
|
||||||
} else {
|
} else {
|
||||||
//avideoToastSuccess(response.msg);
|
//avideoToastSuccess(response.msg);
|
||||||
setTimeout(function(){
|
setTimeout(function () {
|
||||||
$(t).parent().remove();
|
$(t).parent().remove();
|
||||||
updateUserNotificationCount();
|
updateUserNotificationCount();
|
||||||
},500);
|
}, 500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteAllNotifications(){
|
function getCountNotificationIcons() {
|
||||||
|
var selector = '#topMenuUserNotifications > ul .list-group .icon i';
|
||||||
|
var iconsCountList = [];
|
||||||
|
$(selector).each(function (index) {
|
||||||
|
var className = $(this).attr('class');
|
||||||
|
var classNameType = $(this).parent().attr('class');
|
||||||
|
|
||||||
|
classNameType = classNameType.replace("icon bg-", "");
|
||||||
|
|
||||||
|
var id = $(this).closest('div.userNotifications').attr('id');
|
||||||
|
var listIndex = className + classNameType;
|
||||||
|
//console.log('getCountNotificationIcons class', listIndex);
|
||||||
|
if (empty(iconsCountList[listIndex])) {
|
||||||
|
iconsCountList[listIndex] = [];
|
||||||
|
}
|
||||||
|
iconsCountList[listIndex].push([id, classNameType, className]);
|
||||||
|
});
|
||||||
|
//console.log('getCountNotificationIcons finish', iconsCountList);
|
||||||
|
return iconsCountList;
|
||||||
|
}
|
||||||
|
|
||||||
|
function createFilterButtons() {
|
||||||
|
|
||||||
|
var icons = getCountNotificationIcons();
|
||||||
|
var buttons = '<div class="btn-group btn-group-justified">';
|
||||||
|
|
||||||
|
var count = 0;
|
||||||
|
for (var i in icons) {
|
||||||
|
var icon = icons[i];
|
||||||
|
if (typeof icon == 'function') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
count++;
|
||||||
|
var id = 'uNotfFilter_' + count;
|
||||||
|
//buttons += '<button class="btn btn-'+icon[0][1]+' btn-sm" onclick=""><i class="'+icon[0][2]+'"></i> <span class="badge">'+icon.length+'</span></button>';
|
||||||
|
buttons += '<input type="checkbox" value="' + icon[0][2] + '" id="' + id + '" class="hidden check-with-label" checked><label for="' + id + '" class="btn btn-' + icon[0][1] + ' label-for-check"><i class="' + icon[0][2] + '"></i> <span class="badge">' + icon.length + '</span></label>';
|
||||||
|
}
|
||||||
|
buttons += '</div>';
|
||||||
|
|
||||||
|
$('#userNotificationsFilterButtons').empty();
|
||||||
|
$('#userNotificationsFilterButtons').append(buttons);
|
||||||
|
setCheckboxOnChange();
|
||||||
|
}
|
||||||
|
|
||||||
|
function getCheckedFilterButtons() {
|
||||||
|
var iconsList = {};
|
||||||
|
var selector = '#userNotificationsFilterButtons .check-with-label:checked';
|
||||||
|
$(selector).each(function (index) {
|
||||||
|
var val = $(this).val();
|
||||||
|
iconsList[val] = val;
|
||||||
|
});
|
||||||
|
return iconsList;
|
||||||
|
}
|
||||||
|
|
||||||
|
function setCheckboxOnChange() {
|
||||||
|
$('.check-with-label').on('change', function () {
|
||||||
|
var iconsList = getCheckedFilterButtons();
|
||||||
|
var selector = '#topMenuUserNotifications > ul .list-group .icon i';
|
||||||
|
$(selector).each(function (index) {
|
||||||
|
var parent = $(this).closest('div.userNotifications');
|
||||||
|
var className = $(this).attr('class');
|
||||||
|
if(empty(iconsList[className])){
|
||||||
|
$(parent).slideUp();
|
||||||
|
}else{
|
||||||
|
$(parent).slideDown();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function deleteAllNotifications() {
|
||||||
animateChilds('#topMenuUserNotifications .dropdown-menu .list-group .canDelete', 'animate__flipOutX', 0.05);
|
animateChilds('#topMenuUserNotifications .dropdown-menu .list-group .canDelete', 'animate__flipOutX', 0.05);
|
||||||
var url = webSiteRootURL + 'plugin/UserNotifications/View/User_notifications/delete.json.php';
|
var url = webSiteRootURL + 'plugin/UserNotifications/View/User_notifications/delete.json.php';
|
||||||
$.ajax({
|
$.ajax({
|
||||||
|
@ -184,10 +255,10 @@ function deleteAllNotifications(){
|
||||||
avideoAlertError(response.msg);
|
avideoAlertError(response.msg);
|
||||||
} else {
|
} else {
|
||||||
//avideoToastSuccess(response.msg);
|
//avideoToastSuccess(response.msg);
|
||||||
setTimeout(function(){
|
setTimeout(function () {
|
||||||
$('#topMenuUserNotifications .dropdown-menu .list-group .canDelete').remove();
|
$('#topMenuUserNotifications .dropdown-menu .list-group .canDelete').remove();
|
||||||
updateUserNotificationCount();
|
updateUserNotificationCount();
|
||||||
},500);
|
}, 500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -48,6 +48,13 @@
|
||||||
#topMenuUserNotifications .dropdown-menu .list-group .priority > div{
|
#topMenuUserNotifications .dropdown-menu .list-group .priority > div{
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
.check-with-label + .label-for-check {
|
||||||
|
opacity: 0.5;
|
||||||
|
}
|
||||||
|
.check-with-label:checked + .label-for-check {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
|
||||||
@media (max-width: 767px) {
|
@media (max-width: 767px) {
|
||||||
#topMenuUserNotifications .dropdown-menu .list-group{
|
#topMenuUserNotifications .dropdown-menu .list-group{
|
||||||
max-height: calc(100vh - 300px);
|
max-height: calc(100vh - 300px);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<div class="{element_class} {type}" id="{element_id}">
|
<div class="userNotifications {element_class} {type}" id="{element_id}">
|
||||||
<a href="{href}" onclick="{onclick}" class="list-group-item {status}">
|
<a href="{href}" onclick="{onclick}" class="list-group-item {status}">
|
||||||
<div class="media">
|
<div class="media">
|
||||||
<div class="media-left">
|
<div class="media-left">
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue