|
20 | 20 | }
|
21 | 21 |
|
22 | 22 | }(this, function(_, Backbone) {
|
23 |
| - |
| 23 | + |
24 | 24 | // Epoxy namespace:
|
25 | 25 | var Epoxy = Backbone.Epoxy = {};
|
26 | 26 |
|
|
49 | 49 | return extend;
|
50 | 50 | }
|
51 | 51 | };
|
52 |
| - |
53 |
| - // Partial application for calling method implementations of a super-class object: |
54 |
| - function superClass(sup) { |
55 |
| - return function(instance, method, args) { |
56 |
| - return sup.prototype[ method ].apply(instance, args); |
57 |
| - }; |
| 52 | + |
| 53 | + // Calls method implementations of a super-class object: |
| 54 | + function _super(instance, method, args) { |
| 55 | + return instance._super.prototype[method].apply(instance, args); |
58 | 56 | }
|
59 |
| - |
60 |
| - |
| 57 | + |
61 | 58 | // Epoxy.Model
|
62 | 59 | // -----------
|
63 | 60 | var modelMap;
|
64 |
| - var modelSuper = superClass(Backbone.Model); |
65 | 61 | var modelProps = ['computeds'];
|
66 | 62 |
|
67 | 63 | Epoxy.Model = Backbone.Model.extend({
|
68 |
| - |
| 64 | + _super: Backbone.Model, |
| 65 | + |
69 | 66 | // Backbone.Model constructor override:
|
70 | 67 | // configures computed model attributes around the underlying native Backbone model.
|
71 | 68 | constructor: function(attributes, options) {
|
72 | 69 | _.extend(this, _.pick(options||{}, modelProps));
|
73 |
| - modelSuper(this, 'constructor', arguments); |
| 70 | + _super(this, 'constructor', arguments); |
74 | 71 | this.initComputeds(attributes, options);
|
75 | 72 | },
|
76 | 73 |
|
|
95 | 92 | }
|
96 | 93 |
|
97 | 94 | // Default to native Backbone.Model get operation:
|
98 |
| - return modelSuper(this, 'get', arguments); |
| 95 | + return _super(this, 'get', arguments); |
99 | 96 | },
|
100 | 97 |
|
101 | 98 | // Backbone.Model.set() override:
|
|
124 | 121 | }
|
125 | 122 |
|
126 | 123 | // Pass all resulting set params along to the underlying Backbone Model.
|
127 |
| - return modelSuper(this, 'set', [params, options]); |
| 124 | + return _super(this, 'set', [params, options]); |
128 | 125 | },
|
129 | 126 |
|
130 | 127 | // Backbone.Model.toJSON() override:
|
131 | 128 | // adds a 'computed' option, specifying to include computed attributes.
|
132 | 129 | toJSON: function(options) {
|
133 |
| - var json = modelSuper(this, 'toJSON', arguments); |
| 130 | + var json = _super(this, 'toJSON', arguments); |
134 | 131 |
|
135 | 132 | if (options && options.computed) {
|
136 | 133 | _.each(this.c(), function(computed, attribute) {
|
|
145 | 142 | // clears all computed attributes before destroying.
|
146 | 143 | destroy: function() {
|
147 | 144 | this.clearComputeds();
|
148 |
| - return modelSuper(this, 'destroy', arguments); |
| 145 | + return _super(this, 'destroy', arguments); |
149 | 146 | },
|
150 | 147 |
|
151 | 148 | // Computed namespace manager:
|
|
950 | 947 | // Epoxy.View
|
951 | 948 | // ----------
|
952 | 949 | var viewMap;
|
953 |
| - var viewSuper = superClass(Backbone.View); |
954 | 950 | var viewProps = ['viewModel', 'bindings', 'bindingFilters', 'bindingHandlers', 'bindingSources', 'computeds'];
|
955 | 951 |
|
956 |
| - |
957 | 952 | Epoxy.View = Backbone.View.extend({
|
958 |
| - |
| 953 | + _super: Backbone.View, |
| 954 | + |
959 | 955 | // Backbone.View constructor override:
|
960 | 956 | // sets up binding controls around call to super.
|
961 | 957 | constructor: function(options) {
|
962 | 958 | _.extend(this, _.pick(options||{}, viewProps));
|
963 |
| - viewSuper(this, 'constructor', arguments); |
| 959 | + _super(this, 'constructor', arguments); |
964 | 960 | this.applyBindings();
|
965 | 961 | },
|
966 | 962 |
|
|
1091 | 1087 | // unbinds the view before performing native removal tasks.
|
1092 | 1088 | remove: function() {
|
1093 | 1089 | this.removeBindings();
|
1094 |
| - viewSuper(this, 'remove', arguments); |
| 1090 | + _super(this, 'remove', arguments); |
1095 | 1091 | }
|
1096 | 1092 |
|
1097 | 1093 | }, mixins);
|
|
0 commit comments