Asp.net源码专业站
首页->电子商务->云南工艺品网前台源码>>ArtsAndCrafts/Jscript/highslide/highslide-with-html.js>>源码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:云南工艺品网前台源码
当前文件:文件类型 ArtsAndCrafts/ArtsAndCrafts/Jscript/highslide/highslide-with-html.js[58K,2009-6-12 11:31:42]打开代码结构图
普通视图
		            
1/****************************************************************************** 2Name: Highslide JS 3Version: 3.3.3 (December 8 2007) 4Config: default +inline +ajax +iframe +flash 5Author: Torstein H鴑si 6Support: http://vikjavev.no/highslide/forum 7 8Licence: 9Highslide JS is licensed under a Creative Commons Attribution-NonCommercial 2.5 10License (http://creativecommons.org/licenses/by-nc/2.5/). 11 12You are free: 13 * to copy, distribute, display, and perform the work 14 * to make derivative works 15 16Under the following conditions: 17 * Attribution. You must attribute the work in the manner specified by the 18 author or licensor. 19 * Noncommercial. You may not use this work for commercial purposes. 20 21* For any reuse or distribution, you must make clear to others the license 22 terms of this work. 23* Any of these conditions can be waived if you get permission from the 24 copyright holder. 25 26Your fair use and other rights are in no way affected by the above. 27******************************************************************************/ 28 29var hs = { 30 31// Apply your own settings here, or override them in the html file. 32graphicsDir : 'highslide/graphics/', 33restoreCursor : 'zoomout.cur', // necessary for preload 34expandSteps : 10, // number of steps in zoom. Each step lasts for duration/step milliseconds. 35expandDuration : 250, // milliseconds 36restoreSteps : 10, 37restoreDuration : 250, 38marginLeft : 15, 39marginRight : 15, 40marginTop : 15, 41marginBottom : 15, 42zIndexCounter : 1001, // adjust to other absolutely positioned elements 43 44restoreTitle : '', 45loadingText : 'Loading...', 46loadingTitle : '', 47loadingOpacity : 0.75, 48focusTitle : '', 49allowMultipleInstances: true, 50numberOfImagesToPreload : 5, 51captionSlideSpeed : 1, // set to 0 to disable slide in effect 52padToMinWidth : false, // pad the popup width to make room for wide caption 53outlineWhileAnimating : 2, // 0 = never, 1 = always, 2 = HTML only 54outlineStartOffset : 3, // ends at 10 55fullExpandTitle : 'Expand to actual size', 56fullExpandPosition : 'bottom right', 57fullExpandOpacity : 1, 58showCredits : true, // you can set this to false if you want 59creditsText : '', 60creditsHref : '', 61creditsTitle : '', 62enableKeyListener : true, 63 64 65// HTML extension 66 67previousText : 'Previous', 68nextText : 'Next', 69moveText : '移动', 70closeText : '关闭', 71closeTitle : 'Click to close', 72resizeTitle : 'Resize', 73allowWidthReduction : false, 74allowHeightReduction : true, 75preserveContent : true, // Preserve changes made to the content and position of HTML popups. 76objectLoadTime : 'before', // Load iframes 'before' or 'after' expansion. 77cacheAjax : true, // Cache ajax popups for instant display. Can be overridden for each popup. 78 79// These settings can also be overridden inline for each image 80captionId : null, 81spaceForCaption : 30, // leaves space below images with captions 82slideshowGroup : null, // defines groups for next/previous links and keystrokes 83minWidth: 200, 84minHeight: 200, 85allowSizeReduction: true, // allow the image to reduce to fit client size. If false, this overrides minWidth and minHeight 86outlineType : 'drop-shadow', // set null to disable outlines 87wrapperClassName : 'highslide-wrapper', // for enhanced css-control 88 89// END OF YOUR SETTINGS 90 91 92// declare internal properties 93preloadTheseImages : [], 94continuePreloading: true, 95expanders : [], 96overrides : [ 97 'allowSizeReduction', 98 'outlineType', 99 'outlineWhileAnimating', 100 'spaceForCaption', 101 'captionId', 102 'captionText', 103 'captionEval', 104 105 'contentId', 106 'allowWidthReduction', 107 'allowHeightReduction', 108 'preserveContent', 109 'objectType', 110 'cacheAjax', 111 'objectWidth', 112 'objectHeight', 113 'objectLoadTime', 114 'swfObject', 115 'wrapperClassName', 116 'minWidth', 117 'minHeight', 118 'slideshowGroup' 119], 120overlays : [], 121faders : [], 122 123pendingOutlines : {}, 124sleeping : [], 125preloadTheseAjax : [], 126cacheBindings : [], 127cachedGets : {}, 128clones : {}, 129ie : (document.all && !window.opera), 130safari : navigator.userAgent.indexOf("Safari") != -1, 131 132$ : function (id) { 133 return document.getElementById(id); 134}, 135 136push : function (arr, val) { 137 arr[arr.length] = val; 138}, 139 140createElement : function (tag, attribs, styles, parent, nopad) { 141 var el = document.createElement(tag); 142 if (attribs) hs.setAttribs(el, attribs); 143 if (nopad) hs.setStyles(el, {padding: 0, border: 'none', margin: 0}); 144 if (styles) hs.setStyles(el, styles); 145 if (parent) parent.appendChild(el); 146 return el; 147}, 148 149setAttribs : function (el, attribs) { 150 for (var x in attribs) { 151 el[x] = attribs[x]; 152 } 153}, 154 155setStyles : function (el, styles) { 156 for (var x in styles) { 157 try { 158 if (hs.ie && x == 'opacity') el.style.filter = 'alpha(opacity='+ (styles[x] * 100) +')'; 159 else el.style[x] = styles[x]; 160 } 161 catch (e) {} 162 } 163}, 164 165ieVersion : function () { 166 arr = navigator.appVersion.split("MSIE"); 167 return parseFloat(arr[1]); 168}, 169 170getPageSize : function () { 171 var iebody = document.compatMode && document.compatMode != "BackCompat" 172 ? document.documentElement : document.body; 173 174 var width = hs.ie ? iebody.clientWidth : 175 (document.documentElement.clientWidth || self.innerWidth), 176 height = hs.ie ? iebody.clientHeight : self.innerHeight; 177 178 return { 179 width: width, 180 height: height, 181 scrollLeft: hs.ie ? iebody.scrollLeft : pageXOffset, 182 scrollTop: hs.ie ? iebody.scrollTop : pageYOffset 183 } 184}, 185 186position : function(el) { 187 var p = { x: el.offsetLeft, y: el.offsetTop }; 188 while (el.offsetParent) { 189 el = el.offsetParent; 190 p.x += el.offsetLeft; 191 p.y += el.offsetTop; 192 if (el != document.body && el != document.documentElement) { 193 p.x -= el.scrollLeft; 194 p.y -= el.scrollTop; 195 } 196 } 197 return p; 198}, 199 200expand : function(a, params, custom) { 201 if (a.getParams) return params; 202 203 try { 204 new hs.Expander(a, params, custom); 205 return false; 206 } catch (e) { return true; } 207}, 208 209htmlExpand : function(a, params, custom) { 210 if (a.getParams) return params; 211 212 for (var i = 0; i < hs.sleeping.length; i++) { 213 if (hs.sleeping[i] && hs.sleeping[i].a == a) { 214 hs.sleeping[i].awake(); 215 hs.sleeping[i] = null; 216 return false; 217 } 218 } 219 try { 220 hs.hasHtmlexpanders = true; 221 new hs.Expander(a, params, custom, 'html'); 222 return false; 223 } catch (e) { 224 return true; 225 } 226}, 227 228getElementByClass : function (el, tagName, className) { 229 var els = el.getElementsByTagName(tagName); 230 for (i = 0; i < els.length; i++) { 231 if (els[i].className == className) { 232 return els[i]; 233 } 234 } 235}, 236 237getSelfRendered : function() { 238 var s = 239 '<div class="highslide-header"><ul>' 240 + '<li class="highslide-previous"><a onclick="return hs.previous(this)" href="#">'+ hs.previousText +'</a></li>' 241 + '<li class="highslide-next"><a onclick="return hs.next(this)" href="#">'+ hs.nextText +'</a></li>' 242 + '<li class="highslide-move"><a href="#" onclick="return false">'+ hs.moveText +'</a></li>' 243 + '<li class="highslide-close"><a onclick="return hs.close(this)" title="'+ hs.closeTitle +'" href="#">' 244 + hs.closeText +'</a></li>' 245 +'</ul></div>' 246 +'<div class="highslide-body"></div>' 247 +'<div class="highslide-footer"><div>' 248 + '<span class="highslide-resize" title="'+ hs.resizeTitle +'"><span></span></span>' 249 +'</div></div>'; 250 return hs.createElement('div', { className: 'highslide-html-content', innerHTML: s } ); 251}, 252 253 254getCacheBinding : function (a) { 255 for (i = 0; i < hs.cacheBindings.length; i++) { 256 if (hs.cacheBindings[i][0] == a) { 257 var c = hs.cacheBindings[i][1]; 258 hs.cacheBindings[i][1] = c.cloneNode(1); 259 return c; 260 } 261 } 262}, 263 264preloadAjax : function (e) { 265 var aTags = document.getElementsByTagName('A'); 266 var a, re; 267 for (i = 0; i < aTags.length; i++) { 268 a = aTags[i]; 269 re = hs.isHsAnchor(a); 270 if (re && re[0] == 'hs.htmlExpand' && hs.getParam(a, 'objectType') == 'ajax' 271 && hs.getParam(a, 'cacheAjax')) { 272 hs.push(hs.preloadTheseAjax, a); 273 } 274 } 275 hs.preloadAjaxElement(0); 276}, 277 278preloadAjaxElement : function (i) { 279 if (!hs.preloadTheseAjax[i]) return; 280 var a = hs.preloadTheseAjax[i]; 281 var cache = hs.getNode(hs.getParam(a, 'contentId')); 282 if (!cache) cache = hs.getSelfRendered(); 283 var ajax = new hs.Ajax(a, cache, 1); 284 ajax.onError = function () { }; 285 ajax.onLoad = function () { 286 hs.push(hs.cacheBindings, [a, cache]); 287 hs.preloadAjaxElement(i + 1); 288 }; 289 ajax.run(); 290}, 291 292focusTopmost : function() { 293 var topZ = 0, topmostKey = -1; 294 for (i = 0; i < hs.expanders.length; i++) { 295 if (hs.expanders[i]) { 296 if (hs.expanders[i].wrapper.style.zIndex && hs.expanders[i].wrapper.style.zIndex > topZ) { 297 topZ = hs.expanders[i].wrapper.style.zIndex; 298 299 topmostKey = i; 300 } 301 } 302 } 303 if (topmostKey == -1) hs.focusKey = -1; 304 else hs.expanders[topmostKey].focus(); 305}, 306 307getAdjacentAnchor : function(key, op) { 308 var aAr = document.getElementsByTagName('A'), hsAr = {}, activeI = -1, j = 0; 309 for (i = 0; i < aAr.length; i++) { 310 if (hs.isHsAnchor(aAr[i]) && ((hs.expanders[key].slideshowGroup == hs.getParam(aAr[i], 'slideshowGroup')))) { 311 hsAr[j] = aAr[i]; 312 if (hs.expanders[key] && aAr[i] == hs.expanders[key].a) { 313 activeI = j; 314 } 315 j++; 316 } 317 } 318 return hsAr[activeI + op]; 319}, 320 321getParam : function (a, param) { 322 a.getParams = a.onclick; 323 var p = a.getParams(); 324 a.getParams = null; 325 326 return (p && typeof p[param] != 'undefined') ? p[param] : hs[param]; 327}, 328 329getSrc : function (a) { 330 var src = hs.getParam(a, 'src'); 331 if (src) return src; 332 return a.href; 333}, 334 335getNode : function (id) { 336 var node = hs.$(id), clone = hs.clones[id], a = {}; 337 if (!node && !clone) return null; 338 if (!clone) { 339 clone = node.cloneNode(true); 340 clone.id = ''; 341 hs.clones[id] = clone; 342 return node; 343 } else { 344 return clone.cloneNode(true); 345 } 346}, 347 348purge : function(d) { 349 if (!hs.ie) return; 350 var a = d.attributes, i, l, n; 351 if (a) { 352 l = a.length; 353 for (i = 0; i < l; i += 1) { 354 n = a[i].name; 355 if (typeof d[n] === 'function') { 356 d[n] = null; 357 } 358 } 359 } 360 a = d.childNodes; 361 if (a) { 362 l = a.length; 363 for (i = 0; i < l; i += 1) { 364 hs.purge(d.childNodes[i]); 365 } 366 } 367}, 368 369previousOrNext : function (el, op) { 370 var exp = hs.getExpander(el); 371 try { 372 var adj = hs.upcoming = hs.getAdjacentAnchor(exp.key, op); 373 adj.onclick(); 374 } catch (e){} 375 try { exp.close(); } catch (e) {} 376 return false; 377}, 378 379previous : function (el) { 380 return hs.previousOrNext(el, -1); 381}, 382 383next : function (el) { 384 return hs.previousOrNext(el, 1); 385}, 386 387keyHandler : function(e) { 388 if (!e) e = window.event; 389 if (!e.target) e.target = e.srcElement; // ie 390 if (e.target.form) return; // form element has focus 391 392 var op = null; 393 switch (e.keyCode) { 394 case 34: // Page Down 395 case 39: // Arrow right 396 case 40: // Arrow down 397 op = 1; 398 break; 399 case 33: // Page Up 400 case 37: // Arrow left 401 case 38: // Arrow up 402 op = -1; 403 break; 404 case 27: // Escape 405 case 13: // Enter 406 op = 0; 407 } 408 if (op !== null) { 409 hs.removeEventListener(document, 'keydown', hs.keyHandler); 410 try { if (!hs.enableKeyListener) return true; } catch (e) {} 411 412 if (e.preventDefault) e.preventDefault(); 413 else e.returnValue = false; 414 if (op == 0) { 415 try { hs.getExpander().close(); } catch (e) {} 416 return false; 417 } else { 418 return hs.previousOrNext(hs.focusKey, op); 419 } 420 } else return true; 421}, 422 423 424registerOverlay : function (overlay) { 425 hs.push(hs.overlays, overlay); 426}, 427 428getWrapperKey : function (element) { 429 var el, re = /^highslide-wrapper-([0-9]+)$/; 430 // 1. look in open expanders 431 el = element; 432 while (el.parentNode) { 433 if (el.id && el.id.match(re)) return el.id.replace(re, "$1"); 434 el = el.parentNode; 435 } 436 // 2. look in thumbnail 437 el = element; 438 while (el.parentNode) { 439 if (el.tagName && hs.isHsAnchor(el)) { 440 for (key = 0; key < hs.expanders.length; key++) { 441 exp = hs.expanders[key]; 442 if (exp && exp.a == el) return key; 443 } 444 } 445 el = el.parentNode; 446 } 447}, 448 449getExpander : function (el) { 450 try { 451 if (!el) return hs.expanders[hs.focusKey]; 452 if (typeof el == 'number') return hs.expanders[el]; 453 if (typeof el == 'string') el = hs.$(el); 454 return hs.expanders[hs.getWrapperKey(el)]; 455 } catch (e) {} 456}, 457 458isHsAnchor : function (a) { 459 return (a.onclick && a.onclick.toString().replace(/\s/g, ' ').match(/hs.(htmlE|e)xpand/)); 460}, 461 462cleanUp : function () { 463 for (i = 0; i < hs.expanders.length; i++) 464 if (hs.expanders[i] && hs.expanders[i].isExpanded) hs.focusTopmost(); 465}, 466 467mouseClickHandler : function(e) 468{ 469 if (!e) e = window.event; 470 if (e.button > 1) return true; 471 if (!e.target) e.target = e.srcElement; 472 473 var el = e.target; 474 while (el.parentNode 475 && !(/highslide-(image|move|html|resize)/.test(el.className))) 476 { 477 el = el.parentNode; 478 } 479 var exp = hs.getExpander(el); 480 481 if (exp && e.type == 'mousedown') { 482 if (e.target.form) return; 483 var match = el.className.match(/highslide-(image|move|resize)/); 484 if (match) { 485 hs.dragArgs = { exp: exp , type: match[1], left: exp.x.min, width: exp.x.span, top: exp.y.min, 486 height: exp.y.span, clickX: e.clientX, clickY: e.clientY }; 487 488 if (hs.dragArgs.type == 'image') exp.content.style.cursor = 'move'; 489 490 hs.addEventListener(document, 'mousemove', hs.dragHandler); 491 if (e.preventDefault) e.preventDefault(); // FF 492 493 if (/highslide-(image|html)-blur/.test(exp.content.className)) { 494 exp.focus(); 495 hs.hasFocused = true; 496 } 497 return false; 498 } 499 else if (/highslide-html/.test(el.className) && hs.focusKey != exp.key) { 500 exp.focus(); 501 exp.redoShowHide(); 502 } 503 } else if (e.type == 'mouseup') { 504 505 hs.removeEventListener(document, 'mousemove', hs.dragHandler); 506 507 if (hs.dragArgs) { 508 509 if (hs.dragArgs.type == 'image') 510 hs.dragArgs.exp.content.style.cursor = hs.styleRestoreCursor; 511 512 var hasDragged = (Math.abs(hs.dragArgs.dX) + Math.abs(hs.dragArgs.dY) > 0); 513 514 if (!hasDragged &&!hs.hasFocused && !/(move|resize)/.test(hs.dragArgs.type)) { 515 exp.close(); 516 } 517 else if (hasDragged || (!hasDragged && hs.hasHtmlexpanders)) { 518 hs.dragArgs.exp.redoShowHide(); 519 } 520 521 hs.hasFocused = false; 522 hs.dragArgs = null; 523 524 } else if (/highslide-image-blur/.test(el.className)) { 525 el.style.cursor = hs.styleRestoreCursor; 526 } 527 } 528}, 529 530dragHandler : function(e) 531{ 532 if (!hs.dragArgs) return; 533 if (!e) e = window.event; 534 var exp = hs.dragArgs.exp; 535 if (exp.iframe && exp.setIframeRelease) exp.setIframeRelease(); 536 537 hs.dragArgs.dX = e.clientX - hs.dragArgs.clickX; 538 hs.dragArgs.dY = e.clientY - hs.dragArgs.clickY; 539 540 541 if (hs.dragArgs.type == 'resize') exp.resize(hs.dragArgs); 542 else exp.move(hs.dragArgs); 543 return false; 544}, 545 546addEventListener : function (el, event, func) { 547 try { 548 el.addEventListener(event, func, false); 549 } catch (e) { 550 try { 551 el.detachEvent('on'+ event, func); 552 el.attachEvent('on'+ event, func); 553 } catch (e) { 554 el['on'+ event] = func; 555 } 556 } 557}, 558 559removeEventListener : function (el, event, func) { 560 try { 561 el.removeEventListener(event, func, false); 562 } catch (e) { 563 try { 564 el.detachEvent('on'+ event, func); 565 } catch (e) { 566 el['on'+ event] = null; 567 } 568 } 569}, 570 571preloadFullImage : function (i) { 572 if (hs.continuePreloading && hs.preloadTheseImages[i] && hs.preloadTheseImages[i] != 'undefined') { 573 var img = document.createElement('img'); 574 img.onload = function() { hs.preloadFullImage(i + 1); }; 575 img.src = hs.preloadTheseImages[i]; 576 } 577}, 578preloadImages : function (number) { 579 if (number && typeof number != 'object') hs.numberOfImagesToPreload = number; 580 var a, re, j = 0; 581 582 var aTags = document.getElementsByTagName('A'); 583 for (i = 0; i < aTags.length; i++) { 584 a = aTags[i]; 585 re = hs.isHsAnchor(a); 586 if (re && re[0] == 'hs.expand') { 587 if (j < hs.numberOfImagesToPreload) { 588 hs.preloadTheseImages[j] = hs.getSrc(a); 589 j++; 590 } 591 } 592 } 593 594 // preload outlines 595 new hs.Outline(hs.outlineType, function () { hs.preloadFullImage(0)} ); 596 597 598 // preload cursor 599 var cur = hs.createElement('img', { src: hs.graphicsDir + hs.restoreCursor }); 600}, 601 602 603genContainer : function () { 604 if (!hs.container) { 605 hs.container = hs.createElement('div', 606 null, 607 { position: 'absolute', left: 0, top: 0, width: '100%', zIndex: hs.zIndexCounter }, 608 document.body, 609 true 610 ); 611 hs.loading = hs.createElement('a', 612 { 613 className: 'highslide-loading', 614 title: hs.loadingTitle, 615 innerHTML: hs.loadingText 616 }, 617 { 618 position: 'absolute', 619 opacity: hs.loadingOpacity, 620 left: '-9999px', 621 zIndex: 1 622 }, hs.container 623 ); 624 hs.clearing = hs.createElement('div', null, 625 { clear: 'both', paddingTop: '1px' }, null, true); 626 } 627}, 628 629fade : function (el, o, oFinal, i, dir) { 630 if (dir == null) var dir = oFinal > o ? 1 : -1; 631 o = parseFloat(o); 632 el.style.visibility = (o <= 0) ? 'hidden' : 'visible'; 633 if (o < 0 || (dir == 1 && o > oFinal)) return; 634 if (i == null) i = hs.faders.length; 635 if (typeof(el.i) != 'undefined' && el.i != i) { 636 clearTimeout(hs.faders[el.i]); 637 o = el.tempOpacity; 638 } 639 el.i = i; 640 el.tempOpacity = o; 641 el.style.visibility = (o <= 0) ? 'hidden' : 'visible'; 642 hs.setStyles(el, { opacity: o }); 643 hs.faders[i] = setTimeout(function() { 644 hs.fade(el, Math.round((o + 0.1 * dir)*100)/100, oFinal, i, dir); 645 }, 25); 646}, 647 648close : function(el) { 649 try { hs.getExpander(el).close(); } catch (e) {} 650 return false; 651} 652}; // end hs object 653 654 655//----------------------------------------------------------------------------- 656hs.Outline = function (outlineType, onLoad) { 657 this.onLoad = onLoad; 658 this.outlineType = outlineType; 659 var v = hs.ieVersion(), tr; 660 661 this.hasAlphaImageLoader = hs.ie && v >= 5.5 && v < 7; 662 if (!outlineType) { 663 if (onLoad) onLoad(); 664 return; 665 } 666 667 hs.genContainer(); 668 this.table = hs.createElement( 669 'table', { cellSpacing: 0 }, 670 { 671 visibility: 'hidden', 672 position: 'absolute', 673 borderCollapse: 'collapse' 674 }, 675 hs.container, 676 true 677 ); 678 this.tbody = hs.createElement('tbody', null, null, this.table, 1); 679 680 this.td = []; 681 for (var i = 0; i <= 8; i++) { 682 if (i % 3 == 0) tr = hs.createElement('tr', null, { height: 'auto' }, this.tbody, true); 683 this.td[i] = hs.createElement('td', null, null, tr, true); 684 var style = i != 4 ? { lineHeight: 0, fontSize: 0} : { position : 'relative' }; 685 hs.setStyles(this.td[i], style); 686 } 687 this.td[4].className = outlineType; 688 689 this.preloadGraphic(); 690}; 691 692hs.Outline.prototype = { 693preloadGraphic : function () { 694 var src = hs.graphicsDir + "outlines/"+ this.outlineType +".png"; 695 696 var appendTo = hs.safari ? hs.container : null; 697 this.graphic = hs.createElement('img', null, { position: 'absolute', left: '-9999px', 698 top: '-9999px' }, appendTo, true); // for onload trigger 699 700 var pThis = this; 701 this.graphic.onload = function() { pThis.onGraphicLoad(); }; 702 703 this.graphic.src = src; 704}, 705 706onGraphicLoad : function () { 707 var o = this.offset = this.graphic.width / 4, 708 pos = [[0,0],[0,-4],[-2,0],[0,-8],0,[-2,-8],[0,-2],[0,-6],[-2,-2]], 709 dim = { height: (2*o) +'px', width: (2*o) +'px' }; 710 711 for (var i = 0; i <= 8; i++) { 712 if (pos[i]) { 713 if (this.hasAlphaImageLoader) { 714 var w = (i == 1 || i == 7) ? '100%' : this.graphic.width +'px'; 715 var div = hs.createElement('div', null, { width: '100%', height: '100%', position: 'relative', overflow: 'hidden'}, this.td[i], true); 716 hs.createElement ('div', null, { 717 filter: "progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale, src='"+ this.graphic.src + "')", 718 position: 'absolute', 719 width: w, 720 height: this.graphic.height +'px', 721 left: (pos[i][0]*o)+'px', 722 top: (pos[i][1]*o)+'px' 723 }, 724 div, 725 true); 726 } else { 727 hs.setStyles(this.td[i], { background: 'url('+ this.graphic.src +') '+ (pos[i][0]*o)+'px '+(pos[i][1]*o)+'px'}); 728 } 729 730 if (window.opera && (i == 3 || i ==5)) 731 hs.createElement('div', null, dim, this.td[i], true); 732 733 hs.setStyles (this.td[i], dim); 734 } 735 } 736 737 hs.pendingOutlines[this.outlineType] = this; 738 if (this.onLoad) this.onLoad(); 739}, 740 741setPosition : function (exp, x, y, w, h, vis) { 742 if (vis) this.table.style.visibility = (h >= 4 * this.offset) 743 ? 'visible' : 'hidden'; 744 this.table.style.left = (x - this.offset) +'px'; 745 this.table.style.top = (y - this.offset) +'px'; 746 this.table.style.width = (w + 2 * (exp.offsetBorderW + this.offset)) +'px'; 747 w += 2 * (exp.offsetBorderW - this.offset); 748 h += + 2 * (exp.offsetBorderH - this.offset); 749 this.td[4].style.width = w >= 0 ? w +'px' : 0; 750 this.td[4].style.height = h >= 0 ? h +'px' : 0; 751 if (this.hasAlphaImageLoader) this.td[3].style.height 752 = this.td[5].style.height = this.td[4].style.height; 753}, 754 755destroy : function(hide) { 756 if (hide) this.table.style.visibility = 'hidden'; 757 else { 758 hs.purge(this.table); 759 try { this.table.parentNode.removeChild(this.table); } catch (e) {} 760 } 761} 762}; 763 764//----------------------------------------------------------------------------- 765// The expander object 766hs.Expander = function(a, params, custom, contentType) { 767 this.a = a; 768 this.custom = custom; 769 this.contentType = contentType || 'image'; 770 this.isHtml = (contentType == 'html'); 771 this.isImage = !this.isHtml; 772 773 hs.continuePreloading = false; 774 hs.genContainer(); 775 var key = this.key = hs.expanders.length; 776 777 // override inline parameters 778 for (i = 0; i < hs.overrides.length; i++) { 779 var name = hs.overrides[i]; 780 this[name] = params && typeof params[name] != 'undefined' ? 781 params[name] : hs[name]; 782 } 783 784 // get thumb 785 var el = this.thumb = (params ? hs.$(params.thumbnailId) : null) 786 || a.getElementsByTagName('IMG')[0] || a; 787 this.thumbsUserSetId = el.id || a.id; 788 789 // check if already open 790 for (i = 0; i < hs.expanders.length; i++) { 791 if (hs.expanders[i] && hs.expanders[i].a == a) { 792 hs.expanders[i].focus(); 793 return false; 794 } 795 } 796 // cancel other 797 for (i = 0; i < hs.expanders.length; i++) { 798 if (hs.expanders[i] && hs.expanders[i].thumb != el && !hs.expanders[i].onLoadStarted) { 799 hs.expanders[i].cancelLoading(); 800 } 801 } 802 hs.expanders[this.key] = this; 803 804 if (!hs.allowMultipleInstances) { 805 try { hs.expanders[key - 1].close(); } catch (e){} 806 try { hs.expanders[hs.focusKey].close(); } catch (e){} // preserved 807 } 808 this.overlays = []; 809 810 var pos = hs.position(el); 811 812 // store properties of thumbnail 813 this.thumbWidth = el.width ? el.width : el.offsetWidth; 814 this.thumbHeight = el.height ? el.height : el.offsetHeight; 815 this.thumbLeft = pos.x; 816 this.thumbTop = pos.y; 817 this.thumbOffsetBorderW = (this.thumb.offsetWidth - this.thumbWidth) / 2; 818 this.thumbOffsetBorderH = (this.thumb.offsetHeight - this.thumbHeight) / 2; 819 820 // instanciate the wrapper 821 this.wrapper = hs.createElement( 822 'div', 823 { 824 id: 'highslide-wrapper-'+ this.key, 825 className: this.wrapperClassName 826 }, 827 { 828 visibility: 'hidden', 829 position: 'absolute', 830 zIndex: hs.zIndexCounter++ 831 }, null, true ); 832 833 this.wrapper.onmouseover = function (e) { 834 try { hs.expanders[key].wrapperMouseHandler(e); } catch (e) {} 835 }; 836 this.wrapper.onmouseout = function (e) { 837 try { hs.expanders[key].wrapperMouseHandler(e); } catch (e) {} 838 }; 839 if (this.contentType == 'image' && this.outlineWhileAnimating == 2) 840 this.outlineWhileAnimating = 0; 841 // get the outline 842 if (hs.pendingOutlines[this.outlineType]) { 843 this.connectOutline(); 844 this[this.contentType +'Create'](); 845 } else if (!this.outlineType) { 846 this[this.contentType +'Create'](); 847 } else { 848 this.displayLoading(); 849 var exp = this; 850 new hs.Outline(this.outlineType, 851 function () { 852 exp.connectOutline(); 853 exp[exp.contentType +'Create'](); 854 } 855 ); 856 } 857}; 858 859hs.Expander.prototype = { 860 861connectOutline : function(x, y) { 862 var w = hs.pendingOutlines[this.outlineType]; 863 this.objOutline = w; 864 w.table.style.zIndex = this.wrapper.style.zIndex; 865 hs.pendingOutlines[this.outlineType] = null; 866}, 867 868displayLoading : function() { 869 if (this.onLoadStarted || this.loading) return; 870 871 this.originalCursor = this.a.style.cursor; 872 this.a.style.cursor = 'wait'; 873 874 this.loading = hs.loading; 875 this.loading.href = 'javascript:hs.expanders['+ this.key +'].cancelLoading()'; 876 this.loading.style.top = (this.thumbTop 877 + (this.thumbHeight - this.loading.offsetHeight) / 2) +'px'; 878 var exp = this, left = (this.thumbLeft + this.thumbOffsetBorderW 879 + (this.thumbWidth - this.loading.offsetWidth) / 2) +'px'; 880 setTimeout(function () { if (exp.loading) exp.loading.style.left = left }, 100); 881}, 882 883imageCreate : function() { 884 var exp = this; 885 886 var img = document.createElement('img'); 887 this.content = img; 888 img.onload = function () { try { exp.contentLoaded(); } catch (e) {} }; 889 img.className = 'highslide-image'; 890 img.style.visibility = 'hidden'; // prevent flickering in IE 891 img.style.display = 'block'; 892 img.style.position = 'absolute'; 893 img.style.maxWidth = 'none'; 894 img.style.zIndex = 3; 895 img.title = hs.restoreTitle; 896 if (hs.safari) hs.container.appendChild(img); 897 // uncomment this to flush img size: 898 // if (hs.ie) img.src = null; 899 img.src = hs.getSrc(this.a); 900 901 this.displayLoading(); 902}, 903 904htmlCreate : function () { 905 this.tempContainer = hs.createElement('div', { className: this.wrapperClassName }, 906 { 907 padding: '0 '+ hs.marginRight +'px 0 '+ hs.marginLeft +'px', 908 visibility: 'hidden' 909 }, hs.container 910 ); 911 912 this.content = hs.getCacheBinding(this.a); 913 if (!this.content) 914 this.content = hs.getNode(this.contentId); 915 if (!this.content) 916 this.content = hs.getSelfRendered(); 917 this.innerContent = this.content; 918 919 if (this.swfObject || this.objectType == 'iframe') this.setObjContainerSize(this.innerContent); 920 this.tempContainer.appendChild(this.innerContent); // to get full width 921 hs.setStyles (this.innerContent, { position: 'relative', visibility: 'hidden' }); 922 this.innerContent.className += ' highslide-display-block'; 923 924 this.content = hs.createElement( 925 'div', 926 { className: 'highslide-html' }, 927 { 928 position: 'relative', 929 zIndex: 3, 930 overflow: 'hidden', 931 width: this.thumbWidth +'px', 932 height: this.thumbHeight +'px' 933 } 934 ); 935 936 if (this.objectType == 'ajax' && !hs.getCacheBinding(this.a)) { 937 var ajax = new hs.Ajax(this.a, this.innerContent); 938 var exp = this; 939 ajax.onLoad = function () { exp.contentLoaded(); }; 940 ajax.onError = function () { location.href = hs.getSrc(this.a); }; 941 ajax.run(); 942 } 943 else 944 945 if (this.objectType == 'iframe' && this.objectLoadTime == 'before') { 946 this.writeExtendedContent(); 947 } 948 else 949 this.contentLoaded(); 950}, 951 952setIframeRelease : function () { 953 try { 954 var doc = this.iframe.contentDocument || this.iframe.contentWindow.document; 955 hs.addEventListener(doc, 'mouseup', function () { 956 hs.mouseClickHandler({type: 'mouseup', target: 1}); 957 }); 958 } catch (e) {} 959 this.setIframeRelease = null; // only run once 960}, 961 962contentLoaded : function() { 963 try { 964 965 if (!this.content) return; 966 if (this.onLoadStarted) return; // old Gecko loop 967 else this.onLoadStarted = true; 968 969 970 if (this.loading) { 971 this.loading.style.left = '-9999px'; 972 this.loading = null; 973 this.a.style.cursor = this.originalCursor || ''; 974 } 975 this.marginBottom = hs.marginBottom; 976 if (this.isImage) { 977 this.newWidth = this.content.width; 978 this.newHeight = this.content.height; 979 this.fullExpandWidth = this.newWidth; 980 this.fullExpandHeight = this.newHeight; 981 982 this.content.style.width = this.thumbWidth +'px'; 983 this.content.style.height = this.thumbHeight +'px'; 984 this.getCaption(); 985 } else if (this.htmlGetSize) this.htmlGetSize(); 986 987 988 this.wrapper.appendChild(this.content); 989 this.content.style.position = 'relative'; // Saf 990 if (this.caption) this.wrapper.appendChild(this.caption); 991 this.wrapper.style.left = this.thumbLeft +'px'; 992 this.wrapper.style.top = this.thumbTop +'px'; 993 hs.container.appendChild(this.wrapper); 994 995 // correct for borders 996 this.offsetBorderW = (this.content.offsetWidth - this.thumbWidth) / 2; 997 this.offsetBorderH = (this.content.offsetHeight - this.thumbHeight) / 2; 998 var modMarginRight = hs.marginRight + 2 * this.offsetBorderW; 999 this.marginBottom += 2 * this.offsetBorderH; 1000 1001 var ratio = this.newWidth / this.newHeight; 1002 var minWidth = this.allowSizeReduction 1003 ? this.minWidth : this.newWidth; 1004 var minHeight = this.allowSizeReduction 1005 ? this.minHeight : this.newHeight; 1006 1007 var justify = { x: 'auto', y: 'auto' }; 1008