11< div class ="drawer-pf hide drawer-pf-notifications-non-clickable ">
22 < div class ="drawer-pf-title ">
33 < a class ="drawer-pf-toggle-expand "> </ a >
4+ < a class ="drawer-pf-close "> </ a >
45 < h3 class ="text-center "> Notifications Drawer</ h3 >
56 </ div >
67 < div class ="panel-group " id ="notification-drawer-accordion ">
@@ -17,8 +18,22 @@ <h4 class="panel-title">
1718 < div class ="panel-body ">
1819 {% include widgets/notification-drawer-notifications.html id="1" %}
1920 </ div >
21+ < div class ="blank-slate-pf hidden ">
22+ < div class ="blank-slate-pf-icon ">
23+ < span class ="pficon-info "> </ span >
24+ </ div >
25+ < h1 > There are no notifications to display.</ h1 >
26+ </ div >
2027 < div class ="drawer-pf-action ">
21- < button class ="btn btn-link btn-block "> Mark All Read</ button >
28+ < div class ="drawer-pf-action-link " data-toggle ="mark-all-read ">
29+ < button class ="btn btn-link "> Mark All Read</ button >
30+ </ div >
31+ < div class ="drawer-pf-action-link " data-toggle ="clear-all ">
32+ < button class ="btn btn-link ">
33+ < span class ="pficon pficon-close "> </ span >
34+ Clear All
35+ </ button >
36+ </ div >
2237 </ div >
2338 </ div >
2439 </ div >
@@ -40,8 +55,22 @@ <h4 class="panel-title">
4055 < span class ="spinner spinner-xs spinner-inline "> </ span > Loading More
4156 </ div >
4257 </ div >
58+ < div class ="blank-slate-pf hidden ">
59+ < div class ="blank-slate-pf-icon ">
60+ < span class ="pficon-info "> </ span >
61+ </ div >
62+ < h1 > There are no notifications to display.</ h1 >
63+ </ div >
4364 < div class ="drawer-pf-action ">
44- < button class ="btn btn-link btn-block "> Mark All Read</ button >
65+ < div class ="drawer-pf-action-link " data-toggle ="mark-all-read ">
66+ < button class ="btn btn-link "> Mark All Read</ button >
67+ </ div >
68+ < div class ="drawer-pf-action-link " data-toggle ="clear-all ">
69+ < button class ="btn btn-link ">
70+ < span class ="pficon pficon-close "> </ span >
71+ Clear All
72+ </ button >
73+ </ div >
4574 </ div >
4675 </ div >
4776 </ div >
@@ -60,15 +89,31 @@ <h4 class="panel-title">
6089 {% include widgets/notification-drawer-notifications.html id="6" %}
6190 {% include widgets/notification-drawer-notifications.html id="7" %}
6291 </ div >
92+ < div class ="blank-slate-pf hidden ">
93+ < div class ="blank-slate-pf-icon ">
94+ < span class ="pficon-info "> </ span >
95+ </ div >
96+ < h1 > There are no notifications to display.</ h1 >
97+ </ div >
6398 < div class ="drawer-pf-action ">
64- < button class ="btn btn-link btn-block "> Mark All Read</ button >
99+ < div class ="drawer-pf-action-link " data-toggle ="mark-all-read ">
100+ < button class ="btn btn-link "> Mark All Read</ button >
101+ </ div >
102+ < div class ="drawer-pf-action-link " data-toggle ="clear-all ">
103+ < button class ="btn btn-link ">
104+ < span class ="pficon pficon-close "> </ span >
105+ Clear All
106+ </ button >
107+ </ div >
65108 </ div >
66109 </ div >
67110 </ div >
68111 </ div >
69112</ div >
70113< script >
71114 $ ( document ) . ready ( function ( ) {
115+ // Initialize to unread notifications
116+ $ ( '.drawer-pf-trigger' ) . addClass ( 'unread' ) ;
72117 // Show/Hide Notifications Drawer
73118 $ ( '.drawer-pf-trigger' ) . click ( function ( ) {
74119 var $drawer = $ ( '.drawer-pf' ) ;
@@ -89,6 +134,12 @@ <h4 class="panel-title">
89134 $drawer . addClass ( 'hide' ) ;
90135 }
91136 } ) ;
137+ $ ( '.drawer-pf-close' ) . click ( function ( ) {
138+ var $drawer = $ ( '.drawer-pf' ) ;
139+
140+ $ ( '.drawer-pf-trigger' ) . removeClass ( 'open' ) ;
141+ $drawer . addClass ( 'hide' ) ;
142+ } ) ;
92143 $ ( '.drawer-pf-toggle-expand' ) . click ( function ( ) {
93144 var $drawer = $ ( '.drawer-pf' ) ;
94145 var $drawerNotifications = $drawer . find ( '.drawer-pf-notification' ) ;
@@ -102,12 +153,47 @@ <h4 class="panel-title">
102153 }
103154 } ) ;
104155
105- // Mark All Read
156+ // Mark All Read / Clear All
106157 $ ( '.panel-collapse' ) . each ( function ( index , panel ) {
107158 var $panel = $ ( panel ) ;
108- $panel . on ( 'click' , '.drawer-pf-action .btn' , function ( ) {
159+ var unreadCount = $panel . find ( '.drawer-pf-notification.unread' ) . length ;
160+ $ ( panel . parentElement ) . find ( '.panel-counter' ) . text ( unreadCount + ' New Event' + ( unreadCount !== 1 ? 's' : '' ) ) ;
161+ if ( $ ( '.drawer-pf .panel-collapse .unread' ) . length === 0 ) {
162+ $ ( '.drawer-pf-trigger' ) . removeClass ( 'unread' ) ;
163+ }
164+
165+ $panel . on ( 'click' , '.drawer-pf-action [data-toggle="mark-all-read"] .btn' , function ( ) {
109166 $panel . find ( '.unread' ) . removeClass ( 'unread' ) ;
167+ $panel . find ( '.drawer-pf-action [data-toggle="mark-all-read"]' ) . remove ( ) ;
110168 $ ( panel . parentElement ) . find ( '.panel-counter' ) . text ( '0 New Events' ) ;
169+ if ( $ ( '.drawer-pf .panel-collapse .unread' ) . length === 0 ) {
170+ $ ( '.drawer-pf-trigger' ) . removeClass ( 'unread' ) ;
171+ }
172+ } ) ;
173+ $panel . on ( 'click' , '.drawer-pf-action [data-toggle="clear-all"] .btn' , function ( ) {
174+ $panel . find ( '.panel-body .drawer-pf-notification' ) . remove ( ) ;
175+ $panel . find ( '.drawer-pf-action' ) . remove ( ) ;
176+ $panel . find ( '.blank-slate-pf' ) . removeClass ( 'hidden' ) ;
177+ $panel . find ( '.drawer-pf-loading' ) . addClass ( 'hidden' ) ;
178+ $ ( panel . parentElement ) . find ( '.panel-counter' ) . text ( '0 New Events' ) ;
179+ if ( $ ( '.drawer-pf .panel-collapse .unread' ) . length === 0 ) {
180+ $ ( '.drawer-pf-trigger' ) . removeClass ( 'unread' ) ;
181+ }
182+ } ) ;
183+
184+ $panel . find ( '.drawer-pf-notification' ) . each ( function ( index , notification ) {
185+ var $notification = $ ( notification ) ;
186+ $notification . on ( 'click' , '.drawer-pf-notification-content' , function ( ) {
187+ $notification . removeClass ( 'unread' ) ;
188+ var unreadCount = $panel . find ( '.drawer-pf-notification.unread' ) . length ;
189+ $ ( panel . parentElement ) . find ( '.panel-counter' ) . text ( unreadCount + ' New Event' + ( unreadCount !== 1 ? 's' : '' ) ) ;
190+ if ( unreadCount === 0 ) {
191+ $panel . find ( '.drawer-pf-action [data-toggle="mark-all-read"]' ) . remove ( ) ;
192+ if ( $ ( '.drawer-pf .panel-collapse .unread' ) . length === 0 ) {
193+ $ ( '.drawer-pf-trigger' ) . removeClass ( 'unread' ) ;
194+ }
195+ }
196+ } ) ;
111197 } ) ;
112198 } ) ;
113199
0 commit comments