PageSourceSearch

https://inforegulator.org.za/wp-content/plugins/wp-photo-album-plus/js/wppa-popup.js?ver=250824-73212

js inforegulator.org.za collected 2026-09-24 20:19:05 UTC 7,094 bytes, 180 lines download raw bytes

1// wppa-popup.js
2//
3// Contains popup modules
4// Dependancies: wppa.js and default wp $ library
5//
6var wppaJsPopupVersion = '9.0.11.006';
7
8jQuery(document).on('click',function(){wppaPopDown()});
9var wppaSkipPop = false;
10
11// Popup of thumbnail images
12function wppaPopUp( mocc, elm, id, name, desc, rating, ncom, videohtml, maxsizex, maxsizey ) {
13
14	if ( wppaSkipPop ) {
15		wppaSkipPop = false;
16		return;
17	}
18
19	// Before we start, make sure old popups vanish
20	wppaPopDown();
21
22	// Find all we need
23	var topDivBig, topDivSmall, leftDivBig, leftDivSmall;
24	var heightImgBig, heightImgSmall, widthImgBig, widthImgSmall;
25	var imghtml;
26	var areaWidth 	= jQuery( '#wppa-thumb-area-'+mocc ).width();
27	var namediv 	= name ? '<div id="wppa-name-'+mocc+'" style="display:none; padding:1px;" class="wppa_pu_info">'+name+'</div>' : '';
28	var descdiv 	= desc ? '<div id="wppa-desc-'+mocc+'" style="clear:both; display:none; padding:1px;" class="wppa_pu_info">'+desc+'</div>' : '';
29	var ratediv 	= rating ? '<div id="wppa-rat-'+mocc+'" style="clear:both; display:none; padding:1px;" class="wppa_pu_info">'+rating+'</div>' : '';
30	var ncomdiv 	= ncom ? '<div id="wppa-ncom-'+mocc+'" style="clear:both; display:none; padding:1px;" class="wppa_pu_info">'+ncom+'</div>' : '';
31	var popuptext 	= namediv+descdiv+ratediv+ncomdiv;
32	var elmCursor 	= jQuery( elm ).css('cursor');
33	var target 		= wppaThumbTargetBlank ? ' target="_blank"' : '';
34
35	var href = jQuery(elm).parent().attr('href');
36
37	imghtml = href ? '<a href="'+href+'" >' : '';
38	imghtml += videohtml != '' ? videohtml : '<img id="wppa-img-'+mocc+'" src="'+elm.src+'" title="" style="border-width: 0px;" />';
39	imghtml += href ? '</a>' : '';
40	jQuery( '#wppa-popup-'+mocc ).html( '<div class="wppa-popup" style="background-color:'+wppaBackgroundColorImage+';box-sizing:content-box;text-align:center;">'+imghtml+popuptext+'</div>' );
41	if ( wppaThumbNolink ) {
42		jQuery( '.wppa-popup' ).on( 'click', function(){wppaStopProp(event)} );
43	}
44	else {
45		jQuery( '.wppa-popup' ).on( 'click', function(){wppaSkipPop=true;jQuery(elm).trigger('click');return false;});
46	}
47	jQuery( '.wppa-popup' ).css({cursor:elmCursor});
48
49	// Compute ending sizes
50	widthImgBig = parseInt(maxsizex);
51	heightImgBig = parseInt(maxsizey);
52
53	// Set width of text fields to width of image
54	jQuery( ".wppa-popup" ).css({width:elm.clientWidth});
55
56	// Compute starting coords
57	leftDivSmall = parseInt( elm.offsetLeft ) - 7 - 5;
58	topDivSmall = parseInt( elm.offsetTop ) - 7 - 2;
59
60	// Is it masonry plus?
61	if ( jQuery( '#grid-item-'+mocc+'-'+id ).length ) {
62		leftDivSmall += parseInt( jQuery( '#grid-item-'+mocc+'-'+id ).css( 'left' ) ) + 6;
63		topDivSmall += parseInt( jQuery( '#grid-item-'+mocc+'-'+id ).css( 'top' ) );
64	}
65
66	// Compute starting sizes
67	widthImgSmall = parseInt( elm.clientWidth );
68	heightImgSmall = parseInt( elm.clientHeight );
69
70	// Compute ending coords
71	leftDivBig = leftDivSmall - parseInt( ( widthImgBig - widthImgSmall ) / 2 );
72	if ( leftDivBig < 0 ) {
73		leftDivBig = 0;
74	}
75	if ( leftDivBig + widthImgBig + 16 > areaWidth ) {
76		leftDivBig = areaWidth - widthImgBig - 16;
77	}
78
79	topDivBig = topDivSmall - parseInt( ( heightImgBig - heightImgSmall ) / 2 );
80	if ( topDivBig < 0 ) {
81		topDivBig = 0;
82	}
83
84	// To fix a Chrome bug where a theme class effect is: max-width:100% causing the width not being animated:
85	jQuery( '#wppa-img-'+mocc ).css({maxWidth:widthImgBig});
86
87	// Setup starting properties
88	jQuery( '#wppa-popup-'+mocc ).css({marginLeft:leftDivSmall,marginTop:topDivSmall});
89	jQuery( '#wppa-img-'+mocc ).css({marginLeft:0,marginRight:0,width:widthImgSmall,height:heightImgSmall});
90
91	// Do the animation
92	var duration = 500;
93	wppaAnimate( '#wppa-popup-'+mocc, {marginLeft:leftDivBig,marginTop:topDivBig}, duration, wppaEasingPopup);
94	wppaAnimate( '#wppa-img-'+mocc, {width:widthImgBig,height:heightImgBig}, duration, wppaEasingPopup,
95		function(){
96			jQuery(this).on('touchend',function(){wppaPopDown()});
97			jQuery(this).on('click',function(e){e.stopPropagation})
98		});
99	wppaAnimate( '.wppa-popup', {width:widthImgBig}, duration, wppaEasingPopup);
100	wppaAnimate( '.wppa_pu_info', {width:widthImgBig}, duration, wppaEasingPopup, function(){jQuery( '.wppa_pu_info' ).show()});
101
102	// Hide rightclick optionally
103	wppaProtect();
104}
105
106// Dismiss all popups
107function wppaPopDown() {
108	jQuery( '.wppa-popup-frame' ).html( "" );
109	return;
110}
111
112var wppaFullPopupBusy = false;
113// Popup of fullsize image
114function wppaFullPopUp( mocc, id, url, xwidth, xheight, xname ) {
115
116	// To prevent double popups, set busy for 500 msec.
117	if ( wppaFullPopupBusy ) return;
118	wppaFullPopupBusy = true;
119	setTimeout( function(){wppaFullPopupBusy = false;}, 500 );
120
121	var xFactor = screen.width / ( xwidth + 14 );
122	var yFactor = screen.height / ( xheight + 80 );
123	var factor 	= Math.min( xFactor, yFactor ) * 0.9;
124
125	if ( factor < 1 ) {
126		xwidth *= factor;
127		xheight *= factor;
128	}
129
130	var height 	= xheight+80;
131	var width  	= xwidth+14;
132	var name 	= '';
133	var desc 	= '';
134	var elm 	= document.getElementById( 'i-'+id+'-'+mocc );
135	if ( elm ) {
136		name = elm.alt;
137		desc = elm.title;
138	}
139	var isPdf = url.substr( url.length - 4, url.length ) == '.pdf';
140
141	var d = new Date();
142	var time = d.getTime();
143
144	// Open new browser window
145	var wnd = window.open( '', 'Print-'+time, 'width='+width+', height='+height+', location=no, resizable=no, menubar=yes ' );
146
147	// Create the html
148	var result =
149	'<html>' +
150		'<head>' +
151			'<style>body{margin:0;padding:6px;
151background-color:'+wppaBackgroundColorImage+';text-align:center;}</style>' +
152			'<title>'+name+'</title>' +
153			'<script>function wppa_print() {' +
154				'document.getElementById( "wppa_printer" ).style.visibility="hidden";' +
155				'document.getElementById( "wppa_download" ).style.visibility="hidden";' +
156				'window.print();' +
157			'}</script>' +
158		'</head>' +
159		'<body>' +
160			'<div style="width:'+xwidth+'px;" >';
161				if ( isPdf ) {
162					result += '<iframe src="'+url+'" style="padding-bottom:6px;width:100%;height:'+(height-60)+'px;" ></iframe><br />';
163				}
164				else {
165					result += '<img src="'+url+'" style="width:'+xwidth+'px;height:'+xheight+'px;padding-bottom:6px;" /><br />';
166				}
167				result += '<div style="text-align:center">'+xname+'</div>';
168				if ( ! isPdf ) { // Pdf has its own print and download buttons
169					result +=
170					'<a href="'+url+'" download="'+xname+'" ><img src="'+wppaImageDirectory+'download.png" id="wppa_download" title="Download" style="position:absolute; top:6px; left:'+(xwidth-66)+'px; background-color:'+wppaBackgroundColorImage+'; padding: 2px; cursor:pointer;" /></a>' +
171					'<img src="'+wppaImageDirectory+'printer.png" id="wppa_printer" title="Print" style="position:absolute; top:6px; left:'+(xwidth-30)+'px; background-color:'+wppaBackgroundColorImage+'; padding: 2px; cursor:pointer;" onclick="wppa_print();" />';
172				}
173			result += '</div>' +
174		'</body>' +
175	'</html>';
176	wnd.document.write( result );
177
178	// Hide rightclick optionally
179	wppaProtect();
180}

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.