1/* 2 mediaboxAdvanced v0.9.9 - The ultimate extension of Mediabox into an all-media script 3 updated 2009.01.30 4 (c) 2007-2009 John Einselen <http://iaian7.com> 5 based on 6 Slimbox v1.64 - The ultimate lightweight Lightbox clone 7 (c) 2007-2008 Christophe Beyls <http://www.digitalia.be> 8 MIT-style license. 9*/ 10 11var Mediabox; 12 13(function() { 14 15 // Global variables, accessible to Mediabox only 16 var state = 0, options, images, activeImage, prevImage, nextImage, top, fx, preload, preloadPrev = new Image(), preloadNext = new Image(), // State values: 0 (closed or closing), 1 (open and ready), 2+ (open and busy with animation) 17 // DOM elements 18 overlay, center, image, bottomContainer, bottom, captionSplit, title, caption, prevLink, number, nextLink, 19 // Mediabox specific vars 20 URL, WH, WHL, elrel, mediaWidth, mediaHeight, mediaType = "none", mediaSplit, mediaId = "mediaBox", mediaFmt; 21 22 /* 23 Initialization 24 */ 25 26 window.addEvent("domready", function() { 27 // Create and append the Mediabox HTML code at the bottom of the document 28 $(document.body).adopt( 29 $$([ 30 overlay = new Element("div", {id: "mbOverlay"}).addEvent("click", close), 31 center = new Element("div", {id: "mbCenter"}), 32 bottomContainer = new Element("div", {id: "mbBottomContainer"}) 33 ]).setStyle("display", "none") 34 ); 35 36 image = new Element("div", {id: "mbImage"}).injectInside(center); 37 bottom = new Element("div", {id: "mbBottom"}).injectInside(bottomContainer).adopt( 38 new Element("a", {id: "mbCloseLink", href: "#"}).addEvent("click", close), 39 nextLink = new Element("a", {id: "mbNextLink", href: "#"}).addEvent("click", next), 40 prevLink = new Element("a", {id: "mbPrevLink", href: "#"}).addEvent("click", previous), 41 title = new Element("div", {id: "mbTitle"}), 42 number = new Element("div", {id: "mbNumber"}), 43 caption = new Element("div", {id: "mbCaption"}), 44 new Element("div", {styles: {clear: "both"}}) 45 ); 46 47 fx = { 48 overlay: new Fx.Tween(overlay, {property: "opacity", duration: 360}).set(0), 49 image: new Fx.Tween(image, {property: "opacity", duration: 360, onComplete: nextEffect}), 50 bottom: new Fx.Tween(bottom, {property: "margin-top", duration: 240}) 51 }; 52 }); 53 54 /* 55 API 56 */ 57 58 Mediabox = { 59 close: function(){ 60 close(); // Thanks to Yosha on the google group for fixing the close function API! 61 }, 62 63 open: function(_images, startImage, _options) { 64 options = $extend({ 65 loop: false, // Allows to navigate between first and last images 66 stopKey: true, // Prevents default keyboard action (such as up/down arrows), in lieu of the shortcuts 67 // Does not apply to iFrame content 68 // Does not affect mouse scrolling 69 overlayOpacity: 0.7, // 1 is opaque, 0 is completely transparent (change the color in the CSS file) 70 // Remember that Firefox 2 and Camino 1.6 on the Mac require a background .png set in the CSS 71 resizeDuration: 240, // Duration of each of the box resize animations (in milliseconds) 72 resizeTransition: false, // Default transition in mootools 73 initialWidth: 360, // Initial width of the box (in pixels) 74 initialHeight: 240, // Initial height of the box (in pixels) 75 showCaption: true, // Display the title and caption, true / false 76 animateCaption: true, // Animate the caption, true / false 77 showCounter: true, // If true, a counter will only be shown if there is more than 1 image to display 78 counterText: ' ({x} of {y})', // Translate or change as you wish 79// Global media options 80 scriptaccess: 'true', // Allow script access to flash files 81 fullscreen: 'true', // Use fullscreen 82 fullscreenNum: '1', // 1 = true 83 autoplay: 'true', // Plays the video as soon as it's opened 84 autoplayNum: '1', // 1 = true 85 bgcolor: '#000000', // Background color, used for both flash and QT media 86// JW Media Player settings and options 87 playerpath: '../players/player_video.swf', // Path to the mediaplayer.swf or flvplayer.swf file 88 backcolor: '000000', // Base color for the controller, color name / hex value (0x000000) 89 frontcolor: '999999', // Text and button color for the controller, color name / hex value (0x000000) 90 lightcolor: '000000', // Rollover color for the controller, color name / hex value (0x000000) 91 screencolor: '000000', // Rollover color for the controller, color name / hex value (0x000000) 92 controlbar: 'over', // bottom, over, none (this setting is ignored when playing audio files) 93// NonverBlaster 94 useNB: true, // use NonverBlaster in place of the JW Media Player for .flv and .mp4 files 95 NBpath: '../players/NonverBlaster.swf', // Path to NonverBlaster.swf 96 controllerColor: '0x777777', // set the controlbar colour
97 showTimecode: 'true', // turn timecode display off or on 98// Quicktime options 99 controller: 'true', // Show controller, true / false 100// Flickr options 101 flInfo: 'true', // Show title and info at video start 102// Revver options 103 revverID: '187866', // Revver affiliate ID, required for ad revinue sharing 104 revverFullscreen: 'true', // Fullscreen option 105 revverBack: '000000', // Background colour 106 revverFront: 'ffffff', // Foreground colour 107 revverGrad: '000000', // Gradation colour 108// Youtube options 109 ytColor1: '000000', // Outline colour 110 ytColor2: '333333', // Base interface colour (highlight colours stay consistent) 111 ytQuality: '&ap=%2526fmt%3D18', // Empty for standard quality, use '&ap=%2526fmt%3D18' for high quality, and '&ap=%2526fmt%3D22' for HD (note that not all videos are availible in high quality, and very few in HD) 112// Vimeo options 113 vdPlayer: 'false', // Use simple (smaller) player (22px less) 114// Vimeo options 115 vmTitle: '1', // Show video title 116 vmByline: '1', // Show byline 117 vmPortrait: '1', // Show author portrait 118 vmColor: 'ffffff' // Custom controller colours, hex value minus the # sign, defult is 5ca0b5 119 }, _options || {}); 120 121 if (typeof _images == "string") { // The function is called for a single image, with URL and Title as first two arguments 122 _images = [[_images,startImage,_options]]; 123 startImage = 0; 124 } 125 126// Fixes Firefox 2 and Camino 1.6 incompatibility with opacity + flash 127if ((Browser.Engine.gecko) && (Browser.Engine.version<19)) { 128 options.overlayOpacity = 1; 129 overlay.className = 'mbOverlayFF'; 130} 131 132// Bypasses IE6 transparency errors via CSS (modify to use PNG instead of GIF if you have a transparent PNG fix applied to your site) 133if ((Browser.Engine.trident) && (Browser.Engine.version<5)) { 134 options.overlayOpacity = 1; 135 overlay.className = 'mbOverlayIE'; 136} 137 138 images = _images; 139 options.loop = options.loop && (images.length > 1); 140 position(); 141 setup(true); 142 top = window.getScrollTop() + (window.getHeight() / 15); 143 fx.resize = new Fx.Morph(center, $extend({duration: options.resizeDuration, onComplete: nextEffect}, options.resizeTransition ? {transition: options.resizeTransition} : {})); 144 center.setStyles({top: top, width: options.initialWidth, height: options.initialHeight, marginLeft: -(options.initialWidth/2), display: ""}); 145 fx.overlay.start(options.overlayOpacity); 146 state = 1; 147 return changeImage(startImage); 148 } 149 }; 150 151 Element.implement({ 152 mediabox: function(_options, linkMapper) { 153 $$(this).mediabox(_options, linkMapper); // The processing of a single element is similar to the processing of a collection with a single element 154 155 return this; 156 } 157 }); 158 159 Elements.implement({ 160 /* 161 options: Optional options object, see Mediabox.open() 162 linkMapper: Optional function taking a link DOM element and an index as arguments and returning an array containing 3 elements: 163 the image URL and the image caption (may contain HTML) 164 linksFilter: Optional function taking a link DOM element and an index as arguments and returning true if the element is part of 165 the image collection that will be shown on click, false if not. "this" refers to the element that was clicked. 166 This function must always return true when the DOM element argument is "this". 167 */ 168 mediabox: function(_options, linkMapper, linksFilter) { 169 linkMapper = linkMapper || function(el) { 170 elrel = el.rel.split(/[\[\]]/); 171 elrel = elrel[1]; 172 return [el.href, el.title, elrel]; 173 }; 174 175 linksFilter = linksFilter || function() { 176 return true; 177 }; 178 179 var links = this; 180 181 links.removeEvents("click").addEvent("click", function() { 182 // Build the list of images that will be displayed 183 var filteredArray = links.filter(linksFilter, this); 184 var filteredLinks = []; 185 var filteredHrefs = []; 186 187 filteredArray.each(function(item, index){ 188 if(filteredHrefs.indexOf(item.toString()) < 0) { 189 filteredLinks.include(filteredArray[index]); 190 filteredHrefs.include(filteredArray[index].toString()); 191 }; 192 }); 193 194 return Mediabox.open(filteredLinks.map(linkMapper), filteredHrefs.indexOf(this.toString()), _options); 195 }); 196 197 return links; 198 } 199 }); 200 201 /* 202 Internal functions 203 */ 204 205 function position() { 206 overlay.setStyles({top: window.getScrollTop(), height: window.getHeight()}); 207 } 208 209 function setup(open) { 210 ["object", window.ie ? "select" : "embed"].forEach(function(tag) { 211 Array.forEach(document.getElementsByTagName(tag), function(el) { 212 if (open) el._mediabox = el.style.visibility; 213 el.style.visibility = open ? "hidden" : el._mediabox; 214 }); 215 }); 216 217 overlay.style.display = open ? "" : "none"; 218 219 var fn = open ? "addEvent" : "removeEvent"; 220 window[fn]("scroll", position)[fn]("resize", position);
221 document[fn]("keydown", keyDown); 222 } 223 224 function keyDown(event) { 225 switch(event.code) { 226 case 27: // Esc 227 case 88: // 'x' 228 case 67: // 'c' 229 close(); 230 break; 231 case 37: // Left arrow 232 case 80: // 'p' 233 previous(); 234 break; 235 case 39: // Right arrow 236 case 78: // 'n' 237 next(); 238 } 239 if (options.stopKey) { return false; }; 240 } 241 242 function previous() { 243 return changeImage(prevImage); 244 } 245 246 function next() { 247 return changeImage(nextImage); 248 } 249 250 function changeImage(imageIndex) { 251 if ((state == 1) && (imageIndex >= 0)) { 252 state = 2; 253 image.set('html', ''); 254 activeImage = imageIndex; 255 prevImage = ((activeImage || !options.loop) ? activeImage : images.length) - 1; 256 nextImage = activeImage + 1; 257 if (nextImage == images.length) nextImage = options.loop ? 0 : -1; 258 259 $$(prevLink, nextLink, image, bottomContainer).setStyle("display", "none"); 260 fx.bottom.cancel().set(0); 261 fx.image.set(0); 262 center.className = "mbLoading"; 263 264// MEDIABOX FORMATING 265 WH = images[imageIndex][2].split(' '); 266 WHL = WH.length; 267 if (WHL>1) { 268 mediaWidth = (WH[WHL-2].match("%")) ? (window.getWidth()*("0."+(WH[WHL-2].replace("%", ""))))+"px" : WH[WHL-2]+"px"; 269 mediaHeight = (WH[WHL-1].match("%")) ? (window.getHeight()*("0."+(WH[WHL-1].replace("%", ""))))+"px" : WH[WHL-1]+"px"; 270 } else { 271 mediaWidth = ""; 272 mediaHeight = ""; 273 } 274 URL = images[imageIndex][0]; 275 captionSplit = images[activeImage][1].split('::'); 276// MEDIA TYPES 277// IMAGES 278 if (URL.match(/\.gif|\.jpg|\.png/i)) { 279 mediaType = 'img'; 280 preload = new Image(); 281 preload.onload = nextEffect; 282 preload.src = images[imageIndex][0]; 283// FLV, MP4 284 } else if (URL.match(/\.flv|\.mp4/i)) { 285 mediaType = 'obj'; 286 mediaWidth = mediaWidth || options.initialWidth; 287 mediaHeight = mediaHeight || options.initialHeight; 288 if (options.useNB) { 289 preload = new Swiff(''+options.NBpath+'?videoSource='+URL+'&allowSmoothing=true&autoPlay='+options.autoplay+'&buffer=6&showTimecode='+options.showTimecode+'&loop=true&controlColour='+options.controllerColor+'&scaleIfFullScreen=true&showScalingButton=false', { 290 id: 'MediaboxSWF', 291 width: mediaWidth, 292 height: mediaHeight, 293 params: {wmode: 'opaque', bgcolor: options.bgcolor, allowscriptaccess: options.scriptaccess, allowfullscreen: options.fullscreen} 294 }); 295 } else { 296 preload = new Swiff(''+options.playerpath+'?file='+URL+'&backcolor='+options.backcolor+'&frontcolor='+options.frontcolor+'&lightcolor='+options.lightcolor+'&screencolor='+options.screencolor+'&autostart='+options.autoplay+'&controlbar='+options.controlbar, { 297 id: 'MediaboxSWF', 298 width: mediaWidth, 299 height: mediaHeight, 300 params: {wmode: 'opaque', bgcolor: options.bgcolor, allowscriptaccess: options.scriptaccess, allowfullscreen: options.fullscreen} 301 }); 302 } 303 nextEffect(); 304// MP3, AAC 305 } else if (URL.match(/\.mp3|\.aac/i)) { 306 mediaType = 'obj'; 307 mediaWidth = mediaWidth || options.initialWidth; 308 mediaHeight = mediaHeight || options.initialHeight; 309 preload = new Swiff(''+options.playerpath+'?file='+URL+'&backcolor='+options.backcolor+'&frontcolor='+options.frontcolor+'&lightcolor='+options.lightcolor+'&screencolor='+options.screencolor+'&autostart='+options.autoplay, { 310 id: 'MediaboxSWF', 311 width: mediaWidth, 312 height: mediaHeight, 313 params: {wmode: 'opaque', bgcolor: options.bgcolor, allowscriptaccess: options.scriptaccess, allowfullscreen: options.fullscreen} 314 }); 315 nextEffect(); 316// SWF 317 } else if (URL.match(/\.swf/i)) { 318 mediaType = 'obj'; 319 mediaWidth = mediaWidth || options.initialWidth; 320 mediaHeight = mediaHeight || options.initialHeight; 321 preload = new Swiff(URL, { 322 id: 'MediaboxSWF', 323 width: mediaWidth, 324 height: mediaHeight, 325 params: {wmode: 'opaque', bgcolor: options.bgcolor, allowscriptaccess: options.scriptaccess, allowfullscreen: options.fullscreen} 326 }); 327 nextEffect(); 328// SOCIAL SITES 329// DailyMotion 330 } else if (URL.match(/dailymotion\.com/i)) { 331 mediaType = 'obj'; 332 mediaWidth = mediaWidth || "480px"; 333 mediaHeight = mediaHeight || "381px"; 334 preload = new Swiff(URL, { 335 id: mediaId, 336 width: mediaWidth, 337 height: mediaHeight, 338 params: {wmode: 'opaque', bgcolor: options.bgcolor, allowscriptaccess: options.scriptaccess, allowfullscreen: options.fullscreen} 339 });
340 nextEffect(); 341// Flickr 342 } else if (URL.match(/flickr\.com/i)) { 343 mediaType = 'obj'; 344 mediaWidth = mediaWidth || "500px"; 345 mediaHeight = mediaHeight || "375px"; 346 mediaSplit = URL.split('/'); 347 mediaId = mediaSplit[5]; 348 preload = new Swiff('http://www.flickr.com/apps/video/stewart.swf', { 349 id: mediaId, 350 classid: 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000', 351 width: mediaWidth, 352 height: mediaHeight, 353 params: {flashvars: 'photo_id='+mediaId+'&show_info_box='+options.flInfo, wmode: 'opaque', bgcolor: options.bgcolor, allowscriptaccess: options.scriptaccess, allowfullscreen: options.fullscreen} 354 }); 355 nextEffect(); 356// Google Video 357 } else if (URL.match(/google\.com\/videoplay/i)) { 358 mediaType = 'obj'; 359 mediaWidth = mediaWidth || "400px"; 360 mediaHeight = mediaHeight || "326px"; 361 mediaSplit = URL.split('='); 362 mediaId = mediaSplit[1]; 363 preload = new Swiff('http://video.google.com/googleplayer.swf?docId='+mediaId+'&autoplay='+options.autoplayNum, { 364 id: mediaId, 365 width: mediaWidth, 366 height: mediaHeight, 367 params: {wmode: 'opaque', bgcolor: options.bgcolor, allowscriptaccess: options.scriptaccess, allowfullscreen: options.fullscreen} 368 }); 369 nextEffect(); 370// Metacafe 371 } else if (URL.match(/metacafe\.com\/watch/i)) { 372 mediaType = 'obj'; 373 mediaWidth = mediaWidth || "400px"; 374 mediaHeight = mediaHeight || "345px"; 375 mediaSplit = URL.split('/'); 376 mediaId = mediaSplit[4]; 377 preload = new Swiff('http://www.metacafe.com/fplayer/'+mediaId+'/.swf', { 378 id: mediaId, 379 width: mediaWidth, 380 height: mediaHeight, 381 params: {wmode: 'opaque', bgcolor: options.bgcolor, allowscriptaccess: options.scriptaccess, allowfullscreen: options.fullscreen} 382 }); 383 nextEffect(); 384// MyspaceTV 385 } else if (URL.match(/myspacetv\.com|vids\.myspace\.com/i)) { 386 mediaType = 'obj'; 387 mediaWidth = mediaWidth || "425px"; 388 mediaHeight = mediaHeight || "360px"; 389 mediaSplit = URL.split('='); 390 mediaId = mediaSplit[2]; 391 preload = new Swiff('http://lads.myspace.com/videos/vplayer.swf?m='+mediaId+'&v=2&type=video', { 392 id: mediaId, 393 width: mediaWidth, 394 height: mediaHeight, 395 params: {wmode: 'opaque', bgcolor: options.bgcolor, allowscriptaccess: options.scriptaccess, allowfullscreen: options.fullscreen} 396 }); 397 nextEffect(); 398// Revver 399 } else if (URL.match(/revver\.com/i)) { 400 mediaType = 'obj'; 401 mediaWidth = mediaWidth || "480px"; 402 mediaHeight = mediaHeight || "392px"; 403 mediaSplit = URL.split('/'); 404 mediaId = mediaSplit[4]; 405 preload = new Swiff('http://flash.revver.com/player/1.0/player.swf?mediaId='+mediaId+'&affiliateId='+options.revverID+'&allowFullScreen='+options.revverFullscreen+'&backColor=#'+options.revverBack+'&frontColor=#'+options.revverFront+'&gradColor=#'+options.revverGrad+'&shareUrl=revver', { 406 id: mediaId, 407 width: mediaWidth, 408 height: mediaHeight, 409 params: {wmode: 'opaque', bgcolor: options.bgcolor, allowscriptaccess: options.scriptaccess, allowfullscreen: options.fullscreen} 410 }); 411 nextEffect(); 412// Rutube 413 } else if (URL.match(/rutube\.ru/i)) { 414 mediaType = 'obj'; 415 mediaWidth = mediaWidth || "470px"; 416 mediaHeight = mediaHeight || "353px"; 417 mediaSplit = URL.split('='); 418 mediaId = mediaSplit[1]; 419 preload = new Swiff('http://video.rutube.ru/'+mediaId, { 420 movie: 'http://video.rutube.ru/'+mediaId, 421 width: mediaWidth, 422 height: mediaHeight, 423 params: {wmode: 'opaque', bgcolor: options.bgcolor, allowscriptaccess: options.scriptaccess, allowfullscreen: options.fullscreen} 424 }); 425 nextEffect(); 426// Seesmic 427 } else if (URL.match(/seesmic\.com/i)) { 428 mediaType = 'obj'; 429 mediaWidth = mediaWidth || "435px"; 430 mediaHeight = mediaHeight || "355px"; 431 mediaSplit = URL.split('/'); 432 mediaId = mediaSplit[5]; 433 preload = new Swiff('http://seesmic.com/Standalone.swf?video='+mediaId, { 434 id: mediaId, 435 width: mediaWidth, 436 height: mediaHeight, 437 params: {wmode: 'opaque', bgcolor: options.bgcolor, allowscriptaccess: options.scriptaccess, allowfullscreen: options.fullscreen} 438 });
439 nextEffect(); 440// Tudou 441 } else if (URL.match(/tudou\.com/i)) { 442 mediaType = 'obj'; 443 mediaWidth = mediaWidth || "400px"; 444 mediaHeight = mediaHeight || "340px"; 445 mediaSplit = URL.split('/'); 446 mediaId = mediaSplit[5]; 447 preload = new Swiff('http://www.tudou.com/v/'+mediaId, { 448 width: mediaWidth, 449 height: mediaHeight, 450 params: {wmode: 'opaque', bgcolor: options.bgcolor, allowscriptaccess: options.scriptaccess, allowfullscreen: options.fullscreen} 451 }); 452 nextEffect(); 453// YouKu 454 } else if (URL.match(/youku\.com/i)) { 455 mediaType = 'obj'; 456 mediaWidth = mediaWidth || "480px"; 457 mediaHeight = mediaHeight || "400px"; 458 mediaSplit = URL.split('id_'); 459 mediaId = mediaSplit[1]; 460 preload = new Swiff('http://player.youku.com/player.php/sid/'+mediaId+'=/v.swf', { 461 width: mediaWidth, 462 height: mediaHeight, 463 params: {wmode: 'opaque', bgcolor: options.bgcolor, allowscriptaccess: options.scriptaccess, allowfullscreen: options.fullscreen} 464 }); 465 nextEffect(); 466// YouTube 467 } else if (URL.match(/youtube\.com/i)) { 468 mediaType = 'obj'; 469 mediaSplit = URL.split('v='); 470 mediaId = mediaSplit[1]; 471 if (mediaId.match(/fmt=18/i)) { 472 mediaFmt = '&ap=%2526fmt%3D18'; 473 mediaWidth = mediaWidth || "560px"; 474 mediaHeight = mediaHeight || "345px"; 475 } else if (mediaId.match(/fmt=22/i)) { 476 mediaFmt = '&ap=%2526fmt%3D22'; 477 mediaWidth = mediaWidth || "640px"; 478 mediaHeight = mediaHeight || "385px"; 479 } else { 480 mediaFmt = options.ytQuality; 481 mediaWidth = mediaWidth || "480px"; 482 mediaHeight = mediaHeight || "295px"; 483 } 484 preload = new Swiff('http://www.youtube.com/v/'+mediaId+'&autoplay='+options.autoplayNum+'&fs='+options.fullscreenNum+mediaFmt+'&color1=0x'+options.ytColor1+'&color2=0x'+options.ytColor2, { 485 id: mediaId, 486 width: mediaWidth, 487 height: mediaHeight, 488 params: {wmode: 'opaque', bgcolor: options.bgcolor, allowscriptaccess: options.scriptaccess, allowfullscreen: options.fullscreen} 489 }); 490 nextEffect(); 491// Veoh 492 } else if (URL.match(/veoh\.com/i)) { 493 mediaType = 'obj'; 494 mediaWidth = mediaWidth || "410px"; 495 mediaHeight = mediaHeight || "341px"; 496 mediaSplit = URL.split('videos/'); 497 mediaId = mediaSplit[1]; 498 preload = new Swiff('http://www.veoh.com/videodetails2.swf?permalinkId='+mediaId+'&player=videodetailsembedded&videoAutoPlay='+options.AutoplayNum, { 499 id: mediaId, 500 width: mediaWidth, 501 height: mediaHeight, 502 params: {wmode: 'opaque', bgcolor: options.bgcolor, allowscriptaccess: options.scriptaccess, allowfullscreen: options.fullscreen} 503 }); 504 nextEffect(); 505// Viddler 506 } else if (URL.match(/viddler\.com/i)) { 507 mediaType = 'obj'; 508 mediaWidth = mediaWidth || "437px"; 509 mediaHeight = mediaHeight || "370px"; 510 mediaSplit = URL.split('/'); 511 mediaId = mediaSplit[4]; 512 preload = new Swiff(URL, { 513 id: 'viddler_'+mediaId, 514 movie: URL, 515 classid: 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000', 516 width: mediaWidth, 517 height: mediaHeight, 518 params: {wmode: 'opaque', bgcolor: options.bgcolor, allowscriptaccess: options.scriptaccess, allowfullscreen: options.fullscreen, id: 'viddler_'+mediaId, movie: URL} 519 }); 520 nextEffect(); 521// Vimeo 522 } else if (URL.match(/vimeo\.com/i)) { 523 mediaType = 'obj'; 524 mediaWidth = mediaWidth || "400px"; 525 mediaHeight = mediaHeight || "225px"; 526 mediaSplit = URL.split('/'); 527 mediaId = mediaSplit[3]; 528 preload = new Swiff('http://www.vimeo.com/moogaloop.swf?clip_id='+mediaId+'&server=www.vimeo.com&fullscreen='+options.fullscreenNum+'&show_title='+options.vmTitle+'&show_byline='+options.vmByline+'&show_portrait='+options.vmPortrait+'&color='+options.vmColor, { 529 id: mediaId, 530 width: mediaWidth, 531 height: mediaHeight, 532 params: {wmode: 'opaque', bgcolor: options.bgcolor, allowscriptaccess: options.scriptaccess, allowfullscreen: options.fullscreen} 533 }); 534 nextEffect(); 535// 12seconds 536 } else if (URL.match(/12seconds\.tv/i)) { 537 mediaType = 'obj'; 538 mediaWidth = mediaWidth || "430px"; 539 mediaHeight = mediaHeight || "360px"; 540 mediaSplit = URL.split('/'); 541 mediaId = mediaSplit[5]; 542 preload = new Swiff('http://embed.12seconds.tv/players/remotePlayer.swf', { 543 id: mediaId, 544 width: mediaWidth, 545 height: mediaHeight, 546 params: {flashvars: 'vid='+mediaId+'', wmode: 'opaque', bgcolor: options.bgcolor, allowscriptaccess: options.scriptaccess, allowfullscreen: options.fullscreen} 547 });
548 nextEffect(); 549// CONTENT TYPES 550// INLINE 551 } else if (URL.match(/\#mb_/i)) { 552 mediaType = 'inline'; 553 mediaWidth = mediaWidth || options.initialWidth; 554 mediaHeight = mediaHeight || options.initialHeight; 555 URLsplit = URL.split('#'); 556 preload = $(URLsplit[1]).get('html'); 557 nextEffect(); 558// HTML 559 } else { 560 mediaType = 'url'; 561 mediaWidth = mediaWidth || options.initialWidth; 562 mediaHeight = mediaHeight || options.initialHeight; 563 mediaId = "mediaId_"+new Date().getTime(); // Safari will not update iframe content with a static id. 564 preload = new Element('iframe', { 565 'src': URL, 566 'id': mediaId, 567 'width': mediaWidth, 568 'height': mediaHeight, 569 'frameborder': 0 570 }); 571 nextEffect(); 572 } 573 } 574 return false; 575 } 576 577 function nextEffect() { 578 switch (state++) { 579 case 2: 580 if (mediaType == "img"){ 581 mediaWidth = preload.width; 582 mediaHeight = preload.height; 583 image.setStyles({backgroundImage: "url("+URL+")", display: ""}); 584 } else if (mediaType == "obj") { 585 if (Browser.Plugins.Flash.version<8) { 586 image.setStyles({backgroundImage: "none", display: ""}); 587 image.set('html', '<div id="mbError"><b>Error</b><br/>Adobe Flash is either not installed or not up to date,<br/>please visit <a href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" title="Get Flash" target="_new">Adobe.com</a> to download the free player.</div>'); 588 } else { 589 image.setStyles({backgroundImage: "none", display: ""}); 590 preload.inject(image); 591 } 592 } else if (mediaType == "inline") { 593 image.setStyles({backgroundImage: "none", display: ""}); 594 image.set('html', preload); 595 } else if (mediaType == "url") { 596 image.setStyles({backgroundImage: "none", display: ""}); 597 preload.inject(image); 598 } else { 599 alert('this file type is not supported\n'+URL+'\nplease visit iaian7.com/webcode/Mediabox for more information'); 600 } 601 $$(image, bottom).setStyle("width", mediaWidth); 602 image.setStyle("height", mediaHeight); 603 604 title.set('html', (options.showCaption) ? captionSplit[0] : ""); 605 caption.set('html', (options.showCaption && (captionSplit.length > 1)) ? captionSplit[1] : ""); 606 number.set('html', (options.showCounter && (images.length > 1)) ? options.counterText.replace(/{x}/, activeImage + 1).replace(/{y}/, images.length) : ""); 607 608 if ((prevImage >= 0) && (images[prevImage][0].match(/\.gif|\.jpg|\.png/i))) preloadPrev.src = images[prevImage][0]; 609 if ((nextImage >= 0) && (images[nextImage][0].match(/\.gif|\.jpg|\.png/i))) preloadNext.src = images[nextImage][0]; 610 611 state++; 612 case 3: 613 center.className = ""; 614 fx.resize.start({height: image.offsetHeight, width: image.offsetWidth, marginLeft: -image.offsetWidth/2}); 615 break; 616 state++; 617 case 4: 618 bottomContainer.setStyles({top: top + center.clientHeight, marginLeft: center.style.marginLeft, visibility: "hidden", display: ""}); 619 fx.image.start(1); 620 break; 621 case 5: 622 if (prevImage >= 0) prevLink.style.display = ""; 623 if (nextImage >= 0) nextLink.style.display = ""; 624 if (options.animateCaption) { 625 fx.bottom.set(-bottom.offsetHeight).start(0); 626 } 627 bottomContainer.style.visibility = ""; 628 state = 1; 629 } 630 } 631 632 function close() { 633 if (state) { 634 state = 0; 635 preload.onload = $empty; 636 image.set('html', ''); 637 for (var f in fx) fx[f].cancel(); 638 $$(center, bottomContainer).setStyle("display", "none"); 639 fx.overlay.chain(setup).start(0); 640 } 641 return false; 642 } 643 644})(); 645 646// AUTOLOAD CODE BLOCK 647Mediabox.scanPage = function() { 648// $$('#mb_').each(function(hide) { hide.set('display', 'none'); }); 649 var links = $$("a").filter(function(el) { 650 return el.rel && el.rel.test(/^lightbox/i); 651 }); 652 $$(links).mediabox({/* Put custom options here */}, null, function(el) { 653 var rel0 = this.rel.replace(/[[]|]/gi," "); 654 var relsize = rel0.split(" "); 655 return (this == el) || ((this.rel.length > 8) && el.rel.match(relsize[1])); 656 }); 657}; 658window.addEvent("domready", Mediabox.scanPage);
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.