-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontroller.js
43 lines (35 loc) · 1.24 KB
/
controller.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
define(['dib',
'events',
'class'],
function(Dib, Emitter, clazz) {
function Controller() {
Emitter.call(this);
this._init();
}
clazz.inherits(Controller, Emitter);
Controller.prototype._init = function() {
var dib = new Dib(this.template)
, locals = this.willLoadDib()
, element;
if (this.tagName || this.className || this.attributes || this.id) {
element = {}
element.tag = this.tagName || 'div';
element.attrs = this.attributes || {};
if (this.id) element.attrs['id'] = this.id;
if (this.className) element.attrs['class'] = this.className;
}
dib.container(element)
.events(this.events, this);
// TODO: Implement support in `Dib` for automatically instantiating views,
// which will work similarly to automatic event binding.
this.el = dib.create(locals);
this.didLoadDib();
}
Controller.prototype.willLoadDib = function() {};
Controller.prototype.didLoadDib = function() {};
Controller.prototype.willAddEl = function() {};
Controller.prototype.didAddEl = function() {};
Controller.prototype.willRemoveEl = function() {};
Controller.prototype.didRemoveEl = function() {};
return Controller;
});