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