1/** 2 * Handles dismissible notices from the Notice block. 3 */ 4 5/** 6 * IE 11 polyfill for Nodelist.forEach. 7 * 8 * @see https://developer.mozilla.org/en-US/docs/Web/API/NodeList/forEach 9 */ 10if ( window.NodeList && ! NodeList.prototype.forEach ) { 11 NodeList.prototype.forEach = Array.prototype.forEach; 12} 13 14document.addEventListener( 'DOMContentLoaded', function() { 15 var notices = document.querySelectorAll( 16 '.gb-block-notice.gb-dismissable[data-id]' 17 ); 18 19 notices.forEach( function( element ) { 20 var uid = element.getAttribute( 'data-id' ); 21 22 var dismissible = element.querySelector( '.gb-notice-dismiss' ); 23 24 if ( ! localStorage.getItem( 'notice-' + uid ) ) { 25 element.style.display = 'block'; 26 } 27 28 if ( dismissible ) { 29 dismissible.addEventListener( 'click', function( event ) { 30 event.preventDefault(); 31 localStorage.setItem( 'notice-' + uid, '1' ); 32 element.style.display = ''; 33 } ); 34 } 35 } ); 36} );
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.