PageSourceSearch

https://www.worklife.news/_static/??/wp-content/plugins/digiday-me…/js/dist/hooks.min.js?m=1790721892j

js worklife.news collected 2026-10-02 02:57:18 UTC 9,795 bytes, 152 lines download raw bytes

1/**
2 * Share + Copy URL interactions.
3 * Network plugin: digiday-media-network-plugin.
4 * Handles the single-post share/copy bar (.dmn-share-copy-url) and the
5 * archive preview row (.dmn-share-icons-preview). Matches the class
6 * contract defined in share-copy-url.css.
7 *
8 * GA event tracking: each action element carries a unique data-ga-id
9 * (brand + post id + action, built in share-copy-url.php). We push that id
10 * to the dataLayer so every share/copy interaction is uniquely trackable
11 * in GA4. UTM params on outbound links are handled server-side in PHP.
12  * Security: window.location.href is normalized via getSafeUrl() (new URL, http(s) only)
13   * and passed through encodeURI() before clipboard write to satisfy
14    * WordPressVIPMinimum.JS.Window.location. No DOM/HTML sinks are used.
15 */
16( function () {
17	'use strict';
18
19	window.dataLayer = window.dataLayer || [];
20
21	function pushGTM( payload ) {
22		try {
23			window.dataLayer.push( payload );
24		} catch ( e ) {}
25	}
26
27	function gaId( el ) {
28		return ( el && el.getAttribute ) ? ( el.getAttribute( 'data-ga-id' ) || '' ) : '';
29	}
30
31	function trackShare( el, method ) {
32		pushGTM( {
33			event: 'article_share_click',
34			share_method: method,
35			ga_id: gaId( el )
36		} );
37	}
38
39	function closestEl( el, selector ) {
40		while ( el && el.nodeType === 1 ) {
41			if ( el.matches && el.matches( selector ) ) {
42				return el;
43			}
44			el = el.parentNode;
45		}
46		return null;
47	}
48
49	function getSafeUrl( el ) {
50		var attr = el && el.getAttribute ? ( el.getAttribute( 'data-url' ) || el.getAttribute( 'data-copy-url' ) ) : '';
51		if ( attr && /^https?:\/\//i.test( attr ) ) {
52			return attr;
53		}
54		var canonical = document.querySelector( 'link[rel="canonical"]' );
55		if ( canonical && canonical.href && /^https?:\/\//i.test( canonical.href ) ) {
56			return canonical.href;
57		}
58		// Fallback: derive from the current location, but sanitize via the URL
59		// parser and only accept http(s) so nothing user-supplied is trusted raw.
60		try {
61			var loc = new URL( window.location.href );
62			if ( /^https?:$/i.test( loc.protocol ) ) {
63				return loc.origin + loc.pathname;
64			}
65		} catch ( err ) {}
66		return '';
67	}
68
69	function copyText( text, done ) {
70		if ( navigator.clipboard && navigator.clipboard.writeText ) {
71			navigator.clipboard.writeText( text ).then( done ).catch( done );
72			return;
73		}
74		var ta = document.createElement( 'textarea' );
75		ta.value = text;
76		ta.setAttribute( 'readonly', '' );
77		ta.style.position = 'absolute';
78		ta.style.left = '-9999px';
79		document.body.appendChild( ta );
80		ta.select();
81		try {
82			document.execCommand( 'copy' );
83		} catch ( err ) {}
84		document.body.removeChild( ta );
85		done();
86	}
87
88	var copiedTimers = [];
89
90	function showCopied( bar ) {
91		if ( ! bar ) {
92			return;
93		}
94		bar.classList.add( 'is-copied' );
95		var t = window.setTimeout( function () {
96			bar.classList.remove( 'is-copied' );
97		}, 2000 );
98		copiedTimers.push( t );
99	}
100
101	function onClick( e ) {
102		var target = e.target;
103		var bar = closestEl( target, '.dmn-share-copy-url' );
104		var copyBtn = closestEl( target, '.js-dmn-share-copy' );
105
106		if ( copyBtn ) {
107			e.preventDefault();
108			var url = getSafeUrl( copyBtn );
109			var bar2 = bar || closestEl( copyBtn, '.dmn-share-copy-url' );
110			copyText( url, function () {
111				showCopied( bar2 );
112				pushGTM( {
113					event: 'article_copy_link',
114					share_method: 'copy',
115					ga_id: gaId( copyBtn )
116				} );
117			} );
118			return;
119		}
120
121		var socialLink = closestEl( target, '.dmn-share-copy-url__icon[data-network]' );
122		if ( socialLink ) {
123			var network = socialLink.getAttribute( 'data-network' ) || 'unknown';
124			trackShare( socialLink, network );
125			return;
126		}
127	}
128
129	document.addEventListener( 'click', onClick, false );
130
131	document.addEventListener( 'click', function ( e ) {
132		var btn = closestEl( e.target, '.dmn-share-icons-preview__copy, .dmn-share-preview__copy' );
133		if ( ! btn ) {
134			return;
135		}
136		e.preventDefault();
137		var url = getSafeUrl( btn );
138		if ( ! url ) {
139			return;
140		}
141		copyText( url, function () {
142			pushGTM( {
143				event: 'preview_copy_link',
144				share_method: 'copy',
145				ga_id: gaId( btn )
146			} );
147		} );
148	}, false );
149} )();
150;
151/*! This file is auto-generated */
152(()=>{var t={507:(t,e,r)=>{"use strict";r.d(e,{A:()=>A});var n=function(t){return"string"!=typeof t||""===t?(console.error("The namespace must be a non-empty string."),!1):!!/^[a-zA-Z][a-zA-Z0-9_.\-\/]*$/.test(t)||(console.error("The namespace can only contain numbers, letters, dashes, periods, underscores and slashes."),!1)};var i=function(t){return"string"!=typeof t||""===t?(console.error("The hook name must be a non-empty string."),!1):/^__/.test(t)?(console.error("The hook name cannot begin with `__`."),!1):!!/^[a-zA-Z][a-zA-Z0-9_.-]*$/.test(t)||(console.error("The hook name can only contain numbers, letters, dashes, periods and underscores."),!1)};var o=function(t,e){return function(r,o,s,c=10){const l=t[e];if(!i(r))return;if(!n(o))return;if("function"!=typeof s)return void console.error("The hook callback must be a function.");
152if("number"!=typeof c)return void console.error("If specified, the hook priority must be a number.");const a={callback:s,priority:c,namespace:o};if(l[r]){const t=l[r].handlers;let e;for(e=t.length;e>0&&!(c>=t[e-1].priority);e--);e===t.length?t[e]=a:t.splice(e,0,a),l.__current.forEach((t=>{t.name===r&&t.currentIndex>=e&&t.currentIndex++}))}else l[r]={handlers:[a],runs:0};"hookAdded"!==r&&t.doAction("hookAdded",r,o,s,c)}};var s=function(t,e,r=!1){return function(o,s){const c=t[e];if(!i(o))return;if(!r&&!n(s))return;if(!c[o])return 0;let l=0;if(r)l=c[o].handlers.length,c[o]={runs:c[o].runs,handlers:[]};else{const t=c[o].handlers;for(let e=t.length-1;e>=0;e--)t[e].namespace===s&&(t.splice(e,1),l++,c.__current.forEach((t=>{t.name===o&&t.currentIndex>=e&&t.currentIndex--})))}return"hookRemoved"!==o&&t.doAction("hookRemoved",o,s),l}};var c=function(t,e){return function(r,n){const i=t[e];return void 0!==n?r in i&&i[r].handlers.some((t=>t.namespace===n)):r in i}};var l=function(t,e,r,n){return function(i,...o){const s=t[e];s[i]||(s[i]={handlers:[],runs:0}),s[i].runs++;const c=s[i].handlers;if(!c||!c.length)return r?o[0]:void 0;const l={name:i,currentIndex:0};return(n?async function(){try{s.__current.add(l);let t=r?o[0]:void 0;for(;l.currentIndex<c.length;){const e=c[l.currentIndex];t=await e.callback.apply(null,o),r&&(o[0]=t),l.currentIndex++}return r?t:void 0}finally{s.__current.delete(l)}}:function(){try{s.__current.add(l);let t=r?o[0]:void 0;for(;l.currentIndex<c.length;){t=c[l.currentIndex].callback.apply(null,o),r&&(o[0]=t),l.currentIndex++}return r?t:void 0}finally{s.__current.delete(l)}})()}};var a=function(t,e){return function(){const r=t[e],n=Array.from(r.__current);return n.at(-1)?.name??null}};var d=function(t,e){return function(r){const n=t[e];return void 0===r?n.__current.size>0:Array.from(n.__current).some((t=>t.name===r))}};var u=function(t,e){return function(r){const n=t[e];if(i(r))return n[r]&&n[r].runs?n[r].runs:0}};class h{actions;filters;addAction;addFilter;removeAction;removeFilter;hasAction;hasFilter;removeAllActions;removeAllFilters;doAction;doActionAsync;applyFilters;applyFiltersAsync;currentAction;currentFilter;doingAction;doingFilter;didAction;didFilter;constructor(){this.actions=Object.create(null),this.actions.__current=new Set,this.filters=Object.create(null),this.filters.__current=new Set,this.addAction=o(this,"actions"),this.addFilter=o(this,"filters"),this.removeAction=s(this,"actions"),this.removeFilter=s(this,"filters"),this.hasAction=c(this,"actions"),this.hasFilter=c(this,"filters"),this.removeAllActions=s(this,"actions",!0),this.removeAllFilters=s(this,"filters",!0),this.doAction=l(this,"actions",!1,!1),this.doActionAsync=l(this,"actions",!1,!0),this.applyFilters=l(this,"filters",!0,!1),this.applyFiltersAsync=l(this,"filters",!0,!0),this.currentAction=a(this,"actions"),this.currentFilter=a(this,"filters"),this.doingAction=d(this,"actions"),this.doingFilter=d(this,"filters"),this.didAction=u(this,"actions"),this.didFilter=u(this,"filters")}}var A=function(){return new h}},8770:()=>{}},e={};function r(n){var i=e[n];if(void 0!==i)return i.exports;var o=e[n]={exports:{}};return t[n](o,o.exports,r),o.exports}r.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return r.d(e,{a:e}),e},r.d=(t,e)=>{for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var n={};(()=>{"use strict";r.r(n),r.d(n,{actions:()=>x,addAction:()=>s,addFilter:()=>c,applyFilters:()=>m,applyFiltersAsync:()=>v,createHooks:()=>t.A,currentAction:()=>y,currentFilter:()=>F,defaultHooks:()=>o,didAction:()=>b,didFilter:()=>k,doAction:()=>f,doActionAsync:()=>p,doingAction:()=>_,doingFilter:()=>g,filters:()=>w,hasAction:()=>d,hasFilter:()=>u,removeAction:()=>l,removeAllActions:()=>h,removeAllFilters:()=>A,removeFilter:()=>a});var t=r(507),e=r(8770),i={};for(const t in e)["default","actions","addAction","addFilter","applyFilters","applyFiltersAsync","createHooks","currentAction","currentFilter","defaultHooks","didAction","didFilter","doAction","doActionAsync","doingAction","doingFilter","filters","hasAction","hasFilter","removeAction","removeAllActions","removeAllFilters","removeFilter"].indexOf(t)<0&&(i[t]=()=>e[t]);r.d(n,i);const o=(0,t.A)(),{addAction:s,addFilter:c,removeAction:l,removeFilter:a,hasAction:d,hasFilter:u,removeAllActions:h,removeAllFilters:A,doAction:f,doActionAsync:p,applyFilters:m,applyFiltersAsync:v,currentAction:y,currentFilter:F,doingAction:_,doingFilter:g,didAction:b,didFilter:k,actions:x,filters:w}=o})(),(window.wp=window.wp||{}).hooks=n})();;

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.