1/*-----------------------------------------------------------*/ 2// Scripts for Fusion Notifications Components 3/*-----------------------------------------------------------*/ 4 5/** 6 * Bar Layout 7 */ 8 9jQuery(document).ready(function() { 10 var notificationBars = jQuery('.fsn-notifications.bar'); 11 notificationBars.each(function() { 12 var notification = jQuery(this); 13 notification.closest('.col-sm-12').css('min-height','0px'); 14 var notificationsClose = notification.find('.notifications-bar-close'); 15 notificationsClose.on('click', function(event) { 16 event.preventDefault(); 17 if (notification.hasClass('putaway')) { 18 notification.removeClass('putaway'); 19 fsnNotificationReinitSliderAccessibility(notification); 20 } else { 21 notification.addClass('putaway').trigger('fsnNotificationDismissed'); 22 fsnNotificationDeinitSliderAccessibility(notification); 23 } 24 var dismissID = jQuery(this).parent().attr('data-notification-id'); 25 var cookieNotice = setCookiePolicyAccept(notification); 26 if (dismissID && !cookieNotice) { 27 var expires = new Date(); 28 expires.setTime(expires.getTime()+(30*24*60*60*1000)); 29 document.cookie = 'notification'+dismissID+'=closed; path=/; expires='+ expires.toUTCString(); 30 } 31 }); 32 33 var notificationsSliders = jQuery(notification).find('.flexslider'); 34 notificationsSliders.each(function() { 35 var notificationsSlider = jQuery(this); 36 var notificationsSliderID = jQuery(this).attr('data-slider-id'); 37 var dismissID = jQuery(this).parent().attr('data-notification-id'); 38 notificationsSlider.flexslider({ 39 animation: 'fade', 40 slideshow: false, 41 multipleKeyboard: true, 42 pauseOnAction: false, 43 controlsContainer: '.controls-'+notificationsSliderID, 44 controlNav: false, 45 start:function(slider) { 46 fsnNotificationInitSliderAccessibility(slider); 47 var post_id = slider.find('.flex-active-slide .fsn-notification').data('notification-id'); 48 if (getCookie('notification'+dismissID) != '') { 49 slider.closest('.fsn-notifications').remove(); 50 } else { 51 slider.closest('.fsn-notifications').removeClass('dismissed'); 52 } 53 }, 54 before:function(slider) { 55 fsnNotificationUpdateSliderAccessibility(slider); 56 } 57 }); 58 }); 59 }); 60}); 61 62/** 63 * Modal Window Layout 64 */ 65 66jQuery(document).ready(function() { 67 var notificationModalWindows = jQuery('.fsn-notifications.modal_window'); 68 notificationModalWindows.each(function() { 69 var dismissID = jQuery(this).attr('data-notification-id'); 70 var notification = jQuery(this); 71 notification.on('hidden.bs.modal', function(event) { 72 notification.trigger('fsnNotificationDismissed'); 73 var cookieNotice = setCookiePolicyAccept(notification); 74 if (dismissID && !cookieNotice) { 75 var expires = new Date(); 76 expires.setTime(expires.getTime()+(30*24*60*60*1000)); 77 document.cookie = 'notification'+dismissID+'=closed; path=/; expires='+ expires.toUTCString(); 78 } 79 }); 80 81 var notificationsSliders = jQuery(notification).find('.flexslider'); 82 notificationsSliders.each(function() { 83 var notificationsSlider = jQuery(this); 84 var notificationsSliderID = jQuery(this).attr('data-slider-id'); 85 var dismissID = jQuery(this).parent().attr('data-notification-id'); 86 notificationsSlider.flexslider({ 87 animation: 'fade', 88 slideshow: false, 89 multipleKeyboard: true, 90 pauseOnAction: false, 91 controlsContainer: '.controls-'+notificationsSliderID, 92 controlNav: false, 93 start:function(slider) { 94 fsnNotificationInitSliderAccessibility(slider); 95 var post_id = slider.find('.flex-active-slide .fsn-notification').data('notification-id'); 96 if (getCookie('notification'+dismissID) != '') { 97 slider.closest('.fsn-notifications').remove(); 98 } else { 99 slider.closest('.fsn-notifications').removeClass('dismissed'); 100 } 101 }, 102 before:function(slider) { 103 fsnNotificationUpdateSliderAccessibility(slider); 104 } 105 }); 106 }); 107 108 var modalDelay = notification.attr('data-modal-delay')*1000; 109 var targetModal = notificationModalWindows.find('.modal'); 110 var dismissID = notification.attr('data-notification-id'); 111 if (getCookie('notification'+dismissID) == '') { 112 setTimeout(function(){ 113 jQuery(targetModal).modal('show'); 114 }, modalDelay); 115 } 116 jQuery('.fsn-notifications.modal_window .fsn-notification a').on('click',function(event){ 117 var cookieNotice = setCookiePolicyAccept(notification); 118 if (dismissID && !cookieNotice) { 119 var expires = new Date(); 120 expires.setTime(expires.getTime()+(30*24*60*60*1000)); 121 document.cookie = 'notification'+dismissID+'=closed; path=/; expires='+ expires.toUTCString(); 122 } 123 }); 124 }); 125}); 126 127/** 128 * Floating Footer Layout 129 */ 130 131jQuery(document).ready(function() { 132 var notificationFloatingFooters = jQuery('.fsn-notifications.floating_footer'); 133 notificationFloatingFooters.each(function() { 134 var notification = jQuery(this); 135 notification.closest('.col-sm-12').css('min-height','0px'); 136 var notificationsClose = notification.find('.notifications-floating-footer-close'); 137 notificationsClose.on('click', function(event) { 138 event.preventDefault(); 139 if (notification.hasClass('putaway')) { 140 notification.removeClass('putaway'); 141 fsnNotificationReinitSliderAccessibility(notification); 142 } else { 143 notification.addClass('putaway').trigger('fsnNotificationDismissed'); 144 fsnNotificationDeinitSliderAccessibility(notification); 145 } 146 var dismissID = jQuery(this).parent().attr('data-notification-id'); 147 var cookieNotice = setCookiePolicyAccept(notification); 148 if (dismissID && !cookieNotice) { 149 var expires = new Date(); 150 expires.setTime(expires.getTime()+(30*24*60*60*1000)); 151 document.cookie = 'notification'+dismissID+'=closed; path=/; expires='+ expires.toUTCString(); 152 } 153 }); 154 155 var notificationsSliders = jQuery(notification).find('.flexslider'); 156 notificationsSliders.each(function() { 157 var notificationsSlider = jQuery(this);
158 var notificationsSliderID = jQuery(this).attr('data-slider-id'); 159 var dismissID = jQuery(this).parent().attr('data-notification-id'); 160 notificationsSlider.flexslider({ 161 animation: 'fade', 162 slideshow: false, 163 multipleKeyboard: true, 164 pauseOnAction: false, 165 controlsContainer: '.controls-'+notificationsSliderID, 166 controlNav: false, 167 start:function(slider) { 168 fsnNotificationInitSliderAccessibility(slider); 169 var post_id = slider.find('.flex-active-slide .fsn-notification').data('notification-id'); 170 if (getCookie('notification'+dismissID) != '') { 171 slider.closest('.fsn-notifications').remove(); 172 } else { 173 slider.closest('.fsn-notifications').removeClass('dismissed'); 174 } 175 }, 176 before:function(slider) { 177 fsnNotificationUpdateSliderAccessibility(slider); 178 } 179 }); 180 }); 181 }); 182}); 183 184/** 185 * Inline Bar Layout 186 */ 187 188jQuery(document).ready(function() { 189 var notificationInlineBars = jQuery('.fsn-notifications.bar_inline'); 190 notificationInlineBars.each(function() { 191 var notification = jQuery(this); 192 notification.closest('.col-sm-12').css('min-height','0px'); 193 var notificationsClose = notification.find('.notifications-bar-inline-close'); 194 notificationsClose.on('click', function(event) { 195 event.preventDefault(); 196 if (notification.hasClass('putaway')) { 197 notification.removeClass('putaway'); 198 fsnNotificationReinitSliderAccessibility(notification); 199 } else { 200 notification.addClass('putaway').trigger('fsnNotificationDismissed'); 201 fsnNotificationDeinitSliderAccessibility(notification); 202 } 203 var dismissID = jQuery(this).parent().attr('data-notification-id'); 204 var cookieNotice = setCookiePolicyAccept(notification); 205 if (dismissID && !cookieNotice) { 206 var expires = new Date(); 207 expires.setTime(expires.getTime()+(30*24*60*60*1000)); 208 document.cookie = 'notification'+dismissID+'=closed; path=/; expires='+ expires.toUTCString(); 209 } 210 }); 211 212 var notificationsSliders = jQuery(notification).find('.flexslider'); 213 notificationsSliders.each(function() { 214 var notificationsSlider = jQuery(this); 215 var notificationsSliderID = jQuery(this).attr('data-slider-id'); 216 var dismissID = jQuery(this).parent().attr('data-notification-id'); 217 notificationsSlider.flexslider({ 218 animation: 'fade', 219 slideshow: false, 220 multipleKeyboard: true, 221 pauseOnAction: false, 222 controlsContainer: '.controls-'+notificationsSliderID, 223 controlNav: false, 224 start:function(slider) { 225 fsnNotificationInitSliderAccessibility(slider); 226 var post_id = slider.find('.flex-active-slide .fsn-notification').data('notification-id'); 227 if (getCookie('notification'+dismissID) != '') { 228 slider.closest('.fsn-notifications').remove(); 229 } else { 230 slider.closest('.fsn-notifications').removeClass('dismissed'); 231 } 232 }, 233 before:function(slider) { 234 fsnNotificationUpdateSliderAccessibility(slider); 235 } 236 }); 237 }); 238 }); 239}); 240 241/** 242 * Popover Layout 243 */ 244 245jQuery(document).ready(function() { 246 var cookieAccepted = getCookie('fsn_notification_cookie_accepted'); 247 var notificationPopovers = jQuery('.fsn-notifications.notifications-popover'); 248 var notificationHasPopoverCookieSlide = false; 249 notificationPopovers.each(function() { 250 var notificationPopoverSlides = jQuery(this).find('.slide'); 251 notificationPopoverSlides.each(function() { 252 if(jQuery(this).attr('data-cookie-notice') == "true") { 253 notificationHasPopoverCookieSlide = true; 254 } 255 }); 256 if(notificationHasPopoverCookieSlide && cookieAccepted !== 'accepted') { 257 jQuery(this).find('.popover-close').remove(); 258 } 259 notificationPopoverSlides.each(function() { 260 if(cookieAccepted == 'accepted') { 261 if(jQuery(this).attr('data-cookie-notice') == "true") { 262 jQuery(this).remove(); 263 } 264 } else { 265 if(jQuery(this).attr('data-cookie-notice') !== "true" && notificationHasPopoverCookieSlide) { 266 jQuery(this).remove(); 267 } 268 } 269 }); 270 271 var notificationPopoverSlidesUpdated = jQuery(this).find('.slide'); 272 if(notificationPopoverSlidesUpdated.length <= 0) { 273 jQuery(this).remove(); 274 } 275 276 var notification = jQuery(this); 277 notification.closest('.col-sm-12').css('min-height','0px'); 278 if(jQuery(this).find('.slide').attr('data-cookie-notice') == "true") { 279 var notificationsClose = notification.find('.cookie-notice-accept'); 280 } else { 281 var notificationsClose = notification.find('.notifications-popover-close'); 282 } 283 notificationsClose.on('click', function(event) { 284 event.preventDefault(); 285 notification.trigger('fsnNotificationDismissed'); 286 jQuery(this).closest('.fsn-notifications.notifications-popover').addClass('dismissed'); 287 setTimeout(function() { 288 notification.parents('.fsn-notification-container').remove(); 289 }, 300); 290 var dismissID = jQuery(this).parent().attr('data-notification-id'); 291 var cookieNotice = setCookiePolicyAccept(notification); 292 if (dismissID && !cookieNotice) { 293 var expires = new Date(); 294 expires.setTime(expires.getTime()+(30*24*60*60*1000)); 295 document.cookie = 'notification'+dismissID+'=closed; path=/; expires='+ expires.toUTCString(); 296 } 297 }); 298 299 var notificationsSliders = jQuery(notification).find('.flexslider'); 300 notificationsSliders.each(function() { 301 var notificationsSlider = jQuery(this);
302 var notificationsSliderID = jQuery(this).attr('data-slider-id'); 303 var dismissID = jQuery(this).parent().attr('data-notification-id'); 304 notificationsSlider.flexslider({ 305 animation: 'fade', 306 slideshow: false, 307 multipleKeyboard: true, 308 pauseOnAction: false, 309 directionNav: false, 310 controlNav: true, 311 start:function(slider) { 312 fsnNotificationInitSliderAccessibility(slider); 313 var post_id = slider.find('.flex-active-slide .fsn-notification').data('notification-id'); 314 if (getCookie('notification'+dismissID) != '') { 315 slider.closest('.fsn-notification-container').remove(); 316 } else { 317 var popoverDelay = notification.data('popoverDelay') * 1000; 318 setTimeout(function() { 319 slider.closest('.fsn-notifications').removeClass('dismissed not-ready'); 320 }, popoverDelay); 321 } 322 }, 323 before:function(slider) { 324 fsnNotificationUpdateSliderAccessibility(slider); 325 } 326 }); 327 }); 328 }); 329}); 330 331function setCookiePolicyAccept(target) { 332 var cookiePolicyAcceptSet = false; 333 var targetSlides = jQuery(target).find('.slide'); 334 targetSlides.each(function() { 335 if(jQuery(this).attr('data-cookie-notice') == "true") { 336 var expires = new Date(); 337 expires.setTime(expires.getTime()+(3600 * 1000 * 24 * 365)); 338 document.cookie = 'fsn_notification_cookie_accepted=accepted; expires='+ expires.toUTCString()+"; domain="+window.location.hostname+"; path=/"; 339 cookiePolicyAcceptSet = true; 340 } 341 }); 342 return cookiePolicyAcceptSet; 343} 344 345/** 346 * Get Cookie 347 */ 348 349function getCookie(cname) { 350 var name = cname + "="; 351 var ca = document.cookie.split(';'); 352 for(var i=0; i<ca.length; i++) { 353 var c = ca[i]; 354 while (c.charAt(0)==' ') c = c.substring(1); 355 if (c.indexOf(name) != -1) return c.substring(name.length,c.length); 356 } 357 return ""; 358} 359 360function fsnNotificationInitSliderAccessibility(slider) { 361 //add button roles 362 if (slider.directionNav !== undefined) { 363 slider.directionNav.each(function() { 364 jQuery(this).attr('role', 'button'); 365 }); 366 } 367 if (slider.controlNav !== undefined) { 368 slider.controlNav.each(function() { 369 jQuery(this).attr('role', 'button'); 370 }); 371 //add controlNav active text 372 slider.controlNav.eq(0).append('<span class="sr-only">'+ fsnExtNotificationL10n.current_slide +'</span>'); 373 } 374 //set ARIA and tab index 375 if (slider.slides !== undefined) { 376 slider.slides.not(':eq(0)').each(function() { 377 jQuery(this).attr('aria-hidden', true).find('a').attr('tabindex', '-1'); 378 }); 379 } 380} 381 382function fsnNotificationDeinitSliderAccessibility(slider) { 383 var slides = slider.find('li.slide'); 384 //set ARIA and tab index 385 if (slides !== undefined) { 386 slides.each(function() { 387 jQuery(this).attr('aria-hidden', true).find('a').attr('tabindex', '-1'); 388 }); 389 } 390} 391 392function fsnNotificationReinitSliderAccessibility(slider) { 393 var slides = slider.find('li.slide'); 394 //set ARIA and tab index 395 if (slides !== undefined) { 396 jQuery('.flex-active-slide').removeAttr('aria-hidden').find('a').removeAttr('tabindex'); 397 } 398} 399 400function fsnNotificationUpdateSliderAccessibility(slider) { 401 var incomingSlide = slider.find('.slides > li').eq(slider.animatingTo); 402 if (slider.controlNav !== undefined) { 403 //update controlNav active text 404 slider.controlNav.not(':eq('+ slider.animatingTo +')').find('.sr-only').remove(); 405 slider.controlNav.filter(':eq('+ slider.animatingTo +')').append('<span class="sr-only">'+ fsnExtNotificationL10n.current_slide +'</span>'); 406 } 407 //update ARIA and tab index 408 if (slider.slides !== undefined) { 409 slider.slides.not(':eq('+ slider.animatingTo +')').each(function() { 410 jQuery(this).attr('aria-hidden', true).find('a').attr('tabindex', '-1'); 411 }); 412 incomingSlide.removeAttr('aria-hidden').find('a').removeAttr('tabindex'); 413 } 414}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.