-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
54 lines (42 loc) · 877 Bytes
/
index.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
44
45
46
47
48
49
50
51
52
53
54
/*
* viewmodel
* ViewModel component
*
* @copyright 2012 Enrico Marino and Federico Spini
* @license MIT
*/
/*
* Expose `ViewModel`
*/
module.exports = ViewModel;
/*
* Module dependencies
*/
var View = require('view');
var Model = require('model');
/*
* ViewModel
* Create a viewmodel.
*
* @param {Object} options
* @param {Element} [options.el] element
* @param {Object} [options.model] model
* @return {ViewModel} a viewmodel
*/
function ViewModel(options) {
if (!(this instanceof ViewModel)) {
return new ViewModel(options);
}
View.call(this, options);
this.model = options.model || new Model();
this.listen(this.model, this.messages);
}
/**
* Inherit from `View`
*/
ViewModel.prototype = Object.create(View.prototype);
ViewModel.prototype.constructor = ViewModel;
/**
* messages
*/
ViewModel.prototype.messages = {};