1/* 2 * version: 3.0.0 3 * package: OrangeBox 4 * author: David Paul Hamilton - http://davidpaulhamilton.net/orangebox 5 * copyright: Copyright (c) 2012 David Hamilton / DavidPaulHamilton.net All rights reserved. 6 * license: GNU/GPL license: http://www.gnu.org/copyleft/gpl.html 7 */ 8if (typeof oB !== 'undefined') { 9 console.log('OrangeBox: Variable "oB", used by OrangeBox, is already defined'); 10} else { 11 var oB; 12 (function ($) { 13 oB = { 14 gallery: [], 15 settings: { 16 autoplay: false, 17 searchTerm: 'lightbox', 18 fadeControls: false, 19 keyboardNavigation: true, 20 orangeControls: false, 21 showClose: true, 22 showDots: false, 23 showNav: true, 24 addThis: true, 25 addThisServices: 'twitter,facebook,digg,delicious,more', 26 notFound: 'Not Found', 27 overlayOpacity: 0.95, 28 contentBorderWidth: 4, 29 contentRoundedBorder: true, 30 contentMinSize: [100, 200], 31 contentMaxSize: [0.75, 0.75], 32 videoAspect: [390, 640], 33 fadeTime: 200, 34 slideshowTimer: 3000, 35 streamItems: 10, 36 logging: false, 37 checkAlias: true 38 }, 39 methods: { 40 init: function (o) { 41 function checkURL(searchTerm) { 42 if (oB.ourl.match(/#\..{1,}\.facebook/)) { 43 oB.ourl = oB.ourl.substr(0, oB.ourl.search(/#\..{1,}\.facebook/)); 44 } 45 if (oB.ourl.match(/^#\w{1,}$/) && $('#' + oB.ourl).length > 0) { 46 oB.methods.create($('#' + oB.ourl)); 47 } else { 48 $(searchTerm).each(function () { 49 var href = $(this).attr('href'); 50 href = href.replace(/\//gi,'').replace(/\./gi,'').replace(/:/gi,'').replace(/\?/gi,'').replace(/&/gi,'').replace(/\=/gi,'').replace(/#/gi,''); 51 52 if (href.indexOf(oB.ourl) !== -1) { 53 oB.methods.create($(this)); 54 return false; 55 } 56 }); 57 } 58 } 59 if (!$('#ob_content').length) { 60 if (o) { 61 $.extend(oB.settings, o); 62 } 63 var searchTerm = 'a[data-ob*=lightbox], area[data-ob*=lightbox], a[rel*=lightbox], area[rel*=lightbox]'; 64 if(oB.settings.searchTerm !== "") { 65 searchTerm = 'a[data-ob*='+oB.settings.searchTerm+'], area[data-ob*='+oB.settings.searchTerm+'], a[rel*='+oB.settings.searchTerm+'], area[rel*='+oB.settings.searchTerm+']'; 66 } 67 oB.windowURL = window.location.href; 68 if (oB.windowURL.match(/(&|\?)orangebox=/)) { 69 oB.windowURL = oB.windowURL.substr(0, oB.windowURL.search(/(&|\?)orangebox=/)); 70 } 71 oB.ourl = oB.methods.getUrlVars()['orangebox']; 72 try { 73 document.createEvent("TouchEvent"); 74 oB.touch = true; 75 oB.methods.logit('Touch device detected', true); 76 } catch (e) { 77 oB.touch = false; 78 oB.methods.logit('Touch device not detected', true); 79 } 80 if (oB.settings.orangeControls === true && !$().orangeControls) { 81 oB.methods.logit('Connection with OrangeControls failed'); 82 oB.settings.orangeControls = false; 83 } 84 oB.browser = $.browser; 85 86 if (oB.settings.addThis) { 87 $.getScript('http://s7.addthis.com/js/250/addthis_widget.js#pubid=ra-4dd42f2b5b9fc332', function () { 88 if (oB.ourl) { 89 checkURL(searchTerm); 90 } 91 }); 92 } else if (oB.ourl) { 93 checkURL(searchTerm); 94 } 95 return this.each(function () { 96 oB.methods.setupData($(this)); 97 }); 98 } 99 return false; 100 }, 101 setupData: function (o) { 102 var u = o.attr('href'), c = false, s = [0, 0], i = 0, t = "", g = false, rel = o.attr('data-ob'), id, alias = false, unique = true, cap = o.attr('data-ob_caption'); 103 if(!rel || rel === "") { 104 rel = o.attr('rel'); 105 o.attr('data-ob', rel); 106 } 107 if (rel && rel.match(/\[/)) { 108 g = rel.substring(rel.indexOf("[") + 1, rel.indexOf("]")).replace(/ /g, "_"); 109 $.each(oB.gallery, function() { 110 if (this.name === g) { 111 unique = false; 112 if (oB.settings.checkAlias) { 113 $.each(this.objects, function() { 114 if (this.data('oB') && this.data('oB').href === o.attr('href')) { 115 oB.methods.logit('Object already added: ' + u, true); 116 alias = this; 117 } 118 }); 119 } 120 } 121 }); 122 if (unique) { 123 oB.gallery.push({name: g, objects: []}); 124 } 125 }
126 if (oB.settings.checkAlias && (o.data('oB') || alias)) { 127 oB.methods.logit('Object already added: ' + u, true); 128 o.click(function (e) { 129 e.preventDefault(); 130 oB.methods.create(alias); 131 }); 132 } else if (u) { 133 if (typeof o.attr('title') !== "undefined") { 134 t = o.attr('title'); 135 } 136 if (typeof o.attr('data-ob_height') !== 'undefined') { 137 s[0] = parseInt(o.attr('data-ob_height'), 10); 138 } 139 if (typeof o.attr('data-ob_width') !== 'undefined') { 140 s[1] = parseInt(o.attr('data-ob_width'), 10); 141 } 142 if (typeof o.attr('data-ob_iframe') !== 'undefined' && o.attr('data-ob_iframe') === "true") { 143 c = "iframe"; 144 } else if (u.match(/\.(?:jpg|jpeg|bmp|png|gif)/i)) { 145 c = "image"; 146 } else if (u.match(/\.pdf/i)) { 147 c = "pdf"; 148 } else if (u.match(/\.swf/i)) { 149 c = "flash"; 150 } else if (u.match(/^http:\/\/api\.flickr\.com\/services\/feeds\/.{1,}\.gne\?id=\d{1,}@.{1,}&lang=.{1,}&format=rss_200/i)) { 151 c = "flickr"; 152 u = u.replace('rss_200', 'json') + "&jsoncallback=?"; 153 if (!rel.match(/\[/)) { 154 g = 'flickr' + newDate.getTime(); 155 } 156 $.getJSON(u, function (data) { 157 $.each(data.items, function (index, item) { 158 var item_href = item.media.m.replace('_m.jpg', '.jpg'), delay = ""; 159 if(typeof o.attr('data-ob_delayTimer') !== "undefined" && o.attr('data-ob_delayTimer') !== "0") { 160 delay = 'data-ob_delayTimer="' + o.attr('data-ob_delayTimer') + '"'; 161 } 162 if (index === 0) { 163 o.attr({ 164 href: item_href, 165 "data-ob_share": "false", 166 caption: cap, 167 title: item.title 168 }); 169 oB.methods.setupData(o); 170 } else if (index < oB.settings.streamItems) { 171 oB.methods.setupData($('<a href="' + item_href + '" data-ob_linkText="' + o.attr('data-ob_linkText') + '" data-ob_link="' + o.attr('data-ob_link') + '" data-ob_linkTarget="' + o.attr('data-ob_linkTarget') + '" ' + delay + ' data-ob_share="false" title="' + item.title + '" data-ob="lightbox[' + g + ']"></a>')); 172 } else { 173 return false; 174 } 175 }); 176 }); 177 } else if (u.match(/^https:\/\/picasaweb\.google\.com\/data\/feed\/base\//i)) { 178 c = "picasa"; 179 u = u.replace('/base/', '/api/').replace('alt=rss', 'alt=json-in-script') + '&max-results=' + oB.settings.streamItems + '&callback=?'; 180 if (!rel.match(/\[/)) { 181 g = 'picasa' + newDate.getTime(); 182 } 183 $.ajax({
184 url: u, 185 dataType: 'json', 186 success: function (data) { 187 $.each(data.feed.entry, function (index, item) { 188 var picasaSrc, delay = ""; 189 if(typeof o.attr('data-ob_delayTimer') !== "undefined" && o.attr('data-ob_delayTimer') !== "0") { 190 delay = 'data-ob_delayTimer="' + o.attr('data-ob_delayTimer') + '"'; 191 } 192 if (item.content) { 193 picasaSrc = item.content.src; 194 } else if (item.media$group.media$content[0]) { 195 picasaSrc = item.media$group.media$content[0].url; 196 } else { 197 return false; 198 } 199 if(cap === "") { 200 cap = item.summary.$t; 201 } 202 if (index === 0) { 203 o.attr({ 204 href: picasaSrc, 205 "data-ob_share": "false", 206 "data-ob_caption": cap, 207 title: item.title.$t 208 }); 209 oB.methods.setupData(o); 210 } else if (index < oB.settings.streamItems) { 211 oB.methods.setupData($('<a href="' + picasaSrc + '" data-ob_caption="' + item.summary.$t + '" data-ob_linkText="' + o.attr('data-ob_linkText') + '" data-ob_link="' + o.attr('data-ob_link') + '" data-ob_linkTarget="' + o.attr('data-ob_linkTarget') + '" ' + delay + ' data-ob_share="false" title="' + item.title.$t + '" data-ob="lightbox[' + g + ']"></a>')); 212 } else { 213 return false; 214 } 215 }); 216 } 217 }); 218 } else if (u.match(/^http:\/\/\w{0,3}\.?youtube\.\w{2,3}\/watch\?v=[\w\-]{11}/i)) { 219 id = u.match(/\?v=[\w\-]{11}/)[0].substring(3); 220 c = "youtube"; 221 } else if (u.match(/^http:\/\/\w{0,3}\.?youtu\.be\/[\w\-]{11}$/i)) { 222 id = u.match(/youtu\.be\/[\w\-]{11}$/)[0].substring(9); 223 c = "youtube"; 224 } else if (u.match(/^http:\/\/\w{0,3}\.?youtube\.\w{2,3}\/embed\/[\w\-]{11}$/i)) { 225 id = u.match(/\/embed\/[\w\-]{11}$/)[0].substring(7); 226 c = "youtube"; 227 } else if (u.match(/^http:\/\/\w{0,3}\.?vimeo\.com\/\d{1,10}$/i)) { 228 id = u.match(/vimeo\.com\/\d{1,}/)[0].substring(10); 229 c = "vimeo"; 230 } else if (u.match(/^http:\/\/\w{0,3}\.?viddler\.com\/(?:simple|player)\/\w{1,10}$/i)) { 231 id = u.match(/viddler\.com\/(player|simple)\/\w{1,}/)[0].substring(19); 232 c = "viddler"; 233 } else if (u.match(/^#\w{1,}$/i)) { 234 c = "inline"; 235 } else { 236 oB.methods.logit('Unsupported Media: ' + u); 237 } 238 if (c && c !== "flickr" && c !== "picasa") { 239 $.each(oB.gallery, function() { 240 if (this.name === g) { 241 i = this.objects.push(o) - 1; 242 } 243 }); 244 o.data('oB', { 245 size: s, 246 css: '', 247 gallery: g, 248 index: i, 249 contentType: c, 250 href: u, 251 title: t, 252 linkText: o.attr('data-ob_linkText'), 253 "link": o.attr('data-ob_link'), 254 linkTarget: o.attr('data-ob_linkTarget'), 255 caption: cap, 256 share: o.attr('data-ob_share'), 257 delayTimer: o.attr('data-ob_delayTimer'), 258 id: id 259 }).click(function (e) { 260 e.preventDefault(); 261 oB.methods.create(o); 262 }); 263 } 264 } else { 265 oB.methods.logit('Object has no "href" attribute'); 266 } 267 }, 268 create: function (obj, o) { 269 function handleEscape(e) { 270 if (e.keyCode === 27 && oB.progress === null) { 271 oB.methods.destroy(); 272 } else if (e.keyCode === 37 && oB.progress === null) {
273 oB.methods.slideshowPause(); 274 oB.methods.navigate(-1); 275 } else if (e.keyCode === 39 && oB.progress === null) { 276 oB.methods.slideshowPause(); 277 oB.methods.navigate(1); 278 } 279 } 280 if (!$('#ob_content').length) { 281 if (o) { 282 $.extend(oB.settings, o); 283 } 284 if (!obj) { 285 obj = (this instanceof jQuery) ? this : $(this); 286 } 287 if (!obj.data('oB')) { 288 oB.methods.setupData(obj); 289 } 290 if (obj.data('oB').contentType) { 291 //Set Vars 292 oB.currentGallery = []; 293 oB.playing = oB.settings.autoplay; 294 oB.progress = null; 295 oB.docHeight = $(document).height(); 296 oB.docWidth = $(document).width(); 297 $.each(oB.gallery, function() { 298 if (this.name === obj.data('oB').gallery) { 299 oB.currentGallery = this.objects; 300 return false; 301 } 302 }); 303 var overlay = $('<div id="ob_overlay"></div>').css({ 304 "opacity": oB.settings.overlayOpacity, 305 "height": oB.docHeight, 306 "min-height": oB.docHeight, 307 "min-width": oB.docWidth 308 }
308), container = $('<div id="ob_container"></div>'), ob_content = $('<div id="ob_content"></div>').click(function (e) { 309 e.stopPropagation(); 310 }).css("border-width", oB.settings.contentBorderWidth); 311 if(oB.settings.contentRoundedBorder) { 312 ob_content.css({ 313 "-moz-border-radius": oB.settings.contentBorderWidth, 314 "border-radius": oB.settings.contentBorderWidth 315 }); 316 } 317 if (oB.touch) { 318 container.css("min-width", oB.docWidth); 319 } 320 321 //Check for addThis 322 if (oB.settings.addThis === true && typeof addthis === 'undefined') { 323 oB.methods.logit('Connection with addThis failed'); 324 oB.settings.addThis = false; 325 } 326 327 //if IE 6 328 if (typeof document.body.style.maxHeight === "undefined") { 329 $("body", "html").css({ 330 height: "100%", 331 width: "100%" 332 }); 333 } 334 335 //Click to Hide Modal 336 $("body").append(overlay.fadeIn(oB.settings.fadeTime).click(function () { 337 oB.methods.destroy(); 338 })).append(container.click(function () { 339 oB.methods.destroy(); 340 })); 341 $("#ob_container").append('<div id="ob_float"></div>').append(ob_content); 342 343 //Listens for Escape 344 if (oB.settings.keyboardNavigation) { 345 $(document).keydown(handleEscape); 346 } 347 348 //Fire in the Hole 349 oB.methods.showContent(obj, true); 350 } 351 } 352 }, 353 showContent: function (obj, initial) { 354 var href = obj.data('oB').href, 355 title = obj.data('oB').title, 356 contentType = obj.data('oB').contentType, 357 content, 358 ob_caption = '', 359 ob_caption_text = '', 360 tag = href, 361 navRight = $('<a class="ob_nav" id="ob_right"><span class="ob_controls" id="ob_right-ico"></span></a>').click(function (e) { 362 if (oB.progress === null) { 363 oB.methods.slideshowPause(); 364 e.stopPropagation(); 365 oB.methods.navigate(1); 366 } 367 }), 368 navLeft = $('<a class="ob_nav" id="ob_left"><span class="ob_controls" id="ob_left-ico"></span></a>').click(function (e) { 369 if (oB.progress === null) { 370 oB.methods.slideshowPause(); 371 e.stopPropagation(); 372 oB.methods.navigate(-1); 373 } 374 }), 375 dotnav = $('<ul id="ob_dots"></ul>').click(function (e) { e.stopPropagation(); }), 376 ob_link; 377 if(obj.data('oB').caption) { 378 ob_caption_text = $.trim(obj.data('oB').caption); 379 if(ob_caption_text !== "") { 380 ob_caption = $('<div id="ob_caption"></div>').click(function (e) { 381 e.stopPropagation(); 382 }).append('<p>' + ob_caption_text + '</p>'); 383 } 384 } 385 tag = tag.replace(/\//gi,'').replace(/\./gi,'').replace(/:/gi,'').replace(/\?/gi,'').replace(/&/gi,'').replace(/\=/gi,'').replace(/#/gi,''); 386 ob_link = (oB.windowURL.match(/\?/)) ? oB.windowURL + "&orangebox=" + tag : oB.windowURL + "?orangebox=" + tag; 387 oB.currentIndex = obj.data('oB').index; 388 oB.methods.showLoad(); 389 $('#ob_content').removeClass().addClass('content' + oB.currentIndex); 390 391 //Setup Dot Nav 392 if (oB.settings.showDots) { 393 $.each(oB.currentGallery, function (x) { 394 dotnav.append($('<li id="ob_dot' + x + '"></li>').click(function (e) { 395 e.stopPropagation(); 396 if (!$(this).hasClass('current') && oB.progress === null) {
397 oB.methods.slideshowPause(); 398 var x = $(this).attr('id').substr(6); 399 dotnav.find("li").removeClass('current'); 400 $(this).addClass('current'); 401 oB.methods.navigate("", x); 402 } 403 })); 404 }); 405 } 406 407 //Append Navigation 408 if (oB.currentGallery.length > 1) { 409 if (oB.settings.orangeControls) { 410 $(document).orangeControls(); 411 } 412 if (oB.settings.showDots) { 413 $('#ob_content').append(dotnav); 414 } 415 } 416 if (oB.settings.showClose) { 417 $('#ob_content').append($('<div title="close" class="ob_controls ob_cs" id="ob_close"></div>').click(function (e) { 418 e.stopPropagation(); 419 oB.methods.destroy(); 420 })); 421 } 422 423 //Update Navigation 424 function setControls() { 425 if (oB.settings.showDots) { 426 $('#ob_dots').find('li').each(function () { 427 var i = 'ob_dot' + obj.data('oB').index; 428 if ($(this).attr('id') === i) { 429 $(this).addClass('current'); 430 } else { 431 $(this).removeClass('current'); 432 } 433 }); 434 } 435 if (oB.settings.showNav) { 436 if (oB.currentGallery[oB.currentIndex + 1]) { 437 $('#ob_content').append(navRight); 438 } 439 if (oB.currentGallery[oB.currentIndex - 1]) { 440 $('#ob_content').append(navLeft); 441 } 442 } 443 clearTimeout(oB.controlTimer); 444 if (oB.settings.fadeControls && !oB.touch) { 445 if(!oB.playing || initial) { 446 $('.ob_controls').fadeIn(oB.settings.fadeTime); 447 } 448 else { 449 $('.ob_controls').hide(); 450 } 451 oB.controlTimer = setTimeout(function () { 452 $('.ob_controls').fadeOut(oB.settings.fadeTime); 453 }, 1200); 454 $(document).mousemove(function (event) { 455 $('.ob_controls').fadeIn(oB.settings.fadeTime); 456 clearTimeout(oB.controlTimer); 457 oB.controlTimer = setTimeout(function () { 458 if (!$(event.target).hasClass('ob_controls') && !$(event.target).parent().hasClass('ob_controls')) { 459 oB.controlTimer = setTimeout(function () { 460 $('.ob_controls').fadeOut(oB.settings.fadeTime); 461 }, 1200); 462 } 463 }, 20); 464 }); 465 } else { 466 $('.ob_controls').fadeIn(oB.settings.fadeTime); 467 } 468 } 469 470 //Set Window Margin 471 function setWindowMargin(w) { 472 var copied_elem = $('<div>' + title + '</div>').css({ 473 visibility: "hidden", 474 display: "block", 475 position: "absolute",
476 width: w - 40, 477 "line-height": $('#ob_title').css('line-height'), 478 "font-size": $('#ob_title').css('font-size') 479 }); 480 $("body").append(copied_elem); 481 $('#ob_content').css('margin-top', copied_elem.height() + 44); 482 $('#ob_title').css({ 483 'margin-top': -copied_elem.height() - oB.settings.contentBorderWidth - 4, 484 'margin-right': -oB.settings.contentBorderWidth 485 }); 486 copied_elem.remove(); 487 } 488 489 //Adjust Modal Properties 490 function adjustModalProperties() { 491 var size = [content.outerHeight(), content.outerWidth()], dim; 492 if (obj.data('oB').css[0]) { 493 size[0] = obj.data('oB').css[0]; 494 } 495 if (obj.data('oB').css[1]) { 496 size[1] = obj.data('oB').css[1]; 497 } 498 if (content.attr('id') !== "ob_error" && size[0] < oB.settings.contentMinSize[0]) { 499 size[0] = oB.settings.contentMinSize[0]; 500 } 501 if (size[1] < oB.settings.contentMinSize[1]) { 502 size[1] = oB.settings.contentMinSize[1]; 503 } 504 dim = [Math.round(size[0]), Math.round(size[1])]; 505 if (contentType !== "error") { 506 setWindowMargin(dim[1]); 507 } else { 508 dim[1] = 250; 509 } 510 $('#ob_float').css({ 511 "margin-bottom": -(dim[0] + (oB.settings.contentBorderWidth * 2) + 44) / 2 512 }); 513 $('#ob_content').css({ 514 "min-height": dim[0], 515 "width": dim[1] 516 }); 517 } 518 519 //Build the Window 520 function buildWindow() { 521 var delayTimer = (obj.data('oB').delayTimer) ? parseInt(obj.data('oB').delayTimer, 10) + parseInt(oB.settings.slideshowTimer, 10) : oB.settings.slideshowTimer, 522 target = 'target="_blank"', 523 addThis = $('<a id="ob_share" class="addthis_button_compact"></a>'), 524 shareHTML = $('<span class="at300bs at15nc at15t_compact"></span>').css('display', 'inline-block'), 525 p = $(window).scrollTop(); 526 if (p === 0) { 527 p = $(document).scrollTop(); 528 } 529 if (p === 0) { 530 p = window.pageYOffset; 531 } 532 $("#ob_container").css("margin-top", p); 533 $('#ob_content').append('<div id="ob_title"></div>').append(content.addClass('ob_contents')); 534 if(contentType !== "error") { 535 $('#ob_content').append(ob_caption); 536 if (obj.data('oB').link && obj.data('oB').link !== "" && obj.data('oB').link !== "undefined" ) { 537 if (obj.data('oB').linkTarget === "_self") { 538 target = 'target="_self"'; 539 } 540 title = (obj.data('oB').linkText && obj.data('oB').linkText !== "undefined") ? title + ' <a href="' + obj.data('oB').link + '" ' + target + ' >' + obj.data('oB').linkText + '</a>' : title + ' <a href="' + obj.data('oB').link + '" ' + target + ' >' + obj.data('oB').link + '</a>'; 541 } 542 if (oB.settings.addThis && obj.data('oB').share !== "fal
542se") { 543 addThis.addClass("ob_share"); 544 title = $.trim(title); 545 if (title === "") { title = " "; } 546 $('#ob_title').append(addThis); 547 addthis.button('.ob_share', { 548 services_compact: oB.settings.addThisServices, 549 ui_offset_left: -244, 550 ui_offset_top: 4 551 }, { 552 url: ob_link, 553 title: title 554 }); 555 $('#ob_share').html('').append(shareHTML); 556 } 557 $('#ob_title').prepend(title).click(function (e) { e.stopPropagation(); }); 558 setControls(); 559 if(obj.data('oB').share !== "false") { 560 $(document).trigger('oB_init', ob_link); 561 oB.methods.logit('ID:' + oB.currentIndex + ' href:"' + href + '" link:"' + ob_link + '"', true); 562 } else { 563 $(document).trigger('oB_init', ""); 564 oB.methods.logit('ID:' + oB.currentIndex + ' href:"' + href + '"', true); 565 } 566 oB.progress = null; 567 if (oB.playing) { 568 oB.slideshowTimer = setTimeout(function () { 569 oB.methods.navigate(1); 570 }, delayTimer); 571 } 572 } else { 573 oB.methods.logit('Could not find file'); 574 } 575 oB.methods.showLoad(1); 576 $('#ob_content').fadeIn(oB.settings.fadeTime, function () { 577 $('#ob_overlay').css("height", $(document).height()); 578 }); 579 adjustModalProperties(); 580 } 581 582 //Error Content 583 function throwError() { 584 content = $('<div id="ob_error">' + oB.settings.notFound + '</div>'); 585 $('#ob_content').append(content.addClass('ob_contents')); 586 contentType = "error"; 587 clearTimeout(oB.controlTimer); 588 clearTimeout(oB.slideshowTimer); 589 clearTimeout(oB.scrollTimer); 590 $(document).unbind("keydown").unbind("mousemove"); 591 buildWindow(); 592 } 593 594 //iFrame Content 595 function showiFrame() { 596 var dim = oB.methods.getSize(obj, [0, 0]); 597 obj.data('oB').css = dim; 598 content = $('<div id="ob_iframe"><iframe allowTransparency="true" height="100%" width="100%" scrolling="auto" type="text/html" frameborder="0" hspace="0" src="' + href + '"></iframe></div>').css("width", dim[1]); 599 if (dim[0] !== 0) { 600 content.css("height", dim[0]); 601 } 602 buildWindow(); 603 } 604 605 //Inline Content 606 function showInline() { 607 var dim = oB.methods.getSize(obj, [0, 0]), inline_content = $('<div class="inline_content"></div>'), s = obj.data('oB').size, clone, copied_elem, copied_content, height; 608 if (href.match(/\?/)) { 609 href = href.substr(0, href.indexOf("?")); 610 } 611 if ($(href).length && $(href).html() !== "") { 612 613 if (s[0] === 0) { 614 clone = $(href).clone(); 615 clone.css('display', 'block'); 616 copied_elem = $('<div id="ob_inline"></div>').css({visibility: "hidden", display: "block", position: "absolute", width: dim[1]}); 617 copied_content = $('<div class="inline_content"></div>').append(clone); 618 copied_elem.append(copied_content); 619 $("body").append(copied_elem); 620 height = copied_elem.height(); 621 copied_content.empty().remove(); 622 copied_elem.remove(); 623 if(dim[0] > height) { 624 dim[0] = height; 625 } 626 } 627 628 obj.data('oB').css = dim; 629 content = $('<div id="ob_inline"></div>').css({ 630 "width": dim[1] 631 }); 632 $(href).parent().addClass('ob_inline_content_holder'); 633 if($(href).is(':visible')) { 634 $(href).appendTo(inline_content).addClass('ob_inline_content'); 635 }else { 636 $(href).appendTo(inline_content).addClass('ob_inline_content').addClass('ob_inline_hide').show(); 637 } 638 content.append(inline_content); 639 if (dim[0] !== 0) { 640 content.css("height", dim[0]); 641 } 642 buildWindow(); 643 } else { 644 throwError(); 645 } 646 } 647 648 //Video Content 649 function showVideo() { 650 var dim = oB.methods.getSize(obj, [0, 0]), src; 651 switch (contentType) { 652 case "youtube": 653 src = 'http://www.youtube.com/embed/'+ obj.data('oB').id +'?autoplay=1&fs=1&modestbranding=1&rel=0&showsearch=0&wmode=transparent'; 654 break; 655 case "vimeo": 656 src = 'http://player.vimeo.com/video/' + obj.data('oB').id + '?title=0&byline=0&portrait=0&autoplay=1&wmode=transparent'; 657 break; 658 case "viddler": 659 src = 'http://cdn.static.viddler.com/flash/publisher.swf?key='
659+ obj.data('oB').id + '&title=0&byline=0&portrait=0&autoplay=1&wmode=transparent'; 660 break; 661 } 662 obj.data('oB').css = dim; 663 content = $('<div id="ob_iframe"><iframe allowTransparency="true" id="ob_video" width="100%" height="100%" type="text/html" frameborder="0" hspace="0" scrolling="no" src="' + src + '"></iframe></div>').css({ 664 "height": dim[0], 665 "width": dim[1], 666 "background-color": "#000000" 667 }); 668 buildWindow(); 669 } 670 671 //Flash Content 672 function showFlash() { 673 var dim = oB.methods.getSize(obj, [0, 0]); 674 obj.data('oB').css = dim; 675 content = $('<div id="ob_video">' + 676 '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="' + dim[1] + '" height="' + dim[0] + '" id="ob_flash_content" align="middle">' + 677 '<param name="movie" value="' + href + '"/><param name="wmode" value="transparent"/><param name="allowFullScreen" value="true"/>' + 678 '<embed name="ob_flash_content" flashVars="playerVars=autoPlay=yes" src="' + href + '" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" allowFullScreen="true" allowScriptAccess="always" width="' + dim[1] + '" height="' + dim[0] + '" type="application/x-shockwave-flash"></embed>' + 679 '</object></div>').css({ 680 "height": dim[0], 681 "width": dim[1] 682 }); 683 buildWindow(); 684 } 685 686 //Image Content 687 function showImage() { 688 var img = new Image(); 689 content = $(img); 690 content.load(function () { 691 var oSize = [img.height, img.width], 692 sSize = [0, 0], 693 running = false, 694 dim, 695 margin; 696 if (obj.data('oB').size) { //If there is a size set by parameters width=&height=, get them 697 sSize = obj.data('oB').size; 698 } 699 if (sSize[0] > 0 && sSize[1] === 0) { //If height= is set but width= is not scale correctly 700 sSize[1] = oSize[1] / oSize[0] * sSize[0]; 701 } else if (sSize[1] > 0 && sSize[0] === 0) { //If width= is set but height= is not scale correctly 702 sSize[0] = oSize[0] / oSize[1] * sSize[1]; 703 } else if (sSize[0] === 0 && sSize[1] === 0) { //If neither is set, set to original size 704 sSize = [oSize[0], oSize[1]]; 705 } 706 obj.data('oB').size = sSize; 707 dim = oB.methods.getSize(obj, [0, 0]); 708 margin = (oB.settings.contentMinSize[0] / 2) - (dim[0] / 2); 709 obj.data('oB').css = dim; 710 $('#ob_content').unbind('click').click(function (e) { 711 e.stopPropagation(); 712 var fullDim = oB.methods.getSize(false, oSize, true), 713 newDim = oB.methods.getSize(obj, [0, 0]), 714 setDim, 715 p = $(window).scrollTop(); 716 if (p === 0) { 717 p = $(document).scrollTop(); 718 } 719 if (p === 0) { 720 p = window.pageYOffset; 721 } 722 if (!running && dim[0] < oSize[0] && fullDim[1] !== newDim[1]) { 723 $('#ob_title').stop().hide(); 724 running = true; 725 $('.ob_controls').fadeOut(50); 726 if ($(this).hasClass('expanded') || fullDim[0] < $('#ob_image').height()) { 727 $(this).removeClass('expanded'); 728 setDim = newDim; 729 } else { 730 $(this).addClass('expanded'); 731 setDim = fullDim; 732 } 733 setWindowMargin(setDim[1]); 734 $("#ob_container").animate({ 735 "margin-top": p 736 }, 400); 737 $('#ob_float').animate({ 738 "margin-bottom": -(setDim[0] + (oB.settings.contentBorderWidth * 2) + 44) / 2 739 }, 400); 740 $('#ob_content').animate({ 741 "min-height": setDim[0], 742 "width": setDim[1] 743 }, 400); 744 $('#ob_image').animate({ 745 "height": setDim[0], 746 "width": setDim[1] 747 }, 400, function () { 748 running = false; 749 $('.ob_controls').fadeIn(50); 750 $('#ob_title').stop().fadeIn(50); 751 }); 752 } 753 }); 754 if (dim[0] < oB.settings.contentMinSize[0]) { 755 content.css("margin-top", margin); 756 } 757 content.css({ 758 "height": dim[0], 759 "width": dim[1] 760 }); 761 buildWindow(); 762 }).error(function () { 763 throwError(); 764 }).attr({ 765 src: href, 766 id: 'ob_image' 767 }); 768 } 769 switch (contentType) { 770 case "iframe": 771 case "pdf": 772 showiFrame(); 773 break; 774 case "image": 775 case "flickr": 776 case "picasa": 777 showImage(); 778 break; 779 case "inline": 780 showInline(); 781 break; 782 case "youtube": 783 case "vimeo": 784 case "viddler": 785 showVideo(); 786 break; 787 case "flash": 788 showFlash(); 789 break; 790 default: 791 oB.methods.logit('Unsupported Media: ' + href); 792 return false; 793 } 794 }, 795 createCustom: function (content, o) { 796 if (o) { 797 $.extend(oB.settings, o); 798 } 799 if(content.href === "undefined" || content.href === "") { return false; } 800 var obj = $('<a href="'+ content.href +'"></a>'), html; 801 if(content.title) { obj.attr('title', content.title); } 802 if(content.caption) { obj.attr('data-ob_caption', content.caption); } 803 804 if(content.link) { obj.attr('data-ob_link', content.link); } 805 if(content.linkText) { obj.attr('data-ob_linkText', content.linkText); } 806 if(content.linkTarget) { obj.attr('data-ob_linkTarget', content.linkTarget); } 807 808 if(content.delay) { obj.attr('data-ob_delayTimer', content.delay); } 809 810 obj.attr('data-ob_share', 'false'); 811 812 if(content.html) { 813 html = $(content.html).css('display', 'none'); 814 $(body).append(html); 815 } 816 817 if(content.gallery) { obj.attr('data-ob', oB.settings.searchTerm + '['+ content.gallery +']'); } 818 else { obj.attr('data-ob', oB.settings.searchTerm); } 819 820 oB.methods.setupData(obj); 821 oB.methods.create(obj); 822 }, 823 navigate: function (d, i, o) { 824 if (o) { 825 $.extend(oB.settings, o); 826 } 827 if (!i) { 828 if (d === 1) { 829 i = oB.currentIndex + 1; 830 } else if (d === -1) { 831 i = oB.currentIndex - 1; 832 } 833 } 834 if (oB.currentGallery[i]) { 835 oB.progress = true; 836 $(document).trigger('oB_navigate', [i]); 837 $('#ob_content').fadeOut(oB.settings.fadeTime, function () { 838 if($('#ob_iframe').length > 0) { 839 $('#ob_iframe iframe').attr('src', 'about:blank'); 840 } 841 if($('#ob_inline').length) { 842 $('#ob_inline').find('.ob_inline_content').appendTo('.ob_inline_content_holder').removeClass('ob_inline_content'); 843 $('.ob_inline_hide').hide().removeClass('ob_inline_hide'); 844 $('.ob_inline_content_holder').removeClass('ob_inline_content_holder'); 845 } 846 $(this).removeClass('expanded').css({ 847 "min-height": '' 848 }).empty(); 849 oB.delayTimer = oB.currentGallery[i].data('oB').delayTimer; 850 oB.methods.showContent(oB.currentGallery[i]); 851 }); 852 } else { 853 oB.progress = null; 854 } 855 if (!oB.currentGallery[i + 1]) {
856 oB.methods.slideshowPause(); 857 } 858 }, 859 slideshowPlay: function () { 860 $(document).trigger('oB_play'); 861 oB.playing = true; 862 if (oB.currentGallery[parseInt($('#ob_content').attr('class').substr(7), 10) + 1]) { 863 oB.methods.navigate(1); 864 } else { 865 oB.methods.navigate(0, 0); 866 } 867 }, 868 slideshowPause: function () { 869 if (oB.playing) { 870 $(document).trigger('oB_pause'); 871 oB.playing = false; 872 clearTimeout(oB.slideshowTimer); 873 } 874 }, 875 showLoad: function (x) { 876 var ob_load = $('<div id="ob_load"></div>').hide(); 877 if ($('#ob_load').length > 0 || x) { 878 clearTimeout(oB.loadTimer); 879 $('#ob_load').remove(); 880 } else { 881 clearTimeout(oB.loadTimer); 882 $("body").append(ob_load); 883 oB.loadTimer = setTimeout(function () { 884 $('#ob_load').fadeIn(); 885 }, 600); 886 } 887 }, 888 destroy: function (o, x) { 889 if ($('#ob_content').length > 0) { 890 $(document).trigger('oB_closing'); 891 if (o) { 892 $.extend(oB.settings, o); 893 } 894 oB.methods.showLoad(1); 895 clearTimeout(oB.controlTimer); 896 clearTimeout(oB.slideshowTimer); 897 clearTimeout(oB.scrollTimer); 898 if (oB.settings.orangeControls) { 899 $(document).orangeControls('destroy', oB.settings.fadeTime); 900 } 901 $(document).unbind("keydown").unbind("mousemove"); 902 $('#ob_container').stop().fadeOut(oB.settings.fadeTime, function () { 903 if($('#ob_inline').length) { 904 $('#ob_inline').find('.ob_inline_content').appendTo('.ob_inline_content_holder').removeClass('ob_inline_content'); 905 $('.ob_inline_hide').hide().removeClass('ob_inline_hide'); 906 $('.ob_inline_content_holder').removeClass('ob_inline_content_holder'); 907 } 908 if($('#ob_iframe').length > 0) { 909 $('#ob_iframe iframe').attr('src', 'about:blank'); 910 } 911 $(this).empty().remove(); 912 $(document).trigger('oB_closed'); 913 if (x && $.isFunction(x)) { 914 x(); 915 } 916 }); 917 $('#ob_overlay').fadeOut(oB.settings.fadeTime, function () { 918 $(this).remove(); 919 if($('#ob_container').length > 0) { 920 $('#ob_container').remove(); 921 } 922 }); 923 } 924 }, 925 getSize: function (obj, s, noMaxHeight) { 926 var ww = $(window).width(), wh = $(window).height(), mSize = [wh - 44, ww - 44], m, a, c; 927 if (oB.docWidth > ww) { 928 mSize[1] = oB.docWidth - 44; 929 } 930 if (oB.settings.showNav) { 931 mSize[1] -= 120; 932 } 933 if (obj) { 934 s[0] = obj.data('oB').size[0]; 935 s[1] = obj.data('oB').size[1]; 936 m = oB.settings.contentMaxSize; 937 a = oB.settings.videoAspect; 938 c = obj.data('oB').contentType; 939 940 if(c === "youtube" || c === "vimeo" || c === "viddler" || c === "flash") { 941 if (s[0] > 0 && s[1] === 0) { //If height= is set but width= is not scale correctly 942 s[1] = a[1] / a[0] * s[0]; 943 } else if (s[1] > 0 && s[0] === 0) { //If width= is set but height= is not scale correctly 944 s[0] = a[0] / a[1] * s[1]; 945 } else if (s[0] === 0 && s[1] === 0) { //If neither is set, set to original size 946 s = a; 947 } 948 } 949 if(c === "iframe" || c === "pdf") { 950 mSize[0] -= 120; 951 } 952 953 if (m[0] === 0 && c !== "iframe" && c !== "pdf") { 954 mSize[0] = 0; 955 } else if (m[0] > 1 && m[0] < mSize[0]) { 956 mSize[0] = m[0]; 957 } else if (m[0] > 0 && m[0] <= 1) { 958 mSize[0] = Math.round(mSize[0] * m[0]); 959 } 960 if (m[1] > 1 && m[1] < mSize[1]) { 961 mSize[1] = m[1];
962 } else if (m[1] > 0 && m[1] <= 1) { 963 mSize[1] = Math.round(mSize[1] * m[1]); 964 } 965 if (s[1] <= 1) { 966 s[1] = mSize[1]; 967 } 968 if (s[0] === 0 && mSize[0] !== 0) { 969 s[0] = mSize[0]; 970 } 971 } 972 973 //Scale Content to fit 974 if (!noMaxHeight && mSize[0] && s[0] > mSize[0]) { 975 s[1] = s[1] * mSize[0] / s[0]; 976 s[0] = mSize[0]; 977 } 978 if (s[1] > mSize[1]) { 979 s[0] = s[0] * mSize[1] / s[1]; 980 s[1] = mSize[1]; 981 } 982 return [Math.round(s[0]), Math.round(s[1])]; 983 }, 984 getUrlVars: function () { 985 var i, 986 vars = [], 987 hash, 988 hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&'); 989 for (i = 0; i < hashes.length; i++) { 990 hash = hashes[i].split('='); 991 vars[hash[0]] = hash[1]; 992 } 993 return vars; 994 }, 995 logit: function (m, d) { 996 if (d && oB.settings.logging === "debug") { 997 console.log('OrangeBox: ' + m); 998 } else if (!d && oB.settings.logging) { 999 console.log('OrangeBox: ' + m); 1000 } 1001 } 1002 } 1003 }; 1004 1005 $.fn.orangeBox = function (method) { 1006 if (method === "showContent" || method === "getSize" || method === "getUrlVars" || method === "logit") { 1007 oB.methods.logit(method + ' cannot be called externally'); 1008 } else if (oB.methods[method]) { 1009 return oB.methods[method].apply(this, Array.prototype.slice.call(arguments, 1)); 1010 } else if (typeof method === 'object' || !method) { 1011 return oB.methods.init.apply(this, arguments); 1012 } else { 1013 oB.methods.logit(method + ' does not exist in OrangeBox'); 1014 } 1015 }; 1016 })(jQuery); 1017} 1018jQuery(document).ready(function ($) { 1019 var searchTerm = 'a[data-ob*=lightbox], area[data-ob*=lightbox], a[rel*=lightbox], area[rel*=lightbox]'; 1020 if(typeof orangebox_vars !== "undefined") { 1021 $.extend(oB.settings, orangebox_vars); 1022 } 1023 if(oB.settings.searchTerm !== "") { 1024 searchTerm = 'a[data-ob*='+oB.settings.searchTerm+'], area[data-ob*='+oB.settings.searchTerm+'], a[rel*='+oB.settings.searchTerm+'], area[rel*='+oB.settings.searchTerm+']'; 1025 } 1026 $(searchTerm).orangeBox(); 1027 $(document).trigger('oB_ready'); 1028});
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.