📄 fisheyelist.js
字号:
} off_weight *= 2; } for (var i = 0; i < this.itemCount; i++) { var weight = this._weighAt(cen, i); if (weight < 0) { weight = 0; } this._setItemSize(i, weight * off_weight); } var main_p = Math.round(cen); var offset = 0; if (cen < 0) { main_p = 0; } else { if (cen > this.itemCount - 1) { main_p = this.itemCount - 1; } else { offset = (cen - main_p) * ((this.isHorizontal ? this.itemWidth : this.itemHeight) - this.children[main_p].sizeMain); } } this._positionElementsFrom(main_p, offset);}, _weighAt:function (cen, i) { var dist = Math.abs(cen - i); var limit = ((cen - i) > 0) ? this.children[i].effectRangeRght : this.children[i].effectRangeLeft; return (dist > limit) ? 0 : (1 - dist / limit);}, _setItemSize:function (p, scale) { scale *= this.timerScale; var w = Math.round(this.itemWidth + ((this.itemMaxWidth - this.itemWidth) * scale)); var h = Math.round(this.itemHeight + ((this.itemMaxHeight - this.itemHeight) * scale)); if (this.isHorizontal) { this.children[p].sizeW = w; this.children[p].sizeH = h; this.children[p].sizeMain = w; this.children[p].sizeOff = h; var y = 0; if (this.anchorEdge == this.EDGE.TOP) { y = (this.children[p].cenY - (this.itemHeight / 2)); } else { if (this.anchorEdge == this.EDGE.BOTTOM) { y = (this.children[p].cenY - (h - (this.itemHeight / 2))); } else { y = (this.children[p].cenY - (h / 2)); } } this.children[p].usualX = Math.round(this.children[p].cenX - (w / 2)); this.children[p].domNode.style.top = y + "px"; this.children[p].domNode.style.left = this.children[p].usualX + "px"; } else { this.children[p].sizeW = w; this.children[p].sizeH = h; this.children[p].sizeOff = w; this.children[p].sizeMain = h; var x = 0; if (this.anchorEdge == this.EDGE.LEFT) { x = this.children[p].cenX - (this.itemWidth / 2); } else { if (this.anchorEdge == this.EDGE.RIGHT) { x = this.children[p].cenX - (w - (this.itemWidth / 2)); } else { x = this.children[p].cenX - (w / 2); } } this.children[p].domNode.style.left = x + "px"; this.children[p].usualY = Math.round(this.children[p].cenY - (h / 2)); this.children[p].domNode.style.top = this.children[p].usualY + "px"; } this.children[p].domNode.style.width = w + "px"; this.children[p].domNode.style.height = h + "px"; if (this.children[p].svgNode) { this.children[p].svgNode.setSize(w, h); }}, _positionElementsFrom:function (p, offset) { var pos = 0; if (this.isHorizontal) { pos = Math.round(this.children[p].usualX + offset); this.children[p].domNode.style.left = pos + "px"; } else { pos = Math.round(this.children[p].usualY + offset); this.children[p].domNode.style.top = pos + "px"; } this._positionLabel(this.children[p]); var bpos = pos; for (var i = p - 1; i >= 0; i--) { bpos -= this.children[i].sizeMain; if (this.isHorizontal) { this.children[i].domNode.style.left = bpos + "px"; } else { this.children[i].domNode.style.top = bpos + "px"; } this._positionLabel(this.children[i]); } var apos = pos; for (var i = p + 1; i < this.itemCount; i++) { apos += this.children[i - 1].sizeMain; if (this.isHorizontal) { this.children[i].domNode.style.left = apos + "px"; } else { this.children[i].domNode.style.top = apos + "px"; } this._positionLabel(this.children[i]); }}, _positionLabel:function (itm) { var x = 0; var y = 0; var mb = dojo.html.getMarginBox(itm.lblNode); if (this.labelEdge == this.EDGE.TOP) { x = Math.round((itm.sizeW / 2) - (mb.width / 2)); y = -mb.height; } if (this.labelEdge == this.EDGE.BOTTOM) { x = Math.round((itm.sizeW / 2) - (mb.width / 2)); y = itm.sizeH; } if (this.labelEdge == this.EDGE.LEFT) { x = -mb.width; y = Math.round((itm.sizeH / 2) - (mb.height / 2)); } if (this.labelEdge == this.EDGE.RIGHT) { x = itm.sizeW; y = Math.round((itm.sizeH / 2) - (mb.height / 2)); } itm.lblNode.style.left = x + "px"; itm.lblNode.style.top = y + "px";}, _calcHitGrid:function () { var pos = dojo.html.getAbsolutePosition(this.domNode, true); this.hitX1 = pos.x - this.proximityLeft; this.hitY1 = pos.y - this.proximityTop; this.hitX2 = this.hitX1 + this.totalWidth; this.hitY2 = this.hitY1 + this.totalHeight;}, _toEdge:function (inp, def) { return this.EDGE[inp.toUpperCase()] || def;}, _expandSlowly:function () { if (!this.isOver) { return; } this.timerScale += 0.2; this._paint(); if (this.timerScale < 1) { dojo.lang.setTimeout(this, "_expandSlowly", 10); }}, destroy:function () { dojo.event.disconnect(document.documentElement, "onmouseout", this, "_onBodyOut"); dojo.event.disconnect(document.documentElement, "onmousemove", this, "_onMouseMove"); dojo.widget.FisheyeList.superclass.destroy.call(this);}});dojo.widget.defineWidget("dojo.widget.FisheyeListItem", dojo.widget.HtmlWidget, {iconSrc:"", svgSrc:"", caption:"", id:"", _blankImgPath:dojo.uri.moduleUri("dojo.widget", "templates/images/blank.gif"), templateString:"<div class=\"dojoHtmlFisheyeListItem\">" + " <img class=\"dojoHtmlFisheyeListItemImage\" dojoAttachPoint=\"imgNode\" dojoAttachEvent=\"onMouseOver;onMouseOut;onClick\">" + " <div class=\"dojoHtmlFisheyeListItemLabel\" dojoAttachPoint=\"lblNode\"></div>" + "</div>", fillInTemplate:function () { if (this.svgSrc != "") { this.svgNode = this._createSvgNode(this.svgSrc); this.domNode.appendChild(this.svgNode); this.imgNode.style.display = "none"; } else { if ((this.iconSrc.toLowerCase().substring(this.iconSrc.length - 4) == ".png") && (dojo.render.html.ie) && (!dojo.render.html.ie70)) { if (dojo.dom.hasParent(this.imgNode) && this.id != "") { var parent = this.imgNode.parentNode; parent.setAttribute("id", this.id); } this.imgNode.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + this.iconSrc + "', sizingMethod='scale')"; this.imgNode.src = this._blankImgPath.toString(); } else { if (dojo.dom.hasParent(this.imgNode) && this.id != "") { var parent = this.imgNode.parentNode; parent.setAttribute("id", this.id); } this.imgNode.src = this.iconSrc; } } if (this.lblNode) { this.lblNode.appendChild(document.createTextNode(this.caption)); } dojo.html.disableSelection(this.domNode);}, _createSvgNode:function (src) { var elm = document.createElement("embed"); elm.src = src; elm.type = "image/svg+xml"; elm.style.width = "1px"; elm.style.height = "1px"; elm.loaded = 0; elm.setSizeOnLoad = false; elm.onload = function () { this.svgRoot = this.getSVGDocument().rootElement; this.svgDoc = this.getSVGDocument().documentElement; this.zeroWidth = this.svgRoot.width.baseVal.value; this.zeroHeight = this.svgRoot.height.baseVal.value; this.loaded = true; if (this.setSizeOnLoad) { this.setSize(this.setWidth, this.setHeight); } }; elm.setSize = function (w, h) { if (!this.loaded) { this.setWidth = w; this.setHeight = h; this.setSizeOnLoad = true; return; } this.style.width = w + "px"; this.style.height = h + "px"; this.svgRoot.width.baseVal.value = w; this.svgRoot.height.baseVal.value = h; var scale_x = w / this.zeroWidth; var scale_y = h / this.zeroHeight; for (var i = 0; i < this.svgDoc.childNodes.length; i++) { if (this.svgDoc.childNodes[i].setAttribute) { this.svgDoc.childNodes[i].setAttribute("transform", "scale(" + scale_x + "," + scale_y + ")"); } } }; return elm;}, onMouseOver:function (e) { if (!this.parent.isOver) { this.parent._setActive(e); } if (this.caption != "") { dojo.html.addClass(this.lblNode, "selected"); this.parent._positionLabel(this); }}, onMouseOut:function (e) { dojo.html.removeClass(this.lblNode, "selected");}, onClick:function (e) {}});
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -