blob: d954a0835611200a3b9a06e640a38305440f5048 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
var KoControlNames = 0;
function KoControlPoint(x, y, name) {
this.Element = $(document.createElement("DIV"));
this.Element.addClass("KoControlPoint");
this.Element.css("left", x);
this.Element.css("top", y);
this.X = x;
this.Y = y;
KoDraw.Canvas.append(this.Element);
if (name == null) {
this.SetName("CP" + (++KoControlNames));
} else {
this.SetName(name);
}
var t = this;
this.Element.draggable();
KoDraw.Canvas.dblclick(function(event) {
KoDraw.ShowControlPointRules(t);
});
}
KoControlPoint.prototype = {
SetName: function(name) {
// We should check for duplicate names...
// TODO: We should also ban certain characters in names, such as operators, spaces, etc..
for (a in KoDraw.ControlPoints) {
if (KoDraw.ControlPoints[a].GetName() == name) {
return false;
}
}
this.Name = name;
this.Element.attr("title", this.Name);
return true;
},
GetName: function() {
return this.Name;
},
SetXY: function(x, y) {
this.X = x;
this.Y = y;
this.Element.css("left", x);
this.Element.css("top", y);
}
}
|