scratch – Blame information for rev 92
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
84 | office | 1 | DrawingBoard.Control = function(drawingBoard, opts) { |
2 | this.board = drawingBoard; |
||
3 | this.opts = $.extend({}, this.defaults, opts); |
||
4 | |||
5 | this.$el = $(document.createElement('div')).addClass('drawing-board-control'); |
||
6 | if (this.name) |
||
7 | this.$el.addClass('drawing-board-control-' + this.name); |
||
8 | |||
9 | this.board.ev.bind('board:reset', $.proxy(this.onBoardReset, this)); |
||
10 | |||
11 | this.initialize.apply(this, arguments); |
||
12 | return this; |
||
13 | }; |
||
14 | |||
15 | DrawingBoard.Control.prototype = { |
||
16 | |||
17 | name: '', |
||
18 | |||
19 | defaults: {}, |
||
20 | |||
21 | initialize: function() { |
||
22 | |||
23 | }, |
||
24 | |||
25 | addToBoard: function() { |
||
26 | this.board.addControl(this); |
||
27 | }, |
||
28 | |||
29 | onBoardReset: function(opts) { |
||
30 | |||
31 | } |
||
32 | |||
33 | }; |
||
34 | |||
35 | //extend directly taken from backbone.js |
||
36 | DrawingBoard.Control.extend = function(protoProps, staticProps) { |
||
37 | var parent = this; |
||
38 | var child; |
||
39 | if (protoProps && protoProps.hasOwnProperty('constructor')) { |
||
40 | child = protoProps.constructor; |
||
41 | } else { |
||
42 | child = function(){ return parent.apply(this, arguments); }; |
||
43 | } |
||
44 | $.extend(child, parent, staticProps); |
||
45 | var Surrogate = function(){ this.constructor = child; }; |
||
46 | Surrogate.prototype = parent.prototype; |
||
47 | child.prototype = new Surrogate(); |
||
48 | if (protoProps) $.extend(child.prototype, protoProps); |
||
49 | child.__super__ = parent.prototype; |
||
50 | return child; |
||
51 | }; |