1 var Tool, ToolWithStroke, tools,
2 extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
3 hasProp = {}.hasOwnProperty;
7 tools.Tool = Tool = (function() {
10 Tool.prototype.name = null;
12 Tool.prototype.iconName = null;
14 Tool.prototype.usesSimpleAPI = true;
16 Tool.prototype.begin = function(x, y, lc) {};
18 Tool.prototype["continue"] = function(x, y, lc) {};
20 Tool.prototype.end = function(x, y, lc) {};
22 Tool.prototype.optionsStyle = null;
24 Tool.prototype.didBecomeActive = function(lc) {};
26 Tool.prototype.willBecomeInactive = function(lc) {};
32 tools.ToolWithStroke = ToolWithStroke = (function(superClass) {
33 extend(ToolWithStroke, superClass);
35 function ToolWithStroke(lc) {
36 this.strokeWidth = lc.opts.defaultStrokeWidth;
39 ToolWithStroke.prototype.optionsStyle = 'stroke-width';
41 ToolWithStroke.prototype.didBecomeActive = function(lc) {
43 unsubscribeFuncs = [];
44 this.unsubscribe = (function(_this) {
46 var func, i, len, results;
48 for (i = 0, len = unsubscribeFuncs.length; i < len; i++) {
49 func = unsubscribeFuncs[i];
55 return unsubscribeFuncs.push(lc.on('setStrokeWidth', (function(_this) {
56 return function(strokeWidth) {
57 _this.strokeWidth = strokeWidth;
58 return lc.trigger('toolDidUpdateOptions');
63 ToolWithStroke.prototype.willBecomeInactive = function(lc) {
64 return this.unsubscribe();
67 return ToolWithStroke;
71 module.exports = tools;