var weldingStamp = null; var Qs_WeldingStamp = qs.createObject(); Qs_WeldingStamp.prototype = { _containerClass: 'stamp-container', _addMarkLinkClass: 'stamp-add-mark', marks: [], options: { 'callbackUrl': null }, setMark: function(event) { var markOptions = { 'positionX': event.pageX - this.getContainer().offset().left, 'positionY': event.pageY - this.getContainer().offset().top }; this.marks.push(new Qs_WeldingStamp_Mark(markOptions, this)); this.getContainer().css('cursor', 'auto').unbind('click.setMark'); $('a.' + this._addMarkLinkClass).removeClass('selected'); }, initialize: function(options) { this.options = options; var self = this; $('a.' + this._addMarkLinkClass).click(function(){ self.addMark(); return false; }); for (var i = 0; i < this.options.marks.length; i++) { var mark = new Qs_WeldingStamp_Mark(this.options.marks[i], this); this.marks.push(mark); } delete this.options.marks; }, getMarkById: function(id) { for (var i = 0; i < this.marks.length; i++) { if (this.marks[i].id == id) { return this.marks[i]; } } return false; }, addMark: function() { var self = this; var link = $('a.' + this._addMarkLinkClass); var selected = link.hasClass('selected'); link.removeClass('selected'); this.getContainer().css('cursor', 'auto').unbind('click.setMark'); if (!selected) { link.addClass('selected'); this.getContainer().css('cursor', 'crosshair').bind('click.setMark', function(event) { self.setMark(event) }); } }, getContainer: function() { return $('.' + this._containerClass); } };