Start process of better client-side file locations.
[openemr.git] / public / assets / literallycanvas-0-4-13 / js / tools / base.js
blob7d5ce040ecd729a32dfaac71cbdeb6f797b180a9
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;
5 tools = {};
7 tools.Tool = Tool = (function() {
8   function Tool() {}
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) {};
28   return Tool;
30 })();
32 tools.ToolWithStroke = ToolWithStroke = (function(superClass) {
33   extend(ToolWithStroke, superClass);
35   function ToolWithStroke(lc) {
36     this.strokeWidth = lc.opts.defaultStrokeWidth;
37   }
39   ToolWithStroke.prototype.optionsStyle = 'stroke-width';
41   ToolWithStroke.prototype.didBecomeActive = function(lc) {
42     var unsubscribeFuncs;
43     unsubscribeFuncs = [];
44     this.unsubscribe = (function(_this) {
45       return function() {
46         var func, i, len, results;
47         results = [];
48         for (i = 0, len = unsubscribeFuncs.length; i < len; i++) {
49           func = unsubscribeFuncs[i];
50           results.push(func());
51         }
52         return results;
53       };
54     })(this);
55     return unsubscribeFuncs.push(lc.on('setStrokeWidth', (function(_this) {
56       return function(strokeWidth) {
57         _this.strokeWidth = strokeWidth;
58         return lc.trigger('toolDidUpdateOptions');
59       };
60     })(this)));
61   };
63   ToolWithStroke.prototype.willBecomeInactive = function(lc) {
64     return this.unsubscribe();
65   };
67   return ToolWithStroke;
69 })(Tool);
71 module.exports = tools;