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); } }