js_stack 0.6.2 → 0.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +2 -2
- data/lib/js_stack/version.rb +1 -1
- data/vendor/assets/javascripts/js_stack/base/marionette/{1.8.4.js → 1.8.5.js} +439 -617
- data/vendor/assets/javascripts/js_stack/base/marionette.js +1 -1
- data/vendor/assets/javascripts/js_stack/plugins/backbone/routefilter/{0.2.0.js → 0.2.1.js} +13 -5
- data/vendor/assets/javascripts/js_stack/plugins/backbone.routefilter.js +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 859a7e59f443025858bedae178446651c40ae4fb
|
|
4
|
+
data.tar.gz: 93d28d6952ce9eba50d4e3f475bc13a75a3ff395
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b03c12e5e0e285a106d6d317d881f62f5f6b0d896f5e08adfaebe00eef944eb7f5bf5cdeb36ec2d609a68748908fa5a8045847cc3777ded290c0aa9a87f012f1
|
|
7
|
+
data.tar.gz: 793a36439f627f0eaf7571d531b78df3d7c2d04391408d78864acbc7c753b95e3cbd7a143a2b2c1afa3bf35d87d2face11176a4ed2850b85986eb4a1c64f2884
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
|
@@ -53,7 +53,7 @@ Examples:
|
|
|
53
53
|
| Library | Versions | Changelog | Homepage |
|
|
54
54
|
| :-----: | :------: | :-------: | :------: |
|
|
55
55
|
| backbone | **1.1.2**, 1.0.0 | [changelog](http://backbonejs.org/#changelog) | [homepage](http://backbonejs.org/) |
|
|
56
|
-
| marionette | **1.8.
|
|
56
|
+
| marionette | **1.8.5**, 1.7.4, 1.6.4, 1.5.1, 1.4.1, 1.1.0 | [changelog](https://github.com/marionettejs/backbone.marionette/blob/master/changelog.md) | [homepage](http://marionettejs.com/) |
|
|
57
57
|
| underscore | **1.6.0**, 1.5.2 | [changelog](http://underscorejs.org/#changelog) | [homepage](http://underscorejs.org/) |
|
|
58
58
|
| hamlcoffee | **1.16** | [changelog](https://github.com/netzpirat/haml_coffee_assets/blob/master/CHANGELOG.md) | [homepage](https://github.com/netzpirat/haml_coffee_assets) |
|
|
59
59
|
| js-routes | **0.9.7** | none | [homepage](https://github.com/railsware/js-routes) |
|
|
@@ -66,7 +66,7 @@ Examples:
|
|
|
66
66
|
| backbone deepmodel | **0.10.4** | [changelog](https://github.com/powmedia/backbone-deep-model#changelog) | [homepage](https://github.com/powmedia/backbone-deep-model) | Yes
|
|
67
67
|
| backbone mutators | **0.4.2** | [changelog](https://github.com/asciidisco/Backbone.Mutators#changelog) | [homepage](https://github.com/asciidisco/Backbone.Mutators) | No
|
|
68
68
|
| backbone pageable | **1.4.8**, 1.3.2 | [changelog](https://github.com/backbone-paginator/backbone-pageable#change-log) | [homepage](https://github.com/wyuenho/backbone-pageable) | Yes
|
|
69
|
-
| backbone routefilter | **0.2.
|
|
69
|
+
| backbone routefilter | **0.2.1** | [changelog](https://github.com/boazsender/backbone.routefilter#release-history) | [homepage](https://github.com/boazsender/backbone.routefilter) | No
|
|
70
70
|
| backbone stickit | **0.8.0**, 0.7.0, 0.6.3 | [changelog](http://nytimes.github.io/backbone.stickit/#change-log) | [homepage](http://nytimes.github.io/backbone.stickit/) | Yes
|
|
71
71
|
| backbone validation | **0.9.1**, 0.8.1 | [changelog](https://github.com/thedersen/backbone.validation#release-notes) | [homepage](https://github.com/thedersen/backbone.validation) | Yes
|
|
72
72
|
| backbone virtualcollection | **0.4.15** | [changelog](https://github.com/p3drosola/Backbone.VirtualCollection#changelog) | [homepage](https://github.com/p3drosola/Backbone.VirtualCollection) | Yes
|
data/lib/js_stack/version.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// MarionetteJS (Backbone.Marionette)
|
|
2
2
|
// ----------------------------------
|
|
3
|
-
// v1.8.
|
|
3
|
+
// v1.8.5
|
|
4
4
|
//
|
|
5
5
|
// Copyright (c)2014 Derick Bailey, Muted Solutions, LLC.
|
|
6
6
|
// Distributed under MIT license
|
|
@@ -17,637 +17,459 @@
|
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
// -------------------
|
|
22
|
-
// v0.1.2
|
|
23
|
-
//
|
|
24
|
-
// Copyright (c)2014 Derick Bailey, Muted Solutions, LLC.
|
|
25
|
-
// Distributed under MIT license
|
|
26
|
-
//
|
|
27
|
-
// http://github.com/marionettejs/backbone.babysitter
|
|
28
|
-
|
|
29
|
-
(function(root, factory) {
|
|
30
|
-
|
|
31
|
-
if (typeof define === 'function' && define.amd) {
|
|
32
|
-
define(['exports', 'backbone', 'underscore'], function(exports, Backbone, _) {
|
|
33
|
-
return factory(Backbone, _);
|
|
34
|
-
});
|
|
35
|
-
} else if (typeof exports !== 'undefined') {
|
|
36
|
-
var Backbone = require('backbone');
|
|
37
|
-
var _ = require('underscore');
|
|
38
|
-
module.exports = factory(Backbone, _);
|
|
39
|
-
} else {
|
|
40
|
-
factory(root.Backbone, root._);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
}(this, function(Backbone, _) {
|
|
20
|
+
var Marionette = (function(global, Backbone, _){
|
|
44
21
|
"use strict";
|
|
45
22
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
//
|
|
49
|
-
// -----------------------------
|
|
23
|
+
// Backbone.BabySitter
|
|
24
|
+
// -------------------
|
|
25
|
+
// v0.1.4
|
|
50
26
|
//
|
|
51
|
-
//
|
|
52
|
-
//
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
27
|
+
// Copyright (c)2014 Derick Bailey, Muted Solutions, LLC.
|
|
28
|
+
// Distributed under MIT license
|
|
29
|
+
//
|
|
30
|
+
// http://github.com/marionettejs/backbone.babysitter
|
|
31
|
+
(function(Backbone, _) {
|
|
32
|
+
"use strict";
|
|
33
|
+
var previousChildViewContainer = Backbone.ChildViewContainer;
|
|
34
|
+
// BabySitter.ChildViewContainer
|
|
35
|
+
// -----------------------------
|
|
36
|
+
//
|
|
37
|
+
// Provide a container to store, retrieve and
|
|
38
|
+
// shut down child views.
|
|
39
|
+
Backbone.ChildViewContainer = function(Backbone, _) {
|
|
40
|
+
// Container Constructor
|
|
41
|
+
// ---------------------
|
|
42
|
+
var Container = function(views) {
|
|
43
|
+
this._views = {};
|
|
44
|
+
this._indexByModel = {};
|
|
45
|
+
this._indexByCustom = {};
|
|
46
|
+
this._updateLength();
|
|
47
|
+
_.each(views, this.add, this);
|
|
48
|
+
};
|
|
49
|
+
// Container Methods
|
|
50
|
+
// -----------------
|
|
51
|
+
_.extend(Container.prototype, {
|
|
52
|
+
// Add a view to this container. Stores the view
|
|
53
|
+
// by `cid` and makes it searchable by the model
|
|
54
|
+
// cid (and model itself). Optionally specify
|
|
55
|
+
// a custom key to store an retrieve the view.
|
|
56
|
+
add: function(view, customIndex) {
|
|
57
|
+
var viewCid = view.cid;
|
|
58
|
+
// store the view
|
|
59
|
+
this._views[viewCid] = view;
|
|
60
|
+
// index it by model
|
|
61
|
+
if (view.model) {
|
|
62
|
+
this._indexByModel[view.model.cid] = viewCid;
|
|
63
|
+
}
|
|
64
|
+
// index by custom
|
|
65
|
+
if (customIndex) {
|
|
66
|
+
this._indexByCustom[customIndex] = viewCid;
|
|
67
|
+
}
|
|
68
|
+
this._updateLength();
|
|
69
|
+
return this;
|
|
70
|
+
},
|
|
71
|
+
// Find a view by the model that was attached to
|
|
72
|
+
// it. Uses the model's `cid` to find it.
|
|
73
|
+
findByModel: function(model) {
|
|
74
|
+
return this.findByModelCid(model.cid);
|
|
75
|
+
},
|
|
76
|
+
// Find a view by the `cid` of the model that was attached to
|
|
77
|
+
// it. Uses the model's `cid` to find the view `cid` and
|
|
78
|
+
// retrieve the view using it.
|
|
79
|
+
findByModelCid: function(modelCid) {
|
|
80
|
+
var viewCid = this._indexByModel[modelCid];
|
|
81
|
+
return this.findByCid(viewCid);
|
|
82
|
+
},
|
|
83
|
+
// Find a view by a custom indexer.
|
|
84
|
+
findByCustom: function(index) {
|
|
85
|
+
var viewCid = this._indexByCustom[index];
|
|
86
|
+
return this.findByCid(viewCid);
|
|
87
|
+
},
|
|
88
|
+
// Find by index. This is not guaranteed to be a
|
|
89
|
+
// stable index.
|
|
90
|
+
findByIndex: function(index) {
|
|
91
|
+
return _.values(this._views)[index];
|
|
92
|
+
},
|
|
93
|
+
// retrieve a view by its `cid` directly
|
|
94
|
+
findByCid: function(cid) {
|
|
95
|
+
return this._views[cid];
|
|
96
|
+
},
|
|
97
|
+
// Remove a view
|
|
98
|
+
remove: function(view) {
|
|
99
|
+
var viewCid = view.cid;
|
|
100
|
+
// delete model index
|
|
101
|
+
if (view.model) {
|
|
102
|
+
delete this._indexByModel[view.model.cid];
|
|
103
|
+
}
|
|
104
|
+
// delete custom index
|
|
105
|
+
_.any(this._indexByCustom, function(cid, key) {
|
|
106
|
+
if (cid === viewCid) {
|
|
107
|
+
delete this._indexByCustom[key];
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
110
|
+
}, this);
|
|
111
|
+
// remove the view from the container
|
|
112
|
+
delete this._views[viewCid];
|
|
113
|
+
// update the length
|
|
114
|
+
this._updateLength();
|
|
115
|
+
return this;
|
|
116
|
+
},
|
|
117
|
+
// Call a method on every view in the container,
|
|
118
|
+
// passing parameters to the call method one at a
|
|
119
|
+
// time, like `function.call`.
|
|
120
|
+
call: function(method) {
|
|
121
|
+
this.apply(method, _.tail(arguments));
|
|
122
|
+
},
|
|
123
|
+
// Apply a method on every view in the container,
|
|
124
|
+
// passing parameters to the call method one at a
|
|
125
|
+
// time, like `function.apply`.
|
|
126
|
+
apply: function(method, args) {
|
|
127
|
+
_.each(this._views, function(view) {
|
|
128
|
+
if (_.isFunction(view[method])) {
|
|
129
|
+
view[method].apply(view, args || []);
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
},
|
|
133
|
+
// Update the `.length` attribute on this container
|
|
134
|
+
_updateLength: function() {
|
|
135
|
+
this.length = _.size(this._views);
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
// Borrowing this code from Backbone.Collection:
|
|
139
|
+
// http://backbonejs.org/docs/backbone.html#section-106
|
|
140
|
+
//
|
|
141
|
+
// Mix in methods from Underscore, for iteration, and other
|
|
142
|
+
// collection related features.
|
|
143
|
+
var methods = [ "forEach", "each", "map", "find", "detect", "filter", "select", "reject", "every", "all", "some", "any", "include", "contains", "invoke", "toArray", "first", "initial", "rest", "last", "without", "isEmpty", "pluck" ];
|
|
144
|
+
_.each(methods, function(method) {
|
|
145
|
+
Container.prototype[method] = function() {
|
|
146
|
+
var views = _.values(this._views);
|
|
147
|
+
var args = [ views ].concat(_.toArray(arguments));
|
|
148
|
+
return _[method].apply(_, args);
|
|
149
|
+
};
|
|
150
|
+
});
|
|
151
|
+
// return the public API
|
|
152
|
+
return Container;
|
|
153
|
+
}(Backbone, _);
|
|
154
|
+
Backbone.ChildViewContainer.VERSION = "0.1.4";
|
|
155
|
+
Backbone.ChildViewContainer.noConflict = function() {
|
|
156
|
+
Backbone.ChildViewContainer = previousChildViewContainer;
|
|
157
|
+
return this;
|
|
66
158
|
};
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
159
|
+
return Backbone.ChildViewContainer;
|
|
160
|
+
})(Backbone, _);
|
|
161
|
+
// Backbone.Wreqr (Backbone.Marionette)
|
|
162
|
+
// ----------------------------------
|
|
163
|
+
// v1.3.1
|
|
164
|
+
//
|
|
165
|
+
// Copyright (c)2014 Derick Bailey, Muted Solutions, LLC.
|
|
166
|
+
// Distributed under MIT license
|
|
167
|
+
//
|
|
168
|
+
// http://github.com/marionettejs/backbone.wreqr
|
|
169
|
+
(function(Backbone, _) {
|
|
170
|
+
"use strict";
|
|
171
|
+
var previousWreqr = Backbone.Wreqr;
|
|
172
|
+
var Wreqr = Backbone.Wreqr = {};
|
|
173
|
+
Backbone.Wreqr.VERSION = "1.3.1";
|
|
174
|
+
Backbone.Wreqr.noConflict = function() {
|
|
175
|
+
Backbone.Wreqr = previousWreqr;
|
|
176
|
+
return this;
|
|
177
|
+
};
|
|
178
|
+
// Handlers
|
|
179
|
+
// --------
|
|
180
|
+
// A registry of functions to call, given a name
|
|
181
|
+
Wreqr.Handlers = function(Backbone, _) {
|
|
182
|
+
"use strict";
|
|
183
|
+
// Constructor
|
|
184
|
+
// -----------
|
|
185
|
+
var Handlers = function(options) {
|
|
186
|
+
this.options = options;
|
|
187
|
+
this._wreqrHandlers = {};
|
|
188
|
+
if (_.isFunction(this.initialize)) {
|
|
189
|
+
this.initialize(options);
|
|
86
190
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
191
|
+
};
|
|
192
|
+
Handlers.extend = Backbone.Model.extend;
|
|
193
|
+
// Instance Members
|
|
194
|
+
// ----------------
|
|
195
|
+
_.extend(Handlers.prototype, Backbone.Events, {
|
|
196
|
+
// Add multiple handlers using an object literal configuration
|
|
197
|
+
setHandlers: function(handlers) {
|
|
198
|
+
_.each(handlers, function(handler, name) {
|
|
199
|
+
var context = null;
|
|
200
|
+
if (_.isObject(handler) && !_.isFunction(handler)) {
|
|
201
|
+
context = handler.context;
|
|
202
|
+
handler = handler.callback;
|
|
203
|
+
}
|
|
204
|
+
this.setHandler(name, handler, context);
|
|
205
|
+
}, this);
|
|
206
|
+
},
|
|
207
|
+
// Add a handler for the given name, with an
|
|
208
|
+
// optional context to run the handler within
|
|
209
|
+
setHandler: function(name, handler, context) {
|
|
210
|
+
var config = {
|
|
211
|
+
callback: handler,
|
|
212
|
+
context: context
|
|
213
|
+
};
|
|
214
|
+
this._wreqrHandlers[name] = config;
|
|
215
|
+
this.trigger("handler:add", name, handler, context);
|
|
216
|
+
},
|
|
217
|
+
// Determine whether or not a handler is registered
|
|
218
|
+
hasHandler: function(name) {
|
|
219
|
+
return !!this._wreqrHandlers[name];
|
|
220
|
+
},
|
|
221
|
+
// Get the currently registered handler for
|
|
222
|
+
// the specified name. Throws an exception if
|
|
223
|
+
// no handler is found.
|
|
224
|
+
getHandler: function(name) {
|
|
225
|
+
var config = this._wreqrHandlers[name];
|
|
226
|
+
if (!config) {
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
return function() {
|
|
230
|
+
var args = Array.prototype.slice.apply(arguments);
|
|
231
|
+
return config.callback.apply(config.context, args);
|
|
232
|
+
};
|
|
233
|
+
},
|
|
234
|
+
// Remove a handler for the specified name
|
|
235
|
+
removeHandler: function(name) {
|
|
236
|
+
delete this._wreqrHandlers[name];
|
|
237
|
+
},
|
|
238
|
+
// Remove all handlers from this registry
|
|
239
|
+
removeAllHandlers: function() {
|
|
240
|
+
this._wreqrHandlers = {};
|
|
91
241
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
var viewCid = this._indexByModel[modelCid];
|
|
108
|
-
return this.findByCid(viewCid);
|
|
109
|
-
},
|
|
110
|
-
|
|
111
|
-
// Find a view by a custom indexer.
|
|
112
|
-
findByCustom: function(index){
|
|
113
|
-
var viewCid = this._indexByCustom[index];
|
|
114
|
-
return this.findByCid(viewCid);
|
|
115
|
-
},
|
|
116
|
-
|
|
117
|
-
// Find by index. This is not guaranteed to be a
|
|
118
|
-
// stable index.
|
|
119
|
-
findByIndex: function(index){
|
|
120
|
-
return _.values(this._views)[index];
|
|
121
|
-
},
|
|
122
|
-
|
|
123
|
-
// retrieve a view by its `cid` directly
|
|
124
|
-
findByCid: function(cid){
|
|
125
|
-
return this._views[cid];
|
|
126
|
-
},
|
|
127
|
-
|
|
128
|
-
// Remove a view
|
|
129
|
-
remove: function(view){
|
|
130
|
-
var viewCid = view.cid;
|
|
131
|
-
|
|
132
|
-
// delete model index
|
|
133
|
-
if (view.model){
|
|
134
|
-
delete this._indexByModel[view.model.cid];
|
|
242
|
+
});
|
|
243
|
+
return Handlers;
|
|
244
|
+
}(Backbone, _);
|
|
245
|
+
// Wreqr.CommandStorage
|
|
246
|
+
// --------------------
|
|
247
|
+
//
|
|
248
|
+
// Store and retrieve commands for execution.
|
|
249
|
+
Wreqr.CommandStorage = function() {
|
|
250
|
+
"use strict";
|
|
251
|
+
// Constructor function
|
|
252
|
+
var CommandStorage = function(options) {
|
|
253
|
+
this.options = options;
|
|
254
|
+
this._commands = {};
|
|
255
|
+
if (_.isFunction(this.initialize)) {
|
|
256
|
+
this.initialize(options);
|
|
135
257
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
258
|
+
};
|
|
259
|
+
// Instance methods
|
|
260
|
+
_.extend(CommandStorage.prototype, Backbone.Events, {
|
|
261
|
+
// Get an object literal by command name, that contains
|
|
262
|
+
// the `commandName` and the `instances` of all commands
|
|
263
|
+
// represented as an array of arguments to process
|
|
264
|
+
getCommands: function(commandName) {
|
|
265
|
+
var commands = this._commands[commandName];
|
|
266
|
+
// we don't have it, so add it
|
|
267
|
+
if (!commands) {
|
|
268
|
+
// build the configuration
|
|
269
|
+
commands = {
|
|
270
|
+
command: commandName,
|
|
271
|
+
instances: []
|
|
272
|
+
};
|
|
273
|
+
// store it
|
|
274
|
+
this._commands[commandName] = commands;
|
|
142
275
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
//
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
276
|
+
return commands;
|
|
277
|
+
},
|
|
278
|
+
// Add a command by name, to the storage and store the
|
|
279
|
+
// args for the command
|
|
280
|
+
addCommand: function(commandName, args) {
|
|
281
|
+
var command = this.getCommands(commandName);
|
|
282
|
+
command.instances.push(args);
|
|
283
|
+
},
|
|
284
|
+
// Clear all commands for the given `commandName`
|
|
285
|
+
clearCommands: function(commandName) {
|
|
286
|
+
var command = this.getCommands(commandName);
|
|
287
|
+
command.instances = [];
|
|
288
|
+
}
|
|
289
|
+
});
|
|
290
|
+
return CommandStorage;
|
|
291
|
+
}();
|
|
292
|
+
// Wreqr.Commands
|
|
293
|
+
// --------------
|
|
294
|
+
//
|
|
295
|
+
// A simple command pattern implementation. Register a command
|
|
296
|
+
// handler and execute it.
|
|
297
|
+
Wreqr.Commands = function(Wreqr) {
|
|
298
|
+
"use strict";
|
|
299
|
+
return Wreqr.Handlers.extend({
|
|
300
|
+
// default storage type
|
|
301
|
+
storageType: Wreqr.CommandStorage,
|
|
302
|
+
constructor: function(options) {
|
|
303
|
+
this.options = options || {};
|
|
304
|
+
this._initializeStorage(this.options);
|
|
305
|
+
this.on("handler:add", this._executeCommands, this);
|
|
306
|
+
var args = Array.prototype.slice.call(arguments);
|
|
307
|
+
Wreqr.Handlers.prototype.constructor.apply(this, args);
|
|
308
|
+
},
|
|
309
|
+
// Execute a named command with the supplied args
|
|
310
|
+
execute: function(name, args) {
|
|
311
|
+
name = arguments[0];
|
|
312
|
+
args = Array.prototype.slice.call(arguments, 1);
|
|
313
|
+
if (this.hasHandler(name)) {
|
|
314
|
+
this.getHandler(name).apply(this, args);
|
|
315
|
+
} else {
|
|
316
|
+
this.storage.addCommand(name, args);
|
|
167
317
|
}
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
318
|
+
},
|
|
319
|
+
// Internal method to handle bulk execution of stored commands
|
|
320
|
+
_executeCommands: function(name, handler, context) {
|
|
321
|
+
var command = this.storage.getCommands(name);
|
|
322
|
+
// loop through and execute all the stored command instances
|
|
323
|
+
_.each(command.instances, function(args) {
|
|
324
|
+
handler.apply(context, args);
|
|
325
|
+
});
|
|
326
|
+
this.storage.clearCommands(name);
|
|
327
|
+
},
|
|
328
|
+
// Internal method to initialize storage either from the type's
|
|
329
|
+
// `storageType` or the instance `options.storageType`.
|
|
330
|
+
_initializeStorage: function(options) {
|
|
331
|
+
var storage;
|
|
332
|
+
var StorageType = options.storageType || this.storageType;
|
|
333
|
+
if (_.isFunction(StorageType)) {
|
|
334
|
+
storage = new StorageType();
|
|
335
|
+
} else {
|
|
336
|
+
storage = StorageType;
|
|
337
|
+
}
|
|
338
|
+
this.storage = storage;
|
|
339
|
+
}
|
|
340
|
+
});
|
|
341
|
+
}(Wreqr);
|
|
342
|
+
// Wreqr.RequestResponse
|
|
343
|
+
// ---------------------
|
|
344
|
+
//
|
|
345
|
+
// A simple request/response implementation. Register a
|
|
346
|
+
// request handler, and return a response from it
|
|
347
|
+
Wreqr.RequestResponse = function(Wreqr) {
|
|
348
|
+
"use strict";
|
|
349
|
+
return Wreqr.Handlers.extend({
|
|
350
|
+
request: function() {
|
|
351
|
+
var name = arguments[0];
|
|
352
|
+
var args = Array.prototype.slice.call(arguments, 1);
|
|
353
|
+
if (this.hasHandler(name)) {
|
|
354
|
+
return this.getHandler(name).apply(this, args);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
});
|
|
358
|
+
}(Wreqr);
|
|
359
|
+
// Event Aggregator
|
|
360
|
+
// ----------------
|
|
361
|
+
// A pub-sub object that can be used to decouple various parts
|
|
362
|
+
// of an application through event-driven architecture.
|
|
363
|
+
Wreqr.EventAggregator = function(Backbone, _) {
|
|
364
|
+
"use strict";
|
|
365
|
+
var EA = function() {};
|
|
366
|
+
// Copy the `extend` function used by Backbone's classes
|
|
367
|
+
EA.extend = Backbone.Model.extend;
|
|
368
|
+
// Copy the basic Backbone.Events on to the event aggregator
|
|
369
|
+
_.extend(EA.prototype, Backbone.Events);
|
|
370
|
+
return EA;
|
|
371
|
+
}(Backbone, _);
|
|
372
|
+
// Wreqr.Channel
|
|
373
|
+
// --------------
|
|
179
374
|
//
|
|
180
|
-
//
|
|
181
|
-
//
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
var views = _.values(this._views);
|
|
190
|
-
var args = [views].concat(_.toArray(arguments));
|
|
191
|
-
return _[method].apply(_, args);
|
|
375
|
+
// An object that wraps the three messaging systems:
|
|
376
|
+
// EventAggregator, RequestResponse, Commands
|
|
377
|
+
Wreqr.Channel = function(Wreqr) {
|
|
378
|
+
"use strict";
|
|
379
|
+
var Channel = function(channelName) {
|
|
380
|
+
this.vent = new Backbone.Wreqr.EventAggregator();
|
|
381
|
+
this.reqres = new Backbone.Wreqr.RequestResponse();
|
|
382
|
+
this.commands = new Backbone.Wreqr.Commands();
|
|
383
|
+
this.channelName = channelName;
|
|
192
384
|
};
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
//
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
});
|
|
226
|
-
} else if (typeof exports !== 'undefined') {
|
|
227
|
-
var Backbone = require('backbone');
|
|
228
|
-
var _ = require('underscore');
|
|
229
|
-
factory(exports, Backbone, _);
|
|
230
|
-
} else {
|
|
231
|
-
factory({}, root.Backbone, root._);
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
}(this, function(Wreqr, Backbone, _) {
|
|
235
|
-
"use strict";
|
|
236
|
-
|
|
237
|
-
var previousWreqr = Backbone.Wreqr;
|
|
238
|
-
|
|
239
|
-
Backbone.Wreqr = Wreqr;
|
|
240
|
-
|
|
241
|
-
Backbone.Wreqr.VERSION = '1.3.0';
|
|
242
|
-
|
|
243
|
-
Backbone.Wreqr.noConflict = function () {
|
|
244
|
-
Backbone.Wreqr = previousWreqr;
|
|
245
|
-
return this;
|
|
246
|
-
};
|
|
247
|
-
|
|
248
|
-
// Handlers
|
|
249
|
-
// --------
|
|
250
|
-
// A registry of functions to call, given a name
|
|
251
|
-
|
|
252
|
-
Wreqr.Handlers = (function(Backbone, _){
|
|
253
|
-
"use strict";
|
|
254
|
-
|
|
255
|
-
// Constructor
|
|
256
|
-
// -----------
|
|
257
|
-
|
|
258
|
-
var Handlers = function(options){
|
|
259
|
-
this.options = options;
|
|
260
|
-
this._wreqrHandlers = {};
|
|
261
|
-
|
|
262
|
-
if (_.isFunction(this.initialize)){
|
|
263
|
-
this.initialize(options);
|
|
264
|
-
}
|
|
265
|
-
};
|
|
266
|
-
|
|
267
|
-
Handlers.extend = Backbone.Model.extend;
|
|
268
|
-
|
|
269
|
-
// Instance Members
|
|
270
|
-
// ----------------
|
|
271
|
-
|
|
272
|
-
_.extend(Handlers.prototype, Backbone.Events, {
|
|
273
|
-
|
|
274
|
-
// Add multiple handlers using an object literal configuration
|
|
275
|
-
setHandlers: function(handlers){
|
|
276
|
-
_.each(handlers, function(handler, name){
|
|
277
|
-
var context = null;
|
|
278
|
-
|
|
279
|
-
if (_.isObject(handler) && !_.isFunction(handler)){
|
|
280
|
-
context = handler.context;
|
|
281
|
-
handler = handler.callback;
|
|
385
|
+
_.extend(Channel.prototype, {
|
|
386
|
+
// Remove all handlers from the messaging systems of this channel
|
|
387
|
+
reset: function() {
|
|
388
|
+
this.vent.off();
|
|
389
|
+
this.vent.stopListening();
|
|
390
|
+
this.reqres.removeAllHandlers();
|
|
391
|
+
this.commands.removeAllHandlers();
|
|
392
|
+
return this;
|
|
393
|
+
},
|
|
394
|
+
// Connect a hash of events; one for each messaging system
|
|
395
|
+
connectEvents: function(hash, context) {
|
|
396
|
+
this._connect("vent", hash, context);
|
|
397
|
+
return this;
|
|
398
|
+
},
|
|
399
|
+
connectCommands: function(hash, context) {
|
|
400
|
+
this._connect("commands", hash, context);
|
|
401
|
+
return this;
|
|
402
|
+
},
|
|
403
|
+
connectRequests: function(hash, context) {
|
|
404
|
+
this._connect("reqres", hash, context);
|
|
405
|
+
return this;
|
|
406
|
+
},
|
|
407
|
+
// Attach the handlers to a given message system `type`
|
|
408
|
+
_connect: function(type, hash, context) {
|
|
409
|
+
if (!hash) {
|
|
410
|
+
return;
|
|
411
|
+
}
|
|
412
|
+
context = context || this;
|
|
413
|
+
var method = type === "vent" ? "on" : "setHandler";
|
|
414
|
+
_.each(hash, function(fn, eventName) {
|
|
415
|
+
this[type][method](eventName, _.bind(fn, context));
|
|
416
|
+
}, this);
|
|
282
417
|
}
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
//
|
|
289
|
-
//
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
418
|
+
});
|
|
419
|
+
return Channel;
|
|
420
|
+
}(Wreqr);
|
|
421
|
+
// Wreqr.Radio
|
|
422
|
+
// --------------
|
|
423
|
+
//
|
|
424
|
+
// An object that lets you communicate with many channels.
|
|
425
|
+
Wreqr.radio = function(Wreqr) {
|
|
426
|
+
"use strict";
|
|
427
|
+
var Radio = function() {
|
|
428
|
+
this._channels = {};
|
|
429
|
+
this.vent = {};
|
|
430
|
+
this.commands = {};
|
|
431
|
+
this.reqres = {};
|
|
432
|
+
this._proxyMethods();
|
|
294
433
|
};
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
434
|
+
_.extend(Radio.prototype, {
|
|
435
|
+
channel: function(channelName) {
|
|
436
|
+
if (!channelName) {
|
|
437
|
+
throw new Error("Channel must receive a name");
|
|
438
|
+
}
|
|
439
|
+
return this._getChannel(channelName);
|
|
440
|
+
},
|
|
441
|
+
_getChannel: function(channelName) {
|
|
442
|
+
var channel = this._channels[channelName];
|
|
443
|
+
if (!channel) {
|
|
444
|
+
channel = new Wreqr.Channel(channelName);
|
|
445
|
+
this._channels[channelName] = channel;
|
|
446
|
+
}
|
|
447
|
+
return channel;
|
|
448
|
+
},
|
|
449
|
+
_proxyMethods: function() {
|
|
450
|
+
_.each([ "vent", "commands", "reqres" ], function(system) {
|
|
451
|
+
_.each(messageSystems[system], function(method) {
|
|
452
|
+
this[system][method] = proxyMethod(this, system, method);
|
|
453
|
+
}, this);
|
|
454
|
+
}, this);
|
|
455
|
+
}
|
|
456
|
+
});
|
|
457
|
+
var messageSystems = {
|
|
458
|
+
vent: [ "on", "off", "trigger", "once", "stopListening", "listenTo", "listenToOnce" ],
|
|
459
|
+
commands: [ "execute", "setHandler", "setHandlers", "removeHandler", "removeAllHandlers" ],
|
|
460
|
+
reqres: [ "request", "setHandler", "setHandlers", "removeHandler", "removeAllHandlers" ]
|
|
319
461
|
};
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
},
|
|
326
|
-
|
|
327
|
-
// Remove all handlers from this registry
|
|
328
|
-
removeAllHandlers: function(){
|
|
329
|
-
this._wreqrHandlers = {};
|
|
330
|
-
}
|
|
331
|
-
});
|
|
332
|
-
|
|
333
|
-
return Handlers;
|
|
334
|
-
})(Backbone, _);
|
|
335
|
-
|
|
336
|
-
// Wreqr.CommandStorage
|
|
337
|
-
// --------------------
|
|
338
|
-
//
|
|
339
|
-
// Store and retrieve commands for execution.
|
|
340
|
-
Wreqr.CommandStorage = (function(){
|
|
341
|
-
"use strict";
|
|
342
|
-
|
|
343
|
-
// Constructor function
|
|
344
|
-
var CommandStorage = function(options){
|
|
345
|
-
this.options = options;
|
|
346
|
-
this._commands = {};
|
|
347
|
-
|
|
348
|
-
if (_.isFunction(this.initialize)){
|
|
349
|
-
this.initialize(options);
|
|
350
|
-
}
|
|
351
|
-
};
|
|
352
|
-
|
|
353
|
-
// Instance methods
|
|
354
|
-
_.extend(CommandStorage.prototype, Backbone.Events, {
|
|
355
|
-
|
|
356
|
-
// Get an object literal by command name, that contains
|
|
357
|
-
// the `commandName` and the `instances` of all commands
|
|
358
|
-
// represented as an array of arguments to process
|
|
359
|
-
getCommands: function(commandName){
|
|
360
|
-
var commands = this._commands[commandName];
|
|
361
|
-
|
|
362
|
-
// we don't have it, so add it
|
|
363
|
-
if (!commands){
|
|
364
|
-
|
|
365
|
-
// build the configuration
|
|
366
|
-
commands = {
|
|
367
|
-
command: commandName,
|
|
368
|
-
instances: []
|
|
462
|
+
var proxyMethod = function(radio, system, method) {
|
|
463
|
+
return function(channelName) {
|
|
464
|
+
var messageSystem = radio._getChannel(channelName)[system];
|
|
465
|
+
var args = Array.prototype.slice.call(arguments, 1);
|
|
466
|
+
return messageSystem[method].apply(messageSystem, args);
|
|
369
467
|
};
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
return commands;
|
|
376
|
-
},
|
|
377
|
-
|
|
378
|
-
// Add a command by name, to the storage and store the
|
|
379
|
-
// args for the command
|
|
380
|
-
addCommand: function(commandName, args){
|
|
381
|
-
var command = this.getCommands(commandName);
|
|
382
|
-
command.instances.push(args);
|
|
383
|
-
},
|
|
384
|
-
|
|
385
|
-
// Clear all commands for the given `commandName`
|
|
386
|
-
clearCommands: function(commandName){
|
|
387
|
-
var command = this.getCommands(commandName);
|
|
388
|
-
command.instances = [];
|
|
389
|
-
}
|
|
390
|
-
});
|
|
391
|
-
|
|
392
|
-
return CommandStorage;
|
|
393
|
-
})();
|
|
394
|
-
|
|
395
|
-
// Wreqr.Commands
|
|
396
|
-
// --------------
|
|
397
|
-
//
|
|
398
|
-
// A simple command pattern implementation. Register a command
|
|
399
|
-
// handler and execute it.
|
|
400
|
-
Wreqr.Commands = (function(Wreqr){
|
|
401
|
-
"use strict";
|
|
402
|
-
|
|
403
|
-
return Wreqr.Handlers.extend({
|
|
404
|
-
// default storage type
|
|
405
|
-
storageType: Wreqr.CommandStorage,
|
|
406
|
-
|
|
407
|
-
constructor: function(options){
|
|
408
|
-
this.options = options || {};
|
|
409
|
-
|
|
410
|
-
this._initializeStorage(this.options);
|
|
411
|
-
this.on("handler:add", this._executeCommands, this);
|
|
412
|
-
|
|
413
|
-
var args = Array.prototype.slice.call(arguments);
|
|
414
|
-
Wreqr.Handlers.prototype.constructor.apply(this, args);
|
|
415
|
-
},
|
|
416
|
-
|
|
417
|
-
// Execute a named command with the supplied args
|
|
418
|
-
execute: function(name, args){
|
|
419
|
-
name = arguments[0];
|
|
420
|
-
args = Array.prototype.slice.call(arguments, 1);
|
|
421
|
-
|
|
422
|
-
if (this.hasHandler(name)){
|
|
423
|
-
this.getHandler(name).apply(this, args);
|
|
424
|
-
} else {
|
|
425
|
-
this.storage.addCommand(name, args);
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
},
|
|
429
|
-
|
|
430
|
-
// Internal method to handle bulk execution of stored commands
|
|
431
|
-
_executeCommands: function(name, handler, context){
|
|
432
|
-
var command = this.storage.getCommands(name);
|
|
433
|
-
|
|
434
|
-
// loop through and execute all the stored command instances
|
|
435
|
-
_.each(command.instances, function(args){
|
|
436
|
-
handler.apply(context, args);
|
|
437
|
-
});
|
|
438
|
-
|
|
439
|
-
this.storage.clearCommands(name);
|
|
440
|
-
},
|
|
441
|
-
|
|
442
|
-
// Internal method to initialize storage either from the type's
|
|
443
|
-
// `storageType` or the instance `options.storageType`.
|
|
444
|
-
_initializeStorage: function(options){
|
|
445
|
-
var storage;
|
|
446
|
-
|
|
447
|
-
var StorageType = options.storageType || this.storageType;
|
|
448
|
-
if (_.isFunction(StorageType)){
|
|
449
|
-
storage = new StorageType();
|
|
450
|
-
} else {
|
|
451
|
-
storage = StorageType;
|
|
452
|
-
}
|
|
453
|
-
|
|
454
|
-
this.storage = storage;
|
|
455
|
-
}
|
|
456
|
-
});
|
|
457
|
-
|
|
458
|
-
})(Wreqr);
|
|
459
|
-
|
|
460
|
-
// Wreqr.RequestResponse
|
|
461
|
-
// ---------------------
|
|
462
|
-
//
|
|
463
|
-
// A simple request/response implementation. Register a
|
|
464
|
-
// request handler, and return a response from it
|
|
465
|
-
Wreqr.RequestResponse = (function(Wreqr){
|
|
466
|
-
"use strict";
|
|
467
|
-
|
|
468
|
-
return Wreqr.Handlers.extend({
|
|
469
|
-
request: function(){
|
|
470
|
-
var name = arguments[0];
|
|
471
|
-
var args = Array.prototype.slice.call(arguments, 1);
|
|
472
|
-
if (this.hasHandler(name)) {
|
|
473
|
-
return this.getHandler(name).apply(this, args);
|
|
474
|
-
}
|
|
475
|
-
}
|
|
476
|
-
});
|
|
477
|
-
|
|
478
|
-
})(Wreqr);
|
|
479
|
-
|
|
480
|
-
// Event Aggregator
|
|
481
|
-
// ----------------
|
|
482
|
-
// A pub-sub object that can be used to decouple various parts
|
|
483
|
-
// of an application through event-driven architecture.
|
|
484
|
-
|
|
485
|
-
Wreqr.EventAggregator = (function(Backbone, _){
|
|
486
|
-
"use strict";
|
|
487
|
-
var EA = function(){};
|
|
488
|
-
|
|
489
|
-
// Copy the `extend` function used by Backbone's classes
|
|
490
|
-
EA.extend = Backbone.Model.extend;
|
|
491
|
-
|
|
492
|
-
// Copy the basic Backbone.Events on to the event aggregator
|
|
493
|
-
_.extend(EA.prototype, Backbone.Events);
|
|
494
|
-
|
|
495
|
-
return EA;
|
|
496
|
-
})(Backbone, _);
|
|
497
|
-
|
|
498
|
-
// Wreqr.Channel
|
|
499
|
-
// --------------
|
|
500
|
-
//
|
|
501
|
-
// An object that wraps the three messaging systems:
|
|
502
|
-
// EventAggregator, RequestResponse, Commands
|
|
503
|
-
Wreqr.Channel = (function(Wreqr){
|
|
504
|
-
"use strict";
|
|
505
|
-
|
|
506
|
-
var Channel = function(channelName) {
|
|
507
|
-
this.vent = new Backbone.Wreqr.EventAggregator();
|
|
508
|
-
this.reqres = new Backbone.Wreqr.RequestResponse();
|
|
509
|
-
this.commands = new Backbone.Wreqr.Commands();
|
|
510
|
-
this.channelName = channelName;
|
|
511
|
-
};
|
|
512
|
-
|
|
513
|
-
_.extend(Channel.prototype, {
|
|
514
|
-
|
|
515
|
-
// Remove all handlers from the messaging systems of this channel
|
|
516
|
-
reset: function() {
|
|
517
|
-
this.vent.off();
|
|
518
|
-
this.vent.stopListening();
|
|
519
|
-
this.reqres.removeAllHandlers();
|
|
520
|
-
this.commands.removeAllHandlers();
|
|
521
|
-
return this;
|
|
522
|
-
},
|
|
523
|
-
|
|
524
|
-
// Connect a hash of events; one for each messaging system
|
|
525
|
-
connectEvents: function(hash, context) {
|
|
526
|
-
this._connect('vent', hash, context);
|
|
527
|
-
return this;
|
|
528
|
-
},
|
|
529
|
-
|
|
530
|
-
connectCommands: function(hash, context) {
|
|
531
|
-
this._connect('commands', hash, context);
|
|
532
|
-
return this;
|
|
533
|
-
},
|
|
534
|
-
|
|
535
|
-
connectRequests: function(hash, context) {
|
|
536
|
-
this._connect('reqres', hash, context);
|
|
537
|
-
return this;
|
|
538
|
-
},
|
|
539
|
-
|
|
540
|
-
// Attach the handlers to a given message system `type`
|
|
541
|
-
_connect: function(type, hash, context) {
|
|
542
|
-
if (!hash) {
|
|
543
|
-
return;
|
|
544
|
-
}
|
|
545
|
-
|
|
546
|
-
context = context || this;
|
|
547
|
-
var method = (type === 'vent') ? 'on' : 'setHandler';
|
|
548
|
-
|
|
549
|
-
_.each(hash, function(fn, eventName) {
|
|
550
|
-
this[type][method](eventName, _.bind(fn, context));
|
|
551
|
-
}, this);
|
|
552
|
-
}
|
|
553
|
-
});
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
return Channel;
|
|
557
|
-
})(Wreqr);
|
|
558
|
-
|
|
559
|
-
// Wreqr.Radio
|
|
560
|
-
// --------------
|
|
561
|
-
//
|
|
562
|
-
// An object that lets you communicate with many channels.
|
|
563
|
-
Wreqr.radio = (function(Wreqr){
|
|
564
|
-
"use strict";
|
|
565
|
-
|
|
566
|
-
var Radio = function() {
|
|
567
|
-
this._channels = {};
|
|
568
|
-
this.vent = {};
|
|
569
|
-
this.commands = {};
|
|
570
|
-
this.reqres = {};
|
|
571
|
-
this._proxyMethods();
|
|
572
|
-
};
|
|
573
|
-
|
|
574
|
-
_.extend(Radio.prototype, {
|
|
575
|
-
|
|
576
|
-
channel: function(channelName) {
|
|
577
|
-
if (!channelName) {
|
|
578
|
-
throw new Error('Channel must receive a name');
|
|
579
|
-
}
|
|
580
|
-
|
|
581
|
-
return this._getChannel( channelName );
|
|
582
|
-
},
|
|
583
|
-
|
|
584
|
-
_getChannel: function(channelName) {
|
|
585
|
-
var channel = this._channels[channelName];
|
|
586
|
-
|
|
587
|
-
if(!channel) {
|
|
588
|
-
channel = new Wreqr.Channel(channelName);
|
|
589
|
-
this._channels[channelName] = channel;
|
|
590
|
-
}
|
|
591
|
-
|
|
592
|
-
return channel;
|
|
593
|
-
},
|
|
594
|
-
|
|
595
|
-
_proxyMethods: function() {
|
|
596
|
-
_.each(['vent', 'commands', 'reqres'], function(system) {
|
|
597
|
-
_.each( messageSystems[system], function(method) {
|
|
598
|
-
this[system][method] = proxyMethod(this, system, method);
|
|
599
|
-
}, this);
|
|
600
|
-
}, this);
|
|
601
|
-
}
|
|
602
|
-
});
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
var messageSystems = {
|
|
606
|
-
vent: [
|
|
607
|
-
'on',
|
|
608
|
-
'off',
|
|
609
|
-
'trigger',
|
|
610
|
-
'once',
|
|
611
|
-
'stopListening',
|
|
612
|
-
'listenTo',
|
|
613
|
-
'listenToOnce'
|
|
614
|
-
],
|
|
615
|
-
|
|
616
|
-
commands: [
|
|
617
|
-
'execute',
|
|
618
|
-
'setHandler',
|
|
619
|
-
'setHandlers',
|
|
620
|
-
'removeHandler',
|
|
621
|
-
'removeAllHandlers'
|
|
622
|
-
],
|
|
623
|
-
|
|
624
|
-
reqres: [
|
|
625
|
-
'request',
|
|
626
|
-
'setHandler',
|
|
627
|
-
'setHandlers',
|
|
628
|
-
'removeHandler',
|
|
629
|
-
'removeAllHandlers'
|
|
630
|
-
]
|
|
631
|
-
};
|
|
632
|
-
|
|
633
|
-
var proxyMethod = function(radio, system, method) {
|
|
634
|
-
return function(channelName) {
|
|
635
|
-
var messageSystem = radio._getChannel(channelName)[system];
|
|
636
|
-
var args = Array.prototype.slice.call(arguments, 1);
|
|
637
|
-
|
|
638
|
-
return messageSystem[method].apply(messageSystem, args);
|
|
639
|
-
};
|
|
640
|
-
};
|
|
641
|
-
|
|
642
|
-
return new Radio();
|
|
643
|
-
|
|
644
|
-
})(Wreqr);
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
}));
|
|
648
|
-
|
|
649
|
-
var Marionette = (function(global, Backbone, _){
|
|
650
|
-
"use strict";
|
|
468
|
+
};
|
|
469
|
+
return new Radio();
|
|
470
|
+
}(Wreqr);
|
|
471
|
+
return Backbone.Wreqr;
|
|
472
|
+
})(Backbone, _);
|
|
651
473
|
|
|
652
474
|
// Define and export the Marionette namespace
|
|
653
475
|
var Marionette = {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
//= require js_stack/base/marionette/1.8.
|
|
1
|
+
//= require js_stack/base/marionette/1.8.5
|
|
@@ -1,8 +1,16 @@
|
|
|
1
|
-
/*! backbone.routefilter - v0.2.
|
|
1
|
+
/*! backbone.routefilter - v0.2.1 - 2014-05-06
|
|
2
2
|
* https://github.com/boazsender/backbone.routefilter
|
|
3
|
-
* Copyright (c)
|
|
4
|
-
|
|
5
|
-
(function(
|
|
3
|
+
* Copyright (c) 2014 Boaz Sender; Licensed MIT */
|
|
4
|
+
|
|
5
|
+
(function(factory) {
|
|
6
|
+
if (typeof define === 'function' && define.amd) {
|
|
7
|
+
define(['backbone', 'underscore'], factory);
|
|
8
|
+
} else if (typeof exports === 'object') {
|
|
9
|
+
module.exports = factory(require('backbone'), require('underscore'));
|
|
10
|
+
} else {
|
|
11
|
+
factory(window.Backbone, window._);
|
|
12
|
+
}
|
|
13
|
+
})(function(Backbone, _) {
|
|
6
14
|
|
|
7
15
|
// Save a reference to the original route method to be called
|
|
8
16
|
// after we pave it over.
|
|
@@ -117,4 +125,4 @@
|
|
|
117
125
|
|
|
118
126
|
});
|
|
119
127
|
|
|
120
|
-
}
|
|
128
|
+
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
//= require js_stack/plugins/backbone/routefilter/0.2.
|
|
1
|
+
//= require js_stack/plugins/backbone/routefilter/0.2.1
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: js_stack
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.6.
|
|
4
|
+
version: 0.6.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Tomasz Pewiński
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2014-05-
|
|
12
|
+
date: 2014-05-09 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: haml_coffee_assets
|
|
@@ -112,7 +112,7 @@ files:
|
|
|
112
112
|
- vendor/assets/javascripts/js_stack/base/marionette/1.5.1.js
|
|
113
113
|
- vendor/assets/javascripts/js_stack/base/marionette/1.6.4.js
|
|
114
114
|
- vendor/assets/javascripts/js_stack/base/marionette/1.7.4.js
|
|
115
|
-
- vendor/assets/javascripts/js_stack/base/marionette/1.8.
|
|
115
|
+
- vendor/assets/javascripts/js_stack/base/marionette/1.8.5.js
|
|
116
116
|
- vendor/assets/javascripts/js_stack/base/underscore.js
|
|
117
117
|
- vendor/assets/javascripts/js_stack/base/underscore/1.5.2.js
|
|
118
118
|
- vendor/assets/javascripts/js_stack/base/underscore/1.6.0.js
|
|
@@ -131,7 +131,7 @@ files:
|
|
|
131
131
|
- vendor/assets/javascripts/js_stack/plugins/backbone/mutators/0.4.2.js
|
|
132
132
|
- vendor/assets/javascripts/js_stack/plugins/backbone/pageable/1.3.2.js
|
|
133
133
|
- vendor/assets/javascripts/js_stack/plugins/backbone/pageable/1.4.8.js
|
|
134
|
-
- vendor/assets/javascripts/js_stack/plugins/backbone/routefilter/0.2.
|
|
134
|
+
- vendor/assets/javascripts/js_stack/plugins/backbone/routefilter/0.2.1.js
|
|
135
135
|
- vendor/assets/javascripts/js_stack/plugins/backbone/stickit/0.6.3.js
|
|
136
136
|
- vendor/assets/javascripts/js_stack/plugins/backbone/stickit/0.7.0.js
|
|
137
137
|
- vendor/assets/javascripts/js_stack/plugins/backbone/stickit/0.8.0.js
|