source: imaps-frontend/node_modules/utila/lib/classic.js@ 79a0317

main
Last change on this file since 79a0317 was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 3 days ago

F4 Finalna Verzija

  • Property mode set to 100644
File size: 3.0 KB
Line 
1// Generated by CoffeeScript 1.6.3
2var classic,
3 __slice = [].slice;
4
5module.exports = classic = {};
6
7classic.implement = function() {
8 var classProto, classReference, desc, member, mixin, mixins, _i, _j, _len;
9 mixins = 2 <= arguments.length ? __slice.call(arguments, 0, _i = arguments.length - 1) : (_i = 0, []), classReference = arguments[_i++];
10 for (_j = 0, _len = mixins.length; _j < _len; _j++) {
11 mixin = mixins[_j];
12 classProto = classReference.prototype;
13 for (member in mixin.prototype) {
14 if (!Object.getOwnPropertyDescriptor(classProto, member)) {
15 desc = Object.getOwnPropertyDescriptor(mixin.prototype, member);
16 Object.defineProperty(classProto, member, desc);
17 }
18 }
19 }
20 return classReference;
21};
22
23classic.mix = function() {
24 var classProto, classReference, desc, member, mixin, mixins, _i, _j, _len;
25 mixins = 2 <= arguments.length ? __slice.call(arguments, 0, _i = arguments.length - 1) : (_i = 0, []), classReference = arguments[_i++];
26 classProto = classReference.prototype;
27 classReference.__mixinCloners = [];
28 classReference.__applyClonersFor = function(instance, args) {
29 var cloner, _j, _len, _ref;
30 if (args == null) {
31 args = null;
32 }
33 _ref = classReference.__mixinCloners;
34 for (_j = 0, _len = _ref.length; _j < _len; _j++) {
35 cloner = _ref[_j];
36 cloner.apply(instance, args);
37 }
38 };
39 classReference.__mixinInitializers = [];
40 classReference.__initMixinsFor = function(instance, args) {
41 var initializer, _j, _len, _ref;
42 if (args == null) {
43 args = null;
44 }
45 _ref = classReference.__mixinInitializers;
46 for (_j = 0, _len = _ref.length; _j < _len; _j++) {
47 initializer = _ref[_j];
48 initializer.apply(instance, args);
49 }
50 };
51 classReference.__mixinQuitters = [];
52 classReference.__applyQuittersFor = function(instance, args) {
53 var quitter, _j, _len, _ref;
54 if (args == null) {
55 args = null;
56 }
57 _ref = classReference.__mixinQuitters;
58 for (_j = 0, _len = _ref.length; _j < _len; _j++) {
59 quitter = _ref[_j];
60 quitter.apply(instance, args);
61 }
62 };
63 for (_j = 0, _len = mixins.length; _j < _len; _j++) {
64 mixin = mixins[_j];
65 if (!(mixin.constructor instanceof Function)) {
66 throw Error("Mixin should be a function");
67 }
68 for (member in mixin.prototype) {
69 if (member.substr(0, 11) === '__initMixin') {
70 classReference.__mixinInitializers.push(mixin.prototype[member]);
71 continue;
72 } else if (member.substr(0, 11) === '__clonerFor') {
73 classReference.__mixinCloners.push(mixin.prototype[member]);
74 continue;
75 } else if (member.substr(0, 12) === '__quitterFor') {
76 classReference.__mixinQuitters.push(mixin.prototype[member]);
77 continue;
78 }
79 if (!Object.getOwnPropertyDescriptor(classProto, member)) {
80 desc = Object.getOwnPropertyDescriptor(mixin.prototype, member);
81 Object.defineProperty(classProto, member, desc);
82 }
83 }
84 }
85 return classReference;
86};
Note: See TracBrowser for help on using the repository browser.