浏览代码

show the "Close All" button on multiple notifications

Nariman Jelveh 11 月之前
父节点
当前提交
7b724ff1eb
共有 3 个文件被更改,包括 65 次插入17 次删除
  1. 1 1
      src/UI/UIDesktop.js
  2. 30 7
      src/UI/UINotification.js
  3. 34 9
      src/css/style.css

+ 1 - 1
src/UI/UIDesktop.js

@@ -930,7 +930,7 @@ async function UIDesktop(options){
     $(ht).insertBefore(el_desktop);
     $(ht).insertBefore(el_desktop);
 
 
     // notification container
     // notification container
-    $('body').append(`<div class="notification-container"></div>`);
+    $('body').append(`<div class="notification-container"><div class="notifications-close-all">Close all</div></div>`);
 
 
     // adjust window container to take into account the toolbar height
     // adjust window container to take into account the toolbar height
     $('.window-container').css('top', window.toolbar_height);
     $('.window-container').css('top', window.toolbar_height);

+ 30 - 7
src/UI/UINotification.js

@@ -17,13 +17,9 @@
  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
  */
 
 
-window.active_notifs = []
-
 function UINotification(options){
 function UINotification(options){
     window.global_element_id++;
     window.global_element_id++;
-
     options.text = options.text ?? '';
     options.text = options.text ?? '';
-    window.active_notifs.push(window.global_element_id);
 
 
     let h = '';
     let h = '';
     h += `<div id="ui-notification__${window.global_element_id}" data-el-id="${window.global_element_id}" class="notification antialiased animate__animated animate__fadeInRight animate__slow">`;
     h += `<div id="ui-notification__${window.global_element_id}" data-el-id="${window.global_element_id}" class="notification antialiased animate__animated animate__fadeInRight animate__slow">`;
@@ -66,6 +62,15 @@ function UINotification(options){
 
 
     // Show Notification
     // Show Notification
     $(el_notification).delay(100).show(0);
     $(el_notification).delay(100).show(0);
+
+    // count notifications
+    let count = $('.notification-container').find('.notification-wrapper').length;
+    if(count <= 1){
+        $('.notification-container').removeClass('has-multiple');
+    }else{
+        $('.notification-container').addClass('has-multiple');
+    }
+
     return el_notification;
     return el_notification;
 }
 }
 
 
@@ -84,19 +89,37 @@ $(document).on('click', '.notification-close', function(e){
     return false;
     return false;
 });
 });
 
 
-
+$(document).on('click', '.notifications-close-all', function(e){
+    $('.notification-container').find('.notification-wrapper').each(function(){
+        window.close_notification(this);
+    });
+    $('.notifications-close-all').animate({
+        opacity: 0
+    }, 300);
+    $('.notification-container').removeClass('has-multiple');
+    e.stopPropagation();
+    e.preventDefault();
+    return false;
+})
 window.close_notification = function(el_notification){
 window.close_notification = function(el_notification){
     $(el_notification).closest('.notification-wrapper').animate({
     $(el_notification).closest('.notification-wrapper').animate({
         height: 0,
         height: 0,
         opacity: 0
         opacity: 0
-    }, 200);
+    }, 300);
     $(el_notification).addClass('animate__fadeOutRight');
     $(el_notification).addClass('animate__fadeOutRight');
 
 
     // remove notification
     // remove notification
     setTimeout(function(){
     setTimeout(function(){
         $(el_notification).closest('.notification-wrapper').remove();
         $(el_notification).closest('.notification-wrapper').remove();
         $(el_notification).remove();
         $(el_notification).remove();
-    }, 300);
+        // count notifications
+        let count = $('.notification-container').find('.notification-wrapper').length;
+        if(count <= 1){
+            $('.notification-container').removeClass('has-multiple');
+        }else{
+            $('.notification-container').addClass('has-multiple');
+        }
+    }, 500);
 }
 }
 
 
 export default UINotification;
 export default UINotification;

+ 34 - 9
src/css/style.css

@@ -2434,12 +2434,12 @@ label {
  *****************************************************/
  *****************************************************/
 .notification, .notification-wrapper{
 .notification, .notification-wrapper{
     width: 320px;
     width: 320px;
+    border-radius: 11px;
 }
 }
 .notification {
 .notification {
     min-height: 54px;
     min-height: 54px;
     background: #ffffffcd;
     background: #ffffffcd;
     backdrop-filter: blur(5px);
     backdrop-filter: blur(5px);
-    border-radius: 11px;
     z-index: 99999999;
     z-index: 99999999;
     box-shadow: 0px 0px 17px -9px #000;
     box-shadow: 0px 0px 17px -9px #000;
     border: 1px solid #d5d5d5;
     border: 1px solid #d5d5d5;
@@ -2447,7 +2447,9 @@ label {
     display: flex;
     display: flex;
     flex-direction: row;
     flex-direction: row;
 }
 }
-
+.notification-wrapper{
+    overflow: visible;
+}
 .notification-close {
 .notification-close {
     position: absolute;
     position: absolute;
     background: white;
     background: white;
@@ -2491,6 +2493,36 @@ label {
     flex-direction: column;
     flex-direction: column;
     padding: 10px;
     padding: 10px;
 }
 }
+.notification-container{
+    position: absolute;
+    top: 40px;
+    right: 10px;
+    z-index: 1000;
+    padding-top: 30px;
+}
+
+.notifications-close-all{
+    opacity: 0;
+    position: absolute;
+    top: 0px;
+    right: 0px;
+    background-color: #d5d9dc;
+    padding: 3px 7px;
+    border-radius: 3px;
+    border: 1px solid #d5d5d5;
+    font-size: 12px;
+    transition: 0.15s;
+    pointer-events: none;
+    cursor: pointer;
+    filter: drop-shadow(0px 0px 0.5px rgb(51, 51, 51));
+}
+.notifications-close-all:hover{
+    background-color: #dee1e3;
+}
+.notification-container.has-multiple:hover .notifications-close-all{
+    pointer-events: all;
+    opacity: 1 !important;
+}
 /*****************************************************
 /*****************************************************
  * Start
  * Start
  *****************************************************/
  *****************************************************/
@@ -3926,11 +3958,4 @@ fieldset[name=number-code] {
     flex-direction: row;
     flex-direction: row;
     gap: 10px;
     gap: 10px;
     justify-content: flex-end;
     justify-content: flex-end;
-}
-
-.notification-container{
-    position: absolute;
-    top: 70px;
-    right: 10px;
-    z-index: 1000;
 }
 }