PageSourceSearch

https://thedig.nz/wp-content/plugins/powerkit/modules/pinterest/public/js/public-powerkit-pin-it.js?ver=1.8.2

js thedig.nz collected 2026-10-06 13:29:25 UTC 4,707 bytes, 167 lines download raw bytes

1/**
2 * Pin It
3 */
4( function( $ ) {
5
6	$.fn.powerkitPinIt = function() {
7
8		$( this ).each( function() {
9
10			if ( $( this ).hasClass( 'pk-pin-it-ready' ) ) {
11				return;
12			}
13
14			var width  = $( this ).attr( 'width' );
15			var height = $( this ).attr( 'height' );
16
17			if ( typeof width === 'undefined' ) {
18				width = $( this ).width();
19			}
20
21			if ( typeof height === 'undefined' ) {
22				height = $( this ).height();
23			}
24
25			if ( !( parseInt( width ) > 120 && parseInt( height ) > 120 ) ) {
26				$( this ).addClass( 'pk-pin-it-ready' );
27				return;
28			}
29
30			var container = $( this ).parent(),
31				postURL = $( location ).attr( 'href' ),
32				pinURL;
33
34			if ( $( container ).is( 'a' ) ) {
35
36				var imagehref = $( container ).attr( 'href' );
37
38				if ( typeof imagehref !== 'undefined' && imagehref.match( /\.(gif|jpeg|jpg|png)/ ) ) {
39					pinURL = imagehref;
40				}
41
42				if ( !( $( container ).closest( 'figure' ).length ) ) {
43					$( container ).wrap( '<figure class="pk-pin-it-container"></figure>' );
44				}
45
46				container = $( container ).parent();
47
48			} else {
49
50				if ( !( $( container ).is( 'figure' ) || $( container ).closest( 'figure' ).length ) ) {
51					$( this ).wrap( '<figure class="pk-pin-it-container"></figure>' );
52				}
53
54				container = $( this ).parent();
55
56			}
57
58			if ( !$( this ).closest( 'figure' ).hasClass( 'pk-pin-it-container' ) ) {
59				$( this ).closest( 'figure' ).addClass( 'pk-pin-it-container' );
60			}
61
62			if ( ! pinURL ) {
63				if ( $( this ).is( 'img' ) ) {
64					pinURL = ( typeof $( this ).data( 'pk-src' ) !== 'undefined' ) ? $( this ).data( 'pk-src' ) : $( this ).attr( 'src' );
65				} else {
66					pinURL = ( typeof $( container ).find( 'img' ).data( 'src' ) !== 'undefined' ) ? $( container ).find( 'img' ).data( 'src' ) : $( container ).find( 'img' ).attr( 'src' );
67				}
68			}
69
70			pinURL = encodeURIComponent( pinURL );
71			postURL = encodeURIComponent( postURL );
72
73			var figure = container;
74
75			if ( !$( container ).is( 'figure' ) ) {
76				figure = $( container ).closest( 'figure' );
77			}
78
79			// Get caption text.
80			var imgDescription = $( figure ).find( '.wp-caption-text' ).text();
81
82			if ( !imgDescription ) {
83				// Get image alt attribute if there's no caption.
84				imgDescription = $( figure ).find( 'img' ).attr( 'alt' );
85			}
86
87			if ( imgDescription ) {
88				// Add attribute to share URL.
89				imgDescription = '&amp;description=' + encodeURIComponent( imgDescription );
90			}
91
92			// Img classes.
93			var imgClasses = [ 'alignnone', 'aligncenter', 'alignleft', 'alignright' ];
94
95			imgClasses.forEach( function( el ) {
96				if ( $( container ).find( 'img' ).hasClass( el ) ) {
97					$( container ).find( 'img' ).removeClass( el );
98					$( container ).find( 'img' ).closest( 'figure' ).addClass( el );
99
100					// Add width to figure.
101					var imgWidth = $( container ).find( 'img' ).attr( 'width' );
102
103					if ( parseInt( imgWidth ) !== 'NaN' ) {
104						$( container ).find( 'img' ).closest( 'figure' ).width( imgWidth );
105					}
106				}
107			} );
108
109			// Add func PintIt.
110			var addPowerkitPintIt = function( container ) {
111				if ( ! $( container ).find( '.pk-pin-it' ).length ) {
112					$( '<a class="pk-pin-it" href="http://www.pinterest.com/pin/create/bookmarklet/?url=' + postURL + '&amp;media=' + pinURL + imgDescription + '&is_video=false" target="_blank"><span>Pin</span><span><i class="pk-icon pk-icon-pinterest"></i></span></a>' )
113						.appendTo( container )
114						.addClass( 'pk-pin-it-visible' );
115				}
116			}
117
118			// PintIt Mode.
119			if ( powerkit_pinit_localize.only_hover ) {
120
121				$( container ).mousemove(function(){
122					addPowerkitPintIt( this );
123				});
124
125				$( container ).mouseleave(function(){
126					var $this = this;
127
128					$( $this ).children( '.pk-pin-it' ).fadeOut( 200, function(){
129						$( $this ).children( '.pk-pin-it' ).remove();
130					});
131				});
132
133			} else {
134				addPowerkitPintIt( container );
135			}
136
137			$( this ).addClass( 'pk-pin-it-ready' );
138		} );
139	};
140
141
142	function initPowerkitPinIt() {
143
144		// Exclude.
145		var filterPowerkitPinIt = function() {
146			var exclude = powerkit_pinit_localize.exclude_selectors;
147			if ( exclude ) {
148				if ( $( this ).closest( exclude ).length > 0 ) {
149					return false;
150				}
151			}
152			return true;
153		}
154
155		// Init.
156		$( powerkit_pinit_localize.image_selectors ).imagesLoaded( function() {
157			$( powerkit_pinit_localize.image_selectors ).filter( filterPowerkitPinIt ).powerkitPinIt();
158		} );
159	}
160
161	$( document ).ready( function() {
162		initPowerkitPinIt();
163		$( document.body ).on( 'post-load image-load', function() {
164			initPowerkitPinIt();
165		} );
166	} );
167} )( jQuery );

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.