UNPKG

1.5 kBJavaScriptView Raw
1window.GMP = window.GMP || {};
2
3GMP.Class = function() {
4 var len = arguments.length;
5 var P = arguments[0];
6 var F = arguments[len-1];
7
8 var C = typeof F.initialize == 'function' ?
9 F.initialize :
10 function(){ P.prototype.initialize.apply(this, arguments); };
11
12 if (len > 1) {
13 var newArgs = [C, P].concat(
14 Array.prototype.slice.call(arguments).slice(1, len-1), F);
15 GMP.inherit.apply(null, newArgs);
16 } else {
17 C.prototype = F;
18 }
19 return C;
20};
21
22GMP.inherit = function(C, P) {
23 var F = function() {};
24 F.prototype = P.prototype;
25 C.prototype = new F;
26 var i, l, o;
27 for(i=2, l=arguments.length; i<l; i++) {
28 o = arguments[i];
29 if(typeof o === 'function') {
30 o = o.prototype;
31 }
32 GMP.Util.extend(C.prototype, o);
33 }
34};
35
36GMP.Util = GMP.Util || {};
37GMP.Util.extend = function(destination, source) {
38 destination = destination || {};
39 if (source) {
40 for (var property in source) {
41 var value = source[property];
42 if (value !== undefined) {
43 destination[property] = value;
44 }
45 }
46
47 var sourceIsEvt = typeof window.Event == 'function'
48 && source instanceof window.Event;
49
50 if (!sourceIsEvt
51 && source.hasOwnProperty && source.hasOwnProperty('toString')) {
52 destination.toString = source.toString;
53 }
54 }
55 return destination;
56};
57
58module.exports = GMP;
\No newline at end of file