【发布时间】:2012-01-23 20:01:06
【问题描述】:
我有点击选择区域的 javascript 函数(使用 Raphael)。我需要在双击时添加新功能:
- 添加新图像(象征点的小图像)
- 在此图像(点)旁边添加一些文本字段,以便用户可以在此点添加描述
- 在图像和文本字段旁边添加删除按钮。因此,如果用户想删除它,他可以。它应该使用文本字段删除这个全新的点(图像)
- 我还需要知道这个新点的坐标,以便保存它
这是我的 javascript 函数的代码:
<script type="text/javascript" charset="utf-8">
window.onload = function () {
var R = Raphael("paper", 500, 500);
var attr = {
fill: "#EEC7C3",
stroke: "#E0B6B2",
"stroke-width": 1,
"stroke-linejoin": "round"
};
var area = {};
area.Element1 = R.path("...").attr(attr);
area.Element2 = R.path("...").attr(attr);
...
area.Element63 = R.path("...").attr(attr);
var current = null;
for (var state in area) {
area[state].color = Raphael.getColor();
(function (st, state) {
st[0].state = 0;
st[0].style.cursor = "pointer";
st[0].onmouseover = function () {
current && area[current].animate({ fill: "#EEC7C3", stroke: "#E0B6B2" }, 500) && (document.getElementById(current).style.display = "");
st.animate({ fill: st.color, stroke: "#ccc" }, 500);
st.toFront();
R.safari();
document.getElementById(state).style.display = "block";
current = state;
};
st[0].onmouseout = function () {
if (this.state == 0)
st.animate({ fill: "#EEC7C3", stroke: "#E0B6B2" }, 500);
else
st.animate({ fill: "#C05219", stroke: "#E0B6B2" }, 500);
st.toFront();
R.safari();
};
st[0].onclick = function () {
st.animate({ fill: "#C05219", stroke: "#E0B6B2" }, 500);
st.toFront();
if (this.state == 0)
this.state = 1;
else
this.state = 0;
R.safari();
};
})(area[state], state);
}
};
</script>
我不是 javascript 程序员,所以我什至不知道从哪里开始。因此,非常感谢这里的任何帮助!
【问题讨论】:
-
请添加JavaScript函数的源代码以及HTML,至少与此问题相关的部分。
标签: javascript jquery html raphael double-click