PageSourceSearch

https://static2.agorapulse.com/blog/wp-content/plugins/social-warfare/assets/js/script.min.js?ver=4.5.6

js agorapulse.com collected 2026-09-24 06:51:18 UTC 28,876 bytes, 948 lines download raw bytes

1window.socialWarfare = window.socialWarfare || {};
2( function ( window, $ ) {
3	'use strict';
4	if ( typeof $ !== 'function' ) {
5		if ( typeof jQuery === 'function' ) {
6			var $ = jQuery;
7		} else {
8			console.log(
9				'Social Warfare requires jQuery, or $ as an alias of jQuery. Please make sure your theme provides access to jQuery before activating Social Warfare.'
10			);
11			return;
12		}
13	}
14	function isString( maybeString ) {
15		return typeof maybeString === 'string' && maybeString.length > 0;
16	}
17	socialWarfare.paddingTop = parseInt( $( 'body' ).css( 'padding-top' ) );
18	socialWarfare.paddingBottom = parseInt(
19		$( 'body' ).css( 'padding-bottom' )
20	);
21	socialWarfare.initPlugin = function () {
22		$( 'body' ).css( {
23			paddingTop: socialWarfare.paddingTop,
24			paddingBottom: socialWarfare.paddingBottom,
25		} );
26		socialWarfare.establishPanels();
27		socialWarfare.establishBreakpoint();
28		if (
29			! socialWarfare.panels.staticHorizontal &&
30			! socialWarfare.panels.floatingSide &&
31			! socialWarfare.panels.floatingHorizontal
32		) {
33			return;
34		}
35		socialWarfare.emphasizeButtons();
36		socialWarfare.createFloatHorizontalPanel();
37		socialWarfare.positionFloatSidePanel();
38		socialWarfare.activateHoverStates();
39		socialWarfare.handleButtonClicks();
40		socialWarfare.updateFloatingButtons();
41		socialWarfare.closeLightboxOverlay();
42		socialWarfare.preloadPinterestImages();
43		if ( typeof swpPinIt === 'object' && swpPinIt.enabled == true ) {
44			socialWarfare.createHoverSaveButton();
45			socialWarfare.triggerImageListeners();
46		}
47		setTimeout( function () {
48			socialWarfare.checkListeners( 0, 5 );
49		}, 2e3 );
50		let time = Date.now();
51		const scrollDelay = 50;
52		$( window ).on( 'scroll', function () {
53			if ( time + scrollDelay - Date.now() < 0 ) {
54				socialWarfare.updateFloatingButtons();
55				time = Date.now();
56			}
57		} );
58	};
59	let resizeWait;
60	socialWarfare.onWindowResize = function () {
61		clearTimeout( resizeWait );
62		resizeWait = setTimeout( socialWarfare.initPlugin, 100 );
63	};
64	socialWarfare.establishPanels = function () {
65		socialWarfare.panels = {
66			staticHorizontal: null,
67			floatingSide: null,
68			floatingHorizontal: null,
69		};
70		socialWarfare.panels.staticHorizontal = $( '.swp_social_panel' ).not(
71			'.swp_social_panelSide'
72		);
73		socialWarfare.panels.floatingSide = $( '.swp_social_panelSide' );
74		return socialWarfare.panels;
75	};
76	socialWarfare.emphasizeButtons = function () {
77		if ( typeof socialWarfare.variables.emphasizeIcons === 'undefined' ) {
78			return;
79		}
80		if ( socialWarfare.isMobile() ) {
81			return;
82		}
83		jQuery( '.swp_social_panel:not(.swp_social_panelSide)' ).each(
84			function ( i, panel ) {
85				jQuery( panel )
86					.find( '.nc_tweetContainer:not(.total_shares)' )
87					.each( function ( index, button ) {
88						if ( index < socialWarfare.variables.emphasizeIcons ) {
89							const shareWidth = jQuery( button )
90								.find( '.swp_share' )
91								.width();
92							const iconWidth = jQuery( button )
93								.find( 'i.sw' )
94								.outerWidth();
95							const iconTextWidth = shareWidth + iconWidth + 35;
96							const containerWidth = jQuery( button ).width();
97							const change =
98								1 + ( shareWidth + 35 ) / containerWidth;
99							if ( change < 2 ) {
100								jQuery( button )
101									.addClass( 'swp_nohover' )
102									.css( { flex: '2 1 0%' } )
103									.find( '.iconFiller' )
104									.width( iconTextWidth );
105							} else {
106								jQuery( button )
107									.addClass( 'swp_nohover' )
108									.css( { flex: change + ' 1 0%' } )
109									.find( '.iconFiller' )
110									.width( iconTextWidth );
111							}
112						}
113					} );
114			}
115		);
116	};
117	socialWarfare.activateHoverStates = function () {
118		socialWarfare.trigger( 'pre_activate_buttons' );
119		$(
120			'.swp_social_panel:not(.swp_social_panelSide) .nc_tweetContainer'
121		).on( 'mouseenter', function () {
122			if ( $( this ).hasClass( 'swp_nohover' ) ) {
123				return;
124			}
125			socialWarfare.resetStaticPanel();
126			const termWidth = $( this ).find( '.swp_share' ).outerWidth();
127			const iconWidth = $( this ).find( 'i.sw' ).outerWidth();
128			const containerWidth = $( this ).width();
129			const change = 1 + ( termWidth + 35 ) / containerWidth;
130			$( this )
131				.find( '.iconFiller' )
132				.width( termWidth + iconWidth + 25 + 'px' );
133			$( this ).css( 'flex', change + ' 1 0%' );
134		} );
135		$( '.swp_social_panel:not(.swp_social_panelSide)' ).on(
136			'mouseleave',
137			socialWarfare.resetStaticPanel
138		);
139	};
140	socialWarfare.resetStaticPanel = function () {
141		$(
142			'.swp_social_panel:not(.swp_social_panelSide) .nc_tweetContainer:not(.swp_nohover) .iconFiller'
143		).removeAttr( 'style' );
144		$(
145			'.swp_social_panel:not(.swp_social_panelSide) .nc_tweetContainer:not(.swp_nohover)'
146		).removeAttr( 'style' );
147	};
148	socialWarfare.handleButtonClicks = function () {
149		$( '.nc_tweet, a.swp_CTT' ).off( 'click' );
150		$( '.nc_tweet, a.swp_CTT' ).on( 'click', function ( event ) {
151			if ( $( this ).parent( '.swp_print' ).length > 0 ) {
152				event.preventDefault();
153				window.print();
154				return;
155			}
156			if (
157				true === $( this ).hasClass( 'pinterest_multi_image_select' )
158			) {
159				event.preventDefault();
160				socialWarfare.openMultiPinterestOverlay( $( this ) );
161				return;
162			}
163			if ( $( this ).parent( '.swp_more' ).length > 0 ) {
164				event.preventDefault();
165				socialWarfare.openMoreOptions( $( this ) );
166				return;
167			}
168			if ( $( this ).hasClass( 'noPop' ) ) {
169				return event;
170			}
171			if (
172				'undefined' === typeof $( this ).data( 'link' ) &&
173				false === $( this ).is( '.swp-hover-pin-button' )
174			) {
175				return event;
176			}
177			event.preventDefault();
178			const href = $( this ).data( 'link' ).replace( '’', "'" );
179			let height, width, top, left, instance, windowAttributes, network;
180			height = 270;
181			width = 500;
182			if (
183				$( this ).is(
184					'.swp_pinterest a, .buffer_link a, .flipboard a, .swp-hover-pin-button'
185				)
186			) {
187				height = 550;
188				width = 775;
189			}
190			if ( $( this ).hasClass( 'nc_tweet' ) ) {
191				network = $( this )
192					.parents( '.nc_tweetContainer' )
193					.data( 'network' );
194			} else if ( $( this ).hasClass( 'swp_CTT' ) ) {
195				network = 'ctt';
196			}
197			top = window.screenY + ( window.innerHeight - height ) / 2;
198			left = window.screenX + ( window.innerWidth - width ) / 2;
199			windowAttributes =
200				'height=' +
201				height +
202				',width=' +
203				width +
204				',top=' +
205				top +
206				',left=' +
207				left;
208			instance = window.open( href, network, windowAttributes );
209			socialWarfare.trackClick( network );
210		} );
211	};
212	socialWarfare.openMultiPinterestOverlay = function ( element ) {
213		if ( $( '.pinterest-overlay' ).length > 0 ) {
214			$( '.pinterest-overlay' ).fadeIn();
215			$( '.swp-lightbox-inner' ).scrollTop( 0 );
216			return;
217		}
218		let html = '';
219		const pin_data = element.data( 'pins' );
220		let pin_images = '';
221		pin_data.images.forEach( function ( image ) {
222			const share_url =
223				'https://pinterest.com/pin/create/button/?url=' +
224				pin_data.url +
225				'&media=' +
226				image +
227				'&description=' +
228				encodeURIComponent( pin_data.description );
229			let pin_html = '';
230			pin_html += '<div class="pin_image_select_wrapper">';
231			pin_html += '<img class="pin_image" src="' + image + '" />';
232			pin_html +=
233				'<a class="swp-hover-pin-button" href="' +
234				share_url +
235				'" data-link="' +
236				share_url +
237				'">Save</a>';
238			pin_html += '</div>';
239			pin_images += pin_html;
240		} );
241		html +=
242			'<div class="swp-lightbox-wrapper pinterest-overlay"><div class="swp-lightbox-inner">';
243		html += '<i class="sw swp_pinterest_icon top_icon"></i>';
244		html += '<div class="swp-lightbox-close"></div>';
245		html += '<h5>Which image would you like to pin?</h5>';
246		html += '<div class="pin_images_wrapper">';
247		html += pin_images;
248		html += '</div>';
249		html += socialWarfare.buildPoweredByLink();
250		html += '</div></div>';
251		$( 'body' ).append( html );
252		$( '.pinterest-overlay' ).hide().fadeIn();
253		socialWarfare.handleButtonClicks();
254		let max_height = 999999;
255		let iteration = 0,
256			images = $( '.pinterest-overlay .pin_images_wrapper img' );
257		images.load( function () {
258			if ( ++iteration === images.length ) {
259				images
260					.each( function () {
261						if ( $( this ).height() < max_height ) {
262							max_height = $( this ).height();
263						}
264					} )
265					.promise()
266					.done( function () {
267						images.height( max_height + 'px' );
268						const number_of_rows = Math.ceil( images.length / 4 );
269						for ( i = 0; i < number_of_rows; i++ ) {
270							const current_row_images = images.slice(
271								i * 4,
272								i * 4 + 4
273							);
274							var max_allowable_width =
275								current_row_images.length / 4;
276							var total_width = $(
277								'.pin_images_wrapper'
278							).width();
279							var total_images_width = 0;
280							current_row_images.each( function () {
281								total_images_width =
282									total_images_width + $( this ).width();
283							} );
284							var ratio = total_width / total_images_width;
285							current_row_images.each( function () {
286								const new_width =
287									( ( $( this ).width() * ratio ) /
288										total_width ) *
289										100 *
290										max_allowable_width -
291									1;
292								$( this )
293									.parent()
294									.width( new_width + '%' );
295								$( this ).height( 'auto' );
296							} );
297							var height = current_row_images.first().height();
298							current_row_images.each( function () {
299								$( this )
300									.width( $( this ).width() )
301									.height( height );
302							} );
303						}
304					} );
305			}
306		} );
307	};
308	socialWarfare.buildPoweredByLink = function () {
309		let html = '';
310		if ( true === socialWarfare.variables.powered_by_toggle ) {
311			let anchor_tag_open = '';
312			let anchor_tag_close = '';
313			if ( false !== socialWarfare.variables.affiliate_link ) {
314				anchor_tag_open =
315					'<a href="' +
316					socialWarfare.variables.affiliate_link +
317					'" target="_blank">';
318				anchor_tag_close = '</a>';
319			}
320			html =
321				'<div class="swp_powered_by">' +
322				anchor_tag_open +
323				'<span>Powered by</span> <img src="/wp-content/plugins/social-warfare/assets/images/admin-options-page/social-warfare-pro-light.png">' +
324				anchor_tag_close +
325				'</div>';
326		}
327		return html;
328	};
329	socialWarfare.preloadPinterestImages = function () {
330		if ( $( '.pinterest_multi_image_select' ).length < 1 ) {
331			return;
332		}
333		const pin_data = $( '.pinterest_multi_image_select' ).data( 'pins' );
334		pin_data.images.forEach( function ( image_url ) {
335			const image_object = new Image();
336			image_object.src = image_url;
337		} );
338	};
339	socialWarfare.openMoreOptions = function ( element ) {
340		if ( $( '.swp-more-wrapper' ).length > 0 ) {
341			$( '.swp-more-wrapper' ).fadeIn();
342			return;
343		}
344		const post_id = element
345			.parents( '.swp_social_panel' )
346			.data( 'post-id' );
347		const data = {
348			action: 'swp_buttons_panel',
349			post_id,
350			_ajax_nonce: swp_nonce,
351		};
352		jQuery.post( swp_ajax_url, data, function ( response ) {
353			$( 'body' ).append( response );
354			$( '.swp-lightbox-wrapper' ).hide().fadeIn();
355			socialWarfare.activateHoverStates();
356			socialWarfare.handleButtonClicks();
357		} );
358	};
359	socialWarfare.closeLightboxOverlay = function () {
360		$( 'body' ).on( 'click', '.swp-lightbox-close', function () {
361			$( '.swp-lightbox-wrapper' ).fadeOut();
362		} );
363		$( document ).on( 'keyup', function ( e ) {
364			if ( e.key === 'Escape' ) {
365				$( '.swp-lightbox-wrapper' ).fadeOut();
366			}
367		} );
368	};
369	socialWarfare.createFloatHorizontalPanel = function () {
370		if ( ! socialWarfare.panels.staticHorizontal.length ) {
371			return;
372		}
373		const floatLocation =
374			socialWarfare.panels.staticHorizontal.data( 'float' );
375		const mobileFloatLocation =
376			socialWarfare.panels.staticHorizontal.data( 'float-mobile' );
377		const backgroundColor =
378			socialWarfare.panels.staticHorizontal.data( 'float-color' );
379		const wrapper = $(
380			'<div class="nc_wrapper swp_floating_horizontal_wrapper" style="background-color:' +
381				backgroundColor +
382				'"></div>'
383		);
384		let barLocation = '';
385		if ( $( '.nc_wrapper' ).length ) {
386			$( '.nc_wrapper' ).remove();
387		}
388		if ( $( '.swp_floating_horizontal_wrapper' ).length ) {
389			$( '.swp_floating_horizontal_wrapper' ).remove();
390		}
391		if (
392			floatLocation != 'top' &&
393			floatLocation != 'bottom' &&
394			mobileFloatLocation != 'top' &&
395			mobileFloatLocation != 'bottom'
396		) {
397			return;
398		}
399		if ( socialWarfare.isMobile() ) {
400			barLocation = mobileFloatLocation;
401		} else {
402			barLocation = floatLocation;
403		}
404		wrapper.addClass( barLocation ).hide().appendTo( 'body' );
405		socialWarfare.panels.floatingHorizontal =
406			socialWarfare.panels.staticHorizontal.first().clone();
407		socialWarfare.panels.floatingHorizontal
408			.addClass( 'nc_floater' )
409			.appendTo( wrapper );
410		socialWarfare.updateFloatingHorizontalDimensions();
411		$( '.swp_social_panel .swp_count' ).css( {
412			transition: 'padding .1s linear',
413		} );
414	};
415	socialWarfare.updateFloatingHorizontalDimensions = function () {
416		if ( ! socialWarfare.panels.staticHorizontal.length ) {
417			return;
418		}
419		if ( ! socialWarfare.panels.floatingHorizontal ) {
420			return;
421		}
422		let width = '100%';
423		let left = 0;
424		const panel = socialWarfare.panels.staticHorizontal;
425		let parent = panel.parent();
426		if ( parent.hasClass( 'swp-hidden-panel-wrap' ) ) {
427			parent = parent.parent();
428		}
429		if ( 'undefined' !== typeof panel.offset().left ) {
430			left = panel.offset().left;
431		}
432		if ( 'undefined' !== typeof panel.width() ) {
433			width = panel.width();
434		}
435		if ( left == 0 ) {
436			left = parent.offset().left;
437		}
438		if ( width == 100 || width == 0 ) {
439			width = parent.width();
440		}
441		socialWarfare.panels.floatingHorizontal.css( {
442			width,
443			left,
444		} );
445	};
446	socialWarfare.staticPanelIsVisible = function () {
447		let visible = false;
448		const scrollPos = $( window ).scrollTop();
449		$( '.swp_social_panel' )
450			.not( '.swp_social_panelSide, .nc_floater' )
451			.each( function ( index ) {
452				const offset = $( this ).offset();
453				if (
454					typeof socialWarfare.floatBeforeContent !== 'undefined' &&
455					'1' != socialWarfare.floatBeforeContent
456				) {
457					const theContent = $( '.swp-content-locator' ).parent();
458					if (
459						index === 0 &&
460						theContent.length &&
461						theContent.offset().top >
462							scrollPos + $( window ).height()
463					) {
464						visible = true;
465					}
466				}
467				if (
468					$( this ).is( ':visible' ) &&
469					offset.top + $( this ).height() > scrollPos &&
470					offset.top < scrollPos + $( window ).height()
471				) {
472					visible = true;
473				}
474			} );
475		return visible;
476	};
477	socialWarfare.updateFloatingButtons = function () {
478		if ( socialWarfare.panels.staticHorizontal.length ) {
479			var panel = socialWarfare.panels.staticHorizontal;
480		} else if ( socialWarfare.panels.floatingSide.length ) {
481			var panel = socialWarfare.panels.floatingSide;
482		} else {
483			return;
484		}
485		var location = panel.data( 'float' );
486		if ( true == socialWarfare.isMobile() ) {
487			var location = panel.data( 'float-mobile' );
488		}
489		if ( location == 'none' ) {
490			return $(
491				'.nc_wrapper, .swp_floating_horizontal_wrapper, .swp_social_panelSide'
492			).hide();
493		}
494		if ( socialWarfare.isMobile() ) {
495			socialWarfare.toggleMobileButtons();
496			socialWarfare.toggleFloatingHorizontalPanel();
497			return;
498		}
499		if ( location == 'right' || location == 'left' ) {
500			socialWarfare.toggleFloatingVerticalPanel();
501		}
502		if ( location == 'bottom' || location == 'top' ) {
503			socialWarfare.toggleFloatingHorizontalPanel();
504		}
505	};
506	socialWarfare.toggleMobileButtons = function () {
507		socialWarfare.panels.floatingSide.hide();
508		const visibility = socialWarfare.staticPanelIsVisible()
509			? 'collapse'
510			: 'visible';
511		$( '.nc_wrapper, .swp_floating_horizontal_wrapper' ).css(
512			'visibility',
513			visibility
514		);
515	};
516	socialWarfare.toggleFloatingVerticalPanel = function () {
517		let direction = '';
518		const location = socialWarfare.panels.floatingSide.data( 'float' );
519		let visible = socialWarfare.staticPanelIsVisible();
520		let offset = '';
521		if ( socialWarfare.isMobile() ) {
522			return socialWarfare.panels.floatingSide.hide();
523		}
524		if (
525			! socialWarfare.panels.floatingSide ||
526			! socialWarfare.panels.floatingSide.length
527		) {
528			visible = true;
529		}
530		if (
531			socialWarfare.panels.floatingSide.data( 'transition' ) == 'slide'
532		) {
533			direction = location;
534			offset = visible ? '-150px' : '5px';
535			socialWarfare.panels.floatingSide.css( direction, offset ).show();
536		} else if ( visible ) {
537			socialWarfare.panels.floatingSide
538				.css( 'opacity', 1 )
539				.fadeOut( 300 )
540				.css( 'opacity', 0 );
541		} else {
542			socialWarfare.panels.floatingSide
543				.css( 'opacity', 0 )
544				.fadeIn( 300 )
545				.css( 'display', 'flex' )
546				.css( 'opacity', 1 );
547		}
548	};
549	socialWarfare.hasReferencePanel = function () {
550		return (
551			typeof socialWarfare.panels.staticHorizontal !== 'undefined' &&
552			socialWarfare.panels.staticHorizontal.length > 0
553		);
554	};
555	socialWarfare.toggleFloatingHorizontalPanel = function () {
556		if ( ! socialWarfare.hasReferencePanel() ) {
557			return;
558		}
559		if ( ! socialWarfare.panels.floatingHorizontal ) {
560			return;
561		}
562		const panel = socialWarfare.panels.floatingHorizontal.first();
563		const location = socialWarfare.isMobile()
564			? $( panel ).data( 'float-mobile' )
565			: $( panel ).data( 'float' );
566		let newPadding =
567			location == 'bottom'
568				? socialWarfare.paddingBottom
569				: socialWarfare.paddingTop;
570		const paddingProp = 'padding-' + location;
571		if ( location == 'off' ) {
572			return;
573		}
574		if ( socialWarfare.staticPanelIsVisible() ) {
575			$( '.nc_wrapper, .swp_floating_horizontal_wrapper' ).hide();
576			if ( socialWarfare.isMobile() && $( '#wpadminbar' ).length ) {
577				$( '#wpadminbar' ).css( 'top', 0 );
578			}
579		} else {
580			newPadding += 50;
581			$( '.nc_wrapper, .swp_floating_horizontal_wrapper' ).show();
582			if (
583				socialWarfare.isMobile() &&
584				location == 'top' &&
585				$( '#wpadminbar' ).length
586			) {
587				$( '#wpadminbar' ).css( 'top', panel.parent().height() );
588			}
589		}
590		$( 'body' ).css( paddingProp, newPadding );
591	};
592	socialWarfare.positionFloatSidePanel = function () {
593		let panelHeight, windowHeight, offset;
594		const sidePanel = socialWarfare.panels.floatingSide;
595		if ( ! sidePanel || ! sidePanel.length ) {
596			return;
597		}
598		if (
599			sidePanel.hasClass( 'swp_side_top' ) ||
600			sidePanel.hasClass( 'swp_side_bottom' )
601		) {
602			return;
603		}
604		panelHeight = sidePanel.outerHeight();
605		windowHeight = window.innerHeight;
606		if ( panelHeight > windowHeight ) {
607			return sidePanel.css( 'top', 0 );
608		}
609		offset = ( windowHeight - panelHeight ) / 2;
610		sidePanel.css( 'top', offset );
611	};
612	socialWarfare.createHoverSaveButton = function () {
613		if ( $( '.tve_editor_page' ).length ) {
614			$( '.sw-pinit-button' ).remove();
615			$( '.sw-pinit' ).each( function () {
616				const inner_content = $( '.sw-pinit' ).contents();
617				$( this ).replaceWith( inner_content );
618			} );
619			return;
620		}
621		const button = $( document.createElement( 'a' ) );
622		button.css( 'display: none' );
623		button.addClass( 'swp-hover-pin-button' );
624		button.text( 'Save' );
625		socialWarfare.hoverSaveButton = $( button );
626		return button;
627	};
628	socialWarfare.triggerImageListeners = function () {
629		$( '.swp-content-locator' )
630			.parent()
631			.find( 'img' )
632			.off( 'mouseenter', socialWarfare.renderPinterestSaveButton );
633		$( '.swp-content-locator' )
634			.parent()
635			.find( 'img' )
636			.on( 'mouseenter', socialWarfare.renderPinterestSaveButton );
637		setTimeout( socialWarfare.triggerImageListeners, 2e3 );
638	};
639	socialWarfare.getPinMedia = function ( image ) {
640		if ( isString( swpPinIt.image_source ) ) {
641			return swpPinIt.image_source;
642		}
643		if ( isString( image.attr( 'src' ) ) ) {
644			return image.attr( 'src' );
645		}
646		const dataSources = [ 'src', 'lazy-src', 'media' ];
647		let media = '';
648		dataSources.some( function ( maybeSource ) {
649			if ( isString( image.data( maybeSource ) ) ) {
650				media = image.data( maybeSource );
651				return true;
652			}
653		} );
654		if ( media == '' ) {
655			return;
656		}
657		const i = $( '<img>' );
658		i.attr( 'src', media );
659		return i.prop( 'src' );
660	};
661	socialWarfare.getPinDescription = function ( image ) {
662		if ( isString( image.data( 'pin-description' ) ) ) {
663			return image.data( 'pin-description' );
664		}
665		if ( isString( swpPinIt.image_description ) ) {
666			return swpPinIt.image_description;
667		}
668		if ( isString( image.attr( 'title' ) ) ) {
669			return image.attr( 'title' );
670		}
671		if ( isString( image.attr( 'alt' ) ) ) {
672			return image.attr( 'alt' );
673		}
674		if ( isString( swpPinIt.post_title ) ) {
675			return swpPinIt.post_title;
676		}
677	};
678	socialWarfare.enablePinterestSaveButtons = function () {
679		jQuery( 'img' ).on( 'mouseenter', function () {
680			const pinterestBrowserButtons =
681				socialWarfare.findPinterestBrowserSaveButtons();
682			if (
683				typeof pinterestBrowserButtons !== 'undefined' &&
684				pinterestBrowserButtons
685			) {
686				socialWarfare.removePinterestBrowserSaveButtons(
687					pinterestBrowserButtons
688				);
689			}
690		} );
691	};
692	socialWarfare.toggleHoverSaveDisplay = function ( image ) {
693		let top = image.offset().top;
694		let left = image.offset().left;
695		const vMargin = 15;
696		const hMargin = 15;
697		const button_size = swpPinIt.button_size || 1;
698		const buttonHeight = 24;
699		const buttonWidth = 120;
700		switch ( swpPinIt.vLocation ) {
701			case 'top':
702				top += vMargin;
703				break;
704			case 'middle':
705				var offset =
706					image.height() / 2 - vMargin / 2 - buttonHeight / 2;
707				top += offset;
708				break;
709			case 'bottom':
710				top += image.height() - vMargin - buttonHeight;
711				break;
712		}
713		switch ( swpPinIt.hLocation ) {
714			case 'left':
715				left += hMargin;
716				break;
717			case 'center':
718				var offset = image.width() / 2 - hMargin / 2 - buttonWidth / 2;
719				left += offset;
720				break;
721			case 'right':
722				left += image.width() - hMargin - buttonWidth;
723				break;
724		}
725		socialWarfare.hoverSaveButton.css( {
726			top,
727			left,
728			transform: 'scale(' + button_size + ')',
729			'transform-origin': swpPinIt.vLocation + ' ' + swpPinIt.hLocation,
730		} );
731		image.on( 'mouseleave', function ( event ) {
732			if (
733				event.relatedTarget != null &&
734				event.relatedTarget.className == 'swp-hover-pin-button'
735			) {
736				return;
737			}
738			$( '.swp-hover-pin-button' ).remove();
739		} );
740		$( document.body ).append( socialWarfare.hoverSaveButton );
741	};
742	socialWarfare.renderPinterestSaveButton = function ( event ) {
743		if (
744			event.relatedTarget &&
745			event.relatedTarget.className == 'swp-hover-pin-button'
746		) {
747			return;
748		}
749		if ( $( '.swp-hover-pin-button' ).length > 0 ) {
750			return;
751		}
752		const image = $( event.target );
753		if (
754			typeof swpPinIt.disableOnAnchors !== undefined &&
755			swpPinIt.disableOnAnchors
756		) {
757			if ( image.parents().filter( 'a' ).length ) {
758				return;
759			}
760		}
761		if (
762			image.outerHeight() < swpPinIt.minHeight ||
763			image.outerWidth() < swpPinIt.minWidth
764		) {
765			return;
766		}
767		if ( image.hasClass( 'no_pin' ) || image.hasClass( 'no-pin' ) ) {
768			return;
769		}
770		socialWarfare.toggleHoverSaveDisplay( image );
771		const description = socialWarfare.getPinDescription( image );
772		const media = socialWarfare.getPinMedia( image );
773		const shareLink =
774			'http://pinterest.com/pin/create/bookmarklet/?media=' +
775			encodeURI( media ) +
776			'&url=' +
777			encodeURI( document.URL ) +
778			'&is_video=false' +
779			'&description=' +
780			encodeURIComponent( description );
781		function openPinterestDialogue( event ) {
782			const offsetLeft = ( $( window ).width() - 775 ) / 2;
783			const offsetTop = ( $( window ).height() - 550 ) / 2;
784			const position = ',top=' + offsetTop + ',left=' + offsetLeft;
785			window.open(
786				shareLink,
787				'Pinterest',
788				'width=775,height=550,status=0,toolbar=0,menubar=0,location=1,scrollbars=1' +
789					position
790			);
791			socialWarfare.trackClick( 'pin_image' );
792			$( '.swp-hover-pin-button' ).remove();
793		}
794		$( '.swp-hover-pin-button' ).on( 'click', openPinterestDialogue );
795	};
796	socialWarfare.findPinterestBrowserSaveButtons = function () {
797		let pinterestRed,
798			pinterestRed2019,
799			pinterestZIndex,
800			pinterestBackgroundSize,
801			button,
802			style;
803		pinterestRed = 'rgb(189, 8, 28)';
804		pinterestRed2019 = 'rgb(230, 0, 35)';
805		pinterestZIndex = '8675309';
806		pinterestBackgroundSize = '14px 14px';
807		button = null;
808		document
809			.querySelectorAll( 'span' )
810			.forEach( function ( element, index ) {
811				style = window.getComputedStyle( element );
812				if (
813					style.backgroundColor == pinterestRed ||
814					style.backgroundColor == pinterestRed2019
815				) {
816					if (
817						style.backgroundSize == pinterestBackgroundSize &&
818						style.zIndex == pinterestZIndex
819					) {
820						button = element;
821					}
822				}
823			} );
824		return button;
825	};
826	socialWarfare.removePinterestBrowserSaveButtons = function ( button ) {
827		let pinterestSquare, style, size;
828		pinterestSquare = button.nextSibling;
829		if (
830			pinterestSquare != undefined &&
831			pinterestSquare.nodeName == 'SPAN'
832		) {
833			style = window.getComputedStyle( pinterestSquare );
834			size = '24px';
835			if (
836				style.width.indexOf( size ) === 0 &&
837				style.height.indexOf( size ) === 0
838			) {
839				pinterestSquare.remove();
840			}
841		}
842		button.remove();
843	};
844	socialWarfare.fetchFacebookShares = function () {
845		const url1 =
846			'https://graph.facebook.com/v18.0/?fields=og_object{engagement}&id=' +
847			swp_post_url;
848		const url2 = swp_post_recovery_url
849			? 'https://graph.facebook.com/v18.0/?fields=og_object{engagement}&id=' +
850			  swp_post_recovery_url
851			: '';
852		console.log( 'Facebook Share API: ' + url1 );
853		console.log( 'Facebook Share API (recovery): ' + url2 );
854		$.when( $.get( url1 ), $.get( url2 ) ).then(
855			function ( response1, response2 ) {
856				var shares, shares1, shares2, data;
857				shares1 = socialWarfare.parseFacebookShares( response1[ 0 ] );
858				shares2 = 0;
859				if ( swp_post_recovery_url ) {
860					shares2 = socialWarfare.parseFacebookShares(
861						response2[ 0 ]
862					);
863				}
864				shares = shares1;
865				if ( shares1 !== shares2 ) {
866					shares = shares1 + shares2;
867				}
868				var data = {
869					action: 'swp_facebook_shares_update',
870					post_id: swp_post_id,
871					share_counts: shares,
872				};
873				$.post( swp_admin_ajax, data, function ( response ) {
874					console.log( response );
875				} );
876			}
877		);
878	};
879	socialWarfare.parseFacebookShares = function ( response ) {
880		if ( 'undefined' === typeof response.og_object ) {
881			console.log( 'Facebook Shares: 0' );
882			return 0;
883		}
884		console.log(
885			'Facebook Shares: ' + response.og_object.engagement.count
886		);
887		return parseInt( response.og_object.engagement.count );
888	};
889	socialWarfare.trigger = function ( event ) {
890		$( window ).trigger( $.Event( event ) );
891	};
892	socialWarfare.trackClick = function ( event ) {
893		if ( true === swpClickTracking ) {
894			if ( 'function' === typeof ga ) {
895				ga(
896					'send',
897					'event',
898					'social_media',
899					'swp_' + event + '_share'
900				);
901			}
902			if ( 'object' === typeof dataLayer ) {
903				dataLayer.push( { event: 'swp_' + event + '_share' } );
904			}
905		}
906	};
907	socialWarfare.checkListeners = function ( count, limit ) {
908		if ( count > limit ) {
909			return;
910		}
911		const panel = $( '.swp_social_panel' );
912		if ( panel.length > 0 && panel.find( '.swp_pinterest' ) ) {
913			socialWarfare.handleButtonClicks();
914			return;
915		}
916		setTimeout( function () {
917			socialWarfare.checkListeners( ++count, limit );
918		}, 2e3 );
919	};
920	socialWarfare.establishBreakpoint = function () {
921		const panel = $( '.swp_social_panel' );
922		socialWarfare.breakpoint = 1100;
923		if (
924			( panel.length && panel.data( 'min-width' ) ) ||
925			panel.data( 'min-width' ) == 0
926		) {
927			socialWarfare.breakpoint = parseInt( panel.data( 'min-width' ) );
928		}
929	};
930	socialWarfare.isMobile = function () {
931		return $( window ).width() < socialWarfare.breakpoint;
932	};
933	$( document ).ready( function () {
934		socialWarfare.initPlugin();
935		socialWarfare.panels.floatingSide.hide();
936		$( window ).on( 'resize', socialWarfare.onWindowResize );
937		if ( 'undefined' !== typeof swpPinIt && swpPinIt.enabled ) {
938			socialWarfare.enablePinterestSaveButtons();
939		}
940	} );
941	$( window ).on( 'load', function () {
942		if ( 'undefined' !== typeof swpPinIt && swpPinIt.enabled ) {
943			socialWarfare.enablePinterestSaveButtons();
944		}
945		window.clearCheckID = 0;
946	} );
947} )( this, jQuery );
948//# sourceMappingURL=script.min.js.map

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.