1/************************************************************************************************ 2* Floatbox v3.23 3* November 23, 2008 4* 5* Copyright (C) 2008 Byron McGregor 6* Website: http://randomous.com/tools/floatbox/ 7* License: Creative Commons Attribution 3.0 License (http://creativecommons.org/licenses/by/3.0/) 8* This comment block must be retained in all deployments and distributions 9*************************************************************************************************/ 10 11function Floatbox() { 12this.defaultOptions = { 13 14/***** BEGIN OPTIONS CONFIGURATION *****/ 15// see docs/options.html for detailed descriptions 16 17/*** <General Options> ***/ 18theme: 'custom' ,// 'auto'|'black'|'white'|'blue'|'yellow'|'red'|'custom' 19padding: 12 ,// pixels 20panelPadding: 8 ,// pixels 21outerBorder: 4 ,// pixels 22innerBorder: 1 ,// pixels 23overlayOpacity: 55 ,// 0-100 24controlOpacity: 60 ,// 0-100 25autoSizeImages: true ,// true|false 26autoSizeOther: false ,// true|false 27resizeImages: true ,// true|false 28resizeOther: false ,// true|false 29resizeTool: 'cursor' ,// 'cursor'|'topleft'|'both' 30infoPos: 'bl' ,// 'tl'|'tc'|'tr'|'bl'|'bc'|'br' 31controlPos: 'br' ,// 'tl'|'tr'|'bl'|'br' 32boxLeft: 'auto' ,// 'auto'|pixels|'[-]xx%' 33boxTop: 'auto' ,// 'auto'|pixels|'[-]xx%' 34shadowType: 'drop' ,// 'drop'|'halo'|'none' 35shadowSize: 12 ,// 8|12|16|24 36enableDrag: true ,// true|false 37showCaption: true ,// true|false 38showItemNumber: true ,// true|false 39showClose: true ,// true|false 40hideFlash: true ,// true|false 41hideJava: true ,// true|false 42disableScroll: false ,// true|false 43autoGallery: false ,// true|false 44preloadAll: true ,// true|false 45enableCookies: false ,// true|false 46cookieScope: 'site' ,// 'site'|'folder' 47language: 'auto' ,// 'auto'|'en'|... (see the languages folder) 48graphicsType: 'auto' ,// 'auto'|'international'|'english' 49urlGraphics: '/site/template/floatbox/graphics/' ,// change this if you install in another folder 50urlLanguages: '/site/template/floatbox/languages/' ,// change this if you install in another folder 51/*** </General Options> ***/ 52 53/*** <Navigation Options> ***/ 54navType: 'both' ,// 'overlay'|'button'|'both'|'none' 55navOverlayWidth: 35 ,// 0-50 56navOverlayPos: 30 ,// 0-100 57showNavOverlay: 'never' ,// 'always'|'once'|'never' 58showHints: 'once' ,// 'always'|'once'|'never' 59enableWrap: true ,// true|false 60enableKeyboardNav: true ,// true|false 61outsideClickCloses: true ,// true|false 62numIndexLinks: 0 ,// number, -1 = no limit 63indexLinksPanel: 'control' ,// 'info'|'control' 64showIndexThumbs: true ,// true|false 65/*** </Navigation Options> ***/ 66 67/*** <Animation Options> ***/ 68doAnimations: true ,// true|false 69resizeDuration: 3.5 ,// 0-10 70imageFadeDuration: 3.5 ,// 0-10 71overlayFadeDuration: 4 ,// 0-10 72splitResize: 'no' ,// 'no'|'auto'|'wh'|'hw' 73startAtClick: true ,// true|false 74zoomImageStart: true ,// true|false 75liveImageResize: false ,// true|false 76/*** </Animation Options> ***/ 77 78/*** <Slideshow Options> ***/ 79slideInterval: 4.5 ,// seconds 80endTask: 'exit' ,// 'stop'|'exit'|'loop' 81showPlayPause: true ,// true|false 82startPaused: false ,// true|false 83pauseOnResize: true ,// true|false 84pauseOnPrev: true ,// true|false 85pauseOnNext: false // true|false 86/*** </Slideshow Options> ***/ 87}; 88 89/*** <New Child Window Options> ***/ 90// Will inherit from the primary floatbox options unless overridden here 91// Add any you like 92this.childOptions = { 93overlayOpacity: 45, 94resizeDuration: 3, 95imageFadeDuration: 3, 96overlayFadeDuration: 0 97}; 98/*** </New Child Window Options> ***/ 99 100/***** END OPTIONS CONFIGURATION *****/ 101this.init(); 102} 103Floatbox.prototype = { 104init: function() { 105 this.bod = document.body || document.getElementsByTagName('body')[0]; 106 this.html = document.documentElement; 107 this.items = []; 108 this.nodeNames = []; 109 this.hiddenEls = []; 110 this.timeouts = {}; 111 this.pos = {}; 112 this.setOptions(this.defaultOptions); 113 if (typeof fbPageOptions === 'object') this.setOptions(fbPageOptions); 114 this.setOptions(this.parseOptionString(location.search.substring(1))); 115 this.panelGap = 22; 116 this.infoLinkGap = 16; 117 this.showHintsTime = 1600; 118 this.zoomPopBorder = 1; 119 this.controlSpacing = 8; 120 this.minInfoWidth = 80; 121 this.minIndexWidth = 120; 122 this.ctrlJump = 5; 123 this.slowLoadDelay = 750; 124 this.loaderDelay = 200; 125 this.autoSizeSpace = 4; 126 this.initialSize = 120; 127 this.slowZoomImg = this.urlGraphics + 'loading_white.gif'; 128 this.slowLoadImg = this.urlGraphics + 'loading_black.gif'; 129 this.iframeSrc = this.urlGraphics + 'loading_iframe.html'; 130 this.resizeUpCursor = this.urlGraphics + 'magnify_plus.cur'; 131 this.resizeDownCursor = this.urlGraphics + 'magnify_minus.cur'; 132 this.notFoundImg = this.urlGraphics + '404.jpg'; 133 this.defaultWidth = '85%'; 134 this.defaultHeight = '82%'; 135 this.isChild = !!(self.fb && self.fb.fbBox); 136 if (!this.isChild) { 137 this.fbParent = this.lastChild = this; 138 this.anchors = []; 139 this.children = []; 140 this.preloads = {}; 141 this.preloads.count = 0; 142 this.xhr = this.getXMLHttpRequest(); 143 this.strings = { 144 hintClose: 'Exit (key: Esc)', 145 hintPrev: 'Previous (key: <--)', 146 hintNext: 'Next (key: -->)', 147 hintPlay: 'Play (key: spacebar)', 148 hintPause: 'Pause (key: spacebar)',
149 hintResize: 'Resize (key: Tab)', 150 imgCount: 'Image %1 of %2', 151 nonImgCount: 'Page %1 of %2', 152 mixedCount: '(%1 of %2)', 153 infoText: 'Info...', 154 printText: 'Print...' 155 }; 156 } else { 157 this.fbParent = fb.lastChild; 158 fb.lastChild = this; 159 fb.children.push(this); 160 if (this.fbParent.isSlideshow) this.fbParent.setPause(true); 161 this.anchors = fb.anchors; 162 this.children = fb.children; 163 this.xhr = fb.xhr; 164 this.strings = fb.strings; 165 } 166 var agent = navigator.userAgent, 167 version = navigator.appVersion; 168 this.mac = version.indexOf('Macintosh') !== -1; 169 if (window.opera) { 170 this.opera = true; 171 this.operaOld = parseFloat(version) < 9.5; 172 this.operaMac = this.mac; 173 } else if (document.all) { 174 this.ie = true; 175 this.ieOld = parseInt(version.substr(version.indexOf('MSIE') + 5), 10) < 7; 176 this.ie8b2 = version.indexOf('MSIE 8.0') !== -1 && navigator.appMinorVersion === 'beta 2'; 177 this.ieXP = parseInt(version.substr(version.indexOf('Windows NT') + 11), 10) < 6; 178 } else if (agent.indexOf('Firefox') !== -1) { 179 this.ff = true; 180 this.ffOld = parseInt(agent.substr(agent.indexOf('Firefox') + 8), 10) < 3; 181 this.ffNew = !this.ffOld; 182 this.ffMac = this.mac; 183 } else if (version.indexOf('WebKit') !== -1) { 184 this.webkit = true; 185 this.webkitNew = parseInt(version.substr(version.indexOf('WebKit') + 7), 10) >= 500; 186 this.webkitOld = !this.webkitNew; 187 this.webkitMac = this.mac; 188 } 189 this.browserLanguage = (navigator.language || navigator.userLanguage || navigator.systemLanguage || navigator.browserLanguage || 'en').substring(0, 2); 190 if (!this.isChild) { 191 var lang = this.language === 'auto' ? this.browserLanguage : this.language; 192 if (this.xhr) { 193 var that = this; 194 this.xhr.getResponse(this.urlLanguages + lang + '.json', function(xhr) { 195 if ((xhr.status === 200 || xhr.status === 203 || xhr.status === 304) && xhr.responseText) { 196 var text = xhr.responseText; 197 if (that.ieXP) { 198 text = text.replace(String.fromCharCode(8592), '<--').replace(String.fromCharCode(8594), '-->'); 199 } 200 try { 201 var obj = eval('(' + text + ')'); 202 if (obj && obj.hintClose) that.strings = obj; 203 } catch(e) {} 204 } 205 }); 206 } 207 } 208 if (this.graphicsType.toLowerCase() === 'english' || (this.graphicsType === 'auto' && this.browserLanguage === 'en')) { 209 this.offPos = 'top left'; 210 this.onPos = 'bottom left'; 211 } else { 212 this.offPos = 'top right'; 213 this.onPos = 'bottom right'; 214 this.controlSpacing = 0; 215 } 216 this.zIndex = { 217 base: 90000 + 10*this.children.length, 218 fbOverlay: 1, 219 fbBox: 2, 220 fbCanvas: 3, 221 fbMainDiv: 4, 222 fbLeftNav: 5, 223 fbRightNav: 5, 224 fbOverlayPrev: 6, 225 fbOverlayNext: 6, 226 fbResizer: 7, 227 fbZoomDiv: 8, 228 fbInfoPanel: 8, 229 fbControlPanel: 8 230 }; 231 var match = /\bautoStart=(.+?)(?:&|$)/i.exec(location.search); 232 this.autoHref = match ? match[1] : false; 233}, 234tagAnchors: function(baseEl) { 235 var that = fb.lastChild, 236 doOutline = this.ieOld && /^fb/.test(baseEl.id); 237 function tag(tagName) { 238 var elements = baseEl.getElementsByTagName(tagName); 239 for (var i = 0, len = elements.length; i < len; i++) { 240 var el = elements[i]; 241 if (that.autoGallery && that.fileType(el.href) === 'img' && el.getAttribute('rel') !== 'nofloatbox') { 242 el.setAttribute('rel', 'floatbox.autoGallery'); 243 if (that.autoTitle && !el.getAttribute('title')) el.setAttribute('title', that.autoTitle); 244 } 245 if (doOutline) el.setAttribute('hideFocus', 'true'); 246 that.tagOneAnchor(el); 247 } 248 } 249 tag('a'); 250 tag('area'); 251}, 252tagOneAnchor: function(anchor) { 253 var that = this, 254 isAnchor = !!anchor.getAttribute; 255 if (isAnchor) { 256 var a = { 257 href: anchor.href || anchor.getAttribute('href'), 258 rel: anchor.getAttribute('rel'), 259 rev: anchor.getAttribute('rev'), 260 title: anchor.getAttribute('title'), 261 anchor: anchor, 262 thumb: this.getThumb(anchor) 263 }; 264 var match; 265 if (a.thumb && (match = /(?:^|\s)fbPop(up|down)(?:\s|$)/i.exec(anchor.className))) { 266 var up = (match[1] === 'up'); 267 a.popup = true; 268 a.thumb.style.borderWidth = this.zoomPopBorder + 'px'; 269 anchor.onmouseover = function () { 270 a.thumb.style.display = 'none'; 271 var aPos = that.getLeftTop(this, true), 272 aLeft = aPos.left, 273 aTop = aPos.top; 274 aPos = that.getLayout(this); 275 a.thumb.style.display = ''; 276 var relLeft = (aPos.width - a.thumb.offsetWidth)/2, 277 relTop = up ? 2 - a.thumb.offsetHeight : aPos.height, 278 scroll = that.getScroll(), 279 screenRight = scroll.left + that.getDisplayWidth(); 280 var spill = aPos.left + relLeft + a.thumb.offsetWidth - screenRight; 281 if (spill > 0) relLeft -= spill; 282 var spill = aPos.left + relLeft - scroll.left; 283 if (spill < 0) relLeft -= spill; 284 if (up) { 285 if (aPos.top + relTop < scroll.top) relTop = aPos.height; 286 } else { 287 if (aPos.top + relTop + a.thumb.offsetHeight > scroll.top + that.getDisplayHeight()) relTop = 2 - a.thumb.offsetHeight; 288 } 289 a.thumb.style.left = (aLeft + relLeft) + 'px'; 290 a.thumb.style.top = (aTop + relTop) + 'px'; 291 }; 292 anchor.onmouseout = function () { 293 a.thumb.style.left = '-9999px'; 294 a.thumb.style.top = '0'; 295 }; 296 if (!anchor.onclick) anchor.onclick = anchor.onmouseout; 297 } 298 } else { 299 var a = anchor; 300 } 301 if (/^(floatbox|gallery|iframe|slideshow|lytebox|lyteshow|lyteframe|lightbox)/i.test(a.rel)) { 302 if (isAnchor) { 303 anchor.onclick = function() { 304 fb.start(this); 305 if (window.event) event.returnValue = false; 306 return false; 307 }; 308 } 309 a.revOptions = this.parseOptionString(a.rev); 310 a.level = this.children.length + (fb.lastChild.fbBox && !a.revOptions.sameBox ? 1 : 0); 311 var a_i, i = this.anchors.length; 312 while (i--) { 313 a_i = this.anchors[i]; 314 if (a_i.href === a.href && a_i.rel === a.rel && a_i.rev === a.rev && a_i.title === a.title && a_i.level === a.level) { 315 a_i.anchor = anchor; 316 break; 317 } 318 } 319 if (i === -1) { 320 a.type = a.revOptions.type || this.fileType(a.href); 321 if (a.type === 'html') { 322 a.type = 'iframe'; 323 var match = /#(\w+)/.exec(a.href); 324 if (match) { 325 var doc = document; 326 if (a.anchor) {
327 doc = a.anchor.ownerDocument || a.anchor.document || doc; 328 } 329 if (doc === document && this.currentItem && this.currentItem.anchor) { 330 doc = this.currentItem.anchor.ownerDocument || this.currentItem.anchor.document || doc; 331 } 332 var el = doc.getElementById(match[1]); 333 if (el) { 334 a.type = 'inline'; 335 a.sourceEl = el; 336 } 337 } 338 } 339 this.anchors.push(a); 340 if (this.autoHref) { 341 if (a.revOptions.showThis !== false && this.autoHref === a.href.substr(a.href.length - this.autoHref.length)) this.autoStart = a; 342 } else if (a.revOptions.autoStart === true) { 343 this.autoStart = a; 344 } else if (a.revOptions.autoStart === 'once') { 345 var match = /fbAutoShown=(.+?)(;|$)/.exec(document.cookie), 346 val = match ? match[1] : '', 347 href = escape(a.href); 348 if (val.indexOf(href) === -1) { 349 this.autoStart = a; 350 document.cookie = 'fbAutoShown=' + val + href + '; path=/'; 351 } 352 } 353 } 354 } 355 return a; 356}, 357fileType: function(href) { 358 var s = href.toLowerCase(), 359 i = s.indexOf('?'); 360 if (i !== -1) s = s.substr(0, i); 361 s = s.substr(s.lastIndexOf('.') + 1); 362 if (/^(jpe?g|png|gif|bmp)$/.test(s)) return 'img'; 363 if (s === 'swf' || /^(http:)?\/\/(www.)?youtube.com\/v\//i.test(href)) return 'flash'; 364 if (/^(mov|mpe?g|movie)$/.test(s)) return 'quicktime'; 365 return 'html'; 366}, 367preloadImages: function(href, chain) { 368 if (this !== fb) return fb.preloadImages(href, chain); 369 if (typeof chain !== 'undefined') arguments.callee.chain = chain; 370 if (!href && arguments.callee.chain && (this.preloadAll || !this.preloads.count)) { 371 for (var i = 0, len = this.anchors.length; i < len; i++) { 372 var a = this.anchors[i]; 373 if (a.type === 'img' && !this.preloads[a.href]) { 374 href = a.href; 375 break; 376 } 377 } 378 } 379 if (href) { 380 if (this.preloads[href]) { 381 this.preloadImages(); 382 } else { 383 var img = this.preloads[href] = new Image(); 384 img.onerror = function() { 385 setTimeout(function() { fb.preloadImages(); }, 50); 386 fb.preloads[href] = true; 387 }; 388 img.onload = function() { 389 fb.preloads.count++; 390 this.onerror(); 391 }; 392 img.src = href; 393 } 394 } 395}, 396start: function(anchor) { 397 if (this !== fb.lastChild) return fb.lastChild.start(anchor); 398 var that = this; 399 this.preloadImages('', false); 400 if (anchor.getAttribute) { 401 var a = { 402 href: anchor.href || anchor.getAttribute('href'), 403 rel: anchor.getAttribute('rel'), 404 rev: anchor.getAttribute('rev'), 405 title: anchor.getAttribute('title') 406 }; 407 a.revOptions = this.parseOptionString(a.rev); 408 anchor.blur(); 409 } else { 410 var a = anchor; 411 } 412 this.isRestart = !!this.fbBox; 413 if (this.isRestart) { 414 if (!a.revOptions.sameBox) return new Floatbox().start(anchor); 415 this.setOptions(a.revOptions); 416 } else { 417 this.clickedAnchor = anchor.getAttribute ? anchor : false; 418 } 419 a.level = this.children.length + (fb.lastChild.fbBox && !a.revOptions.sameBox ? 1 : 0); 420 this.itemsShown = 0; 421 fb.previousAnchor = this.currentItem; 422 this.buildItemArray(a); 423 if (!this.itemCount) return; 424 if (this.itemCount === 1 && this.fbNavControls) this.fbNavControls.style.display = 'none'; 425 self.focus(); 426 this.revOptions = a.revOptions; 427 if (!this.isRestart) { 428 this.getOptions(); 429 this.buildDOM(); 430 this.addEventHandlers(); 431 this.initState(); 432 } 433 this.collapse(); 434 this.updatePanels(); 435 var fetchAndGo = function() { 436 that.fetchContent(function() { 437 that.clearTimeout('slowLoad'); 438 that.calcSize(); 439 } ); 440 }; 441 if (this.fbBox.style.visibility || this.isRestart) { 442 fetchAndGo(); 443 } else { 444 var offset = this.initialSize/2, 445 size = { id: 'fbBox', left: that.pos.fbBox.left - offset, top: that.pos.fbBox.top - offset, 446 width: that.initialSize, height: that.initialSize, borderWidth: that.outerBorder }; 447 if (this.splitResize) { 448 var oncomplete = function() { 449 that.setSize(fetchAndGo, size); 450 }; 451 } else { 452 this.timeouts.slowLoad = setTimeout(function() { 453 that.setSize(size); 454 }, this.slowLoadDelay); 455 var oncomplete = fetchAndGo; 456 } 457 this.fadeOpacity(this.fbOverlay, this.overlayOpacity, this.overlayFadeDuration, oncomplete); 458 } 459}, 460buildItemArray: function(a) { 461 this.itemCount = this.items.length = this.currentIndex = 0; 462 this.justImages = true; 463 var isSingle = /^(floatbox|gallery|iframe|lytebox|lyteframe|lightbox)$/i.test(a.rel); 464 for (var i = 0, len = this.anchors.length; i < len; i++) { 465 var a_i = this.anchors[i]; 466 if (a_i.rel === a.rel && a_i.level === a.level) { 467 if (a_i.revOptions.showThis !== false) { 468 var isMatch = a_i.rev === a.rev && a_i.title === a.title && a_i.href === a.href.substr(a.href.length - a_i.href.length); 469 if (isMatch || !isSingle) { 470 a_i.seen = false; 471 this.items.push(a_i);
472 if (a_i.type !== 'img') this.justImages = false; 473 if (isMatch) this.currentIndex = this.items.length - 1; 474 } 475 } 476 } 477 } 478 if (a.revOptions.showThis === false && a.href) { 479 i = this.items.length; 480 while (i--) { 481 var href = this.items[i].href; 482 if (href === a.href.substr(a.href.length - href.length)) { 483 this.currentIndex = i; 484 } 485 } 486 } 487 this.itemCount = this.items.length; 488 this.currentItem = this.items[this.currentIndex]; 489}, 490getOptions: function() { 491 if (this.isChild) { 492 for (var name in this.defaultOptions) { 493 if (this.defaultOptions.hasOwnProperty(name)) this[name] = this.fbParent[name]; 494 } 495 this.setOptions(this.childOptions); 496 } else { 497 this.setOptions(this.defaultOptions); 498 } 499 this.doSlideshow = this.loadPageOnClose = this.sameBox = false; 500 if (!(this.isChild || this.fbBox)) { 501 if (typeof setFloatboxOptions === 'function') setFloatboxOptions(); 502 if (typeof fbPageOptions === 'object') this.setOptions(fbPageOptions); 503 if (this.enableCookies) { 504 var match = /fbOptions=(.+?)(;|$)/.exec(document.cookie); 505 if (match) this.setOptions(this.parseOptionString(match[1])); 506 var strOptions = ''; 507 for (var name in this.defaultOptions) { 508 if (this.defaultOptions.hasOwnProperty(name)) { 509 strOptions += ' ' + name + ':' + this[name]; 510 } 511 } 512 var strPath = '/'; 513 if (this.cookieScope === 'folder') { 514 strPath = location.pathname; 515 strPath = strPath.substring(0, strPath.lastIndexOf('/') + 1); 516 } 517 document.cookie = 'fbOptions=' + strOptions + '; path=' + strPath; 518 } 519 } 520 this.setOptions(this.revOptions); 521 this.setOptions(this.parseOptionString(location.search.substring(1))); 522 if (this.theme === 'grey') this.theme = 'white'; 523 if (this.endTask === 'cont') this.endTask = 'loop'; 524 if (this.navType === 'upper') this.navType = 'overlay'; 525 if (this.navType === 'lower') this.navType = 'button'; 526 if (this.upperOpacity) this.controlOpacity = this.upperOpacity; 527 if (this.upperNavWidth) this.navOverlayWidth = this.upperNavWidth; 528 if (this.upperNavPos) this.navOverlayPos = this.upperNavPos; 529 if (this.showUpperNav) this.showNavOverlay = this.showUpperNav; 530 if (this.dropShadow) this.shadowType = 'drop'; 531 if (!/^(auto|black|white|blue|yellow|red|custom)$/.test(this.theme)) this.theme='auto'; 532 if (!/^(overlay|button|both|none)$/i.test(this.navType)) this.navType = 'button'; 533 if (!/^(auto|wh|hw)$/.test(this.splitResize)) this.splitResize = false; 534 if (this.webkitOld && (this.navType === 'overlay' || this.navType === 'both') ) { 535 this.navType = 'button'; 536 } 537 if (this.itemCount > 1) { 538 this.isSlideshow = this.doSlideshow || /^(slideshow|lyteshow)/i.test(this.currentItem.rel); 539 var overlayRequest = /overlay|both/i.test(this.navType), 540 buttonRequest = /button|both/i.test(this.navType); 541 this.navOverlay = this.justImages && overlayRequest; 542 this.navButton = buttonRequest || (!this.justImages && overlayRequest); 543 this.lclShowItemNumber = this.showItemNumber; 544 this.lclNumIndexLinks = this.numIndexLinks; 545 } else { 546 this.isSlideshow = this.navOverlay = this.navButton = this.lclShowItemNumber = this.lclNumIndexLinks = false; 547 } 548 this.isPaused = this.startPaused; 549 if ((this.lclTheme = this.theme) === 'auto') { 550 this.lclTheme = this.currentItem.type === 'img' ? 'black' : /flash|quicktime/.test(this.currentItem.type) ? 'blue' : 'white'; 551 } 552 if (!this.doAnimations) { 553 this.resizeDuration = this.imageFadeDuration = this.overlayFadeDuration = 0; 554 } 555 if (!this.resizeDuration) this.zoomImageStart = false; 556 this.controlTop = this.controlPos.charAt(0) === 't'; 557 this.controlLeft = this.controlPos.charAt(1) === 'l'; 558 this.infoTop = this.infoPos.charAt(0) === 't'; 559 this.infoCenter = this.infoPos.charAt(1) === 'c'; 560 this.infoLeft = this.infoPos.charAt(1) === 'l' || (this.infoCenter && this.controlTop === this.infoTop && !this.controlLeft); 561 if (this.infoLeft === this.controlLeft && this.infoTop === this.controlTop) { 562 this.infoLeft = true; 563 this.controlLeft = false; 564 } 565 if (this.indexLinksPanel === 'info') { 566 this.indexCenter = this.infoCenter; 567 this.indexLeft = this.infoLeft; 568 this.indexTop = this.infoTop; 569 } else {
570 this.indexLeft = this.controlLeft; 571 this.indexTop = this.controlTop; 572 } 573 if (!/^(drop|halo|none)$/.test(this.shadowType)) this.shadowType='drop'; 574 if (!/^(8|12|16|24)$/.test(this.shadowSize + '')) this.shadowSize = 8; 575 this.shadowSize = +this.shadowSize; 576 if (this.opera || (this.mac && !this.webkitNew)) { 577 this.resizeTool = 'topleft'; 578 } else { 579 this.resizeTool = this.resizeTool.toLowerCase(); 580 if (!/topleft|cursor|both/.test(this.resizeTool)) this.resizeTool = 'cursor'; 581 } 582 if (this.ieOld) this.shadowType = 'none'; 583 this.overlayOpacity /= 100; 584 this.controlOpacity /= 100; 585}, 586parseOptionString: function(str) { 587 if (!str) return {}; 588 var quotes = [], match, 589 rex = /`([^`]*?)`/g; 590 while ((match = rex.exec(str))) quotes.push(match[1]); 591 if (quotes.length) str = str.replace(rex, '``'); 592 str = str.replace(/\s*[:=]\s*/g, ':'); 593 str = str.replace(/\s*[;&]\s*/g, ' '); 594 str = str.replace(/^\s+|\s+$/g, ''); 595 var pairs = {}, 596 aVars = str.split(' '), 597 i = aVars.length; 598 while (i--) { 599 var aThisVar = aVars[i].split(':'), 600 name = aThisVar[0], 601 value = aThisVar[1]; 602 if (typeof value === 'string') { 603 if (!isNaN(value)) value = +value; 604 else if (value === 'true') value = true; 605 else if (value === 'false') value = false; 606 } 607 if (value === '``') value = quotes.pop() || ''; 608 pairs[name] = value; 609 } 610 return pairs; 611}, 612setOptions: function(pairs) { 613 for (var name in pairs) { 614 if (pairs.hasOwnProperty(name)) this[name] = pairs[name]; 615 } 616}, 617buildDOM: function() { 618 this.fbOverlay = this.newNode('div', 'fbOverlay', this.bod); 619 this.fbZoomDiv = this.newNode('div', 'fbZoomDiv', this.bod); 620 this.fbZoomImg = this.newNode('img', 'fbZoomImg', this.fbZoomDiv); 621 this.fbBox = this.newNode('div', 'fbBox'); 622 this.fbShadowTop = this.newNode('div', 'fbShadowTop', this.fbBox); 623 this.fbShadowRight = this.newNode('div', 'fbShadowRight', this.fbBox); 624 this.fbShadowBottom = this.newNode('div', 'fbShadowBottom', this.fbBox); 625 this.fbShadowLeft = this.newNode('div', 'fbShadowLeft', this.fbBox); 626 this.fbShadowCorner = this.newNode('div', 'fbShadowCorner', this.fbBox); 627 this.fbLoader = this.newNode('div', 'fbLoader', this.fbBox); 628 this.fbCanvas = this.newNode('div', 'fbCanvas', this.fbBox); 629 this.fbMainDiv = this.newNode('div', 'fbMainDiv', this.fbCanvas); 630 this.fbLeftNav = this.newNode('a', 'fbLeftNav', this.fbMainDiv); 631 this.fbRightNav = this.newNode('a', 'fbRightNav', this.fbMainDiv); 632 this.fbOverlayPrev = this.newNode('a', 'fbOverlayPrev', this.fbMainDiv, this.strings.hintPrev); 633 this.fbOverlayNext = this.newNode('a', 'fbOverlayNext', this.fbMainDiv, this.strings.hintNext); 634 this.fbResizer = this.newNode('a', 'fbResizer', this.fbMainDiv, this.strings.hintResize); 635 this.fbInfoPanel = this.newNode('div', 'fbInfoPanel', this.fbCanvas); 636 this.fbCaptionDiv = this.newNode('div', 'fbCaptionDiv', this.fbInfoPanel); 637 this.fbCaption = this.newNode('span', 'fbCaption', this.fbCaptionDiv); 638 this.fbInfoDiv = this.newNode('div', 'fbInfoDiv', this.fbInfoPanel); 639 if (this.infoLeft || this.infoCenter) { 640 this.fbInfoLink = this.newNode('span', 'fbInfoLink', this.fbInfoDiv); 641 this.fbPrintLink = this.newNode('span', 'fbPrintLink', this.fbInfoDiv); 642 this.fbItemNumber = this.newNode('span', 'fbItemNumber', this.fbInfoDiv); 643 } else { 644 this.fbItemNumber = this.newNode('span', 'fbItemNumber', this.fbInfoDiv); 645 this.fbPrintLink = this.newNode('span', 'fbPrintLink', this.fbInfoDiv); 646 this.fbInfoLink = this.newNode('span', 'fbInfoLink', this.fbInfoDiv); 647 } 648 this.fbControlPanel = this.newNode('div', 'fbControlPanel', this.fbCanvas); 649 this.fbControls = this.newNode('div', 'fbControls', this.fbControlPanel); 650 this.fbNavControls = this.newNode('div', 'fbNavControls', this.fbControls); 651 this.fbPrev = this.newNode('a', 'fbPrev', this.fbNavControls, this.strings.hintPrev); 652 this.fbNext = this.newNode('a', 'fbNext', this.fbNavControls, this.strings.hintNext); 653 this.fbSubControls = this.newNode('div', 'fbSubControls', this.fbControls); 654 this.fbPlayPause = this.newNode('div', 'fbPlayPause', this.fbSubControls); 655 this.fbPlay = this.newNode('a', 'fbPlay', this.fbPlayPause, this.strings.hintPlay); 656 this.fbPause = this.newNode('a', 'fbPause', this.fbPlayPause, this.strings.hintPause); 657 this.fbClose = this.newNode('a', 'fbClose', this.fbSubControls, this.strings.hintClose); 658 this.fbIndexLinks = this.newNode('span', 'fbIndexLinks', this.indexLinksPanel === 'info' ? this.fbInfoPanel : this.fbControlPanel); 659 this.bod.appendChild(this.fbBox); 660}, 661newNode: function(nodeType, id, parentNode, title) { 662 if (this[id] && this[id].parentNode) { 663 this[id].parentNode.removeChild(this[id]); 664 } 665 var node = document.createElement(nodeType); 666 node.id = id; 667 node.className = id + '_' + (id.indexOf('fbShadow') === -1 ? this.lclTheme : this.shadowType + this.shadowSize); 668 if (nodeType === 'a') { 669 if (!this.operaOld) node.setAttribute('href', ''); 670 if (this.ieOld) node.setAttribute('hideFocus', 'true'); 671 node.style.outline = 'none'; 672 } else if (nodeType === 'iframe') { 673 node.setAttribute('scrolling', this.itemScroll); 674 node.setAttribute('frameBorder', '0'); 675 node.setAttribute('align', 'middle'); 676 node.src = this.iframeSrc; 677 } 678 if (this.isChild && this.fbParent[id]) title = this.fbParent[id].getAttribute('title'); 679 if (title && this.showHints !== 'never') node.setAttribute('title', title); 680 if (this.zIndex[id]) node.style.zIndex = this.zIndex.base + this.zIndex[id]; 681 node.style.display = 'none'; 682 if (parentNode) parentNode.appendChild(node); 683 this.nodeNames.push(id); 684 return node; 685}, 686addEventHandlers: function() { 687 var that = this, 688 leftNav = this.fbLeftNav.style, 689 rightNav = this.fbRightNav.style, 690 overlayPrev = this.fbOverlayPrev.style, 691 overlayNext = this.fbOverlayNext.style, 692 prev = this.fbPrev.style, 693 next = this.fbNext.style; 694 if (this.showHints === 'once') { 695 this.hideHint = function(id) { 696 if (that[id].title) { 697 that.timeouts[id] = setTimeout(function() { 698 that[id].title = that.fbParent[id].title = ''; 699 var id2 = ''; 700 if (/fbOverlay(Prev|Next)/.test(id)) { 701 id2 = id.replace('Overlay', ''); 702 } else if (/fb(Prev|Next)/.test(id)) { 703 id2 = id.replace('fb', 'fbOverlay'); 704 } 705 if (id2) that[id2].title = that.fbParent[id2].title = ''; 706 }, that.showHintsTime); 707 } 708 }; 709 } else { 710 this.hideHint = function() {}; 711 } 712 this.fbPlay.onclick = function() { 713 that.setPause(false); 714 if (window.event) event.returnValue = false; 715 return false; 716 }; 717 this.fbPause.onclick = function() { 718 that.setPause(true); 719 if (window.event) event.returnValue = false; 720 return false; 721 }; 722 this.fbClose.onclick = function() { 723 that.end(); 724 if (window.event) event.returnValue = false; 725 return false; 726 }; 727 if (this.outsideClickCloses) { 728 this.fbOverlay.onclick = this.fbShadowTop.onclick = this.fbShadowRight.onclick =
729 this.fbShadowBottom.onclick = this.fbShadowLeft.onclick = this.fbShadowCorner.onclick = this.fbClose.onclick; 730 } 731 this.fbPrev.onclick = function(step) { 732 if (typeof step !== 'number') step = 1; 733 var newIndex = (that.currentIndex - step) % that.itemCount; 734 if (newIndex < 0) newIndex += that.itemCount; 735 if (that.enableWrap || newIndex < that.currentIndex) { 736 that.newContent(newIndex); 737 if (that.isSlideshow && that.pauseOnPrev && !that.isPaused) { 738 that.setPause(true); 739 } 740 } 741 if (window.event) event.returnValue = false; 742 return false; 743 }; 744 this.fbNext.onclick = function(step) { 745 if (typeof step !== 'number') step = 1; 746 var newIndex = (that.currentIndex + step) % that.itemCount; 747 if (that.enableWrap || newIndex > that.currentIndex) { 748 that.newContent(newIndex); 749 if (that.isSlideshow && that.pauseOnNext && !that.isPaused) { 750 that.setPause(true); 751 } 752 } 753 if (window.event) event.returnValue = false; 754 return false; 755 }; 756 this.fbLeftNav.onclick = this.fbOverlayPrev.onclick = this.fbPrev.onclick; 757 this.fbRightNav.onclick = this.fbOverlayNext.onclick = this.fbNext.onclick; 758 this.fbLeftNav.onmouseover = this.fbLeftNav.onmousemove = 759 this.fbOverlayPrev.onmousemove = function() { 760 if (!that.timeouts.fbCanvas) overlayPrev.visibility = ''; 761 if (that.navButton) prev.backgroundPosition = that.onPos; 762 return true; 763 }; 764 this.fbRightNav.onmouseover = this.fbRightNav.onmousemove = 765 this.fbOverlayNext.onmousemove = function() { 766 if (!that.timeouts.fbCanvas) overlayNext.visibility = ''; 767 if (that.navButton) next.backgroundPosition = that.onPos; 768 return true; 769 }; 770 this.fbOverlayPrev.onmouseover = this.fbOverlayNext.onmouseover = function() { 771 this.onmousemove(); 772 that.hideHint(this.id); 773 return true; 774 }; 775 this.fbLeftNav.onmouseout = function() { 776 overlayPrev.visibility = 'hidden'; 777 if (that.navButton) prev.backgroundPosition = that.offPos; 778 }; 779 this.fbRightNav.onmouseout = function() { 780 overlayNext.visibility = 'hidden'; 781 if (that.navButton) next.backgroundPosition = that.offPos; 782 }; 783 this.fbOverlayPrev.onmouseout = this.fbOverlayNext.onmouseout = function() { 784 this.style.visibility = 'hidden'; 785 that.clearTimeout(this.id); 786 }; 787 this.fbLeftNav.onmousedown = this.fbRightNav.onmousedown = function(e) { 788 e = e || window.event; 789 if (e.button === 2) { 790 leftNav.visibility = rightNav.visibility = 'hidden'; 791 that.timeouts.hideNavOverlay = setTimeout(function() { 792 leftNav.visibility = rightNav.visibility = ''; 793 }, 600); 794 } 795 }; 796 this.fbPlay.onmouseover = this.fbPause.onmouseover = this.fbClose.onmouseover = 797 this.fbPrev.onmouseover = this.fbNext.onmouseover = function() { 798 this.style.backgroundPosition = that.onPos; 799 that.hideHint(this.id); 800 return true; 801 }; 802 this.fbResizer.onmouseover = function() { 803 that.hideHint(this.id); 804 return true; 805 }; 806 this.fbPlay.onmouseout = this.fbPause.onmouseout = this.fbClose.onmouseout = 807 this.fbPrev.onmouseout = this.fbNext.onmouseout = function() { 808 this.style.backgroundPosition = that.offPos; 809 that.clearTimeout(this.id); 810 }; 811 this.fbResizer.onmouseout = function() { 812 that.clearTimeout(this.id); 813 }; 814 if (this.enableKeyboardNav) { 815 if (!document.keydownSet) { 816 this.priorOnkeydown = document.onkeydown; 817 document.onkeydown = this.keyboardHandler; 818 document.keydownSet = true; 819 } 820 } else if (document.keydownSet) { 821 document.onkeydown = this.priorOnkeydown; 822 document.keydownSet = false; 823 } 824 if (this.opera && !document.keypressSet) { 825 this.priorOnkeypress = document.onkeypress; 826 document.onkeypress = function() { return false; }; 827 document.keypressSet = true; 828 } 829 if (this.enableDrag) this.fbBox.onmousedown = this.dragonDrop(); 830}, 831keyboardHandler: function(e) { 832 e = e || window.event; 833 var that = fb.lastChild, 834 keyCode = e.keyCode || e.which; 835 switch (keyCode) { 836 case 37: case 39: 837 if (that.itemCount > 1) { 838 that[keyCode === 37 ? 'fbPrev' : 'fbNext'].onclick((e.ctrlKey || e.metaKey) ? that.ctrlJump : 1); 839 if (that.showHints === 'once') { 840 that.fbPrev.title = that.fbNext.title = 841 that.fbOverlayPrev.title = that.fbOverlayNext.title = ''; 842 } 843 } 844 return false; 845 case 32: 846 if (that.isSlideshow) { 847 that.setPause(!that.isPaused); 848 if (that.showHints === 'once') that.fbPlay.title = that.fbPause.title = ''; 849 } 850 return false; 851 case 9: 852 if (that.fbResizer.onclick) { 853 that.fbResizer.onclick(); 854 if (that.showHints === 'once') that.fbResizer.title = ''; 855 } 856 return false; 857 case 27: 858 if (that.showHints === 'once') that.fbClose.title = ''; 859 that.end(); 860 return false; 861 case 13: 862 return false; 863 } 864}, 865dragonDrop: function() { 866 var that = this, 867 fbBox = this.fbBox; 868 return function(e) { 869 e = e || window.event; 870 if (/fb(Box|Canvas|Info|Caption|Item|Control|Index)/.test((e.target || e.srcElement).id)) { 871 var startX = e.clientX, 872 startY = e.clientY, 873 box = that.fbBox.style, 874 content = that.fbContent.style,
875 pos = that.pos.fbBox, 876 boxX = pos.left, 877 boxY = pos.top; 878 pos.dx = pos.dy = 0; 879 var moveHandler = function(e) { 880 if (that.currentItem.type === 'iframe' && !(that.ie || that.opera) && !content.visibility) content.visibility = 'hidden'; 881 if (that.isSlideshow && !that.isPaused) that.setPause(true); 882 e = e || window.event; 883 pos.dx = e.clientX - startX; 884 pos.dy = e.clientY - startY; 885 box.left = (boxX + pos.dx) + 'px'; 886 box.top = (boxY + pos.dy) + 'px'; 887 (e.stopPropagation && e.stopPropagation()) || (e.cancelBubble = true); 888 that.clearTimeout('dragonDrop'); 889 that.timeouts.dragonDrop = setTimeout(upHandler, 1500); 890 return false; 891 }; 892 var upHandler = function(e) { 893 that.clearTimeout('dragonDrop'); 894 e = e || window.event; 895 if (document.removeEventListener) { 896 document.removeEventListener("mouseup", upHandler, true); 897 document.removeEventListener("mousemove", moveHandler, true); 898 } else if (fbBox.detachEvent) { 899 fbBox.detachEvent("onlosecapture", upHandler); 900 fbBox.detachEvent("onmouseup", upHandler); 901 fbBox.detachEvent("onmousemove", moveHandler); 902 fbBox.releaseCapture(); 903 } 904 if (e) (e.stopPropagation && e.stopPropagation()) || (e.cancelBubble = true); 905 pos.left += pos.dx; 906 pos.top += pos.dy; 907 content.visibility = ''; 908 return false; 909 }; 910 if (document.addEventListener) { 911 document.addEventListener("mousemove", moveHandler, true); 912 document.addEventListener("mouseup", upHandler, true); 913 } else if (fbBox.attachEvent) { 914 fbBox.setCapture(); 915 fbBox.attachEvent("onmousemove", moveHandler); 916 fbBox.attachEvent("onmouseup", upHandler); 917 fbBox.attachEvent("onlosecapture", upHandler); 918 } 919 return false; 920 } 921 }; 922}, 923initState: function() { 924 var that = this, 925 box = this.fbBox.style, 926 mainDiv = this.fbMainDiv.style, 927 resizer = this.fbResizer.style, 928 canvas = this.fbCanvas.style, 929 zoomDiv = this.fbZoomDiv.style, 930 zoomImg = this.fbZoomImg.style; 931 if (this.currentItem.popup) this.currentItem.anchor.onmouseover(); 932 var anchorPos = this.getAnchorPos(this.clickedAnchor, this.currentItem.anchor === this.clickedAnchor && this.currentItem.type === 'img'); 933 if (anchorPos.width) { 934 this.pos.fbZoomDiv = anchorPos; 935 zoomDiv.borderWidth = this.zoomPopBorder + 'px'; 936 zoomDiv.left = (anchorPos.left - this.zoomPopBorder) + 'px'; 937 zoomDiv.top = (anchorPos.top - this.zoomPopBorder) + 'px'; 938 zoomDiv.width = (this.fbZoomImg.width = anchorPos.width) + 'px'; 939 zoomDiv.height = (this.fbZoomImg.height = anchorPos.height) + 'px'; 940 this.fbZoomImg.src = anchorPos.src; 941 box.visibility = 'hidden'; 942 this.timeouts.slowLoad = setTimeout(function() { 943 if (that.fbOverlay.style.display) that.fadeOpacity(that.fbOverlay, that.overlayOpacity, that.overlayFadeDuration); 944 that.fbZoomImg.src = that.slowZoomImg; 945 zoomDiv.display = zoomImg.display = ''; 946 }, this.slowLoadDelay); 947 } else { 948 this.pos.fbBox = anchorPos; 949 this.pos.fbBox.borderWidth = 0; 950 this.pos.fbMainDiv = { width:0, height:0 }; 951 } 952 box.position = 'absolute'; 953 box.left = box.top = box.width = box.height = box.borderWidth = '0'; 954 mainDiv.borderWidth = this.innerBorder + 'px'; 955 mainDiv.left = this.padding + 'px'; 956 this.fbControlPanel.style[this.controlLeft ? 'left' : 'right'] = 957 this.fbInfoPanel.style[this.infoLeft ? 'left' : 'right'] = Math.max(this.padding, this.panelPadding) + 'px'; 958 canvas.visibility = 'hidden'; 959 box.display = canvas.display = ''; 960 if (this.shadowType === 'none') { 961 this.shadowSize = 0; 962 } else { 963 var shadowTop = this.fbShadowTop.style, 964 shadowRight = this.fbShadowRight.style, 965 shadowBottom = this.fbShadowBottom.style, 966 shadowLeft = this.fbShadowLeft.style, 967 shadowCorner = this.fbShadowCorner.style; 968 shadowRight.top = shadowBottom.left = shadowLeft.top = -this.outerBorder + 'px'; 969 shadowRight.paddingRight = shadowBottom.paddingBottom = 970 shadowCorner.paddingRight = shadowCorner.paddingBottom = (this.outerBorder + this.shadowSize) + 'px'; 971 if (this.shadowType === 'halo') { 972 shadowTop.paddingRight = shadowRight.paddingBottom = 973 shadowBottom.paddingRight = shadowLeft.paddingBottom = (this.outerBorder*2 + this.shadowSize) + 'px'; 974 shadowTop.top = shadowTop.left = shadowRight.top = shadowLeft.left = -(this.outerBorder + this.shadowSize) + 'px'; 975 } else { 976 shadowBottom.backgroundPosition = 'bottom left'; 977 shadowRight.paddingBottom = shadowBottom.paddingRight = this.outerBorder*2 + 'px'; 978 } 979 } 980 if (this.navOverlay) { 981 if (fb.showNavOverlay === 'never' || (fb.showNavOverlay === 'once' && fb.navOverlayShown)) { 982 fb.showNavOverlay = false; 983 } else { 984 this.fbOverlayPrev.style.backgroundPosition = this.fbOverlayNext.style.backgroundPosition = this.onPos; 985 this.fadeOpacity(this.fbOverlayPrev, this.controlOpacity); 986 this.fadeOpacity(this.fbOverlayNext, this.controlOpacity); 987 } 988 } 989 this.initPanels(); 990 this.lastShown = false; 991 if (this.hideFlash) this.hideElements('flash'); 992 if (this.hideJava) this.hideElements('applet'); 993 if (this.ieOld) { 994 this.hideElements('select'); 995 this.fbOverlay.style.position = 'absolute'; 996 this.stretchOverlay()(); 997 attachEvent('onresize', this.stretchOverlay()); 998 attachEvent('onscroll', this.stretchOverlay()); 999 } 1000}, 1001hideElements: function(type, thisWindow) { 1002 if (!thisWindow) { 1003 this.hideElements(type, self); 1004 } else { 1005 var tagName, tagNames = type === 'flash' ? ['object', 'embed'] : [type]; 1006 try { 1007 while ((tagName = tagNames.pop())) { 1008 var els = thisWindow.document.getElementsByTagName(tagName), 1009 i = els.length; 1010 while (i--) { 1011 var el = els[i]; 1012 if (el.style.visibility !== 'hidden' && (tagName !== 'object' || 1013 (el.getAttribute('type') && el.getAttribute('type').toLowerCase() === 'application/x-shockwave-flash') || 1014 (el.getAttribute('classid') && el.getAttribute('classid').toLowerCase() === 'clsid:d27cdb6e-ae6d-11cf-96b8-444553540000') ||
1015 /data\s*=\s*"?[^>"]+\.swf\b/i.test(el.innerHTML) || 1016 /param\s+name\s*=\s*"?(movie|src)("|\s)[^>]+\.swf\b/i.test(el.innerHTML))) { 1017 this.hiddenEls.push(el); 1018 el.style.visibility = 'hidden'; 1019 } 1020 } 1021 } 1022 } catch(e) {} 1023 var frames = thisWindow.frames, i = frames.length; 1024 while (i--) { 1025 try { 1026 if (typeof frames[i].window === 'object') this.hideElements(type, frames[i].window); 1027 } catch(e) {} 1028 } 1029 } 1030}, 1031getAnchorPos: function(anchor, useThumb) { 1032 var display = this.getDisplaySize(), 1033 scroll = this.getScroll(), 1034 noAnchorPos = { left: display.width/2 + scroll.left, top: display.height/3 + scroll.top, width: 0, height: 0 }; 1035 var thumb = useThumb ? this.getThumb(anchor) : false; 1036 if (thumb && this.zoomImageStart) { 1037 var pos = this.getLeftTop(thumb), 1038 border = (thumb.offsetWidth - thumb.width)/2; 1039 pos.left += border; 1040 pos.top += border; 1041 pos.width = thumb.width; 1042 pos.height = thumb.height; 1043 pos.src = thumb.src; 1044 } else if (this.startAtClick && anchor && anchor.offsetWidth && anchor.tagName.toLowerCase() === 'a') { 1045 var pos = this.getLayout(thumb || anchor); 1046 } else { 1047 return noAnchorPos; 1048 } 1049 var centerPos = { left: pos.left + pos.width/2, top: pos.top + pos.height/2, width: 0, height: 0 }; 1050 if (centerPos.left < scroll.left || centerPos.left > (scroll.left + display.width) || 1051 centerPos.top < scroll.top || centerPos.top > (scroll.top + display.height)) { 1052 return noAnchorPos; 1053 } 1054 return (thumb && this.zoomImageStart ? pos : centerPos); 1055}, 1056getThumb: function(anchor) { 1057 var nodes = anchor && anchor.childNodes, i = (nodes && nodes.length) || 0; 1058 while (i--) { 1059 if ((nodes[i].tagName || '').toLowerCase() === 'img') return nodes[i]; 1060 } 1061 return false; 1062}, 1063initPanels: function() { 1064 var infoPanel = this.fbInfoPanel.style, 1065 infoLink = this.fbInfoLink.style, 1066 printLink = this.fbPrintLink.style, 1067 itemNumber = this.fbItemNumber.style; 1068 if (this.infoCenter) { 1069 var infoPos = ' posCenter'; 1070 infoPanel.textAlign = 'center'; 1071 infoLink.paddingLeft = printLink.paddingLeft = itemNumber.paddingLeft = 1072 infoLink.paddingRight = printLink.paddingRight = itemNumber.paddingRight = (this.infoLinkGap/2) + 'px'; 1073 } else if (this.infoLeft) { 1074 var infoPos = ' posLeft'; 1075 infoPanel.textAlign = 'left'; 1076 infoLink.paddingRight = printLink.paddingRight = this.infoLinkGap + 'px'; 1077 } else { 1078 var infoPos = ' posRight'; 1079 infoPanel.textAlign = 'right'; 1080 infoLink.paddingLeft = printLink.paddingLeft = this.infoLinkGap + 'px'; 1081 } 1082 this.fbInfoPanel.className += infoPos; 1083 this.fbInfoDiv.className += infoPos; 1084 infoPanel.width = '400px'; 1085 var controlPanel = this.fbControlPanel.style, 1086 controls = this.fbControls.style, 1087 subControls = this.fbSubControls.style; 1088 if (this.controlLeft) { 1089 var controlPos = ' posLeft'; 1090 controlPanel.textAlign = 'left'; 1091 } else { 1092 var controlPos = ' posRight'; 1093 controlPanel.textAlign = 'right'; 1094 controls.right = '0'; 1095 } 1096 this.fbControlPanel.className += controlPos; 1097 this.fbSubControls.className += controlPos; 1098 if (!this.ieOld) this.fbControls.className += controlPos; 1099 if (this.navButton) { 1100 var prev = this.fbPrev.style, 1101 next = this.fbNext.style, 1102 navControls = this.fbNavControls.style; 1103 prev.backgroundPosition = next.backgroundPosition = this.offPos; 1104 navControls['padding' + (this.controlLeft ? 'Left' : 'Right')] = this.controlSpacing + 'px'; 1105 this.fbNavControls.className += controlPos; 1106 controlPanel.display = navControls.display = prev.display = next.display = ''; 1107 } 1108 var width = 0; 1109 if (this.showClose) { 1110 var close = this.fbClose.style; 1111 close.backgroundPosition = this.offPos; 1112 this.fbClose.className += controlPos; 1113 controlPanel.display = controls.display = subControls.display = close.display = ''; 1114 width = this.fbClose.offsetWidth; 1115 } 1116 if (this.showPlayPause && this.isSlideshow) { 1117 var play = this.fbPlay.style, 1118 pause = this.fbPause.style, 1119 playPause = this.fbPlayPause.style; 1120 play.backgroundPosition = pause.backgroundPosition = this.offPos;
1121 playPause['padding' + (this.controlLeft ? 'Left' : 'Right')] = this.controlSpacing + 'px'; 1122 this.fbPlayPause.className += controlPos; 1123 controlPanel.display = controls.display = subControls.display = playPause.display = play.display = pause.display = ''; 1124 play.left = this.isPaused ? '' : '-9999px'; 1125 pause.left = this.isPaused ? '-9999px' : ''; 1126 width += this.fbPlayPause.offsetWidth; 1127 } 1128 subControls.width = width + 'px'; 1129 controlPanel.width = controls.width = (width + this.fbNavControls.offsetWidth) + 'px'; 1130 if (this.lclNumIndexLinks) { 1131 var indexLinks = this.fbIndexLinks.style; 1132 if (this.indexLinksPanel === 'info') { 1133 this.fbIndexLinks.className += infoPos; 1134 infoPanel.display = ''; 1135 if (this.showIndexThumbs) infoPanel.overflow = 'visible'; 1136 } else { 1137 this.fbIndexLinks.className += controlPos; 1138 controlPanel.display = ''; 1139 if (this.showIndexThumbs) controlPanel.overflow = 'visible'; 1140 indexLinks['padding' + (this.indexLeft ? 'Left' : 'Right')] = '2px'; 1141 } 1142 indexLinks.width = '250px'; 1143 indexLinks.display = ''; 1144 } 1145}, 1146fetchContent: function(callback, phase) { 1147 var that = this; 1148 if (!phase) { 1149 if (this.fbContent) { 1150 this.fbMainDiv.removeChild(this.fbContent); 1151 delete this.fbContent; 1152 return this.timeouts.fetch = setTimeout(function() { that.fetchContent(callback, 1); }, 10); 1153 } 1154 } 1155 var item = this.currentItem; 1156 item.nativeWidth = item.revOptions.width; 1157 item.nativeHeight = item.revOptions.height; 1158 if (item.type !== 'img') { 1159 item.nativeWidth = item.nativeWidth || (fb.previousAnchor && fb.previousAnchor.nativeWidth) || this.defaultWidth; 1160 item.nativeHeight = item.nativeHeight || (fb.previousAnchor && fb.previousAnchor.nativeHeight) || this.defaultHeight; 1161 } 1162 if (this.ieOld) this.fbMainDiv.style.backgroundColor = item.type === 'img' ? '#000' : ''; 1163 this.itemScroll = item.revOptions.scrolling || item.revOptions.scroll || 'auto'; 1164 if (/img|iframe/.test(item.type)) { 1165 this.fbContent = this.newNode(item.type, 'fbContent', this.fbMainDiv); 1166 if (item.type === 'img') { 1167 var loader = new Image(); 1168 loader.onload = function() { 1169 item.nativeWidth = item.nativeWidth || loader.width; 1170 item.nativeHeight = item.nativeHeight || loader.height; 1171 that.fbContent.src = loader.src; 1172 if (callback) callback(); 1173 }; 1174 loader.onerror = function() { 1175 if (this.src !== that.notFoundImg) this.src = that.notFoundImg; 1176 }; 1177 loader.src = item.href; 1178 } 1179 } else { 1180 this.fbContent = this.newNode('div', 'fbContent', this.fbMainDiv); 1181 this.fbContent.style.overflow = this.itemScroll === 'yes' ? 'scroll' : (this.itemScroll === 'no' ? 'hidden' : 'auto'); 1182 if (item.type === 'inline') { 1183 var el = item.sourceEl.cloneNode(true); 1184 el.style.display = el.style.visibility = ''; 1185 try { this.fbContent.appendChild(el); } 1186 catch(e) { this.setInnerHTML(this.fbContent, el.innerHTML); } 1187 this.tagAnchors(this.fbContent); 1188 } else if (item.type === 'ajax') { 1189 this.xhr.getResponse(item.href, function(xhr) { 1190 if ((xhr.status === 200 || xhr.status === 203 || xhr.status === 304) && xhr.responseText) { 1191 that.setInnerHTML(that.fbContent, xhr.responseText); 1192 that.tagAnchors(that.fbContent); 1193 } else { 1194 that.setInnerHTML(that.fbContent, '<p style="color:#000; background:#fff; margin:1em; padding:1em;">' + 1195 'Unable to fetch content from ' + item.href + '</p>'); 1196 } 1197 }); 1198 } 1199 } 1200 this.fbContent.style.border = '0'; 1201 this.fbContent.style.display = ''; 1202 if (item.type !== 'img' && callback) callback(); 1203}, 1204updatePanels: function() { 1205 var infoPanel = this.fbInfoPanel.style, 1206 captionDiv = this.fbCaptionDiv.style, 1207 caption = this.fbCaption.style, 1208 infoDiv = this.fbInfoDiv.style, 1209 infoLink = this.fbInfoLink.style, 1210 printLink = this.fbPrintLink.style, 1211 itemNumber = this.fbItemNumber.style, 1212 item = this.currentItem, 1213 str; 1214 infoPanel.display = captionDiv.display = caption.display = infoDiv.display = infoLink.display = printLink.display = itemNumber.display = 'none'; 1215 if (this.showCaption) { 1216 str = item.revOptions.caption || item.title || ''; 1217 if (str === 'href') { 1218 str = this.encodeHTML(this.currentItem.href); 1219 } else { 1220 str = this.decodeHTML(str).replace(/&/g, '&'); 1221 } 1222 if (this.setInnerHTML(this.fbCaption, str) && str) infoPanel.display = captionDiv.display = caption.display = ''; 1223 } 1224 if (item.revOptions.info) { 1225 str = this.encodeHTML(this.decodeHTML(item.revOptions.info)); 1226 var options = item.revOptions.infoOptions || ''; 1227 if (options) options = this.encodeHTML(this.decodeHTML(options)); 1228 str = '<a href="' + str + '" rel="floatbox" rev="' + options + '"><b>' + 1229 (item.revOptions.infoText || this.strings.infoText) + '</b></a>'; 1230 if (this.setInnerHTML(this.fbInfoLink, str)) infoPanel.display = infoDiv.display = infoLink.display = ''; 1231 } 1232 if (item.revOptions.showPrint) { 1233 var css = item.revOptions.printCSS || ''; 1234 str = '<a href="' + this.encodeHTML(this.currentItem.href) + 1235 '" onclick="fb.printContents(null, \'' + css + '\'); if (window.event) event.returnValue = false; return false;"><b>' + 1236 (item.revOptions.printText || this.strings.printText) + '</b></a>'; 1237 if (this.setInnerHTML(this.fbPrintLink, str)) infoPanel.display = infoDiv.display = printLink.display = ''; 1238 } 1239 if (this.lclShowItemNumber) { 1240 str = this.justImages ? this.strings.imgCount : this.strings.nonImgCount; 1241 str = str.replace('%1', this.currentIndex + 1); 1242 str = str.replace('%2', this.itemCount); 1243 if (this.setInnerHTML(this.fbItemNumber, str)) infoPanel.display = infoDiv.display = itemNumber.display = ''; 1244 } 1245 var w = this.fbInfoLink.offsetWidth + this.fbPrintLink.offsetWidth + this.fbItemNumber.offsetWidth; 1246 if (this.ie) { 1247 if (this.fbInfoLink.offsetWidth) w += this.infoLinkGap; 1248 if (this.fbPrintLink.offsetWidth) w += this.infoLinkGap; 1249 if (this.fbItemNumber.offsetWidth) w += this.infoLinkGap; 1250 } 1251 infoDiv.width = w + 'px'; 1252 if (this.lclNumIndexLinks) { 1253 str = ''; 1254 var max = this.itemCount - 1, 1255 loRange, hiRange; 1256 if (this.lclNumIndexLinks === -1) { 1257 loRange = 0; 1258 hiRange = max; 1259 } else { 1260 var range = Math.floor(this.lclNumIndexLinks/2) - 1; 1261 loRange = this.currentIndex - range; 1262 hiRange = this.currentIndex + range; 1263 if (loRange <= 0) hiRange += Math.min(1 - loRange, range); 1264 if (this.currentIndex === 0) hiRange++; 1265 if (hiRange - max >= 0) loRange -= Math.min(1 + hiRange - max, range); 1266 if (this.currentIndex === max) loRange--; 1267 } 1268 var pos = this.indexTop ? 'down' : 'up', 1269 i = 0; 1270 while (i < this.itemCount) { 1271 if (i !== 0 && i < loRange) { 1272 str += '... '; 1273 i = loRange; 1274 } else if (i !== max && i > hiRange) { 1275 str += '... '; 1276 i = max; 1277 } else { 1278 if (i !== this.currentIndex) { 1279 var item = this.items[i]; 1280 str += '<a class="fbPop' + pos + '" rel="nofloatbox" href="' + item.href + 1281 '" onclick="fb.newContent(' + i + '); if (window.event) event.returnValue = false; return false;">' + ++i; 1282 try { 1283 if (this.showIndexThumbs && item.thumb) { 1284 str += '<img src="' + item.thumb.src + '" />'; 1285 } 1286 } catch(e) {} 1287 str += '</a> '; 1288 } else { 1289 str += ++i + ' '; 1290 } 1291 } 1292 } 1293 if (this.setInnerHTML(this.fbIndexLinks, str)) { 1294 if (this.indexLinksPanel === 'info') { 1295 infoPanel.display = ''; 1296 } else { 1297 this.tagAnchors(this.fbIndexLinks); 1298 } 1299 } 1300 } 1301 if (!infoPanel.display) this.tagAnchors(this.fbInfoPanel); 1302}, 1303calcSize: function(fit, pass) { 1304 var that = this; 1305 if (!this.fbBox) return; 1306 var boxX, boxY, boxW, boxH, mainW, mainH ; 1307 if (typeof fit === 'undefined') { 1308 fit = this.currentItem.type === 'img' ? this.autoSizeImages : this.autoSizeOther; 1309 } 1310 var box = this.fbBox.style, 1311 infoPanel = this.fbInfoPanel.style, 1312 controlPanel = this.fbControlPanel.style, 1313 indexLinks = this.fbIndexLinks.style, 1314 captionDiv = this.fbCaptionDiv.style, 1315 itemNumber = this.fbItemNumber.style; 1316 if (!pass) { 1317 this.displaySize = this.getDisplaySize(); 1318 if (this.showCaption && this.fbCaption.innerHTML) captionDiv.display = ''; 1319 if (this.lclShowItemNumber) itemNumber.display = ''; 1320 }
1321 this.upperSpace = Math.max(this.infoTop ? this.fbInfoPanel.offsetHeight : 0, this.controlTop ? this.fbControlPanel.offsetHeight : 0); 1322 this.lowerSpace = Math.max(this.infoTop ? 0 : this.fbInfoPanel.offsetHeight, this.controlTop ? 0 : this.fbControlPanel.offsetHeight); 1323 if (this.upperSpace) this.upperSpace += 2*this.panelPadding; 1324 if (this.lowerSpace) this.lowerSpace += 2*this.panelPadding; 1325 this.upperSpace = Math.max(this.upperSpace, this.padding); 1326 this.lowerSpace = Math.max(this.lowerSpace, this.padding); 1327 var extraSpace; 1328 if (this.shadowType === 'none') { 1329 extraSpace = 2*this.autoSizeSpace; 1330 } else if (this.shadowType === 'halo') { 1331 extraSpace = 2*this.shadowSize + this.autoSizeSpace; 1332 } else { 1333 extraSpace = this.shadowSize + 1.5*this.autoSizeSpace; 1334 } 1335 var pad = 2*(this.outerBorder + this.innerBorder) + extraSpace, 1336 maxW = Math.floor(this.displaySize.width - pad - 2*this.padding), 1337 maxH = Math.floor(this.displaySize.height - pad - this.upperSpace - this.lowerSpace), 1338 hardW = false, hardH = false; 1339 mainW = this.currentItem.nativeWidth + ''; 1340 if (mainW === 'max') { 1341 mainW = maxW; 1342 } else if (mainW.substr(mainW.length - 1) === '%') { 1343 mainW = Math.floor(maxW * parseInt(mainW, 10) / 100); 1344 } else { 1345 mainW = parseInt(mainW, 10); 1346 hardW = true; 1347 } 1348 mainH = this.currentItem.nativeHeight + ''; 1349 if (mainH === 'max') { 1350 mainH = maxH; 1351 } else if (mainH.substr(mainH.length - 1) === '%') { 1352 mainH = Math.floor(maxH * parseInt(mainH, 10) / 100); 1353 } else { 1354 mainH = parseInt(mainH, 10); 1355 hardH = true; 1356 } 1357 this.scaledBy = this.oversizedBy = 0; 1358 if (fit) { 1359 var scaleW = maxW/mainW, 1360 scaleH = maxH/mainH, 1361 fullW = mainW, fullH = mainH; 1362 if (hardW && hardH) scaleW = scaleH = Math.min(scaleW, scaleH); 1363 if (scaleW < 1) mainW = Math.round(mainW * scaleW); 1364 if (scaleH < 1) mainH = Math.round(mainH * scaleH); 1365 this.scaledBy = Math.max(fullW - mainW, fullH - mainH); 1366 if (this.scaledBy && this.scaledBy < this.outerBorder + extraSpace + this.panelPadding) { 1367 mainW = fullW; 1368 mainH = fullH; 1369 this.scaledBy = 0; 1370 } 1371 } 1372 boxW = mainW + 2*(this.innerBorder + this.padding); 1373 boxH = mainH + 2*this.innerBorder + this.upperSpace + this.lowerSpace; 1374 var infoH = this.fbInfoPanel.offsetHeight, 1375 controlH = this.fbControlPanel.offsetHeight; 1376 var infoW = boxW - 2*Math.max(this.padding, this.panelPadding); 1377 if (this.infoTop === this.controlTop && this.fbControls.offsetWidth) { 1378 infoW -= this.fbControls.offsetWidth + this.panelGap; 1379 } 1380 if (infoW < 0) infoW = 0; 1381 infoPanel.width = infoW + 'px'; 1382 if (!this.lclNumIndexLinks) { 1383 var indexW = 0; 1384 } else if (this.indexLinksPanel === 'info' || this.infoTop !== this.controlTop) { 1385 var indexW = infoW; 1386 } else if (this.indexLinksPanel !== 'info' && this.infoTop === this.controlTop && this.infoCenter) { 1387 var indexW = Math.max(this.minIndexWidth, this.fbControls.offsetWidth); 1388 } else { 1389 var infoUsed = Math.max(this.fbCaption.offsetWidth, this.fbInfoLink.offsetWidth + this.fbPrintLink.offsetWidth + this.fbItemNumber.offsetWidth); 1390 var indexW = Math.max(this.minIndexWidth, this.fbControls.offsetWidth, (boxW - infoUsed - 2*Math.max(this.padding, this.panelPadding))); 1391 if (infoUsed) indexW -= this.panelGap; 1392 } 1393 if (indexW) indexLinks.width = (indexW - (this.indexLinksPanel !== 'info' ? 2 : 0)) + 'px'; 1394 controlPanel.width = Math.max(indexW, this.fbControls.offsetWidth) + 'px'; 1395 var changed = this.fbInfoPanel.offsetHeight !== infoH || this.fbControlPanel.offsetHeight !== controlH; 1396 if (this.showCaption) { 1397 if (this.minInfoWidth > infoW && !captionDiv.display) { 1398 captionDiv.display = 'none'; 1399 changed = true; 1400 } 1401 } 1402 if (this.lclShowItemNumber) { 1403 if (this.fbInfoLink.offsetWidth + this.fbPrintLink.offsetWidth + this.fbItemNumber.offsetWidth > infoW && !itemNumber.display) { 1404 itemNumber.display = 'none'; 1405 changed = true; 1406 } 1407 } 1408 if (changed && pass !== 3) return this.calcSize(fit, (pass || 0) + 1); 1409 if (!fit) this.oversizedBy = Math.max(boxW - this.displaySize.width, boxH - this.displaySize.height) + 2*this.outerBorder + extraSpace; 1410 if (this.oversizedBy < 0) this.oversizedBy = 0; 1411 if (this.shadowType === 'halo') { 1412 extraSpace = this.shadowSize + this.autoSizeSpace/2; 1413 } else { 1414 extraSpace = this.autoSizeSpace; 1415 } 1416 if (typeof this.boxLeft === 'number') { 1417 boxX = this.boxLeft; 1418 } else if (mainW === maxW) { 1419 boxX = extraSpace; 1420 } else {
1421 var freeSpace = this.displaySize.width - boxW - 2*this.outerBorder; 1422 boxX = Math.floor(freeSpace/2); 1423 if (boxX < this.autoSizeSpace) { 1424 boxX = this.autoSizeSpace; 1425 } else { 1426 if (typeof this.boxLeft === 'string' && this.boxLeft.substr(this.boxLeft.length - 1) === '%') { 1427 boxX += parseInt(this.boxLeft, 10)/100 * boxX; 1428 } 1429 } 1430 } 1431 if (typeof this.boxTop === 'number') { 1432 boxY = this.boxTop; 1433 } else if (mainH === maxH) { 1434 boxY = extraSpace; 1435 } else { 1436 var freeSpace = this.displaySize.height - boxH - 2*this.outerBorder, 1437 ratio = freeSpace / this.displaySize.height, factor; 1438 if (ratio <= 0.15) { 1439 factor = 2; 1440 } else if (ratio >= 0.3) { 1441 factor = 3; 1442 } else { 1443 factor = 1 + ratio/0.15; 1444 } 1445 boxY = Math.floor(freeSpace/factor); 1446 if (boxY < this.autoSizeSpace) { 1447 boxY = this.autoSizeSpace; 1448 } else { 1449 if (typeof this.boxTop === 'string' && this.boxTop.substr(this.boxTop.length - 1) === '%') { 1450 boxY += parseInt(this.boxTop, 10)/100 * boxY; 1451 } 1452 } 1453 } 1454 var boxPosition = box.position; 1455 if (this.ieOld) { 1456 box.display = 'none'; 1457 this.stretchOverlay()(); 1458 } else { 1459 this.setPosition(this.fbBox, 'fixed'); 1460 } 1461 var scroll = this.getScroll(); 1462 this.setPosition(this.fbBox, boxPosition); 1463 box.display = ''; 1464 boxX += scroll.left; 1465 boxY += scroll.top; 1466 if (this.isChild) { 1467 var rex = /max|%/i, 1468 pos = this.fbParent.pos.fbBox, 1469 childX = rex.test(this.currentItem.nativeWidth) ? 99999 : (pos.left + boxX)/2, 1470 childY = rex.test(this.currentItem.nativeHeight) ? 99999 : (pos.top + boxY)/2; 1471 if (scroll.left < childX && scroll.top < childY) { 1472 boxX = Math.min(boxX, childX); 1473 boxY = Math.min(boxY, childY); 1474 } 1475 } 1476 var split = (pos = this.pos.fbBox) && !this.liveResize && this.splitResize; 1477 if (split === 'auto') split = boxW - pos.width <= boxH - pos.height ? 'wh' : 'hw'; 1478 var oncomplete2 = function() { 1479 that.fbBox.style.visibility ? that.zoomIn() : that.showContent(); 1480 }; 1481 var oncomplete = function() { 1482 that.setSize(split, 1483 { id: 'fbBox', left: boxX, top: boxY, width: boxW, height: boxH, borderWidth: that.outerBorder }, 1484 { id: 'fbMainDiv', width: mainW, height: mainH, top: that.upperSpace }, 1485 function() { that.timeouts.showContent = setTimeout(oncomplete2, 10); } 1486 ); 1487 }; 1488 this.timeouts.setSize = setTimeout(oncomplete, 10); 1489}, 1490setPosition: function(el, position) { 1491 if (el.style.position === position) return; 1492 var scroll = this.getScroll(); 1493 if (position === 'fixed') { 1494 scroll.left = -scroll.left; 1495 scroll.top = -scroll.top; 1496 } 1497 if (this.pos[el.id]) { 1498 this.pos[el.id].left += scroll.left; 1499 this.pos[el.id].top += scroll.top; 1500 } 1501 el.style.left = (el.offsetLeft + scroll.left) + 'px'; 1502 el.style.top = (el.offsetTop + scroll.top) + 'px'; 1503 el.style.position = position; 1504}, 1505collapse: function(callback, phase) { 1506 var that = this; 1507 if (!phase) { 1508 this.setPosition(this.fbBox, 'absolute'); 1509 this.fbResizer.onclick = null; 1510 this.fbResizer.style.display = 'none'; 1511 if (this.fbContent) { 1512 this.fbContent.onclick = null; 1513 this.fbContent.style.cursor = ''; 1514 } 1515 if (this.navOverlay) { 1516 this.fbLeftNav.style.display = this.fbRightNav.style.display = 1517 this.fbOverlayPrev.style.display = this.fbOverlayNext.style.display = 'none'; 1518 } 1519 var opacity = 0, duration = 0; 1520 if (this.currentItem.type === 'img' && !this.fbCanvas.style.visibility) { 1521 if (this.currentItem === this.lastShown && this.liveImageResize) opacity = 1; 1522 duration = this.imageFadeDuration; 1523 } 1524 this.liveResize = (opacity === 1); 1525 var oncomplete = function() { that.collapse(callback, 1); }; 1526 return this.fadeOpacity(this.fbCanvas, opacity, duration, oncomplete); 1527 } 1528 if (!this.liveResize) { 1529 this.fbMainDiv.style.display = 'none'; 1530 if (this.fbContent) this.fbContent.style.display = 'none'; 1531 this.clearTimeout('loader'); 1532 this.timeouts.loader = setTimeout(function() { that.fbLoader.style.display = ''; }, this.loaderDelay); 1533 } 1534 var infoPanel = this.fbInfoPanel.style, 1535 controlPanel = this.fbControlPanel.style; 1536 infoPanel.visibility = controlPanel.visibility = 'hidden'; 1537 infoPanel.left = controlPanel.left = infoPanel.top = controlPanel.top = '-9999px'; 1538 if (callback) callback(); 1539}, 1540restore: function(callback, phase) { 1541 var that = this; 1542 if (!phase) { 1543 if (this.fbShadowRight.style.display && this.shadowType !== 'none') { 1544 this.fbShadowRight.style.display = this.fbShadowBottom.style.display = ''; 1545 if (this.shadowType === 'halo') { 1546 this.fbShadowTop.style.display = this.fbShadowLeft.style.display = ''; 1547 } else { 1548 this.fbShadowCorner.style.display = ''; 1549 } 1550 } 1551 var infoPanel = this.fbInfoPanel.style,
1552 controlPanel = this.fbControlPanel.style, 1553 pad = this.upperSpace + this.pos.fbMainDiv.height + 2*this.innerBorder; 1554 infoPanel.top = (((this.infoTop ? this.upperSpace : this.lowerSpace) - this.fbInfoPanel.offsetHeight) / 2 - 1 + (this.infoTop ? 0 : pad)) + 'px'; 1555 controlPanel.top = (((this.controlTop ? this.upperSpace : this.lowerSpace) - this.fbControlPanel.offsetHeight) / 2 + (this.controlTop ? 0 : pad)) + 'px'; 1556 var pad = Math.max(this.padding, this.panelPadding) + 'px'; 1557 infoPanel.left = [this.infoLeft ? pad : '']; 1558 controlPanel.left = [this.controlLeft ? pad : '']; 1559 infoPanel.visibility = controlPanel.visibility = ''; 1560 this.clearTimeout('loader'); 1561 this.fbLoader.style.display = 'none'; 1562 this.fbMainDiv.style.display = this.fbContent.style.display = ''; 1563 var duration = (this.currentItem.type === 'img' && !this.fbCanvas.style.visibility) ? this.imageFadeDuration : 0, 1564 oncomplete = function() { that.restore(callback, 1); }; 1565 return this.fadeOpacity(this.fbCanvas, 1, duration, oncomplete); 1566 } 1567 if (this.currentItem.type === 'img' ? this.resizeImages : this.resizeOther) { 1568 var scale = 0; 1569 if (this.scaledBy > 35) { 1570 scale = 1; 1571 } else if (this.oversizedBy > 28){ 1572 scale = -1; 1573 } 1574 if (scale) { 1575 this.fbResizer.onclick = function() { 1576 if (that.isSlideshow && that.pauseOnResize && !that.isPaused) { 1577 that.setPause(true); 1578 } 1579 that.collapse(function() { that.calcSize(scale === -1); }); 1580 if (window.event) event.returnValue = false; 1581 return false; 1582 }; 1583 if (this.currentItem.type === 'img' && /cursor|both/.test(this.resizeTool)) { 1584 this.fbContent.style.cursor = 'url(' + (scale === -1 ? this.resizeDownCursor : this.resizeUpCursor) +'), default'; 1585 this.fbContent.onclick = this.fbResizer.onclick; 1586 } 1587 if (this.currentItem.type !== 'img' || /topleft|both/.test(this.resizeTool)) { 1588 this.fbResizer.style.backgroundPosition = (scale === -1 ? 'bottom' : 'top'); 1589 this.fadeOpacity(this.fbResizer, this.controlOpacity); 1590 } 1591 } 1592 } 1593 if (this.navOverlay) { 1594 var leftNav = this.fbLeftNav.style, 1595 rightNav = this.fbRightNav.style, 1596 overlayPrev = this.fbOverlayPrev.style, 1597 overlayNext = this.fbOverlayNext.style; 1598 leftNav.width = rightNav.width = Math.max(this.navOverlayWidth/100 * this.pos.fbMainDiv.width, this.fbOverlayPrev.offsetWidth) + 'px'; 1599 leftNav.display = rightNav.display = ''; 1600 if (fb.showNavOverlay) { 1601 overlayPrev.visibility = overlayNext.visibility = 'hidden'; 1602 overlayPrev.display = overlayNext.display = '';
1603 overlayPrev.top = overlayNext.top = ((this.pos.fbMainDiv.height - this.fbOverlayPrev.offsetHeight) * this.navOverlayPos/100) + 'px'; 1604 } 1605 } 1606 if (callback) callback(); 1607}, 1608setSize: function(order) { 1609 var that = this, 1610 oncomplete = function() {}, 1611 arr = [[], []], 1612 defer = {}, 1613 node, 1614 i = arguments.length; 1615 if (order === 'wh') { 1616 defer.top = 1; 1617 defer.height = 1; 1618 } else if (order === 'hw') { 1619 defer.left = 1; 1620 defer.width = 1; 1621 } 1622 while (i--) { 1623 if (typeof arguments[i] === 'object' && (node = this[arguments[i].id])) { 1624 var obj = arguments[i]; 1625 if (!this.pos[obj.id]) this.pos[obj.id] = {}; 1626 for (var property in obj) { 1627 if (obj.hasOwnProperty(property) && property !== 'id') { 1628 var idx = defer[property] || 0; 1629 var start = this.pos[obj.id][property]; 1630 if (typeof start !== 'number' || node.style.display || node.style.visibility) { 1631 start = obj[property]; 1632 } 1633 arr[idx].push({ node: node, property: property, start: start, finish: obj[property] }); 1634 if (obj.id === 'fbMainDiv') { 1635 arr[idx].push({ node: this.fbContent, property: property, start: start, finish: obj[property] }); 1636 } 1637 if (obj.id === 'fbZoomDiv' && /\b(width|height)\b/i.test(property)) { 1638 arr[idx].push({ node: this.fbZoomImg, property: property, start: start, finish: obj[property] }); 1639 } 1640 this.pos[obj.id][property] = obj[property]; 1641 } 1642 } 1643 } else if (typeof arguments[i] === 'function') { 1644 oncomplete = arguments[i]; 1645 } 1646 } 1647 this.resizeGroup(arr[0], function() { that.resizeGroup(arr[1], oncomplete); }); 1648}, 1649showContent: function(phase) { 1650 var that = this; 1651 if (!phase) { 1652 var displaySize = this.getDisplaySize(); 1653 if (!this.resized) { 1654 var vscrollChanged = displaySize.width !== this.displaySize.width, 1655 hscrollChanged = displaySize.height !== this.displaySize.height; 1656 if ((vscrollChanged && Math.abs(this.pos.fbBox.width - displaySize.width) < 50) || 1657 (hscrollChanged && Math.abs(this.pos.fbBox.height - displaySize.height) < 50)) { 1658 this.resized = true; 1659 return this.calcSize(this.scaledBy); 1660 } 1661 } 1662 this.resized = false; 1663 self.focus(); 1664 if (this.ieOld) this.stretchOverlay()(); 1665 if ((this.disableScroll || (this.ffOld && /iframe|quicktime/i.test(this.currentItem.type))) && !(this.ieOld || this.webkitOld || this.ie8b2)) { 1666 if (this.pos.fbBox.width <= displaySize.width && this.pos.fbBox.height <= displaySize.height) { 1667 this.setPosition(this.fbBox, 'fixed'); 1668 } 1669 } 1670 if (this.currentItem.type === 'iframe') { 1671 this.fbContent.src = this.currentItem.href; 1672 } else if (/flash|quicktime/.test(this.currentItem.type)) { 1673 this.setInnerHTML(this.fbContent, this.objectHTML(this.currentItem.href, 1674 this.currentItem.type, this.pos.fbMainDiv.width, this.pos.fbMainDiv.he
1674ight)); 1675 } 1676 this.prevIndex = this.currentIndex ? this.currentIndex - 1 : this.itemCount - 1; 1677 this.nextIndex = this.currentIndex < this.itemCount - 1 ? this.currentIndex + 1 : 0; 1678 var prevHref = this.enableWrap || this.currentIndex !== 0 ? this.items[this.prevIndex].href : '', 1679 nextHref = this.enableWrap || this.currentIndex !== this.itemCount - 1 ? this.items[this.nextIndex].href : ''; 1680 if (this.navButton) { 1681 if (prevHref) { 1682 if (!this.operaOld) this.fbPrev.href = prevHref; 1683 this.fbPrev.title = this.fbOverlayPrev.title; 1684 } else { 1685 this.fbPrev.removeAttribute('href'); 1686 this.fbPrev.title = ''; 1687 } 1688 if (nextHref) { 1689 if (!this.operaOld) this.fbNext.href = nextHref; 1690 this.fbNext.title = this.fbOverlayNext.title; 1691 } else { 1692 this.fbNext.removeAttribute('href'); 1693 this.fbNext.title = ''; 1694 } 1695 var prevOn = this.fbPrev.className.replace('_off', ''), 1696 nextOn = this.fbNext.className.replace('_off', ''); 1697 this.fbPrev.className = prevOn + (prevHref ? '' : '_off'); 1698 this.fbNext.className = nextOn + (nextHref ? '' : '_off'); 1699 } 1700 if (this.navOverlay) { 1701 if (!this.operaOld) { 1702 this.fbLeftNav.href = this.fbOverlayPrev.href = prevHref; 1703 this.fbRightNav.href = this.fbOverlayNext.href = nextHref; 1704 } 1705 this.fbLeftNav.style.visibility = prevHref ? '' : 'hidden'; 1706 this.fbRightNav.style.visibility = nextHref ? '' : 'hidden'; 1707 fb.navOverlayShown = true; 1708 } 1709 this.fbCanvas.style.visibility = ''; 1710 return this.restore(function() { 1711 that.timeouts.showContent = setTimeout(function() { that.showContent(1); }, 10); 1712 } ); 1713 } 1714 this.lastShown = this.currentItem; 1715 if (!this.currentItem.seen) { 1716 this.currentItem.seen = true; 1717 this.itemsShown++; 1718 } 1719 if (this.isSlideshow && !this.isPaused) { 1720 this.timeouts.slideshow = setTimeout(function() { 1721 if (that.endTask === 'loop' || that.itemsShown < that.itemCount) { 1722 that.newContent(that.nextIndex); 1723 } else if (that.endTask === 'exit') { 1724 that.end(); 1725 } else { 1726 that.setPause(true); 1727 var i = that.itemCount; 1728 while (i--) that.items[i].seen = false; 1729 that.itemsShown = 0; 1730 } 1731 }, this.slideInterval*1000); 1732 } 1733 this.timeouts.preload = setTimeout(function() { 1734 that.preloadImages(nextHref || prevHref || '', true); 1735 }, 10); 1736}, 1737objectHTML: function(href, type, width, height) { 1738 if (type === 'flash') { 1739 var classid = 'classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"', 1740 mime = 'type="application/x-shockwave-flash"', 1741 pluginurl = 'http://get.adobe.com/flashplayer/', 1742 match = /\bwmode=(\w+?)\b/i.exec(href), 1743 wmode = match ? match[1] : 'window', 1744 match = /\bbgcolor=(#\w+?)\b/i.exec(href), 1745 bgcolor = match ? match[1] : '', 1746 match = /\bscale=(\w+?)\b/i.exec(href), 1747 scale = match ? match[1] : 'exactfit', 1748 params = { wmode:wmode, bgcolor:bgcolor, scale:scale, quality:'high', 1749 flashvars:'autoplay=1&ap=true&border=0&rel=0' }; 1750 if (this.ffOld) params.wmode = this.ffMac ? 'window' : 'opaque'; 1751 if (this.ffNew && href.indexOf('YV_YEP.swf') !== -1) params.wmode = 'window'; 1752 } else { 1753 var classid = 'classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"', 1754 mime = 'type="video/quicktime"', 1755 pluginurl = 'http://www.apple.com/quicktime/download/', 1756 params = { autoplay:'true', controller:'true', showlogo:'false', scale:'tofit' }; 1757 } 1758 var html = '<object id="fbObject" name="fbObject" width="' + width + '" height="' + height + '" '; 1759 if (this.ie) { 1760 html += classid + '>'; 1761 params[type === 'flash' ? 'movie' : 'src'] = this.encodeHTML(href); 1762 } else { 1763 html += mime + ' data="' + this.encodeHTML(href) + '">'; 1764 } 1765 for (var name in params) { 1766 if (params.hasOwnProperty(name)) { 1767 html += '<param name="' + name + '" value="' + params[name] + '" />'; 1768 } 1769 } 1770 if (type === 'quicktime' && this.webkitMac) { 1771 html += '<embed src="' + this.encodeHTML(href) + 1772 '" width="' + width + '" height="' + height + '" autoplay="true" controller="true" showlogo="false" scale="tofit" pluginspage="' + 1773 pluginurl + '"></embed></object>'; 1774 } else { 1775 html += '<p style="color:#000; background:#fff; margin:1em; padding:1em;">' + 1776 (type === 'flash' ? 'Flash' : 'QuickTime') + ' player is required to view this content.' + 1777 '<br /><a href="' + pluginurl + '">
1777download player</a></p></object>'; 1778 } 1779 return html; 1780}, 1781newContent: function(index) { 1782 var that = this; 1783 this.clearTimeout('slideshow'); 1784 this.clearTimeout('resize'); 1785 this.currentIndex = index; 1786 fb.previousAnchor = this.currentItem; 1787 this.currentItem = this.items[index]; 1788 if (this.showNavOverlay == 'once' && this.navOverlayShown) this.showNavOverlay = false; 1789 var oncomplete = function() { 1790 that.updatePanels(); 1791 that.fetchContent(function() { that.calcSize(); }); 1792 }; 1793 this.collapse(function() { 1794 that.timeouts.fetch = setTimeout(oncomplete, 10); 1795 } ); 1796}, 1797end: function(all) { 1798 if (this !== fb.lastChild) return fb.lastChild.end(all); 1799 var that = this; 1800 this.endAll = this.endAll || all; 1801 this.fbOverlay.onclick = null; 1802 if (this.isChild) { 1803 if (this.endAll) this.imageFadeDuration = this.overlayFadeDuration = this.resizeDuration = 0; 1804 } else { 1805 if (document.keydownSet) { 1806 document.onkeydown = this.priorOnkeydown; 1807 document.keydownSet = false; 1808 } 1809 if (document.keypressSet) { 1810 document.onkeypress = this.priorOnkeypress; 1811 document.keypressSet = false; 1812 } 1813 parent.focus(); 1814 } 1815 if (this.ieOld) { 1816 detachEvent('onresize', this.stretchOverlay()); 1817 detachEvent('onscroll', this.stretchOverlay()); 1818 } 1819 for (var key in this.timeouts) { 1820 if (this.timeouts.hasOwnProperty(key)) this.clearTimeout(key); 1821 } 1822 if (this.fbBox.style.visibility) { 1823 if (!this.lastShown) this.fbZoomDiv.style.display = 'none'; 1824 } else if (this.currentItem.type === 'img' && this.zoomImageStart) { 1825 if (this.currentItem.popup) this.currentItem.anchor.onmouseover(); 1826 var anchorPos = this.getAnchorPos(this.currentItem.anchor, true); 1827 if (this.currentItem.popup) this.currentItem.anchor.onmouseout(); 1828 if (anchorPos.width) { 1829 this.fbZoomDiv.style.borderWidth = this.zoomPopBorder + 'px'; 1830 anchorPos.left -= this.zoomPopBorder; 1831 anchorPos.top -= this.zoomPopBorder; 1832 this.pos.thumb = anchorPos; 1833 return this.zoomOut(); 1834 } 1835 } 1836 if (!this.fbBox.style.visibility) { 1837 var anchorPos = this.getAnchorPos(this.currentItem.anchor, !this.currentItem.popup), 1838 offset = this.initialSize/2, 1839 initialPos = { id: 'fbBox', left: anchorPos.left - offset, top: anchorPos.top - offset, width: this.initialSize, height: this.initialSize }, 1840 zeroPos = { id: 'fbBox', left: anchorPos.left, top: anchorPos.top, width: 0, height: 0, borderWidth: 0 }, 1841 split = this.splitResize; 1842 if (split === 'wh') { 1843 split = 'hw'; 1844 } else if (split === 'hw') { 1845 split = 'wh'; 1846 } else if (split === 'auto') { 1847 split = this.pos.fbBox.width <= this.pos.fbBox.height ? 'hw' : 'wh'; 1848 } 1849 var oncomplete3 = function() { 1850 setTimeout(function() { 1851 that.fbBox.style.visibility = 'hidden'; 1852 that.end(); 1853 }, 10); 1854 }; 1855 if (split) { 1856 var oncomplete2 = function() { 1857 that.setSize(split, initialPos, function() { 1858 that.setSize(zeroPos, oncomplete3); 1859 }); 1860 }; 1861 } else { 1862 var oncomplete2 = function() { 1863 that.setSize(zeroPos, oncomplete3); 1864 }; 1865 } 1866 var oncomplete = function() { 1867 if (that.fbContent) { 1868 that.fbMainDiv.removeChild(that.fbContent); 1869 delete that.fbContent; 1870 } 1871 that.fbLoader.style.display = ''; 1872 that.fbCanvas.style.display = that.fbShadowTop.style.display = that.fbShadowRight.style.display = 1873 that.fbShadowBottom.style.display = that.fbShadowLeft.style.display = that.fbShadowCorner.style.display = 'none'; 1874 oncomplete2(); 1875 }; 1876 return this.collapse(oncomplete); 1877 } 1878 this.fbBox.style.display = 'none'; 1879 var level = this.children.length + 1, 1880 i = this.anchors.length; 1881 while(i && this.anchors[i-1].level >= level) i--; 1882 this.anchors.length = i; 1883 if (this.isChild) this.children.length--; 1884 fb.lastChild = this.children[this.children.length-1] || fb; 1885 var oncomplete2 = function() { 1886 setTimeout(function() { 1887 while (that.nodeNames.length) { 1888 var id = that.nodeNames.pop(); 1889 if (that[id] && that[id].parentNode) { 1890 that[id].parentNode.removeChild(that[id]); 1891 delete that[id]; 1892 } 1893 } 1894 if (that.endAll && that.isChild) { 1895 return fb.end(true); 1896 }
1896 else if (that.loadPageOnClose) { 1897 if (that.loadPageOnClose === 'self' || that.loadPageOnClose === 'this') { 1898 location.reload(true); 1899 } else if (that.loadPageOnClose === 'back') { 1900 history.back(); 1901 } else { 1902 location.replace(that.loadPageOnClose); 1903 } 1904 } 1905 }, 10); 1906 }; 1907 var oncomplete = function() { 1908 while(that.hiddenEls.length) { 1909 var el = that.hiddenEls.pop(); 1910 el.style.visibility = 'visible'; 1911 if (this.ffOld && this.ffMac) { 1912 el.focus(); 1913 el.blur(); 1914 } 1915 } 1916 var overlay = that.fbOverlay.style; 1917 overlay.display = 'none'; 1918 overlay.width = overlay.height = '0'; 1919 var duration = that.currentItem.popup ? 6.5 : 0; 1920 that.fbZoomDiv.style.opacity = '1'; 1921 that.fadeOpacity( that.fbZoomDiv, 0, duration, oncomplete2); 1922 that.currentItem = fb.previousAnchor = null; 1923 }; 1924 this.fadeOpacity(this.fbOverlay, 0, this.overlayFadeDuration, oncomplete); 1925}, 1926zoomIn: function(phase) { 1927 var that = this, 1928 zoomDiv = this.fbZoomDiv.style; 1929 if (!phase) { 1930 this.clearTimeout('slowLoad'); 1931 zoomDiv.display = this.fbZoomImg.style.display = ''; 1932 if (this.currentItem.popup) this.currentItem.anchor.onmouseout(); 1933 var pad = this.outerBorder + this.innerBorder - this.zoomPopBorder; 1934 var oncomplete = function () { 1935 that.fbZoomImg.src = that.currentItem.href; 1936 that.setSize( 1937 { id: 'fbZoomDiv', width: that.pos.fbMainDiv.width, height: that.pos.fbMainDiv.he
1937ight, 1938 left: that.pos.fbBox.left + pad + that.padding, top: that.pos.fbBox.top + pad + that.upperSpace }, 1939 function() { that.zoomIn(1); } ); 1940 }; 1941 return this.fadeOpacity(this.fbOverlay, this.overlayOpacity, this.overlayFadeDuration, oncomplete); 1942 } 1943 if (phase === 1) { 1944 var boxPos = { 1945 left: this.pos.fbBox.left, top: this.pos.fbBox.top, 1946 width: this.pos.fbBox.width, height: this.pos.fbBox.height 1947 }; 1948 var pad = 2*(this.zoomPopBorder - this.outerBorder); 1949 this.pos.fbBox = { 1950 left: this.pos.fbZoomDiv.left, top: this.pos.fbZoomDiv.top, 1951 width: this.pos.fbZoomDiv.width + pad, height: this.pos.fbZoomDiv.height + pad 1952 }; 1953 this.fbBox.style.visibility = ''; 1954 var oncomplete = function() { 1955 that.restore(function() { that.zoomIn(2); }); 1956 }; 1957 return this.setSize( 1958 { id: 'fbBox', left: boxPos.left, top: boxPos.top, 1959 width: boxPos.width, height: boxPos.height}, 1960 oncomplete); 1961 } 1962 var show = function() { 1963 zoomDiv.display = 'none'; 1964 that.fbZoomImg.src = ''; 1965 zoomDiv.left = zoomDiv.top = zoomDiv.width = zoomDiv.height = that.fbZoomImg.width = that.fbZoomImg.height = '0'; 1966 that.showContent(); 1967 }; 1968 this.timeouts.showContent = setTimeout(show, 10); 1969}, 1970zoomOut: function(phase) { 1971 var that = this; 1972 if (!phase) { 1973 this.fbZoomImg.src = this.currentItem.href; 1974 var pad = this.outerBorder + this.innerBorder - this.zoomPopBorder; 1975 this.setSize( 1976 { id: 'fbZoomDiv', width: this.pos.fbMainDiv.width, height: this.pos.fbMainDiv.he
1976ight, 1977 left: this.pos.fbBox.left + pad + this.padding, top: this.pos.fbBox.top + pad + this.upperSpace }, 1978 function() { that.zoomOut(1); } ); 1979 } 1980 if (phase === 1) { 1981 this.fbZoomDiv.style.display = this.fbZoomImg.style.display = ''; 1982 this.fbCanvas.style.visibility = 'hidden'; 1983 return this.collapse(function() { that.zoomOut(2); }); 1984 } 1985 if (phase === 2) { 1986 var pad = 2*(this.zoomPopBorder - this.outerBorder); 1987 return this.setSize( 1988 { id: 'fbBox', left: this.pos.fbZoomDiv.left, top: this.pos.fbZoomDiv.top, 1989 width: this.pos.fbZoomDiv.width + pad, height: this.pos.fbZoomDiv.height + pad }, 1990 function() { that.zoomOut(3); } 1991 ); 1992 } 1993 this.fbBox.style.visibility = 'hidden'; 1994 var end = function() { 1995 that.fbZoomImg.src = that.pos.thumb.src; 1996 that.end(); 1997 }; 1998 this.setSize( 1999 { id: 'fbZoomDiv', left: this.pos.thumb.left, top: this.pos.thumb.top, 2000 width: this.pos.thumb.width, height: this.pos.thumb.height }, 2001 end); 2002}, 2003setPause: function(pause) { 2004 this.isPaused = pause; 2005 if (pause) { 2006 this.clearTimeout('slideshow'); 2007 } else { 2008 this.newContent(this.nextIndex); 2009 } 2010 if (this.showPlayPause) { 2011 this.fbPlay.style.left = pause ? '' : '-9999px'; 2012 this.fbPause.style.left = pause ? '-9999px' : ''; 2013 } 2014}, 2015fadeOpacity: function(el, opacity, duration, callback) { 2016 var startOp = +(el.style.opacity || 0); 2017 duration = duration || 0; 2018 this.clearTimeout['fade' + el.id]; 2019 var fadeIn = (startOp <= opacity && opacity > 0); 2020 if (duration > 10) duration = 10; 2021 if (duration < 0) duration = 0; 2022 if (duration === 0) { 2023 startOp = opacity; 2024 var incr = 1; 2025 } else { 2026 var root = Math.pow(100, 0.1), 2027 power = duration + ((10 - duration)/9) * (Math.log(2)/Math.log(root) - 1), 2028 incr = 1/Math.pow(root, power); 2029 } 2030 if (fadeIn) { 2031 el.style.display = el.style.visibility = ''; 2032 } else { 2033 incr = -incr; 2034 } 2035 this.stepFade(el, startOp, opacity, incr, fadeIn, callback); 2036}, 2037stepFade: function(el, thisOp, finishOp, incr, fadeIn, callback) { 2038 if (!el) return; 2039 var that = this; 2040 if ((fadeIn && thisOp >= finishOp) || (!fadeIn && thisOp <= finishOp)) thisOp = finishOp; 2041 if (this.ie) el.style.filter = 'alpha(opacity=' + thisOp*100 + ')'; 2042 el.style.opacity = thisOp + ''; 2043 if (thisOp === finishOp) { 2044 if (this.ie && finishOp >= 1) el.style.removeAttribute('filter'); 2045 if (callback) callback(); 2046 } else { 2047 this.timeouts['fade' + el.id] = setTimeout(function() { that.stepFade(el, thisOp + incr, finishOp, incr, fadeIn, callback); }, 20); 2048 } 2049}, 2050resizeGroup: function(arr, callback) { 2051 var i = arr.length; 2052 if (!i) return callback ? callback() : null; 2053 this.clearTimeout('resize'); 2054 var diff = 0; 2055 while (i--) { 2056 diff = Math.max(diff, Math.abs(arr[i].finish - arr[i].start)); 2057 } 2058 var duration = this.resizeDuration * (this.liveResize ? 0.65 : 1); 2059 var rate = diff && duration ? Math.pow(Math.max(1, 2.2 - duration/10), (Math.log(diff))) / diff : 1; 2060 i = arr.length; 2061 while (i--) arr[i].diff = arr[i].finish - arr[i].start; 2062 this.stepResize(rate, rate, arr, callback); 2063}, 2064stepResize: function(increment, rate, arr, callback) { 2065 var that = this; 2066 if (increment > 1) increment = 1; 2067 var i = arr.length; 2068 while (i--) { 2069 var node = arr[i].node, 2070 prop = arr[i].property, 2071 val = Math.round(arr[i].start + arr[i].diff * increment), 2072 tag = node.tagName.toLowerCase(); 2073 if (tag === 'img' || tag === 'iframe') { 2074 node[prop] = val; 2075 } else { 2076 node.style[prop] = val + 'px'; 2077 } 2078 } 2079 if (increment >= 1) { 2080 delete this.timeouts.resize; 2081 if (callback) callback(); 2082 } else { 2083 this.timeouts.resize = setTimeout(function() { that.stepResize(increment + rate, rate, arr, callback); }, 20); 2084 } 2085}, 2086getDisplaySize: function() { 2087 return { width: this.getDisplayWidth(), height: this.getDisplayHeight() }; 2088}, 2089getDisplayWidth: function() { 2090 return this.html.clientWidth || this.bod.clientWidth; 2091}, 2092getDisplayHeight: function() { 2093 if (this.webkitOld) return window.innerHeight; 2094 if (!this.html.clientHeight || this.operaOld || document.compatMode === 'BackCompat') { 2095 return this.bod.clientHeight; 2096 } 2097 return this.html.clientHeight; 2098}, 2099getScroll: function(win) { 2100 win = win || self; 2101 var doc = win.document, 2102 bod = doc.body || doc.getElementsByTagName('body')[0]; 2103 return { 2104 left: win.pageXOffset || bod.scrollLeft || doc.documentElement.scrollLeft || 0, 2105 top: win.pageYOffset || bod.scrollTop || doc.documentElement.scrollTop || 0 2106 }; 2107}, 2108getLeftTop: function(el, local) { 2109 var left = el.offsetLeft || 0, 2110 top = el.offsetTop || 0, 2111 doc = el.ownerDocument || el.document, 2112 bod = doc.body || doc.getElementsByTagName('body')[0], 2113 win = doc.defaultView || doc.parentWindow || doc.contentWindow,
2114 scroll = this.getScroll(win), 2115 position = ((el.currentStyle && el.currentStyle.position) || (win.getComputedStyle && win.getComputedStyle(el, '').getPropertyValue('position')) || '').toLowerCase(), 2116 rex = /absolute|fixed/, 2117 elFlow = !rex.test(position), 2118 inFlow = elFlow, 2119 node = el; 2120 if (position === 'fixed') { 2121 left += scroll.left; 2122 top += scroll.top; 2123 } 2124 while (position !== 'fixed' && (node = node.offsetParent)) { 2125 var borderLeft = 0, borderTop = 0, nodeFlow = true; 2126 if (node.currentStyle) { 2127 position = (node.currentStyle.position || '').toLowerCase(); 2128 nodeFlow = !rex.test(position); 2129 if (this.opera) { 2130 if (local && node !== bod) { 2131 left += node.scrollLeft - node.clientLeft; 2132 top += node.scrollTop - node.clientTop; 2133 } 2134 } else { 2135 if (node.currentStyle.hasLayout && node !== doc.documentElement) { 2136 borderLeft = node.clientLeft; 2137 borderTop = node.clientTop; 2138 } 2139 } 2140 } else if (win.getComputedStyle) { 2141 position = (win.getComputedStyle(node, '').getPropertyValue('position') || '').toLowerCase(); 2142 nodeFlow = !rex.test(position); 2143 borderLeft = parseInt(win.getComputedStyle(node, '').getPropertyValue('border-left-width'), 10); 2144 borderTop = parseInt(win.getComputedStyle(node, '').getPropertyValue('border-top-width'), 10); 2145 if (this.ff && node === el.offsetParent && !nodeFlow && (this.ffOld || !elFlow)) { 2146 left += borderLeft; 2147 top += borderTop; 2148 } 2149 } 2150 if (!nodeFlow) { 2151 if (local) return { left: left, top: top }; 2152 inFlow = false; 2153 } 2154 left += node.offsetLeft + borderLeft; 2155 top += node.offsetTop + borderTop; 2156 if (position === 'fixed') { 2157 left += scroll.left; 2158 top += scroll.top; 2159 } 2160 if (!(this.opera && elFlow) && node !== bod && node !== doc.documentElement) { 2161 left -= node.scrollLeft; 2162 top -= node.scrollTop; 2163 } 2164 } 2165 if (this.ff && inFlow) { 2166 left += parseInt(win.getComputedStyle(bod, '').getPropertyValue('border-left-width'), 10); 2167 top += parseInt(win.getComputedStyle(bod, '').getPropertyValue('border-top-width'), 10); 2168 } 2169 if (this.webkitOld) { 2170 var scriptElement = doc.createElement('script'); 2171 scriptElement.innerHTML = 'document.parentWindow=self'; 2172 doc.documentElement.appendChild(scriptElement); 2173 doc.documentElement.removeChild(scriptElement); 2174 win = doc.parentWindow; 2175 } 2176 if (!local && win !== self) { 2177 var iframes = win.parent.document.getElementsByTagName('iframe'), 2178 i = iframes.length; 2179 while (i--) { 2180 var node = iframes[i], 2181 idoc = false; 2182 try { 2183 idoc = node.contentDocument || node.contentWindow; 2184 idoc = idoc.document || idoc; 2185 } catch(e) {} 2186 if (idoc === doc || (typeof idoc !== 'object' && node.src === win.location.href.substr(win.location.href.length - node.src.length))) { 2187 if (this.webkitOld) win = doc.defaultView; 2188 var pos = this.getLeftTop(node); 2189 left += pos.left - scroll.left; 2190 top += pos.top - scroll.top; 2191 if (node.currentStyle) { 2192 var padLeft = 0, padTop = 0; 2193 if (!this.ie || elFlow) { 2194 padLeft = parseInt(node.currentStyle.paddingLeft, 10); 2195 padTop = parseInt(node.currentStyle.paddingTop, 10); 2196 } 2197 left += node.clientLeft + padLeft; 2198 top += node.clientTop + padTop; 2199 } 2200 else if (win.getComputedStyle) { 2201 left += parseInt(win.getComputedStyle(node, '').getPropertyValue('border-left-width'), 10) + 2202 parseInt(win.getComputedStyle(node, '').getPropertyValue('padding-left'), 10); 2203 top += parseInt(win.getComputedStyle(node, '').getPropertyValue('border-top-width'), 10) + 2204 parseInt(win.getComputedStyle(node, '').getPropertyValue('padding-top'), 10); 2205 } 2206 break; 2207 } 2208 } 2209 } 2210 return { left: left, top: top }; 2211}, 2212getLayout: function(el) { 2213 var lay = this.getLeftTop(el); 2214 lay.width = el.offsetWidth; 2215 lay.height = el.offsetHeight; 2216 return lay; 2217}, 2218clearTimeout: function(key) { 2219 if (this.timeouts[key]) { 2220 clearTimeout(this.timeouts[key]); 2221 delete this.timeouts[key]; 2222 } 2223}, 2224stretchOverlay: function() { 2225 var that = this; 2226 return function() { 2227 if (arguments.length === 1) { 2228 that.clearTimeout('stretch'); 2229 that.timeouts.stretch = setTimeout(function() { that.stretchOverlay()(); }, 25); 2230 } else { 2231 delete that.timeouts.stretch; 2232 if (!that.fbBox) return; 2233 var width = that.fbBox.offsetLeft + that.fbBox.offsetWidth, 2234 height = that.fbBox.offsetTop + that.fbBox.offsetHeight, 2235 display = that.getDisplaySize(), 2236 scroll = that.getScroll(),
2237 overlay = that.fbOverlay.style; 2238 overlay.width = overlay.height = '0'; 2239 overlay.width = Math.max(width, that.bod.scrollWidth, that.bod.clientWidth, that.html.clientWidth, display.width + scroll.left) + 'px'; 2240 overlay.height = Math.max(height, that.bod.scrollHeight, that.bod.clientHeight, that.html.clientHeight, display.height + scroll.top) + 'px'; 2241 } 2242 }; 2243}, 2244encodeHTML: function(str) { 2245 return str.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, '''); 2246}, 2247decodeHTML: function(str) { 2248 return str.replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, "'").replace(/'/g, "'"); 2249}, 2250getXMLHttpRequest: function() { 2251 var xhr, that = this; 2252 if (window.XMLHttpRequest) { 2253 if (!(xhr = new XMLHttpRequest())) return false; 2254 } else { 2255 try { xhr = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) { 2256 try { xhr = new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) { return false; } 2257 } 2258 } 2259 return { 2260 getResponse: function(url, callback) { 2261 try { 2262 xhr.open('GET', url, true); 2263 xhr.setRequestHeader('If-Modified-Since', 'Thu, 1 Jan 1970 00:00:00 GMT'); 2264 xhr.setRequestHeader('Cache-Control', 'no-cache'); 2265 xhr.onreadystatechange = function() { 2266 if (xhr.readyState === 4) { 2267 xhr.onreadystatechange = function() {}; 2268 callback(xhr); 2269 } 2270 }; 2271 xhr.send(null); 2272 } catch(e) {} 2273 } 2274 }; 2275}, 2276setInnerHTML: function(el, strHTML) { 2277 try { 2278 var range = document.createRange(); 2279 range.selectNodeContents(el); 2280 range.deleteContents(); 2281 if (strHTML) { 2282 var xmlDiv = new DOMParser().parseFromString('<div xmlns="http://www.w3.org/1999/xhtml">' + strHTML + '</div>', 'application/xhtml+xml'), 2283 childNodes = xmlDiv.documentElement.childNodes; 2284 for (var i = 0, len = childNodes.length; i < len; i++) { 2285 el.appendChild(document.importNode(childNodes[i], true)); 2286 } 2287 } 2288 return true; 2289 } catch (e) {} 2290 try { 2291 el.innerHTML = strHTML; 2292 return true; 2293 } catch(e) {} 2294 return false; 2295}, 2296printContents: function(el, style) { 2297 if (el && el.offsetWidth) { 2298 var width = el.offsetWidth, 2299 height = el.offsetHeight; 2300 } else { 2301 el = fb.lastChild.fbContent; 2302 var pos = fb.lastChild.pos.fbMainDiv, 2303 width = pos.width, 2304 height = pos.height; 2305 } 2306 var win = window.open('', '', 'width=' + width + ', height=' + height), 2307 doc = win && win.document; 2308 if (!doc) { 2309 alert('Popup windows are being blocked by your browser.\nUnable to print.'); 2310 return false; 2311 } 2312 if (/\.css$/i.test(style)) { 2313 style = '<link rel="stylesheet" type="text/css" href="' + style + '" />'; 2314 } else { 2315 style = '<style type="text/css"> html,body{border:0;margin:0;padding:0;}' + (style || '') + '</style>'; 2316 } 2317 var div = document.createElement('div'); 2318 div.appendChild(el.cloneNode(true)); 2319 doc.open('text/html'); 2320 doc.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"' + 2321 ' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html><head>' + 2322 style + '</head><body><div>' + div.innerHTML + '</div></body></html>'); 2323 doc.close(); 2324 setTimeout(function() { win && win.print(); win && win.close(); }, 200); 2325 return true; 2326}, 2327loadAnchor: function(href, rev, title) { 2328 if (href.setAttribute) { 2329 var anchor = href; 2330 if (!anchor.getAttribute('rel')) anchor.setAttribute('rel', 'floatbox'); 2331 fb.lastChild.start(this.tagOneAnchor(anchor)); 2332 } else { 2333 fb.lastChild.start(this.tagOneAnchor({ href: href, rev: rev, title: title, rel: 'floatbox' })); 2334 } 2335}, 2336goBack: function() { 2337 var a = fb.previousAnchor; 2338 if (a) this.loadAnchor(a.href, a.rev + ' sameBox:true', a.title); 2339}, 2340resize: function(width, height) { 2341 var changed = false; 2342 if (width && fb.lastChild.currentItem && fb.lastChild.currentItem.nativeWidth != width) { 2343 fb.lastChild.currentItem.nativeWidth = width; 2344 changed = true; 2345 } 2346 if (height && fb.lastChild.currentItem && fb.lastChild.currentItem.nativeHeight != height) { 2347 fb.lastChild.currentItem.nativeHeight = height; 2348 changed = true; 2349 }
2350 if (changed) fb.lastChild.calcSize(false); 2351} 2352}; 2353function initfb() { 2354 if (arguments.callee.done) return; 2355 var fbWindow = 'self'; 2356 if (self !== parent) { 2357 try { 2358 if (self.location.host === parent.location.host && self.location.protocol === parent.location.protocol) fbWindow = 'parent'; 2359 } catch(e) {} 2360 if (fbWindow === 'parent' && !parent.fb) return setTimeout(initfb, 50); 2361 } 2362 arguments.callee.done = true; 2363 if (document.compatMode === 'BackCompat') { 2364 alert('Floatbox does not support quirks mode.\nPage needs to have a valid a doc type.'); 2365 return; 2366 } 2367 fb = (fbWindow === 'self' ? new Floatbox() : parent.fb); 2368 fb.tagAnchors(self.document.body || self.document.getElementsByTagName('body')[0]); 2369 if (fb.autoStart) { 2370 fb.start(fb.autoStart); 2371 if (typeof fb !== 'undefined') delete fb.autoStart; 2372 } else { 2373 fb.preloadImages('', true); 2374 } 2375} 2376if (document.addEventListener) { 2377 document.addEventListener('DOMContentLoaded', initfb, false); 2378} 2379(function() { 2380 /*@cc_on 2381 if (document.body !== null) { 2382 try { 2383 document.createElement('div').doScroll('left'); 2384 return initfb(); 2385 } catch(e) {} 2386 } 2387 /*@if (false) @*/ 2388 if (/loaded|complete/.test(document.readyState)) return initfb(); 2389 /*@end @*/ 2390 if (!initfb.done) setTimeout(arguments.callee, 50); 2391})(); 2392fb_prevOnload = window.onload; 2393window.onload = function() { 2394 if (typeof fb_prevOnload === 'function') fb_prevOnload(); 2395 initfb(); 2396};
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.