Licence: Highslide JS is licensed under a Creative Commons Attribution-NonCommercial 2.5 License (http://creativecommons.org/licenses/by-nc/2.5/).
You are free: * to copy, distribute, display, and perform the work * to make derivative works
Under the following conditions: * Attribution. You must attribute the work in the manner specified by the author or licensor. * Noncommercial. You may not use this work for commercial purposes.
* For any reuse or distribution, you must make clear to others the license terms of this work. * Any of these conditions can be waived if you get permission from the copyright holder.
Your fair use and other rights are in no way affected by the above. ******************************************************************************/
var hs = {
// Apply your own settings here, or override them in the html file. graphicsDir : "highslide/graphics/", restoreCursor : "zoomout.cur", // necessary for preload fullExpandIcon : "fullexpand.gif", expandSteps : 10, // number of steps in zoom. Each step lasts for duration/step milliseconds. expandDuration : 250, // milliseconds restoreSteps : 10, restoreDuration : 250, allowMultipleInstances: true, hideThumbOnExpand : true, captionSlideSpeed : 1, // set to 0 to disable slide in effect outlineWhileAnimating : 0, // not recommended, animation gets jaggy on slow systems. outlineStartOffset : 3, // ends at 10 marginLeft : 10, marginRight : 35, // leave room for scrollbars + outline marginTop : 10, marginBottom : 35, // leave room for scrollbars + outline zIndexCounter : 1001, // adjust to other absolutely positioned elements fullExpandTitle : "放大到实际尺寸", restoreTitle : "单击可关闭图片, 本窗口可拖动。使用←→键察看上一图或下一图片。", focusTitle : "切换到这幅图片", loadingText : "loading...", loadingTitle : "点击关闭", loadingOpacity : 0.75, showCredits : false, // you can set this to false if you want creditsText : "Powered by <i>Highslide JS</i>", creditsHref : "http://vikjavev.no/highslide/?user=1", creditsTitle : "Go to the Highslide JS homepage",
// These settings can also be overridden inline for each image anchor : "auto", // where the image expands from align : "auto", // position in the client (overrides anchor) captionId : null, captionTemplateId : null, slideshowGroup : null, // defines groups for next/previous links and keystrokes spaceForCaption : 30, // leaves space below images with captions minWidth: 200, minHeight: 200, allowSizeReduction: true, // allow the image to reduce to fit client size. If false, this overrides minWidth and minHeight outlineType : "drop-shadow", // set null to disable outlines wrapperClassName : null, // for enhanced css-control enableKeyListener : true,
// END OF YOUR SETTINGS
// declare internal properties preloadTheseImages : new Array(), continuePreloading: true, expandedImagesCounter : 0, expanders : new Array(), overrides : new Array( "anchor", "align", "outlineType", "outlineWhileAnimating", "spaceForCaption", "wrapperClassName", "minWidth", "minHeight", "captionId", "captionTemplateId", "allowSizeReduction", "slideshowGroup", "enableKeyListener" ), overlays : new Array(), toggleImagesGroup : null, pendingOutlines : new Array(),
$ : function (id) { return document.getElementById(id); },
push : function (arr, val) { arr[arr.length] = val; },
createElement : function (tag, attribs, styles, parent) { var el = document.createElement(tag); if (attribs) hs.setAttribs(el, attribs); if (styles) hs.setStyles(el, styles); if (parent) parent.appendChild(el); return el; },
setAttribs : function (el, attribs) { for (var x in attribs) { el[x] = attribs[x]; } },
setStyles : function (el, styles) { for (var x in styles) { try { el.style[x] = styles[x]; } catch (e) {} } },
getAdjacentAnchor : function(key, op) { var aAr = document.getElementsByTagName("A"); var hsAr = new Array; var activeI = -1; var j = 0; for (i = 0; i < aAr.length; i++) { if (hs.isHsAnchor(aAr[i]) && ((hs.expanders[key].slideshowGroup == hs.getParam(aAr[i], "slideshowGroup")))) { hsAr[j] = aAr[i]; if (hs.expanders[key] && aAr[i] == hs.expanders[key].a) { activeI = j; } j++; } } return hsAr[activeI + op];
},
getParam : function (a, param) { try { var s = a.onclick.toString(); var oneLine = s.replace(/s/g, " "); var sParams = oneLine.replace(/.*?hs.(htmlE|e)xpands*?(s*?thiss*?,s*?{(.*?)}.*?$/, "$2"); if (hs.safari) { // stupid bug for (var i = 0; i < hs.overrides.length; i++) { sParams = sParams.replace(hs.overrides[i] +":", ","+ hs.overrides[i] +":").replace(/^s*?,/, ""); } } if (oneLine == sParams) return null; eval("var arr = {"+ sParams +"};"); for (var x in arr) { if (x == param) return arr[x]; } } catch (e) { return null; } },
getSrc : function (a) { var src = hs.getParam(a, "src"); if (src) return src; return a.rel.replace(/_slash_/g, "/") || a.href; },
previousOrNext : function (el, op) { if (typeof el == "object") var activeKey = hs.getWrapperKey(el); else if (typeof el == "number") var activeKey = el; if (hs.expanders[activeKey]) { hs.toggleImagesExpandEl = hs.getAdjacentAnchor(activeKey, op); hs.expanders[activeKey].doClose(); }
return false; },
previous : function (el) { return hs.previousOrNext(el, -1); },
next : function (el) { return hs.previousOrNext(el, 1); },
keyHandler : function(e) { if (!e) e = window.event; if (!e.target) e.target = e.srcElement; // ie if (e.target.form) return; // form element has focus
var op = null; switch (e.keyCode) { case 34: // Page Down case 39: // Arrow right case 40: // Arrow left op = 1; break; case 33: // Page Up case 37: // Arrow left case 38: // Arrow down op = -1; break; case 27: // Escape case 13: // Enter if (hs.expanders[hs.focusKey]) hs.expanders[hs.focusKey].doClose(); return false; } if (op != null) { hs.removeEventListener(document, "keydown", hs.keyHandler); if (hs.expanders[hs.focusKey] && !hs.expanders[hs.focusKey].enableKeyListener) return true; return hs.previousOrNext(hs.focusKey, op); } else return true; },
registerOverlay : function (overlay) { hs.push(hs.overlays, overlay); },
getWrapperKey : function (el) { var key = -1; while (el.parentNode) { el = el.parentNode; if (el.id && el.id.match(/^highslide-wrapper-[0-9]+$/)) { key = el.id.replace(/^highslide-wrapper-([0-9]+)$/, "$1"); break; } } return key; },
cleanUp : function () { if (hs.toggleImagesExpandEl) { hs.toggleImagesExpandEl.onclick(); hs.toggleImagesExpandEl = null; } else { for (i = 0; i < hs.expanders.length; i++) { if (hs.expanders[i] && hs.expanders[i].isExpanded) hs.focusTopmost(); } } },
mouseClickHandler : function(e) { if (!e) e = window.event; if (e.button > 1) return true; if (!e.target) e.target = e.srcElement;
hs.dragKey = hs.getWrapperKey(fobj); if (fobj.className.match(/highslide-(image|move)/)) { var isDraggable = true; var wLeft = parseInt(hs.expanders[hs.dragKey].wrapper.style.left); var wTop = parseInt(hs.expanders[hs.dragKey].wrapper.style.top); }
if (e.type == "mousedown") { if (isDraggable) // drag or focus { hs.dragObj = hs.expanders[hs.dragKey].content;
if (fobj.className.match("highslide-image")) hs.dragObj.style.cursor = "move";
//----------------------------------------------------------------------------- HsOutline = function (outlineType, onLoad) { if (!outlineType) return; if (onLoad) this.onLoad = onLoad; this.outlineType = outlineType; this.outline = new Array(); var v = hs.ieVersion();
hs.genContainer();
this.hasAlphaImageLoader = hs.ie && v >= 5.5 && v < 8; this.hasPngSupport = !hs.ie || (hs.ie && v >= 8); this.hasOutline = this.outlineType && (this.hasAlphaImageLoader || this.hasPngSupport);
// override inline parameters for (i = 0; i < hs.overrides.length; i++) { var name = hs.overrides[i]; if (params && typeof params[name] != "undefined") this[name] = params[name]; else this[name] = hs[name]; }
if (params && params.thumbnailId) { var el = hs.$(params.thumbnailId);
} else { // first img within anchor for (i = 0; i < a.childNodes.length; i++) { if (a.childNodes[i].tagName && a.childNodes[i].tagName == "IMG") { var el = a.childNodes[i]; break; } } } if (!el) el = a;
// cancel other for (i = 0; i < hs.expanders.length; i++) { if (hs.expanders[i] && hs.expanders[i].thumb != el && !hs.expanders[i].onLoadStarted) { hs.expanders[i].cancelLoading(); } } // check if already open for (i = 0; i < hs.expanders.length; i++) { if (hs.expanders[i] && hs.expanders[i].thumb == el) { hs.expanders[i].focus(); return false; }
else if (hs.expanders[i] && !hs.allowMultipleInstances) { hs.expanders[i].doClose(); }