1// wppa-lightbox.js 2// 3// Conatins lightbox modules 4// Dependancies: wppa.js and default wp $ library 5// 6// 7var wppaJsLightboxVersion = '9.1.04.005'; 8var wppaOvlActivePanorama = 0; 9 10// Initial initialization 11jQuery(document).ready( function( e ) { 12 wppaInitOverlay(); 13}); 14 15// Window resize handler 16jQuery(document).ready(function(e) { 17 jQuery(window ).on('resize',function() { 18 wppaOvlResize(); 19 }); 20}); 21 22// Window orientationchange handler 23jQuery( window ).on('orientationchange',function() { 24 25 if ( wppaOvlOpen ) { 26 setTimeout( function(){ wppaOvlShowSame()}, 200 ); 27 } 28}); 29 30// Keyboard handler 31function wppaOvlKeyboardHandler( e ) { 32 33 var keycode; 34 var escapeKey; 35 36 if ( e == null ) { // ie 37 keycode = event.keyCode; 38 escapeKey = 27; 39 } else { // mozilla 40 keycode = e.keyCode; 41 escapeKey = 27; //e.DOM_VK_ESCAPE; 42 } 43 44 var key = String.fromCharCode( keycode ).toLowerCase(); 45 46 switch ( keycode ) { 47 case escapeKey: 48 wppaStopVideo( 0 ); 49 wppaStopAudio( 0 ); 50 wppaOvlHide(); 51 break; 52 case 37: 53 wppaOvlShowPrev(); 54 break; 55 case 39: 56 wppaOvlShowNext(); 57 break; 58 } 59 60 switch ( key ) { 61 case 'p': 62 wppaOvlShowPrev(); 63 break; 64 case 'n': 65 wppaOvlShowNext(); 66 break; 67 case 's': 68 wppaOvlStartStop(); 69 break; 70 case 'f': 71 wppaFsOn(); 72 break; 73 case 'q': 74 case 'x': 75 wppaStopVideo( 0 ); 76 wppaStopAudio( 0 ); 77 wppaOvlHide(); 78 break; 79 } 80 81 return false; 82} 83 84// Prepare the display of the lightbox overlay. 85// arg is either numeric ( index to current lightbox set ) or 86// 'this' for a single image or for the first of a set 87function wppaOvlShow( arg ) { 88 89 // To avoid conflicts with slideshows, pause them all and stop media execution 90 var i; 91 for ( i=0; i<wppaSlidePause.length; i++ ) { 92 wppaSlidePause[i]=true; 93 wppaStopVideo(i); 94 wppaStopAudio(i); 95 } 96 var panData; 97 var dotPos; 98 99 // Make sure background is present 100 jQuery( '#wppa-overlay-bg' ).css({display:'inline'}); 101 102 // Do the setup right after the invocation of the lightbox 103 if ( wppaOvlFirst ) { 104 105 // Prevent Weaver ii from hiding us 106 jQuery( '#weaver-final' ).removeClass( 'wvr-hide-bang' ); 107 108 // Install keyboard handler 109 if ( ! wppaKbHandlerInstalled ) { 110 jQuery(document).on( 'keydown', wppaOvlKeyboardHandler ); 111 wppaKbHandlerInstalled = true; 112 } 113 114 // Trigger lightbox open event 115 jQuery(window).trigger( 'wppalightboxstart' ); 116 117 } 118 119 // If arg = 'this', setup the array of data 120 if ( typeof( arg ) == 'object' ) { 121 122 // Init the set 123 wppaOvlIds = []; 124 wppaOvlUrls = []; 125 wppaOvlTitles = []; 126 wppaOvlAlts = []; 127 wppaOvlTypes = []; 128 wppaOvlVideoHtmls = []; 129 wppaOvlPosterUrls = []; 130 wppaOvlAudioHtmls = []; 131 wppaOvlPdfHtmls = []; 132 wppaOvlVideoNaturalWidths = []; 133 wppaOvlVideoNaturalHeights = []; 134 wppaOvlImgs = []; 135 wppaOvlIdx = 0; 136 wppaOvlPanoramaHtml = []; 137 wppaOvlPanoramaIds = []; 138 wppaOvlHasPanoramas = false; 139 140 // Do we use rel or data-rel? 141 var rel; 142 if ( arg.rel ) { 143 rel = arg.rel; 144 } 145 else if ( jQuery( arg ).attr( 'data-rel' ) ) { 146 rel = jQuery( arg ).attr( 'data-rel' ); 147 } 148 else { 149 rel = false; 150 } 151 152 // Are we in a set? 153 var temp = rel.split( '[' ); 154 155 // We are in a set if temp[1] is defined 156 if ( temp[1] ) { 157 var setname = temp[1]; 158 var anchors = jQuery( 'a' ); 159 var anchor; 160 var i, j = 0; 161 162 // Save the set 163 for ( i = 0; i < anchors.length; i++ ) { 164 anchor = anchors[i]; 165 if ( jQuery( anchor ).attr( 'data-rel' ) ) { 166 temp = jQuery( anchor ).attr( 'data-rel' ).split( "[" ); 167 } 168 else { 169 temp = false; 170 } 171 172 if ( temp.length > 1 ) { 173 if ( temp[0] == 'wppa' && temp[1] == setname ) { // Same set 174 wppaOvlUrls[j] = anchor.href; 175 if ( jQuery( anchor ).attr( 'data-lbtitle' ) ) { 176 wppaOvlTitles[j] = wppaRepairScriptTags( jQuery( anchor ).attr( 'data-lbtitle' ) ); 177 } 178 else { 179 wppaOvlTitles[j] = wppaRepairScriptTags( anchor.title ); 180 } 181 wppaOvlIds[j] = jQuery( anchor ).attr( 'data-id' ) ? jQuery( anchor ).attr( 'data-id' ) : '0'; 182 wppaOvlAlts[j] = jQuery( anchor ).attr( 'data-alt' ) ? jQuery( anchor ).attr( 'data-alt' ) : '';
183 wppaOvlVideoHtmls[j] = jQuery( anchor ).attr( 'data-videohtml' ) ? decodeURI( jQuery( anchor ).attr( 'data-videohtml' ) ) : ''; 184 wppaOvlPosterUrls[j] = jQuery( anchor ).attr( 'data-posterurl' ) ? decodeURI( jQuery( anchor ).attr( 'data-posterurl' ) ) : ''; 185 wppaOvlPdfHtmls[j] = jQuery( anchor ).attr( 'data-pdfhtml' ) ? decodeURI( jQuery( anchor ).attr( 'data-pdfhtml' ) ) : ''; 186 wppaOvlAudioHtmls[j] = jQuery( anchor ).attr( 'data-audiohtml' ) ? decodeURI( jQuery( anchor ).attr( 'data-audiohtml' ) ) : ''; 187 wppaOvlVideoNaturalWidths[j] = jQuery( anchor ).attr( 'data-videonatwidth' ) ? jQuery( anchor ).attr( 'data-videonatwidth' ) : ''; 188 wppaOvlVideoNaturalHeights[j] = jQuery( anchor ).attr( 'data-videonatheight' ) ? jQuery( anchor ).attr( 'data-videonatheight' ) : ''; 189 panData = jQuery( anchor ).attr( 'data-panorama' ) ? jQuery( anchor ).attr( 'data-panorama' ) : ''; 190 panType = jQuery( anchor ).attr( 'data-pantype' ) ? jQuery( anchor ).attr( 'data-pantype' ) : ''; 191 192 if ( panData.length > 0 ) { 193 wppaOvlHasPanoramas = true; 194 dotPos = panData.indexOf( '.' ); 195 wppaOvlPanoramaHtml[j] = panData.substr(dotPos+1); 196 wppaOvlPanoramaIds[j] = panData.substr(0,dotPos); 197 wppaOvlTypes[j] = panType; 198 } 199 else { 200 wppaOvlPanoramaHtml[j] = ''; 201 wppaOvlPanoramaIds[j] = 0; 202 wppaOvlTypes[j] = ''; 203 } 204 if ( wppaOvlPdfHtmls[j].length > 0 ) { 205 wppaOvlTypes[j] = 'document'; 206 } 207 208 // Is this the one we asked for? 209 // If its not a stub file, one can look at the arg.href (old method). 210 // So, now we look at data-pdfhtml, data-videohtml, data-audiohtml as well as arg.href 211 if ( decodeURI( jQuery( anchor ).attr( 'data-pdfhtml' ) ) == decodeURI( jQuery( arg ).attr( 'data-pdfhtml' ) ) && 212 decodeURI( jQuery( anchor ).attr( 'data-videohtml' ) ) == decodeURI( jQuery( arg ).attr( 'data-videohtml' ) ) && 213 decodeURI( jQuery( anchor ).attr( 'data-audiohtml' ) ) == decodeURI( jQuery( arg ).attr( 'data-audiohtml' ) ) && 214 anchor.href == arg.href ) { 215 wppaOvlIdx = j; // Current index 216 } 217 j++; 218 } 219 } 220 } 221 222 // Find the occ 223 temp = setname.replace(/]+$/, ''); 224 if ( setname.substr(0,3) == 'occ' ) { 225 wppaFromMocc = temp.substr(3); 226 } 227 else if ( temp.substr(0,3) == 'alw' ) { 228 t = temp.split( '-' ); 229 wppaFromMocc = t[1]; 230 } 231 else { 232 wppaFromMocc = setname; 233 } 234 235 // Set slidespeed 236 if ( wppaOvlTimeout[wppaFromMocc] ) { 237 wppaOvlSlideSpeed = wppaOvlTimeout[wppaFromMocc]; 238 } 239 else { 240 wppaOvlSlideSpeed = wppaOvlSlideSpeedDefault; 241 } 242 243// console.log('setname = '+setname+' wppaFromMocc = '+wppaFromMocc+' wppaOvlSlideSpeed = '+wppaOvlSlideSpeed); 244 } 245 246 // Single image, treat as set with one element 247 else { 248 wppaOvlUrls[0] = arg.href; 249 if ( jQuery( arg ).attr( 'data-lbtitle' ) ) { 250 wppaOvlTitles[0] = wppaRepairScriptTags( jQuery( arg ).attr( 'data-lbtitle' ) ); 251 } 252 else { 253 wppaOvlTitles[0] = wppaRepairScriptTags( arg.title ); 254 } 255 wppaOvlIds[0] = jQuery( arg ).attr( 'data-id' ) ? jQuery( arg ).attr( 'data-id' ) : '0'; 256 wppaOvlAlts[0] = jQuery( arg ).attr( 'data-alt' ) ? jQuery( arg ).attr( 'data-alt' ) : ''; 257 wppaOvlVideoHtmls[0] = jQuery( arg ).attr( 'data-videohtml' ) ? decodeURI( jQuery( arg ).attr( 'data-videohtml' ) ) : ''; 258 wppaOvlPosterUrls[0] = jQuery( arg ).attr( 'data-posterurl' ) ? decodeURI( jQuery( arg ).attr( 'data-posterurl' ) ) : ''; 259 wppaOvlAudioHtmls[0] = jQuery( arg ).attr( 'data-audiohtml' ) ? decodeURI( jQuery( arg ).attr( 'data-audiohtml' ) ) : ''; 260 wppaOvlPdfHtmls[0] = jQuery( arg ).attr( 'data-pdfhtml' ) ? decodeURI( jQuery( arg ).attr( 'data-pdfhtml' ) ) : ''; 261 wppaOvlVideoNaturalWidths[0] = jQuery( arg ).attr( 'data-videonatwidth' ) ? jQuery( arg ).attr( 'data-videonatwidth' ) : ''; 262 wppaOvlVideoNaturalHeights[0] = jQuery( arg ).attr( 'data-videonatheight' ) ? jQuery( arg ).attr( 'data-vi
262deonatheight' ) : ''; 263 panData = jQuery( arg ).attr( 'data-panorama' ) ? jQuery( arg ).attr( 'data-panorama' ) : ''; 264 panType = jQuery( arg ).attr( 'data-pantype' ) ? jQuery( arg ).attr( 'data-pantype' ) : ''; 265 266 if ( panData.length > 0 ) { 267 wppaOvlHasPanoramas = true; 268 dotPos = panData.indexOf( '.' ); 269 wppaOvlPanoramaHtml[0] = panData.substr(dotPos+1); 270 wppaOvlPanoramaIds[0] = panData.substr(0,dotPos); 271 wppaOvlTypes[0] = panType; 272 } 273 else { 274 wppaOvlPanoramaHtml[0] = ''; 275 wppaOvlPanoramaIds[0] = 0; 276 wppaOvlTypes[0] = ''; 277 } 278 if ( wppaOvlPdfHtmls[0].length > 0 ) { 279 wppaOvlTypes[0] = 'document'; 280 } 281 wppaOvlIdx = 0; 282 } 283 } 284 285 // Arg is numeric 286 else { 287 wppaOvlIdx = arg; 288 } 289 290 wppaOvlOpen = true; 291 292 // Make sure a possible previous panorama dies 293 jQuery('body').trigger('quitimage'); 294 295 // Now start the actual function 296 setTimeout( function(){ _wppaOvlShow( wppaOvlIdx )}, 100 ); 297 298} 299 300// Show the lightbox overlay. 301// idx is the numeric index to current lightbox set 302function _wppaOvlShow( idx ) { 303 304 // Clear image containers 305 jQuery( '#wppa-overlay-ic' ).html( '' ).hide(); 306 jQuery( '#wppa-overlay-pc' ).html( '' ).hide(); 307 jQuery( '#wppa-overlay-fpc' ).html( '' ).hide(); 308 jQuery( '#wppa-overlay-zpc' ).html( '' ).hide(); 309 310 // Globalize index 311 wppaOvlCurIdx = idx; 312 313 // Show spinner 314 jQuery( "#wppa-ovl-spin" ).show(); 315 316 // Find handy switches 317 wppaIsVideo = wppaOvlVideoHtmls[idx] != ''; 318 wppaHasAudio = wppaOvlAudioHtmls[idx] != ''; 319 wppaOvlIsPdf = wppaOvlPdfHtmls[idx] != ''; 320 321 // Preload current image 322 // Not an empty url, and do not wait infinitely for a possibly non-existend posterimage 323 if ( false && wppaOvlUrls[idx].length > 0 && ! wppaIsVideo ) { 324 if ( ! wppaOvlImgs[idx] ) { 325 wppaOvlImgs[idx] = new Image(); 326 } 327 wppaOvlImgs[idx].src = wppaOvlUrls[idx]; // Preload 328 329 if ( ! wppaIsIe && ! wppaOvlImgs[idx].complete && wppaOvlOpen && ! wppaOvlIsPdf ) { 330 setTimeout( function(){_wppaOvlShow(idx)}, 500 ); 331 return; 332 } 333 } 334 335 // Calc prev and next indexes 336 var next = ( wppaOvlIdx == ( wppaOvlUrls.length - 1 ) ? 0 : wppaOvlIdx + 1 ); 337 var prev = ( wppaOvlIdx == 0 ? ( wppaOvlUrls.length - 1 ) : wppaOvlIdx - 1 ); 338 339 // Preload next, only if not video and not panorama 340 if ( wppaOvlTypes[next] == '' && wppaOvlVideoHtmls[next] == '' && wppaOvlOpen ) { 341 document.getElementById( 'wppa-pre-next' ).src = wppaOvlUrls[next]; // Preload 342 } 343 344 // Preload previous, only if not video 345 if ( wppaOvlTypes[prev] == '' && wppaOvlVideoHtmls[prev] == '' && wppaOvlOpen ) { 346 document.getElementById( 'wppa-pre-prev' ).src = wppaOvlUrls[prev]; // Preload 347 } 348 349 // Find photo id and bump its viewcount 350 _bumpViewCount( wppaOvlIds[idx] ); 351 352 // A single image? 353 wppaOvlIsSingle = ( wppaOvlUrls.length == 1 ); 354 355 wppaOvlActivePanorama = wppaOvlPanoramaIds[idx]; 356 357 // Fullsize? 358 if ( wppaIsFs() || wppaOvlActivePanorama ) { 359 var html; 360 361 // Fullsize panorama? 362 if ( wppaOvlActivePanorama ) { 363 html = wppaOvlPanoramaHtml[idx]; 364 } 365 366 // Fullsize Video 367 else if ( wppaIsVideo ) { 368 369 html = 370 '<div id="wppa-ovl-full-bg" style="position:fixed; width:'+wppaScreenWidth()+'px; height:'+screen.height+'px; left:0px; top:0px; text-align:center;" >'+ 371 '<video id="wppa-overlay-img" controls controlsList="nodownload nofullscreen noremoteplayback" preload="metadata"' + 372 ( wppaOvlVideoStart || wppaIsIntro ? ' autoplay' : '' ) + 373 ( wppaIsIntro ? ' muted' : '' ) + 374 ( wppaOvlPosterUrls[idx] ? ' poster="' + wppaOvlPosterUrls[idx] + '"' : '' ) + 375 ' ontouchstart="wppaTouchStart( event, \'wppa-overlay-img\', -1 );"' + 376 ' ontouchend="wppaTouchEnd( event );"' + 377 ' ontouchmove="wppaTouchMove( event );"' + 378 ' ontouchcancel="wppaTouchCancel( event );"' + 379 ' onclick="wppaOvlImgClick( event );"' + 380 ' onpause="wppaOvlVideoOnPause(this);"' + 381 ' onplay="wppaOvlVideoPlaying = true;"' + 382 ' oncanplay="wppaOvlVideoLoading = false;"' + 383 ' style="border:none; width:'+wppaScreenWidth()+'px; box-shadow:none; position:absolute;"' + 384 ' alt="'+wppaOvlAlts[idx]+'"' + 385 ' >'+ 386 wppaOvlVideoHtmls[idx]+ 387 '</video>'+ 388 '</div>'; 389 390 wppaOvlVideoLoading = true; 391 } 392 393 // Fullsize pdf 394 else if ( wppaOvlIsPdf ) { 395 396 html = 397 '<div id="wppa-ovl-full-bg" style="position:fixed; width:'+wppaScreenWidth()+'px; height:'+screen.height+'px; left:0px; top:0px; text-align:center;" >'+ 398 '<iframe'+ 399 ' id="wppa-overlay-img"' + 400 ' ' + wppaOvlPdfHtmls[idx] + 401 ' ontouchstart="wppaTouchStart( event, \'wppa-overlay-img\', -1 );"' + 402 ' ontouchend="wppaTouchEnd( event );"' + 403 ' ontouchmove="wppaTouchMove( event );"' + 404 ' ontouchcancel="wppaTouchCancel( event );"' + 405 ' onclick="wppaOvlImgClick( event );"' + 406 ' style="border:none; width:'+wppaScreenWidth()+'px; box-shadow:none; position:absolute;"' + 407 ' alt="'+wppaOvlAlts[idx]+'"' + 408 ' >'+ 409 '</iframe>'+ 410 '</div>'; 411 } 412 413 // Fullsize Photo 414 else { 415 html = 416 '<div id="wppa-ovl-full-bg" style="position:fixed; width:'+wppaScreenWidth()+'px; height:'+screen.height+'px; left:0px; top:0px; text-align:center;" >'+ 417 '<img id="wppa-overlay-img"'+ 418 ' ontouchstart="wppaTouchStart( event, \'wppa-overlay-img\', -1 );"'+ 419 ' ontouchend="wppaTouchEnd( event );"'+ 420 ' ontouchmove="wppaTouchMove( event );"'+ 421 ' ontouchcancel="wppaTouchCancel( event );"'+ 422 ' onclick="wppaOvlImgClick( event );"' + 423 ' src="'+wppaOvlUrls[idx]+'"'+ 424 ' style="border:none; width:'+wppaScreenWidth()+'px; visibility:hidden; box-shadow:none; position:absolute;"'+ 425 ' alt="'+wppaOvlAlts[idx]+'"'+ 426 ' />'; 427 428 if ( wppaHasAudio ) { 429 html += 430 '<audio' + 431 ' id="wppa-overlay-audio"' + 432 ' class="wppa-overlay-audio"' + 433 ' data-from="wppa"' + 434 ' preload="metadata"' + 435 ( ( wppaOvlAudioStart ) ? ' autoplay' : '' ) + 436 ' onpause="wppaAudioOnPase(this);"' + 437 ' onplay="wppaOvlAudioPlaying = true;"' + 438 ' style="' + 439 'width:100%;' + 440 'position:absolute;' + 441 'left:0px;' + 442 'bottom:0px;' + 443 'padding:0;' + 444 '"' + 445 ' controls' + 446 ' >' + 447 wppaOvlAudioHtmls[idx] + 448 '</audio>'; 449 } 450 451 html += 452 '</div>'; 453 } 454 455 // Replacing the html stops a running video, 456 // so we only replace html on a new id, or a photo without audio 457 if ( ( ! wppaIsVideo && ! wppaHasAudio ) || wppaOvlFsPhotoId != wppaPhotoId || wppaPhotoId == 0 ) { 458 wppaStopVideo( 0 ); 459 wppaStopAudio(); 460 461 // Fill the right image container 462 if ( wppaOvlActivePanorama > 0) { 463 switch( wppaOvlTypes[idx] ) { 464 case 'spheric': 465 jQuery( '#wppa-overlay-pc' ).html( html ).show(); 466 break; 467 case 'flat': 468 jQuery( '#wppa-overlay-fpc' ).html( html ).show(); 469 break; 470 case 'zoom': 471 jQuery( '#wppa-overlay-zpc' ).html( html ).show(); 472 break; 473 } 474 } 475 else { 476 jQuery( '#wppa-overlay-ic' ).html( html ).show(); 477 } 478 } 479 480 // If panorama and single, hide panorama browse buttons 481 if ( wppaOvlPanoramaIds[idx] > 0 && wppaOvlIsSingle ) { 482 jQuery( '.wppa-pan-prevnext' ).hide(); 483 } 484 485 // Disable right mouse button optionally 486 wppaProtect(); 487 488 wppaOvlIsVideo = wppaIsVideo; 489 setTimeout( wppaOvlFormatFull, 10 ); 490 if ( wppaIsVideo || wppaHasAudio ) { 491 setTimeout( function(){wppaOvlFsPhotoId = wppaPhotoId;}, 20 ); 492 } 493 else { 494 wppaOvlFsPhotoId = 0; 495 } 496 497 // Show 498 if ( wppaOvlTypes[idx] == '' ) { 499 jQuery("#wppa-overlay-ic").show(); 500 } 501 } 502 503 // NOT fullsize 504 else { 505 506 // Initialize 507 wppaOvlFsPhotoId = 0; // Reset ovl fullscreen photo id 508 wppaPhotoId = 0; 509 wppaStopVideo( 0 ); 510 var txtcol = wppaOvlTheme == 'black' ? '#a7a7a7' : '#272727'; // Normal font 511 if ( wppaOvlFontColor ) { 512 txtcol = wppaOvlFontColor; 513 } 514 var showNav = wppaOvlUrls.length > 1; 515 516 // Initial sizing of image container ( contains image, borders and subtext ) 517 if ( wppaOvlActivePanorama == 0 ) { 518 jQuery( '#wppa-overlay-ic' ).css( { 519 width:wppaSavedContainerWidth, 520 marginLeft:wppaSavedMarginLeft, 521 marginTop:wppaSavedMarginTop, 522 });
523 } 524 525 // Make the html 526 var html = ''; 527 528 // The img sub image container 529 html += '<div id="img-sb-img-cont" style="position:relative;line-height:0;" >'; 530 531 // Not Fullsize Video 532 if ( wppaIsVideo ) { 533 html += '<video' + 534 ' id="wppa-overlay-img"' + 535 ' onmouseover="jQuery(\'.wppa-ovl-nav-btn\').stop().fadeTo(200,0.8);"' + 536 ' onmouseout="jQuery(\'.wppa-ovl-nav-btn\').stop().fadeTo(200,0);"' + 537 ' preload="metadata"' + 538 ( wppaOvlVideoStart || wppaIsIntro ? ' autoplay' : '' ) + 539 ( wppaIsIntro ? ' muted' : '' ) + 540 ( wppaOvlPosterUrls[idx] ? ' poster="' + wppaOvlPosterUrls[idx] + '"' : '' ) + 541 ' onpause="wppaOvlVideoOnPause(this)"' + 542 ' onplay="wppaOvlVideoPlaying = true;"' + 543 ' oncanplay="wppaOvlVideoLoading = false;"' + 544 ' ontouchstart="wppaTouchStart( event, \'wppa-overlay-img\', -1 );"' + 545 ' ontouchend="wppaTouchEnd( event );"' + 546 ' ontouchmove="wppaTouchMove( event );"' + 547 ' ontouchcancel="wppaTouchCancel( event );" ' + 548 ' onclick="wppaOvlImgClick( event );"' + 549 ' controls controlsList="nodownload nofullscreen noremoteplayback"' + 550 ' style="' + 551 'border-width:' + wppaOvlBorderWidth + 'px ' + wppaOvlBorderWidth + 'px 0;' + 552 'border-style:solid;' + 553 'border-color:'+wppaOvlTheme+';' + 554 'width:' + wppaSavedImageWidth + 'px;' + 555 'height:' + wppaSavedImageHeight + 'px;' + 556 'box-shadow:none;' + 557 'box-sizing:content-box;' + 558 'position:relative;' + 559 'border-top-left-radius:'+wppaOvlRadius+'px;' + 560 'border-top-right-radius:'+wppaOvlRadius+'px;' + 561 'margin:0;' + 562 'padding:0;' + 563 '"' + 564 ' alt="'+wppaOvlAlts[idx]+'"' + 565 ' >' + 566 wppaOvlVideoHtmls[idx] + 567 '</video>'; 568 569 wppaOvlIsVideo = true; 570 wppaOvlVideoLoading = true; 571 } 572 573 // Not fullsize pdf 574 else if ( wppaOvlIsPdf ) { 575 576 html += '<iframe' + 577 ' ' + wppaOvlPdfHtmls[idx] + 578 ' id="wppa-overlay-img"' + 579 ' onmouseover="jQuery(\'.wppa-ovl-nav-btn\').stop().fadeTo(200,0.8);"' + 580 ' onmouseout="jQuery(\'.wppa-ovl-nav-btn\').stop().fadeTo(200,0);"' + 581 ' ontouchstart="wppaTouchStart( event, \'wppa-overlay-img\', -1 );"' + 582 ' ontouchend="wppaTouchEnd( event );"' + 583 ' ontouchmove="wppaTouchMove( event );"' + 584 ' ontouchcancel="wppaTouchCancel( event );" ' + 585 ' onclick="wppaOvlImgClick( event );"' + 586 ' style="' + 587 'border-width:' + wppaOvlBorderWidth + 'px ' + wppaOvlBorderWidth + 'px 0;' + 588 'border-style:solid;' + 589 'border-color:'+wppaOvlTheme+';' + 590 // 'width:' + wppaSavedImageWidth + 'px;' + 591 // 'height:' + wppaSavedImageHeight + 'px;' + 592 'box-shadow:none;' + 593 'box-sizing:content-box;' + 594 'position:relative;' + 595 'border-top-left-radius:'+wppaOvlRadius+'px;' + 596 'border-top-right-radius:'+wppaOvlRadius+'px;' + 597 'margin:0;' + 598 'padding:0;' + 599 '"' + 600 ' alt="'+wppaOvlAlts[idx]+'"' + 601 ' >' + 602 '</iframe>'; 603 } 604 605 // Not fullsize photo 606 else { 607 html += '<img' + 608 ' id="wppa-overlay-img"'+ 609 ' onmouseover="jQuery(\'.wppa-ovl-nav-btn\').stop().fadeTo(200,0.8);"' + 610 ' onmouseout="jQuery(\'.wppa-ovl-nav-btn\').stop().fadeTo(200,0);"' + 611 ' ontouchstart="wppaTouchStart( event, \'wppa-overlay-img\', -1 );"' + 612 ' ontouchend="wppaTouchEnd( event );"' + 613 ' ontouchmove="wppaTouchMove( event );"' + 614 ' ontouchcancel="wppaTouchCancel( event );"' + 615 ' onclick="wppaOvlImgClick( event );"' + 616 ' src="'+wppaOvlUrls[idx]+'"' + 617 ' style="' + 618 'border-width:' + wppaOvlBorderWidth + 'px ' + wppaOvlBorderWidth + 'px 0;' + 619 'border-style:solid;' + 620 'border-color:'+wppaOvlTheme+';' + 621 'width:' + wppaSavedImageWidth + 'px;' + 622 'height:' + wppaSavedImageHeight + 'px;' + 623 'box-shadow:none;' + 624 'box-sizing:content-box;' + 625 'position:relative;' + 626 'border-top-left-radius:'+wppaOvlRadius+'px;' + 627 'border-top-right-radius:'+wppaOvlRadius+'px;' + 628 'margin:0;' + 629 'padding:0;' + 630 '"' + 631 ' alt="'+wppaOvlAlts[idx]+'"' + 632 ' />'; 633 634 // Audio on not fullsize 635 if ( wppaHasAudio ) { 636 html += '<audio' + 637 ' id="wppa-overlay-audio"' + 638 ' class="wppa-overlay-audio"' + 639 ' data-from="wppa"' + 640 ' preload="metadata"' + 641 ( wppaOvlAudioStart || wppaIsIntro ? ' autoplay' : '' ) + 642 ( wppaIsIntro ? ' muted' : '' ) + 643 ' onpause="wppaAudioOnPase(this);"' + 644 ' onplay="wppaOvlAudioPlaying = true;"' + 645 ' style="' + 646 'width:100%;' + 647 'position:absolute;' + 648 'box-shadow:none;' + 649 'left:0;' + 650 'bottom:0;' + 651 'padding:0 ' + wppaOvlBorderWidth + 'px;' + 652 'margin:0;' + 653 'background-color:transparent;' + 654 'box-sizing:border-box;' + 655 '"' + 656 ' controls' + 657 ' >' + 658 wppaOvlAudioHtmls[idx] + 659 '</audio>'; 660 } 661 wppaOvlIsVideo = false; 662 } 663 664 // Close the #img-sb-img-cont 665 html += '</div>'; 666 667 // The subtext container 668 var showCounter = ! wppaOvlIsSingle && wppaOvlShowCounter; 669 html += 670 '<div id="wppa-overlay-txt-container"' + 671 ' style="' + 672 'position:relative;' + 673 'padding:10px;' + 674 'background-color:' + wppaOvlTheme + ';' + 675 'color:' + txtcol + ';' + 676 'text-align:center;' +
677 'font-family:' + wppaOvlFontFamily + ';' + 678 'font-size:' + wppaOvlFontSize + 'px;' + 679 'font-weight:' + wppaOvlFontWeight + ';' + 680 'line-height:' + wppaOvlLineHeight + 'px;' + 681 'box-shadow:none;' + 682 'border-bottom-left-radius:'+wppaOvlRadius+'px;' + 683 'border-bottom-right-radius:'+wppaOvlRadius+'px;' + 684 '"' + 685 ' >' + 686 '<div' + 687 ' id="wppa-overlay-txt"' + 688 ' style="' + 689 'text-align:center;' + 690 'min-height:36px;' + 691 'width:100%;' + 692 ( wppaOvlTxtHeight == 'auto' ? 'max-height:200px;' : 'max-height:' + wppaOvlTxtHeight + 'px;' ) + 693 'box-shadow:none;' + 694 '"' + 695 ' >'; 696 697 // The nav bar 698 html += wppaOvlNavBar(); 699 700 // The actual text 701 html += 702 ( showCounter ? ( wppaOvlIdx + 1 ) + '/' + wppaOvlUrls.length + '<br />' : '' ) + 703 wppaOvlTitles[idx]; 704 705 // Close wppa-overlay-txt 706 html += 707 '</div>'; 708 709 // Close wppa-overlay-txt-container 710 html += 711 '</div>'; 712 713 // Insert the html 714 if ( wppaOvlActivePanorama == 0 ) { 715 jQuery( '#wppa-overlay-ic' ).html( html ); 716 } 717 else { 718 jQuery( '#wppa-overlay-pc' ).html( html ); 719 } 720 721 // Show 722 if ( wppaOvlTypes[idx] == '' || wppaOvlTypes[idx] == 'document' ) { 723 jQuery("#wppa-overlay-ic").show(); 724 } 725 726 // Restore opacity of fs and exit buttons 727 wppaFsShow(); 728 729 // Disable right mouse button 730 if ( wppaHideRightClick ) { 731 jQuery( '#wppa-overlay-img' ).bind( 'contextmenu', function(e) { 732 return false; 733 }); 734 jQuery( 'canvas' ).bind( 'contextmenu', function(e) { 735 return false; 736 }); 737 } 738 739 // Size if not panorama 740 if ( wppaOvlPanoramaIds[idx] == 0 ) { 741 wppaOvlResize(); 742 } 743 744 // Show fs and exit buttons 745 wppaFsShow(); 746 747 wppaAdjustControlbar(); 748 } 749 750 // Update buttons 751 wppaFsShow(); 752 753 // Optionally disable rightclick 754 wppaProtect(); 755 756 // Handle autostart slideshow 757 var runNow = wppaOvlSlideStartDefault; 758 if ( wppaOvlSlideStart[wppaFromMocc] == 'yes' ) runNow = true; 759 if ( wppaOvlSlideStart[wppaFromMocc] == 'no' ) runNow = false; 760 761 if ( wppaOvlFirst && runNow && ! wppaOvlIsSingle ) { 762// console.log('bendur'); 763 wppaOvlRunning = true; 764 765 // Show stop, hide start buttn 766 jQuery( '#wppa-ovl-stop-btn' ).show(); 767 jQuery( '#wppa-ovl-start-btn' ).hide(); 768 769 clearTimeout( wppaOvlTimer ); 770 wppaOvlTimer = setTimeout( wppaOvlRun, wppaOvlSlideSpeed ); 771 } 772 773 // Done first 774 wppaOvlFirst = false; 775 776// console.log('done first'); 777} 778 779// What to do when a video is paused 780function wppaOvlVideoOnPause(elm) { 781 782 // Indicate that the video no longer playes 783 wppaOvlVideoPlaying = false; 784 785 // Pause event at the end ? 786 if ( elm.ended ) { 787 788 // Quit on end video? 789 if ( wppaIsIntro ) { 790 wppaOvlHide(); 791 } 792 } 793 794 // If we want to stop the running show when manually paused 795 else if ( wppaOvlVideoPauseStop && // we want to stop the running show on pause 796 elm.readyState == 4 && // must be loaded to a playable state 797 elm.played.length > 0 && // must have run 798 elm.played.end(0) > 0 ) { // must have run for some time 799 wppaOvlStop(); // stop the show 800 wppaOvlVideoPlaying = false; // Indicate that the video no longer playes 801 } 802} 803 804// What to do when a video is paused 805function wppaAudioOnPase(elm) { 806 807 // Indicate that the video no longer playes 808 wppaOvlAudioPlaying = false; 809 810 // Pause event at the end ? 811 if ( elm.ended ) { 812 if ( wppaIsIntro ) { 813 wppaOvlHide(); 814 } 815 } 816} 817 818// Adjust display sizes 819function wppaOvlSize( speed ) { 820 821 // Panoramas do their own formatting 822 if ( wppaOvlActivePanorama ) return; 823 824 var img = document.getElementById( 'wppa-overlay-img' ); // Do NOT jquerify this: 825 var txt = document.getElementById( 'wppa-overlay-txt' ); // $ does not support .naturalHeight etc. 826 827 // Are we still visible? 828 if ( ! img || ! txt || jQuery('#wppa-overlay-bg').css('display') == 'none' ) { 829 return; 830 } 831 832 // Full screen? 833 if ( wppaIsFs() ) { 834 wppaOvlFormatFull(); 835 return; 836 } 837 838 var iw = wppaWindowWidth(); 839 var ih = wppaWindowHeight(); 840 var cw, nw, nh; 841 842 if ( wppaOvlIsVideo ) { 843 cw = img.clientWidth;//640;
844 nw = wppaOvlVideoNaturalWidths[wppaOvlCurIdx];//640; 845 nh = wppaOvlVideoNaturalHeights[wppaOvlCurIdx];//480; 846 } 847 else if ( wppaOvlIsPdf ) { 848 cw = wppaWindowWidth() * 0.9; 849 nw = wppaWindowWidth() * 0.9; 850 nh = wppaWindowHeight() * 0.9; 851 } 852 else { 853 cw = img.clientWidth; 854 nw = img.naturalWidth; 855 nh = img.naturalHeight; 856 } 857 858 var fakt1; 859 var fakt2; 860 var fakt; 861 862 // If the width is the limiting factor, adjust the height 863 if ( typeof( nw ) == 'undefined' ) { // ver 4 browser 864 nw = img.clientWidth; 865 nh = img.clientHeight; 866 } 867 fakt1 = ( iw - 3 * wppaOvlBorderWidth ) / nw; 868 fakt2 = ih / nh; 869 if ( fakt1 < fakt2 ) fakt = fakt1; // very landscape, width is the limit 870 else fakt = fakt2; // Height is the limit 871 if ( fakt < 1.0 ) { // Up or downsize 872 nw = parseInt( nw * fakt ); 873 nh = parseInt( nh * fakt ); 874 } 875 876 var mh; // max image height 877 var tch = jQuery( '#wppa-overlay-txt' ).height(); 878 879 if ( wppaOvlTxtHeight == 'auto' ) { 880 if ( tch == 0 ) tch = 20 + 2 * wppaOvlBorderWidth; 881 mh = ih - tch - 20 - 2 * wppaOvlBorderWidth; 882 } 883 else { 884 mh = ih - wppaOvlTxtHeight - 20 - 2 * wppaOvlBorderWidth; 885 } 886 887 var mw = parseInt( mh * nw / nh ); 888 var pt = wppaOvlPadTop; 889 var lft = parseInt( ( iw-mw )/2 ); 890 var wid = mw; 891 892 // Image too small? ( never for ver 4 browsers, we do not know the natural dimensions 893 if ( nh < mh ) { 894 pt = wppaOvlPadTop + ( mh - nh )/2; 895 lft = parseInt( ( iw-nw )/2 ); 896 wid = nw; 897 } 898 899 // Save new image width and height 900 var done = ( wppaSavedImageWidth - wid < 3 && wid - wppaSavedImageWidth < 3 ); 901 902 if ( wid <= 10 ) { 903 wid = 240; 904 nh = 180; 905 nw = 240; 906 done = false; 907 } 908 909 wid = parseInt(wid); 910 911 wppaSavedImageWidth = parseInt( wid ); 912 wppaSavedImageHeight = parseInt( wid * nh / nw ); 913 wppaSavedMarginLeft = - parseInt( ( wid / 2 + wppaOvlBorderWidth ) ); 914 wppaSavedContainerWidth = parseInt( wid + 2 * wppaOvlBorderWidth ); 915 wppaSavedContainerHeight = parseInt( wppaSavedImageHeight + wppaOvlBorderWidth + jQuery( '#wppa-overlay-txt-container' ).height() + 20 ); // padding = 10 916 wppaSavedMarginTop = - parseInt( wppaSavedContainerHeight / 2 ); 917 918 // Go to final size 919 wppaAnimate( '#wppa-overlay-img', {width:wppaSavedImageWidth,height:wppaSavedImageHeight}, speed, wppaEasingLightbox ); 920 wppaAnimate( '#wppa-overlay-ic', {width:wppaSavedContainerWidth,marginLeft:wppaSavedMarginLeft,marginTop:wppaSavedMarginTop}, speed, wppaEasingLightbox ); 921 922 // Done? 923 if ( ! done ) { 924 setTimeout( function(){ wppaOvlSize(wppaOvlAnimSpeed) }, speed + 10 ); 925 } 926 else { 927 928 // Remove spinner 929 jQuery( '#wppa-ovl-spin' ).hide(); 930 wppaOvlFirst = false; 931 } 932 return true; 933} 934 935// Show fullscreen lightbox image 936function wppaOvlFormatFull() { 937 938 // Are we still in? 939 if ( ! wppaOvlOpen ) { 940 return; 941 } 942 943 // Panoramas do their own resize 944 if ( wppaOvlActivePanorama > 0 ) { 945 return; 946 } 947 948 var img; 949 var natWidth; 950 var natHeight; 951 952 // Find the natural image sizes 953 if ( wppaOvlIsVideo ) { 954 img = document.getElementById( 'wppa-overlay-img' ); 955 natWidth = wppaOvlVideoNaturalWidths[wppaOvlIdx]; 956 natHeight = wppaOvlVideoNaturalHeights[wppaOvlIdx]; 957 } 958 else if ( wppaOvlIsPdf ) { 959 img = document.getElementById( 'wppa-overlay-img' ); 960 natWidth = wppaScreenWidth(); 961 natHeight = wppaScreenHeight(); 962 } 963 else { 964 img = document.getElementById( 'wppa-overlay-img' ); 965 if ( ! wppaIsIe && ( ! img || ! img.complete ) ) { 966 967 // Wait for load complete 968 setTimeout( wppaOvlFormatFull, 200 ); 969 return; 970 } 971 natWidth = img.naturalWidth; 972 natHeight = img.naturalHeight; 973 } 974 975 var screenRatio = wppaScreenWidth() / wppaScreenHeight(); 976 var imageRatio = natWidth / natHeight; 977 var margLeft = 0; 978 var margTop = 0; 979 var imgHeight = 0; 980 var imgWidth = 0; 981 var scrollTop = 0; 982 var scrollLeft = 0; 983 var Overflow = 'hidden'; 984 985 if ( screenRatio > imageRatio ) { // Picture is more portrait 986 margLeft = ( wppaScreenWidth() - wppaScreenHeight() * imageRatio ) / 2; 987 margTop = 0; 988 imgHeight = wppaScreenHeight(); 989 imgWidth = wppaScreenHeight() * imageRatio; 990 } 991 else { 992 margLeft = 0; 993 margTop = ( wppaScreenHeight() - wppaScreenWidth() / imageRatio ) / 2; 994 imgHeight = wppaScreenWidth() / imageRatio; 995 imgWidth = wppaScreenWidth(); 996 } 997 998 margLeft = parseInt( margLeft ); 999 margTop = parseInt( margTop ); 1000 imgHeight = parseInt( imgHeight ); 1001 imgWidth = parseInt( imgWidth ); 1002 jQuery(img).css({height:imgHeight,width:imgWidth,marginLeft:margLeft,marginTop:margTop,left:0,top:0,maxWidth:10000}); 1003 jQuery(img).css({visibility:'visible'}); 1004 jQuery( '#wppa-ovl-full-bg' ).css({overflow:Overflow}); 1005 jQuery( '#wppa-ovl-full-bg' ).scrollTop( scrollTop ); 1006 jQuery( '#wppa-ovl-full-bg' ).scrollLeft( scrollLeft ); 1007 jQuery( '#wppa-ovl-spin' ).hide(); 1008jQuery('#wppa-ovl-full-bg').css({visibility:'hidden'}); 1009 1010 // Add navbar 1011 html = jQuery( '#wppa-overlay-ic' ).html(); 1012 html += '<div id="ovl-navbar" style="position:fixed;bottom:0;left:0;right:0;" >' + wppaOvlNavBar() + '</div>'; 1013 1014 // Recompute wppaScreenHeight() 1015 1016// html += '<script>setTimeout(function(){wppaScreenHeight() = jQuery("#ovl-navbar").position().top+wppaOvlNavIconSize;},20);</script>'; 1017 1018 jQuery( '#wppa-overlay-ic' ).html( html ); 1019 1020 1021 wppaFsShow(); 1022 1023 return true; // Done! 1024} 1025 1026// Start audio on the lightbox view 1027function wppaOvlStartAudio() { 1028 1029 // Due to a bug in $ ( $.play() does not exist ), must do myself: 1030 var elm = document.getElementById( 'wppa-overlay-audio' ); 1031 if ( elm ) { 1032 if ( typeof( elm.play ) == 'function' ) { 1033 elm.play(); 1034 } 1035 } 1036} 1037 1038// Start / stop lightbox slideshow 1039function wppaOvlStartStop() { 1040 1041 // Running?
1042 if ( wppaOvlRunning ) { 1043 1044 // Stop it 1045 wppaOvlRunning = false; 1046 1047 // If in a set: Determine visibility of browse buttons and make visible if appliccable 1048 if ( wppaOvlIdx != -1 ) { 1049 1050 // NOT first, show prev button 1051 if ( wppaOvlIdx != 0 ) { 1052 jQuery( '.wppa-ovl-prev-btn' ).css('visibility', 'visible'); 1053 } 1054 1055 // NOT last, show next button 1056 if ( wppaOvlIdx != ( wppaOvlUrls.length-1 ) ) { 1057 jQuery( '.wppa-ovl-next-btn' ).css('visibility', 'visible'); 1058 } 1059 } 1060 1061 // Hide stop, show start buttn 1062 if ( wppaOvlShowStartStop ) { 1063 jQuery( '#wppa-ovl-stop-btn' ).hide(); 1064 jQuery( '#wppa-ovl-start-btn' ).show(); 1065 } 1066 } 1067 1068 // Not running 1069 else { 1070 1071 // Start it 1072 wppaOvlRunning = true; 1073 wppaOvlRun(); 1074 1075 // Show stop, hide start buttn 1076 if ( wppaOvlShowStartStop ) { 1077 jQuery( '#wppa-ovl-stop-btn' ).show(); 1078 jQuery( '#wppa-ovl-start-btn' ).hide(); 1079 } 1080 } 1081} 1082 1083// Stop show 1084function wppaOvlStop() { 1085 if ( wppaOvlRunning ) { 1086 wppaOvlStartStop(); 1087 } 1088} 1089 1090var wppaToggle = '+'; 1091// Start lb slideshow 1092function wppaOvlRun() { 1093 1094 // Are we stopped?? 1095 if ( ! wppaOvlRunning ) return; 1096 1097 var elm = document.getElementById('wppa-overlay-img'); 1098 var msg = ''; 1099 1100 if ( wppaIsVideo ) { 1101 msg = wppaToggle+' s='+elm.readyState+', ct='+elm.currentTime+', dr='+elm.duration; 1102 if (wppaToggle == '+'){wppaToggle='-';}else {wppaToggle='+';} 1103 if ( elm.autoplay ) { 1104 if ( elm.readyState < 4 ) { 1105 if ( elm.duration != elm.currentTime ) { 1106 setTimeout( wppaOvlRun, 1000 ); 1107// jQuery('#wppa-ovl-dbg-msg').html(msg+' 1'); 1108 return; 1109 } 1110 } 1111 } 1112 } 1113 1114 // Wait until playing audio or video ends 1115 if ( wppaOvlVideoLoading || wppaOvlVideoPlaying || wppaOvlAudioPlaying ) { 1116//jQuery('#wppa-ovl-dbg-msg').html(msg+' 2'); 1117 setTimeout( wppaOvlRun, 1000 ); 1118 return; 1119 } 1120 1121 // If the current image is not yet complete, try again after 200 ms 1122 if ( ! wppaIsVideo && ! wppaOvlIsPdf ) { 1123 var elm = document.getElementById( 'wppa-overlay-img' ); 1124 if ( elm ) { 1125 if ( ! wppaIsIe && ! elm.complete ) { 1126//jQuery('#wppa-ovl-dbg-msg').html(msg+' 3'); 1127 setTimeout( wppaOvlRun, 200 ); 1128 return; 1129 } 1130 } 1131 } 1132 1133 wppaOvlShowNext(); 1134 1135 clearTimeout( wppaOvlTimer ); 1136 wppaOvlTimer = setTimeout( wppaOvlRun, wppaOvlSlideSpeed ); 1137} 1138 1139// One back in the set 1140function wppaOvlShowPrev() { 1141 1142 // Not on a single image 1143 if ( wppaOvlIsSingle ) return false; 1144 1145 jQuery("#wppa-ovl-spin").show(); 1146 1147 wppaOvlFsPhotoId = 0; 1148 wppaPhotoId = 0; 1149 1150 var idx = wppaOvlCurIdx - 1; 1151 if ( idx < 0 ) { 1152 idx = wppaOvlUrls.length - 1; 1153 } 1154 1155 // Preload previous, only if not video 1156 var img = document.getElementById( 'wppa-pre-prev' ); 1157 if ( wppaOvlVideoHtmls[idx] == '' && ! wppaIsIe && ! img.complete && wppaOvlOpen ) { 1158 1159 setTimeout( wppaOvlShowPrev, 200 ); 1160 return false; 1161 } 1162 1163 wppaOvlShow( idx ); 1164 return false; 1165} 1166 1167// One further in the set 1168function wppaOvlShowNext() { 1169 1170 // Not on a single image 1171 if ( wppaOvlIsSingle ) return false; 1172 1173 jQuery("#wppa-ovl-spin").show(); 1174 1175 wppaOvlFsPhotoId = 0; 1176 wppaPhotoId = 0; 1177 1178 var idx = wppaOvlCurIdx + 1; 1179 if ( idx > ( wppaOvlUrls.length-1 ) ) { 1180 idx = 0; 1181 } 1182 1183 // Preload next, only if not video 1184 var img = document.getElementById( 'wppa-pre-next' ); 1185 if ( wppaOvlVideoHtmls[idx] == '' && ! wppaIsIe && ! img.complete && wppaOvlOpen ) { 1186 1187 setTimeout( wppaOvlShowNext, 200 ); // show same? to prevent another bump index 1188 return false; 1189 } 1190 1191 wppaOvlShow( idx ); 1192 return false; 1193} 1194 1195// Show the same after orientatiochange or fullscreenchange 1196function wppaOvlShowSame(from) { 1197 1198// wppaConsoleLog('wppaOvlShowSame() from '+from); 1199 1200 // Are we in? 1201 if ( ! wppaOvlOpen ) return; 1202 1203 // Find current index 1204 var now = wppaOvlCurIdx; 1205 1206// if ( from == 'fschange' ) { 1207// now--; 1208// if ( now < 0 ) { 1209// now = wppaOvlUrls.length-1; 1210// } 1211// console.log('now='+now) 1212// } 1213 1214 // Are we running? 1215 var wasRunning = wppaOvlRunning; 1216 1217 // Remove existing, but leave the background 1218 wppaOvlHide(true); 1219 1220 // Show spinner 1221 jQuery( "#wppa-ovl-spin" ).show(); 1222 1223 // Redisplay 1224 setTimeout( function(){ 1225 wppaOvlShow(now); 1226 if ( wasRunning ) { 1227// clearTimeout( wppaOvlTimer ); 1228// wppaOvlTimer = setTimeout( wppaOvlStartStop(), wppaOvlSlideSpeed ); 1229 } 1230 }, 1000 ); 1231 1232} 1233 1234// Quit lightbox mode 1235function wppaOvlHide(keepState) { 1236 1237 // Record we are out 1238 wppaOvlOpen = false; 1239 wppaOvlClosing = ! wppaOvlClosing; 1240 1241 // Stop audio 1242 wppaStopAudio(); 1243 1244 // Clear initial Start 1245 wppaIsIntro = false; 1246 1247 // Give up fullscreen mode optionally 1248 if ( ! keepState && wppaFsPolicy == 'lightbox' ) { 1249 if ( wppaIsFs() ) { 1250 wppaFsOff(); 1251 } 1252 } 1253 1254 // Clear image container 1255 jQuery( '#wppa-overlay-ic' ).html( '' ).hide(); 1256 jQuery( '#wppa-overlay-pc' ).html( '' ).hide(); 1257 jQuery( '#wppa-overlay-fpc' ).html( '' ).hide(); 1258 jQuery( '#wppa-overlay-zpc' ).html( '' ).hide(); 1259 1260 // Remove kb handler 1261 jQuery(document).off( 'keydown', wppaOvlKeyboardHandler ); 1262 wppaKbHandlerInstalled = false; 1263 1264 // Reset switches 1265 wppaOvlFirst = true;
1266 wppaOvlRunning = false; 1267 clearTimeout( wppaOvlTimer ); 1268 1269 // Remove spinner 1270 jQuery( '#wppa-ovl-spin' ).hide(); 1271 1272 // Stop any panorama from running the wppaRenderer 1273 wppaOvlActivePanorama = 0; 1274 jQuery('body').trigger('quitimage'); 1275 1276 // Reatart slideshow if requested 1277 var i; 1278 for ( i=0; i<wppaSlidePause.length; i++ ) { 1279 wppaSlidePause[i]=false; 1280 } 1281 if ( document.onLbquitMocc ) { 1282 wppaStartStop( document.onLbquitMocc ); 1283 document.onLbquitMocc = null; 1284 document.onLbquitIdx = null; 1285 } 1286 1287 // Trigger lightbox end event 1288 jQuery(window).trigger( 'wppalightboxend' ); 1289 1290 // Fake a window reize 1291 jQuery(window).trigger('resize'); 1292 1293 // Do again if closing 1294 if ( wppaOvlClosing && wppaIsMobile ) { 1295 setTimeout(function(){wppaOvlHide(keepState)},250); 1296 return; 1297 } 1298 else { 1299 wppaOvlClosing = false; 1300 } 1301 1302 // Remove background optionally 1303 if ( ! keepState ) { 1304 setTimeout(function(){ 1305 jQuery( '#wppa-overlay-bg' ).hide(); 1306 jQuery( '#wppa-ovl-spin' ).hide(); 1307 1308 // If fs policy == global and big browse, show the right button 1309 if ( wppaFsPolicy == 'global' && wppaOvlBigBrowse ) { 1310 wppaFsShow(); 1311 } 1312 },500); 1313 } 1314 1315 wppaAlbLbBusy = false; 1316} 1317 1318// Perform onclick action 1319function wppaOvlOnclick( event ) { 1320 1321 switch ( wppaOvlOnclickType ) { 1322 case 'none': 1323 break; 1324 case 'close': 1325 wppaOvlHide(); 1326 break; 1327 case 'browse': 1328 var x = event.screenX - window.screenX; 1329 var y = event.clientY; 1330 if ( y > 48 ) { 1331 if ( x < wppaScreenWidth() / 2 ) wppaOvlShowPrev(); 1332 else wppaOvlShowNext(); 1333 } 1334 break; 1335 default: 1336 break; 1337 } 1338 return true; 1339} 1340 1341// Initialize <a> tags with onclick and ontouchstart events to lightbox 1342function wppaInitOverlay() { 1343 1344 // First find subtitles for non-wppa images 1345 jQuery( '.wp-caption' ).each( function() { 1346 var div = jQuery( this ); 1347 var title = div.find( 'IMG[alt]' ).attr( 'alt' ) || ''; 1348 var description = div.find( '.wp-caption-text' ).html() || ''; 1349 var a = div.find( 'a' ); 1350 var lbtitle = title + '<br>' + description; 1351 if ( ! a.attr( 'data-lbtitle' ) ) { 1352 a.attr( 'data-lbtitle', lbtitle ); 1353 } 1354 }); 1355 1356 var anchors = jQuery( 'a' ); 1357 var anchor; 1358 var i; 1359 var temp = []; 1360 1361 wppaOvlFsPhotoId = 0; // Reset ovl fullscreen photo id 1362 wppaPhotoId = 0; 1363 wppaOvlActivePanorama = 0; 1364 1365 // First time ? 1366 if ( wppaSavedContainerWidth == 0 ) { 1367 wppaSavedContainerWidth = 240 + 2 * wppaOvlBorderWidth; 1368 wppaSavedContainerHeight = 180 + 3 * wppaOvlBorderWidth + 20 + ( wppaOvlTxtHeight == 'auto' ? 50 : wppaOvlTxtHeight ); 1369 wppaSavedMarginLeft = - ( 120 + wppaOvlBorderWidth ); 1370 wppaSavedMarginTop = - ( 90 + wppaOvlBorderWidth + 10 + ( wppaOvlTxtHeight == 'auto' ? 25 : wppaOvlTxtHeight / 2 ) ); 1371 wppaSavedImageWidth = 240; 1372 wppaSavedImageHeight = 180 + wppaOvlBorderWidth; 1373 } 1374 1375 for ( i = 0; i < anchors.length; i++ ) { 1376 1377 anchor = anchors[i]; 1378 if ( jQuery( anchor ).attr( 'data-rel' ) ) { 1379 temp = jQuery( anchor ).attr( 'data-rel' ).split( "[" ); 1380 } 1381 else if ( anchor.rel ) { 1382 temp = anchor.rel.split( "[" ); 1383 } 1384 else { 1385 temp[0] = ''; 1386 } 1387 1388 if ( temp[0] == 'wppa' ) { 1389 1390 // found one 1391 wppaWppaOverlayActivated = true; 1392 1393 // Install onclick handler 1394 jQuery( anchor ).on( 'click', function( event ) { 1395 wppaOvlShow( this ); 1396 event.preventDefault(); 1397 }); 1398 1399 // Set cursor to magnifier 1400 switch ( wppaMagnifierCursor ) { 1401 case 'pointer': 1402 jQuery( anchor ).css( 'cursor', 'pointer' ); 1403 break; 1404 case '': 1405 jQuery( anchor ).css( 'cursor', 'default' ); 1406 break; 1407 default: 1408 jQuery( anchor ).css( 'cursor', 'url( ' + wppaImageDirectory + wppaMagnifierCursor + ' ),auto' ); 1409 } 1410 1411 } 1412 } 1413 1414 // Install fullscreen navigation bar positioning 1415 jQuery(window).on('DOMContentLoaded load resize scroll orientationchange', wppaAdjustControlbar ); 1416} 1417 1418// This module is intented to be used in any onclick definition that opens or closes a part of the photo description. 1419// this will automaticly adjust the picturesize so that the full description will be visible. 1420// Example: <a onclick="myproc()" >Show Details</a> 1421// Change to: <a onclick="myproc(); wppaOvlResize()" >Show Details</a> 1422// Isn't it simple? 1423function wppaOvlResize() { 1424 1425 // Panoramas do their own resize 1426 if ( wppaOvlActivePanorama > 0 ) { 1427 return; 1428 } 1429 1430 // After resizing, the number of lines may have changed 1431 setTimeout( 'wppaOvlSize( 10 )', 10 ); 1432 1433 if ( wppaOvlAudioStart && ! wppaOvlAudioPlaying ) { 1434 setTimeout( wppaOvlStartAudio, 100 ); 1435 } 1436} 1437 1438// Click on image 1439function wppaOvlImgClick( event ) { 1440 1441 if ( wppaOvlBrowseOnClick && ! wppaOvlIsSingle ) { 1442 if ( event.screenX < ( wppaScreenWidth() / 2 ) ) { 1443 wppaOvlShowPrev(); 1444 } 1445 else { 1446 wppaOvlShowNext(); 1447 } 1448 } 1449} 1450 1451// Make the navbar html 1452function wppaOvlNavBar() { 1453 1454 // Init 1455 var html = ''; 1456 1457 // Prev / next buttons 1458 if ( ! wppaOvlIsSingle ) { 1459 1460 // Previous 1461 if ( wppaOvlBigBrowse ) { 1462 html += 1463 '<span' + 1464 ' id="wppa-ovl-prev-btn"' + 1465 ' class="wppa-ovl-prev-btn"' + 1466 ' style="position:fixed;top:50%;left:0;width:60px;height:60px;margin-top:-30px;"' + 1467 ' onclick="wppaOvlShowPrev()"' + 1468 ' >' + 1469 wppaSvgHtml( 'Prev-Button-Big', '60px', true, false, 0, 0, 0, 0 ) +
1470 '</span>'; 1471 } 1472 if ( wppaOvlSmallBrowse ) { 1473 html += 1474 '<span' + 1475 ' id="wppa-ovl-prev-btn"' + 1476 ' class="wppa-ovl-prev-btn"' + 1477 ' style="margin:0 2px 0 0;float:left;display:block;"' + 1478 ' onclick="wppaOvlShowPrev()"' + 1479 ' >' + 1480 wppaSvgHtml( 'Prev-Button', wppaOvlIconSize, true, true ) + 1481 '</span>'; 1482 } 1483 1484 if ( wppaOvlShowStartStop ) 1485 html += 1486 '<span' + 1487 ' id="wppa-ovl-start-btn"' + 1488 ' style="margin:0 2px;float:left;display:' + ( wppaOvlRunning ? 'none' : 'block' ) + ';"' + 1489 ' title="Start"' + 1490 ' onclick="wppaOvlStartStop()"' + 1491 ' >' + 1492 wppaSvgHtml( 'Play-Button', wppaOvlIconSize, true, true ) + 1493 '</span>' + 1494 '<span' + 1495 ' id="wppa-ovl-stop-btn"' + 1496 ' style="margin:0 2px;float:left;display:' + ( wppaOvlRunning ? 'block' : 'none' ) + ';"' + 1497 ' title="Stop"' + 1498 ' onclick="wppaOvlStartStop()"' + 1499 ' >' + 1500 wppaSvgHtml( 'Pause-Button', wppaOvlIconSize, true, true ) + 1501 '</span>'; 1502 1503 // Next 1504 if ( wppaOvlBigBrowse ) { 1505 html += 1506 '<span' + 1507 ' id="wppa-ovl-next-btn"' + 1508 ' class="wppa-ovl-next-btn"' + 1509 ' style="position:fixed;top:50%;right:0;width:60px;height:60px;margin-top:-30px;"' + 1510 ' onclick="wppaOvlShowNext()"' + 1511 ' >' + 1512 wppaSvgHtml( 'Next-Button-Big', '60px', true, false, 0, 0, 0, 0 ) + 1513 '</span>'; 1514 } 1515 if ( wppaOvlSmallBrowse ) { 1516 html += 1517 '<span' + 1518 ' id="wppa-ovl-next-btn"' + 1519 ' class="wppa-ovl-next-btn"' + 1520 ' style="margin:0 2px;float:right;display:block;"' + 1521 ' onclick="wppaOvlShowNext()"' + 1522 ' >' + 1523 wppaSvgHtml( 'Next-Button', wppaOvlIconSize, true, true ) + 1524 '</span>'; 1525 } 1526 1527 } 1528 1529 // The exit button 1530 if ( wppaOvlBigBrowse ) { 1531 html += 1532 '<span' + 1533 ' id="wppa-exit-btn-2"' + 1534 ' class="sixty"' + 1535 ' style="position:fixed;top:0;right:0;width:60px;height:60px;"' + 1536 ' title="Exit"' + 1537 ' onclick="wppaOvlHide()"' + 1538 ' >' + 1539 wppaSvgHtml( 'Exit-Big', '60px', true, false, 0, 0, 0, 0 ) + 1540 '</span>'; 1541 } 1542 if ( wppaOvlSmallBrowse ) { 1543 html += 1544 '<span' + 1545 ' id="wppa-exit-btn-2"' + 1546 ' style="margin:0 2px;float:right;display:block;"' + 1547 ' title="Exit"' + 1548 ' onclick="wppaOvlHide()"' + 1549 ' >' + 1550 wppaSvgHtml( 'Exit-2', wppaOvlIconSize, true, true ) + 1551 '</span>'; 1552 } 1553 1554 // The fs buttons 1555 if ( ( wppaFsPolicy == 'lightbox' || ( wppaFsPolicy == 'global' && wppaOvlBigBrowse ) ) && ! wppaIsSafari && ! wppaIsIpad ) { 1556 html += 1557 '<span' + 1558 ' id="wppa-fulls-btn-2"' + 1559 ' class="wppa-fulls-btn"' + 1560 ' style="margin:0 2px;float:right;display:none;"' + 1561 ' title="Enter fullscreen"' + 1562 ' onclick="wppaFsOn()"' + 1563 ' >' + 1564 wppaSvgHtml( 'Full-Screen-2', wppaOvlIconSize, true, true ) + 1565 '</span>' + 1566 '<span' + 1567 ' id="wppa-exit-fulls-btn-2"' + 1568 ' class="wppa-exit-fulls-btn"' + 1569 ' style="margin:0 2px;float:right;display:none;"' + 1570 ' title="Leave fullscreen"' + 1571 ' onclick="wppaFsOff()"' + 1572 ' >' + 1573 wppaSvgHtml( 'Exit-Full-Screen-2', wppaOvlIconSize, true, true ) + 1574 '</span>'; 1575 } 1576 1577 return html; 1578} 1579 1580jQuery(document).ready(function(){jQuery(document).ready(function(){wppaAutoStartOvl()})}); 1581 1582function wppaAutoStartOvl() { 1583 1584 var id = wppaIsIntro; 1585 1586 // Feature enabled? 1587 if ( id == 0 ) { // No 1588 wppaIsIntro = false; 1589 return; 1590 } 1591 1592 jQuery(document).ready(function(){ 1593 1594 // Is the expected item on board? 1595 var elm = jQuery("[data-id='"+id+"']"); 1596 if ( elm.length == 0 ) { // No 1597 wppaIsIntro = false; 1598 return; 1599 } 1600 1601 // Now doit 1602 jQuery( elm[0] ).trigger('click'); 1603 }); 1604}
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.