-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchop.js
More file actions
65 lines (51 loc) · 1.51 KB
/
chop.js
File metadata and controls
65 lines (51 loc) · 1.51 KB
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
55
56
57
58
59
60
61
62
63
64
65
/*
chop.js
Backbone flavour
*/
(function(){
// root : Save a reference to the global object (`window` in the browser, `global`
// on the server).
var root = this
, Chop;
// The top-level namespace. All public chop classes and modules will
// be attached to this. Exported for both CommonJS and the browser.
if (typeof exports !== 'undefined') {
Chop = exports;
} else {
Chop = root.Chop = {};
}
Chop.VERSION = '0.0.1';
Chop.inherits = function (parent, protoProps, staticProps) {
var child
, ctor = function(){}
, merge = function (destination, source) {
for (var prop in source) {
destination[prop] = source[prop];
}
};
//constructor ....
if (protoProps && protoProps.hasOwnProperty('constructor')) {
child = protoProps.constructor;
} else {
child = function(){ parent.apply(this, arguments); };
}
//inherits from parent
merge(child, parent);
ctor.prototype = parent.prototype;
child.prototype = new ctor();
//instance properties
if(protoProps) merge(child.prototype, protoProps);
//static properties
if(staticProps) merge(child, staticProps);
// Correctly set child's `prototype.constructor`.
child.prototype.constructor = child;
// Set a convenience property in case the parent's prototype is needed later.
child.__super__ = parent.prototype;
return child
};
Chop.extend = function (protoProps, staticProps) {
var child = Chop.inherits(this, protoProps, staticProps);
child.extend = this.extend;
return child;
};
}).call(this);