PageSourceSearch

https://edtechbites.com/_static/??wp-content/themes/twentysixteen/…/likes/queuehandler.min.js?m=1789494668

js edtechbites.com collected 2026-10-01 14:08:50 UTC 16,263 bytes, 299 lines download raw bytes

1/* global screenReaderText */
2/**
3 * Theme functions file.
4 *
5 * Contains handlers for navigation and widget area.
6 */
7( function () {
8	'use strict';
9
10	var mainNav, masthead, menuToggle, siteNavigation, socialNavigation, siteHeaderMenu, resizeTimer;
11
12	function matches( el, sel ) {
13		if ( Element.prototype.matches ) {
14			return el.matches( sel );
15		}
16
17		if ( Element.prototype.msMatchesSelector ) {
18			return el.msMatchesSelector( sel );
19		}
20	}
21
22	// Based on https://developer.mozilla.org/en-US/docs/Web/API/Element/closest#Polyfill
23	function closest( el, sel ) {
24		if ( el.closest ) {
25			return el.closest( sel );
26		}
27
28		var current = el;
29
30		do {
31			if ( matches( el, sel ) ) {
32				return current;
33			}
34			current = current.parentElement || current.parentNode;
35		} while ( current !== null && current.nodeType === 1 );
36
37		return null;
38	}
39
40	function forEachNode( parent, selector, fn ) {
41		var nodes = parent.querySelectorAll( selector );
42		for ( var i = 0; i < nodes.length; i++ ) {
43			fn( nodes[ i ] );
44		}
45	}
46
47	function initMainNavigation( container ) {
48		forEachNode( container, '.menu-item-has-children > a', function ( el ) {
49			// Add dropdown toggle that displays child menu items.
50			var dropdownToggle = document.createElement( 'button' );
51			dropdownToggle.className = 'dropdown-toggle';
52			dropdownToggle.setAttribute( 'aria-expanded', 'false' );
53
54			var span = document.createElement( 'span' );
55			span.className = 'screen-reader-text';
56			span.textContent = screenReaderText.expand;
57
58			dropdownToggle.appendChild( span );
59
60			el.parentNode.insertBefore( dropdownToggle, el.nextSibling );
61		} );
62
63		// Toggle buttons and submenu items with active children menu items.
64		forEachNode( container, '.current-menu-ancestor > button', function ( el ) {
65			el.classList.add( 'toggled-on' );
66		} );
67		forEachNode( container, '.current-menu-ancestor > .sub-menu', function ( el ) {
68			el.classList.add( 'toggled-on' );
69		} );
70
71		// Add menu items with submenus to aria-haspopup="true".
72		forEachNode( container, '.menu-item-has-children', function ( el ) {
73			el.setAttribute( 'aria-haspopup', 'true' );
74		} );
75
76		forEachNode( container, '.dropdown-toggle', function ( el ) {
77			el.addEventListener( 'click', function ( e ) {
78				var screenReaderSpan = el.querySelector( '.screen-reader-text' );
79
80				e.preventDefault();
81				el.classList.toggle( 'toggled-on' );
82				var next = el.nextElementSibling;
83				if ( next && matches( next, '.children, .sub-menu' ) ) {
84					next.classList.toggle( 'toggled-on' );
85				}
86
87				el.setAttribute(
88					'aria-expanded',
89					el.getAttribute( 'aria-expanded' ) === 'false' ? 'true' : 'false'
90				);
91				screenReaderSpan.textContent =
92					screenReaderSpan.textContent === screenReaderText.expand ? screenReaderText.collapse: screenReaderText.expand;
93			} );
94		} );
95	}
96
97	mainNav = document.querySelector( '.main-navigation' );
98	if ( mainNav ) {
99		initMainNavigation( mainNav );
100	}
101
102	masthead = document.querySelector( '#masthead' );
103	menuToggle = masthead && masthead.querySelector( '#menu-toggle' );
104	siteHeaderMenu = masthead && masthead.querySelector( '#site-header-menu' );
105	siteNavigation = masthead && masthead.querySelector( '#site-navigation' );
106	socialNavigation = masthead && masthead.querySelector( '#social-navigation' );
107
108	// Enable menuToggle.
109	( function () {
110		// Return early if menuToggle is missing.
111		if ( ! menuToggle ) {
112			return;
113		}
114
115		var controls = [ menuToggle, siteNavigation, socialNavigation ].filter( Boolean );
116
117		// Add an initial values for the attribute.
118		controls.forEach( function ( el ) {
119			el.setAttribute( 'aria-expanded', 'false' );
120		} );
121
122		menuToggle.addEventListener( 'click', function () {
123			menuToggle.classList.toggle( 'toggled-on' );
124			siteHeaderMenu.classList.toggle( 'toggled-on' );
125
126			var newVal = menuToggle.getAttribute( 'aria-expanded' ) === 'false' ? 'true' : 'false';
127			controls.forEach( function ( el ) {
128				el.setAttribute( 'aria-expanded', newVal );
129			} );
130		} );
131	} )();
132
133	// Fix sub-menus for touch devices and better focus for hidden submenu items for accessibility.
134	( function () {
135		if ( ! siteNavigation || ! siteNavigation.children.length ) {
136			return;
137		}
138
139		// Init `focus` class to allow submenu access on tablets.
140		function initFocusClassTouchScreen() {
141			document.body.addEventListener( 'touchstart', function ( e ) {
142				if ( ! closest( e.target, '.main-navigation li' ) ) {
143					forEachNode( document, '.main-navigation li', function ( el ) {
144						el.classList.remove( 'focus' );
145					} );
146				}
147			} );
148			forEachNode( siteNavigation, '.menu-item-has-children > a', function ( link ) {
149				link.addEventListener( 'touchstart', function ( e ) {
150					if ( window.innerWidth >= 910 ) {
151						var el = link.parentElement;
152
153						if ( matches( el, 'li' ) && ! el.classList.contains( 'focus' ) ) {
154							e.preventDefault();
155							el.classList.toggle( 'focus' );
156							var children = el.parentElement.children;
157							for ( var i = 0; i < children.length; i++ ) {
158								if ( children[ i ] !== el ) {
159									children[ i ].classList.remove( 'focus' );
160								}
161							}
162						}
163					}
164				} );
165			} );
166		}
167
168		function toggleFocus( el ) {
169			var item = closest( el, '.menu-item' );
170			if ( item ) {
171				item.classList.toggle( 'focus' );
172			}
173		}
174
175		if ( 'ontouchstart' in window ) {
176			initFocusClassTouchScreen();
177		}
178
179		forEachNode( siteNavigation, 'a', function ( link ) {
180			link.addEventListener( 'focus', toggleFocus( link ) );
181			link.addEventListener( 'blur', toggleFocus( link ) );
182		} );
183	} )();
184
185	// Add the default ARIA attributes for the menu toggle and the navigations.
186	function onResizeARIA() {
187		if ( window.innerWidth < 910 ) {
188			if ( menuToggle && menuToggle.classList.contains( 'toggled-on' ) ) {
189				menuToggle.setAttribute( 'aria-expanded', 'true' );
190			} else {
191				menuToggle.setAttribute( 'aria-expanded', 'false' );
192			}
193
194			if ( siteHeaderMenu && siteHeaderMenu.classList.contains( 'toggled-on' ) ) {
195				siteNavigation && siteNavigation.setAttribute( 'aria-expanded', 'true' );
196				socialNavigation && socialNavigation.setAttribute( 'aria-expanded', 'true' );
197			} else {
198				siteNavigation && siteNavigation.setAttribute( 'aria-expanded', 'false' );
199				socialNavigation && socialNavigation.setAttribute( 'aria-expanded', 'false' );
200			}
201
202			menuToggle && menuToggle.setAttribute( 'aria-controls', 'site-navigation social-navigation' );
203		} else {
204			menuToggle && menuToggle.removeAttribute( 'aria-expanded' );
205			siteNavigation && siteNavigation.removeAttribute( 'aria-expanded' );
206			socialNavigation && socialNavigation.removeAttribute( 'aria-expanded' );
207			menuToggle && menuToggle.removeAttribute( 'aria-controls' );
208		}
209	}
210
211	// Add 'below-entry-meta' class to elements.
212	function belowEntryMetaClass( selector ) {
213		if (
214			document.body.classList.contains( 'page' ) ||
215			document.body.classList.contains( 'search' ) ||
216			document.body.classList.contains( 'single-attachment' ) ||
217			document.body.classList.contains( 'error404' )
218		) {
219			return;
220		}
221
222		forEachNode( document, '.entry-content', function ( content ) {
223			forEachNode( content, selector, function ( element ) {
224				var elementPosTop = element.getBoundingClientRect().top;
225				var article = closest( element, 'article' );
226				var entryFooter = article && article.querySelector( '.entry-footer' );
227				var entryFooterPosBottom =
228					entryFooter ? entryFooter.getBoundingClientRect().top + entryFooter.offsetHeight + 28	: null;
229				var caption = closest( element, 'figure' );
230				var next = element.nextSibling;
231				var figcaption = next && matches( next, 'figcaption' ) ? next : null;
232				var newImg;
233
234				// Add 'below-entry-meta' to elements below the entry meta.
235				if ( entryFooterPosBottom !== null && elementPosTop > entryFooterPosBottom ) {
236					// Check if full-size images and captions are larger than or equal to 840px.
237					if ( selector === 'img.size-full' || selector === '.wp-block-image img' ) {
238						// Create an image to find native image width of resized images (i.e. max-width: 100%).
239						newImg = new Image();
240						newImg.src = element.getAttribute( 'src' );
241						newImg.onload = function () {
242							if ( newImg.width >= 840 ) {
243								// Check if an image in an image block has a width attribute; if its value is less than 840, return.
244								if (
245									selector === '.wp-block-image img' &&
246									element.hasAttribute( 'width' ) &&
247									element.getAttribute( 'width' ) < 840
248								) {
249									return;
250								}
251
252								element.classList.add( 'below-entry-meta' );
253
254								if ( caption && caption.classList.contains( 'wp-caption' ) ) {
255									caption.classList.add( 'below-entry-meta' );
256									caption.removeAttribute( 'style' );
257								}
258
259								if ( figcaption ) {
260									figcaption.classList.add( 'below-entry-meta' );
261								}
262							}
263						};
264					} else {
265						element.classList.add( 'below-entry-meta' );
266					}
267				} else {
268					element.classList.remove( 'below-entry-meta' );
269					caption && caption.classList.remove( 'below-entry-meta' );
270				}
271			} );
272		} );
273	}
274
275	function init() {
276		window.addEventListener( 'load', onResizeARIA );
277		window.addEventListener( 'resize', function () {
278			clearTimeout( resizeTimer );
279			resizeTimer = setTimeout( function () {
280				belowEntryMetaClass( 'img.size-full' );
281				belowEntryMetaClass( 'blockquote.alignleft, blockquote.alignright' );
282				belowEntryMetaClass( '.wp-block-image img' );
283			}, 300 );
284			onResizeARIA();
285		} );
286
287		belowEntryMetaClass( 'img.size-full' );
288		belowEntryMetaClass( 'blockquote.alignleft, blockquote.alignright' );
289		belowEntryMetaClass( '.wp-block-image img' );
290	}
291
292	if ( document.readyState === 'loading' ) {
293		document.addEventListener( 'DOMContentLoaded', init );
294	} else {
295		init();
296	}
297} )();
298;
299(()=>{var e=[],t=!1,n=2e3,i=[],o=new Promise(e=>{"loading"!==document.readyState?e():window.addEventListener("DOMContentLoaded",()=>e())});function s(e,t){if("string"==typeof e)try{e=JSON.parse(e)}catch{return}if(t&&"function"==typeof t.postMessage)try{t.postMessage(JSON.stringify({type:"likesMessage",data:e}),"*")}catch{}}function r(){const t=[];document.querySelectorAll("div.jetpack-likes-widget-unloaded").forEach(n=>{if(!(e.indexOf(n.id)>-1)&&d(n)){e.push(n.id);var i,o=/like-(post|comment)-wrapper-(\d+)-(\d+)-(\w+)/.exec(n.id);o&&5===o.length&&(i={blog_id:o[2],width:n.width},"post"===o[1]?i.post_id=o[3]:"comment"===o[1]&&(i.comment_id=o[3]),i.obj_id=o[4],t.push(i))}}),t.length>0&&s({event:"initialBatch",requests:t},window.frames["likes-master"])}function a(){const e=document.querySelector("#likes-other-gravatars");if(e){e.style.display="none",e.setAttribute("aria-hidden","true");const t=e.__resizeHandler;t&&(window.removeEventListener("resize",t),delete e.__resizeHandler)}}function l(){var e;if(!t)return s({event:"queryMasterReady"},window.frames["likes-master"]),void setTimeout(l,500);!function(){for(let e=i.length-1;e>=0;e--){const t=i[e];if(!d(t)){const n=t&&t.parentElement&&t.parentElement.parentElement;n.classList.remove("jetpack-likes-widget-loaded"),n.classList.remove("jetpack-likes-widget-loading"),n.classList.add("jetpack-likes-widget-unloaded");const o=n.querySelector(".likes-widget-placeholder");o&&(o.style.display=""),i.splice(e,1),t.remove()}}}(),function(){if(!g)return;document.querySelectorAll("div.jetpack-likes-widget-unloaded").forEach(e=>g.observe(e))}();var n=[...document.querySelectorAll("div.jetpack-likes-widget-unloaded")].filter(e=>d(e));n.length>0&&r();for(var o=0,a=n.length;o<=a-1;o++)(e=n[o].id)&&c(e)}function c(e){if(void 0===e)return;const t=document.querySelector("#"+e);t.querySelectorAll("iframe").forEach(e=>e.remove());const n=t.querySelector(".likes-widget-placeholder");if(n&&n.classList.contains("post-likes-widget-placeholder")){const e=document.createElement("iframe");e.classList.add("post-likes-widget","jetpack-likes-widget"),e.name=t.dataset.name,e.src=t.dataset.src,e.height="55px",e.width="100%",e.frameBorder="0",e.scrolling="no",e.title=t.dataset.title,n.after(e)}if(n.classList.contains("comment-likes-widget-placeholder")){const e=document.createElement("iframe");e.class="comment-likes-widget-frame jetpack-likes-widget-frame",e.name=t.dataset.name,e.src=t.dataset.src,e.height="18px",e.width="100%",e.frameBorder="0",e.scrolling="no",t.querySelector(".comment-like-feedback").after(e),i.push(e)}t.classList.remove("jetpack-likes-widget-unloaded"),t.classList.add("jetpack-likes-widget-loading"),t.querySelector("iframe").addEventListener("load",e=>{t.contains(e.target)&&(s({event:"loadLikeWidget",name:e.target.name,width:e.target.width},window.frames["likes-master"]),n&&(n.style.display="none"),t.classList.remove("jetpack-likes-widget-loading"),t.classList.add("jetpack-likes-widget-loaded"))})}function d(e){const t=e.getBoundingClientRect().top,i=e.getBoundingClientRect().bottom;return t+n>=0&&i<=window.innerHeight+n}window.addEventListener("message",function(e){let n=e&&e.data;if("string"==typeof n)try{n=JSON.parse(n)}catch{return}const i=n&&n.type,l=n&&n.data;if("likesMessage"!==i||void 0===l.event)return;if("https://widgets.wp.com"===e.origin)switch(l.event){case"masterReady":o.then(()=>{t=!0;const e={event:"injectStyles"},n=document.querySelector(".sd-text-color"),i=document.querySelector(".sd-link-color"),o=n&&getComputedStyle(n)||{},a=i&&getComputedStyle(i)||{};document.body.classList.contains("single")&&s({event:"reblogsEnabled"},window.frames["likes-master"]),e.textStyles={color:o.color,fontFamily:o["font-family"],fontSize:o["font-size"],direction:o.direction,fontWeight:o["font-weight"],fontStyle:o["font-style"],textDecoration:o["text-decoration"]},e.linkStyles={color:a.color,fontFamily:a["font-family"],fontSize:a["font-size"],textDecoration:a["text-decoration"],fontWeight:a["font-weight"],fontStyle:a["font-style"]},s(e,window.frames["likes-master"]),r()});break;case"showLikeWidget":case"showCommentLikeWidget":break;case"killCommentLikes":document.querySelectorAll(".jetpack-comment-likes-widget-wrapper").forEach(e
299=>e.remove());break;case"clickReblogFlair":wpcom_reblog&&"function"==typeof wpcom_reblog.toggle_reblog_box_flair&&wpcom_reblog.toggle_reblog_box_flair(l.obj_id);break;case"hideOtherGravatars":a();break;case"showOtherGravatars":{const e=document.querySelector("#likes-other-gravatars");if(!e)break;const t=e.querySelector("ul");e.style.display="none",t.innerHTML="",e.querySelectorAll(".likes-text span").forEach(e=>e.textContent=l.totalLikesLabel),(l.likers||[]).forEach(async(e,n)=>{if("http"!==e.profile_URL.substr(0,4))return;const i=document.createElement("li");t.append(i);const o=encodeURI(e.profile_URL),r=encodeURI(e.avatar_URL);i.innerHTML=`<a href="${o}" rel="nofollow" target="_parent" class="wpl-liker">\n\t\t\t\t\t\t<img src="${r}"\n\t\t\t\t\t\t\talt=""\n\t\t\t\t\t\t\tstyle="width: 28px; height: 28px;" />\n\t\t\t\t\t\t<span></span>\n\t\t\t\t\t</a>`,i.classList.add(e.css_class),i.querySelector("img").alt=l.avatarAltTitle.replace("%s",e.name),i.querySelector("span").innerText=e.name,n===l.likers.length-1&&i.addEventListener("keydown",e=>{"Tab"!==e.key||e.shiftKey||(e.preventDefault(),a(),s({event:"focusLikesCount",parent:l.parent},window.frames["likes-master"]))})});const n=function(){const t="rtl"===getComputedStyle(e).direction,n=document.querySelector(`*[name='${l.parent}']`),i=n.getBoundingClientRect(),o=n.ownerDocument.defaultView,s=i.top+o.pageYOffset,r=i.left+o.pageXOffset;let a;if(e.style.top=s+l.position.top-1+"px",t){const t=l&&l.likers?Math.min(l.likers.length,5):0;a=r+l.position.left+24*t+4,e.style.transform="translateX(-100%)"}else a=r+l.position.left;e.style.left=a+"px",e.style.left="-9999px",e.style.display="block";const c=e.offsetWidth;a+c>o.innerWidth&&(a=i.right-c),e.style.left=a+"px",e.setAttribute("aria-hidden","false")};n(),e.focus();const i=function(e,t){var n;return function(){var i=this,o=arguments;clearTimeout(n),n=setTimeout(function(){e.apply(i,o)},t)}},o=i(n,100);e.__resizeHandler=o,window.addEventListener("resize",o),e.focus()}}}),document.addEventListener("click",a);var f,m,u,p=(f=250,m=l,function(){clearTimeout(u),u=setTimeout(m,f)}),g="function"==typeof IntersectionObserver?new IntersectionObserver(p,{rootMargin:"2000px",threshold:[0,1]}):null;l(),window.addEventListener("scroll",p,!0)})();;

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.