backbone-radio-rails 0.9.0
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 +7 -0
- data/.gitignore +23 -0
- data/Gemfile +4 -0
- data/LICENSE +21 -0
- data/README.md +23 -0
- data/VERSION +1 -0
- data/backbone-radio-rails.gemspec +15 -0
- data/lib/backbone-radio-rails.rb +8 -0
- data/vendor/assets/javascripts/backbone.radio.js +426 -0
- data/vendor/assets/javascripts/backbone.radio.min.js +4 -0
- metadata +53 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 818f7c98b75413c6b674c1dea57051012105fecd
|
4
|
+
data.tar.gz: 44ef6191264ce8cc4b4865f1e25029a5a3c43fa3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f6e64bc6ddfb0ca4761744f32e3243042d5728ec8b795e4bc78ce1261a58ab058fda76aa776e2c50d7dfc3145f9dfaccf06656eba6491abbcf073e5a8e5fef96
|
7
|
+
data.tar.gz: 14749b3ebbeefa9cd403e240542a6100c7d451971fcfa7040f0faa77bdae489d85233965aa21827604aeba7d33c52c48d08c7ea20c526f26c69cf792862d345d
|
data/.gitignore
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
23
|
+
.DS_Store
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Alexander Schwartzberg
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
backbone-radio-rails
|
2
|
+
=======================
|
3
|
+
|
4
|
+
Rails (3.1 and up) asset wrapper for the latest version of [backbone.radio](https://github.com/marionettejs/backbone.radio) (0.9.0).
|
5
|
+
|
6
|
+
# Installation
|
7
|
+
#### Step 1: Add it to your gemfile:
|
8
|
+
|
9
|
+
gem 'backbone-radio-rails'
|
10
|
+
|
11
|
+
#### Step 2: Include assets:
|
12
|
+
|
13
|
+
```javascript
|
14
|
+
// In application.js
|
15
|
+
//= require backbone.radio
|
16
|
+
```
|
17
|
+
or
|
18
|
+
```javascript
|
19
|
+
// In application.js
|
20
|
+
//= require backbone.radio.min
|
21
|
+
```
|
22
|
+
|
23
|
+
#####Special thanks to [Marionette.js](https://github.com/marionettejs) for their work on [backbone.radio](https://github.com/marionettejs/backbone.radio).
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.9.0
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
VERSION = File.read(File.expand_path('../VERSION', __FILE__)).strip
|
3
|
+
|
4
|
+
Gem::Specification.new do |spec|
|
5
|
+
spec.name = "backbone-radio-rails"
|
6
|
+
spec.version = VERSION
|
7
|
+
spec.authors = ["Alexander Schwartzberg"]
|
8
|
+
spec.email = ["aeksco@gmail.com"]
|
9
|
+
spec.summary = "Rails asset wrapper for backbone.radio"
|
10
|
+
spec.homepage = "https://github.com/aeksco/backbone-radio-rails"
|
11
|
+
spec.license = "MIT"
|
12
|
+
|
13
|
+
spec.files = `git ls-files`.split("\n")
|
14
|
+
spec.require_paths = ["lib"]
|
15
|
+
end
|
@@ -0,0 +1,426 @@
|
|
1
|
+
// Backbone.Radio v0.9.0
|
2
|
+
(function(root, factory) {
|
3
|
+
if (typeof define === 'function' && define.amd) {
|
4
|
+
define(['backbone', 'underscore'], function(Backbone, _) {
|
5
|
+
return factory(Backbone, _);
|
6
|
+
});
|
7
|
+
}
|
8
|
+
else if (typeof exports !== 'undefined') {
|
9
|
+
var Backbone = require('backbone');
|
10
|
+
var _ = require('underscore');
|
11
|
+
module.exports = factory(Backbone, _);
|
12
|
+
}
|
13
|
+
else {
|
14
|
+
factory(root.Backbone, root._);
|
15
|
+
}
|
16
|
+
}(this, function(Backbone, _) {
|
17
|
+
'use strict';
|
18
|
+
|
19
|
+
var previousRadio = Backbone.Radio;
|
20
|
+
|
21
|
+
var Radio = Backbone.Radio = {};
|
22
|
+
|
23
|
+
Radio.VERSION = '0.9.0';
|
24
|
+
|
25
|
+
// This allows you to run multiple instances of Radio on the same
|
26
|
+
// webapp. After loading the new version, call `noConflict()` to
|
27
|
+
// get a reference to it. At the same time the old version will be
|
28
|
+
// returned to Backbone.Radio.
|
29
|
+
Radio.noConflict = function () {
|
30
|
+
Backbone.Radio = previousRadio;
|
31
|
+
return this;
|
32
|
+
};
|
33
|
+
|
34
|
+
// Whether or not we're in DEBUG mode or not. DEBUG mode helps you
|
35
|
+
// get around the issues of lack of warnings when events are mis-typed.
|
36
|
+
Radio.DEBUG = false;
|
37
|
+
|
38
|
+
// Format debug text.
|
39
|
+
Radio._debugText = function(warning, eventName, channelName) {
|
40
|
+
return warning + (channelName ? ' on the ' + channelName + ' channel' : '') +
|
41
|
+
': "' + eventName + '"';
|
42
|
+
};
|
43
|
+
|
44
|
+
// This is the method that's called when an unregistered event was called.
|
45
|
+
// By default, it logs warning to the console. By overriding this you could
|
46
|
+
// make it throw an Error, for instance. This would make firing a nonexistent event
|
47
|
+
// have the same consequence as firing a nonexistent method on an Object.
|
48
|
+
Radio.debugLog = function(warning, eventName, channelName) {
|
49
|
+
if (Radio.DEBUG && console && console.warn) {
|
50
|
+
console.warn(Radio._debugText(warning, eventName, channelName));
|
51
|
+
}
|
52
|
+
};
|
53
|
+
|
54
|
+
var eventSplitter = /\s+/;
|
55
|
+
|
56
|
+
// An internal method used to handle Radio's method overloading for Requests and
|
57
|
+
// Commands. It's borrowed from Backbone.Events. It differs from Backbone's overload
|
58
|
+
// API (which is used in Backbone.Events) in that it doesn't support space-separated
|
59
|
+
// event names.
|
60
|
+
Radio._eventsApi = function(obj, action, name, rest) {
|
61
|
+
if (!name) {
|
62
|
+
return false;
|
63
|
+
}
|
64
|
+
|
65
|
+
var results = {};
|
66
|
+
|
67
|
+
// Handle event maps.
|
68
|
+
if (typeof name === 'object') {
|
69
|
+
for (var key in name) {
|
70
|
+
var result = obj[action].apply(obj, [key, name[key]].concat(rest));
|
71
|
+
eventSplitter.test(key) ? _.extend(results, result) : results[key] = result;
|
72
|
+
}
|
73
|
+
return results;
|
74
|
+
}
|
75
|
+
|
76
|
+
// Handle space separated event names.
|
77
|
+
if (eventSplitter.test(name)) {
|
78
|
+
var names = name.split(eventSplitter);
|
79
|
+
for (var i = 0, l = names.length; i < l; i++) {
|
80
|
+
results[names[i]] = obj[action].apply(obj, [names[i]].concat(rest));
|
81
|
+
}
|
82
|
+
return results;
|
83
|
+
}
|
84
|
+
|
85
|
+
return false;
|
86
|
+
};
|
87
|
+
|
88
|
+
// An optimized way to execute callbacks.
|
89
|
+
Radio._callHandler = function(callback, context, args) {
|
90
|
+
var a1 = args[0], a2 = args[1], a3 = args[2];
|
91
|
+
switch(args.length) {
|
92
|
+
case 0: return callback.call(context);
|
93
|
+
case 1: return callback.call(context, a1);
|
94
|
+
case 2: return callback.call(context, a1, a2);
|
95
|
+
case 3: return callback.call(context, a1, a2, a3);
|
96
|
+
default: return callback.apply(context, args);
|
97
|
+
}
|
98
|
+
};
|
99
|
+
|
100
|
+
// A helper used by `off` methods to the handler from the store
|
101
|
+
function removeHandler(store, name, callback, context) {
|
102
|
+
var event = store[name];
|
103
|
+
if (
|
104
|
+
(!callback || (callback === event.callback || callback === event.callback._callback)) &&
|
105
|
+
(!context || (context === event.context))
|
106
|
+
) {
|
107
|
+
delete store[name];
|
108
|
+
return true;
|
109
|
+
}
|
110
|
+
}
|
111
|
+
|
112
|
+
function removeHandlers(store, name, callback, context) {
|
113
|
+
store || (store = {});
|
114
|
+
var names = name ? [name] : _.keys(store);
|
115
|
+
var matched = false;
|
116
|
+
|
117
|
+
for (var i = 0, length = names.length; i < length; i++) {
|
118
|
+
name = names[i];
|
119
|
+
|
120
|
+
// If there's no event by this name, log it and continue
|
121
|
+
// with the loop
|
122
|
+
if (!store[name]) {
|
123
|
+
continue;
|
124
|
+
}
|
125
|
+
|
126
|
+
if (removeHandler(store, name, callback, context)) {
|
127
|
+
matched = true;
|
128
|
+
}
|
129
|
+
}
|
130
|
+
|
131
|
+
return matched;
|
132
|
+
}
|
133
|
+
|
134
|
+
/*
|
135
|
+
* tune-in
|
136
|
+
* -------
|
137
|
+
* Get console logs of a channel's activity
|
138
|
+
*
|
139
|
+
*/
|
140
|
+
|
141
|
+
var _logs = {};
|
142
|
+
|
143
|
+
// This is to produce an identical function in both tuneIn and tuneOut,
|
144
|
+
// so that Backbone.Events unregisters it.
|
145
|
+
function _partial(channelName) {
|
146
|
+
return _logs[channelName] || (_logs[channelName] = _.partial(Radio.log, channelName));
|
147
|
+
}
|
148
|
+
|
149
|
+
_.extend(Radio, {
|
150
|
+
|
151
|
+
// Log information about the channel and event
|
152
|
+
log: function(channelName, eventName) {
|
153
|
+
var args = _.rest(arguments, 2);
|
154
|
+
console.log('[' + channelName + '] "' + eventName + '"', args);
|
155
|
+
},
|
156
|
+
|
157
|
+
// Logs all events on this channel to the console. It sets an
|
158
|
+
// internal value on the channel telling it we're listening,
|
159
|
+
// then sets a listener on the Backbone.Events
|
160
|
+
tuneIn: function(channelName) {
|
161
|
+
var channel = Radio.channel(channelName);
|
162
|
+
channel._tunedIn = true;
|
163
|
+
channel.on('all', _partial(channelName));
|
164
|
+
return this;
|
165
|
+
},
|
166
|
+
|
167
|
+
// Stop logging all of the activities on this channel to the console
|
168
|
+
tuneOut: function(channelName) {
|
169
|
+
var channel = Radio.channel(channelName);
|
170
|
+
channel._tunedIn = false;
|
171
|
+
channel.off('all', _partial(channelName));
|
172
|
+
delete _logs[channelName];
|
173
|
+
return this;
|
174
|
+
}
|
175
|
+
});
|
176
|
+
|
177
|
+
/*
|
178
|
+
* Backbone.Radio.Commands
|
179
|
+
* -----------------------
|
180
|
+
* A messaging system for sending orders.
|
181
|
+
*
|
182
|
+
*/
|
183
|
+
|
184
|
+
Radio.Commands = {
|
185
|
+
|
186
|
+
// Issue a command
|
187
|
+
command: function(name) {
|
188
|
+
var args = _.rest(arguments);
|
189
|
+
if (Radio._eventsApi(this, 'command', name, args)) {
|
190
|
+
return this;
|
191
|
+
}
|
192
|
+
var channelName = this.channelName;
|
193
|
+
var commands = this._commands;
|
194
|
+
|
195
|
+
// Check if we should log the command, and if so, do it
|
196
|
+
if (channelName && this._tunedIn) {
|
197
|
+
Radio.log.apply(this, [channelName, name].concat(args));
|
198
|
+
}
|
199
|
+
|
200
|
+
// If the command isn't handled, log it in DEBUG mode and exit
|
201
|
+
if (commands && (commands[name] || commands['default'])) {
|
202
|
+
var handler = commands[name] || commands['default'];
|
203
|
+
args = commands[name] ? args : arguments;
|
204
|
+
Radio._callHandler(handler.callback, handler.context, args);
|
205
|
+
} else {
|
206
|
+
Radio.debugLog('An unhandled command was fired', name, channelName);
|
207
|
+
}
|
208
|
+
|
209
|
+
return this;
|
210
|
+
},
|
211
|
+
|
212
|
+
// Register a handler for a command.
|
213
|
+
comply: function(name, callback, context) {
|
214
|
+
if (Radio._eventsApi(this, 'comply', name, [callback, context])) {
|
215
|
+
return this;
|
216
|
+
}
|
217
|
+
this._commands || (this._commands = {});
|
218
|
+
|
219
|
+
if (this._commands[name]) {
|
220
|
+
Radio.debugLog('A command was overwritten', name, this.channelName);
|
221
|
+
}
|
222
|
+
|
223
|
+
this._commands[name] = {
|
224
|
+
callback: callback,
|
225
|
+
context: context || this
|
226
|
+
};
|
227
|
+
|
228
|
+
return this;
|
229
|
+
},
|
230
|
+
|
231
|
+
// Register a handler for a command that happens just once.
|
232
|
+
complyOnce: function(name, callback, context) {
|
233
|
+
if (Radio._eventsApi(this, 'complyOnce', name, [callback, context])) {
|
234
|
+
return this;
|
235
|
+
}
|
236
|
+
var self = this;
|
237
|
+
|
238
|
+
var once = _.once(function() {
|
239
|
+
self.stopComplying(name);
|
240
|
+
return callback.apply(this, arguments);
|
241
|
+
});
|
242
|
+
|
243
|
+
return this.comply(name, once, context);
|
244
|
+
},
|
245
|
+
|
246
|
+
// Remove handler(s)
|
247
|
+
stopComplying: function(name, callback, context) {
|
248
|
+
if (Radio._eventsApi(this, 'stopComplying', name)) {
|
249
|
+
return this;
|
250
|
+
}
|
251
|
+
|
252
|
+
// Remove everything if there are no arguments passed
|
253
|
+
if (!name && !callback && !context) {
|
254
|
+
delete this._commands;
|
255
|
+
} else if (!removeHandlers(this._commands, name, callback, context)) {
|
256
|
+
Radio.debugLog('Attempted to remove the unregistered command', name, this.channelName);
|
257
|
+
}
|
258
|
+
|
259
|
+
return this;
|
260
|
+
}
|
261
|
+
};
|
262
|
+
|
263
|
+
/*
|
264
|
+
* Backbone.Radio.Requests
|
265
|
+
* -----------------------
|
266
|
+
* A messaging system for requesting data.
|
267
|
+
*
|
268
|
+
*/
|
269
|
+
|
270
|
+
function makeCallback(callback) {
|
271
|
+
return _.isFunction(callback) ? callback : function () { return callback; };
|
272
|
+
}
|
273
|
+
|
274
|
+
Radio.Requests = {
|
275
|
+
|
276
|
+
// Make a request
|
277
|
+
request: function(name) {
|
278
|
+
var args = _.rest(arguments);
|
279
|
+
var results = Radio._eventsApi(this, 'request', name, args);
|
280
|
+
if (results) {
|
281
|
+
return results;
|
282
|
+
}
|
283
|
+
var channelName = this.channelName;
|
284
|
+
var requests = this._requests;
|
285
|
+
|
286
|
+
// Check if we should log the request, and if so, do it
|
287
|
+
if (channelName && this._tunedIn) {
|
288
|
+
Radio.log.apply(this, [channelName, name].concat(args));
|
289
|
+
}
|
290
|
+
|
291
|
+
// If the request isn't handled, log it in DEBUG mode and exit
|
292
|
+
if (requests && (requests[name] || requests['default'])) {
|
293
|
+
var handler = requests[name] || requests['default'];
|
294
|
+
args = requests[name] ? args : arguments;
|
295
|
+
return Radio._callHandler(handler.callback, handler.context, args);
|
296
|
+
} else {
|
297
|
+
Radio.debugLog('An unhandled request was fired', name, channelName);
|
298
|
+
}
|
299
|
+
},
|
300
|
+
|
301
|
+
// Set up a handler for a request
|
302
|
+
reply: function(name, callback, context) {
|
303
|
+
if (Radio._eventsApi(this, 'reply', name, [callback, context])) {
|
304
|
+
return this;
|
305
|
+
}
|
306
|
+
|
307
|
+
this._requests || (this._requests = {});
|
308
|
+
|
309
|
+
if (this._requests[name]) {
|
310
|
+
Radio.debugLog('A request was overwritten', name, this.channelName);
|
311
|
+
}
|
312
|
+
|
313
|
+
this._requests[name] = {
|
314
|
+
callback: makeCallback(callback),
|
315
|
+
context: context || this
|
316
|
+
};
|
317
|
+
|
318
|
+
return this;
|
319
|
+
},
|
320
|
+
|
321
|
+
// Set up a handler that can only be requested once
|
322
|
+
replyOnce: function(name, callback, context) {
|
323
|
+
if (Radio._eventsApi(this, 'replyOnce', name, [callback, context])) {
|
324
|
+
return this;
|
325
|
+
}
|
326
|
+
|
327
|
+
var self = this;
|
328
|
+
|
329
|
+
var once = _.once(function() {
|
330
|
+
self.stopReplying(name);
|
331
|
+
return makeCallback(callback).apply(this, arguments);
|
332
|
+
});
|
333
|
+
|
334
|
+
return this.reply(name, once, context);
|
335
|
+
},
|
336
|
+
|
337
|
+
// Remove handler(s)
|
338
|
+
stopReplying: function(name, callback, context) {
|
339
|
+
if (Radio._eventsApi(this, 'stopReplying', name)) {
|
340
|
+
return this;
|
341
|
+
}
|
342
|
+
|
343
|
+
// Remove everything if there are no arguments passed
|
344
|
+
if (!name && !callback && !context) {
|
345
|
+
delete this._requests;
|
346
|
+
} else if (!removeHandlers(this._requests, name, callback, context)) {
|
347
|
+
Radio.debugLog('Attempted to remove the unregistered request', name, this.channelName);
|
348
|
+
}
|
349
|
+
|
350
|
+
return this;
|
351
|
+
}
|
352
|
+
};
|
353
|
+
|
354
|
+
/*
|
355
|
+
* Backbone.Radio.channel
|
356
|
+
* ----------------------
|
357
|
+
* Get a reference to a channel by name.
|
358
|
+
*
|
359
|
+
*/
|
360
|
+
|
361
|
+
Radio._channels = {};
|
362
|
+
|
363
|
+
Radio.channel = function(channelName) {
|
364
|
+
if (!channelName) {
|
365
|
+
throw new Error('You must provide a name for the channel.');
|
366
|
+
}
|
367
|
+
|
368
|
+
if (Radio._channels[channelName]) {
|
369
|
+
return Radio._channels[channelName];
|
370
|
+
} else {
|
371
|
+
return (Radio._channels[channelName] = new Radio.Channel(channelName));
|
372
|
+
}
|
373
|
+
};
|
374
|
+
|
375
|
+
/*
|
376
|
+
* Backbone.Radio.Channel
|
377
|
+
* ----------------------
|
378
|
+
* A Channel is an object that extends from Backbone.Events,
|
379
|
+
* Radio.Commands, and Radio.Requests.
|
380
|
+
*
|
381
|
+
*/
|
382
|
+
|
383
|
+
Radio.Channel = function(channelName) {
|
384
|
+
this.channelName = channelName;
|
385
|
+
};
|
386
|
+
|
387
|
+
_.extend(Radio.Channel.prototype, Backbone.Events, Radio.Commands, Radio.Requests, {
|
388
|
+
|
389
|
+
// Remove all handlers from the messaging systems of this channel
|
390
|
+
reset: function() {
|
391
|
+
this.off();
|
392
|
+
this.stopListening();
|
393
|
+
this.stopComplying();
|
394
|
+
this.stopReplying();
|
395
|
+
return this;
|
396
|
+
}
|
397
|
+
});
|
398
|
+
|
399
|
+
/*
|
400
|
+
* Top-level API
|
401
|
+
* -------------
|
402
|
+
* Supplies the 'top-level API' for working with Channels directly
|
403
|
+
* from Backbone.Radio.
|
404
|
+
*
|
405
|
+
*/
|
406
|
+
|
407
|
+
var channel, args, systems = [Backbone.Events, Radio.Commands, Radio.Requests];
|
408
|
+
|
409
|
+
_.each(systems, function(system) {
|
410
|
+
_.each(system, function(method, methodName) {
|
411
|
+
Radio[methodName] = function(channelName) {
|
412
|
+
args = _.rest(arguments);
|
413
|
+
channel = this.channel(channelName);
|
414
|
+
return channel[methodName].apply(channel, args);
|
415
|
+
};
|
416
|
+
});
|
417
|
+
});
|
418
|
+
|
419
|
+
Radio.reset = function(channelName) {
|
420
|
+
var channels = !channelName ? this._channels : [this._channels[channelName]];
|
421
|
+
_.invoke(channels, 'reset');
|
422
|
+
};
|
423
|
+
|
424
|
+
|
425
|
+
return Radio;
|
426
|
+
}));
|
@@ -0,0 +1,4 @@
|
|
1
|
+
// Backbone.Radio v0.9.0
|
2
|
+
|
3
|
+
!function(a,b){if("function"==typeof define&&define.amd)define(["backbone","underscore"],function(a,c){return b(a,c)});else if("undefined"!=typeof exports){var c=require("backbone"),d=require("underscore");module.exports=b(c,d)}else b(a.Backbone,a._)}(this,function(a,b){"use strict";function c(a,b,c,d){var e=a[b];return c&&c!==e.callback&&c!==e.callback._callback||d&&d!==e.context?void 0:(delete a[b],!0)}function d(a,d,e,f){a||(a={});for(var g=d?[d]:b.keys(a),h=!1,i=0,j=g.length;j>i;i++)d=g[i],a[d]&&c(a,d,e,f)&&(h=!0);return h}function e(a){return j[a]||(j[a]=b.partial(h.log,a))}function f(a){return b.isFunction(a)?a:function(){return a}}var g=a.Radio,h=a.Radio={};h.VERSION="0.9.0",h.noConflict=function(){return a.Radio=g,this},h.DEBUG=!1,h._debugText=function(a,b,c){return a+(c?" on the "+c+" channel":"")+': "'+b+'"'},h.debugLog=function(a,b,c){h.DEBUG&&console&&console.warn&&console.warn(h._debugText(a,b,c))};var i=/\s+/;h._eventsApi=function(a,c,d,e){if(!d)return!1;var f={};if("object"==typeof d){for(var g in d){var h=a[c].apply(a,[g,d[g]].concat(e));i.test(g)?b.extend(f,h):f[g]=h}return f}if(i.test(d)){for(var j=d.split(i),k=0,l=j.length;l>k;k++)f[j[k]]=a[c].apply(a,[j[k]].concat(e));return f}return!1},h._callHandler=function(a,b,c){var d=c[0],e=c[1],f=c[2];switch(c.length){case 0:return a.call(b);case 1:return a.call(b,d);case 2:return a.call(b,d,e);case 3:return a.call(b,d,e,f);default:return a.apply(b,c)}};var j={};b.extend(h,{log:function(a,c){var d=b.rest(arguments,2);console.log("["+a+'] "'+c+'"',d)},tuneIn:function(a){var b=h.channel(a);return b._tunedIn=!0,b.on("all",e(a)),this},tuneOut:function(a){var b=h.channel(a);return b._tunedIn=!1,b.off("all",e(a)),delete j[a],this}}),h.Commands={command:function(a){var c=b.rest(arguments);if(h._eventsApi(this,"command",a,c))return this;var d=this.channelName,e=this._commands;if(d&&this._tunedIn&&h.log.apply(this,[d,a].concat(c)),e&&(e[a]||e["default"])){var f=e[a]||e["default"];c=e[a]?c:arguments,h._callHandler(f.callback,f.context,c)}else h.debugLog("An unhandled command was fired",a,d);return this},comply:function(a,b,c){return h._eventsApi(this,"comply",a,[b,c])?this:(this._commands||(this._commands={}),this._commands[a]&&h.debugLog("A command was overwritten",a,this.channelName),this._commands[a]={callback:b,context:c||this},this)},complyOnce:function(a,c,d){if(h._eventsApi(this,"complyOnce",a,[c,d]))return this;var e=this,f=b.once(function(){return e.stopComplying(a),c.apply(this,arguments)});return this.comply(a,f,d)},stopComplying:function(a,b,c){return h._eventsApi(this,"stopComplying",a)?this:(a||b||c?d(this._commands,a,b,c)||h.debugLog("Attempted to remove the unregistered command",a,this.channelName):delete this._commands,this)}},h.Requests={request:function(a){var c=b.rest(arguments),d=h._eventsApi(this,"request",a,c);if(d)return d;var e=this.channelName,f=this._requests;if(e&&this._tunedIn&&h.log.apply(this,[e,a].concat(c)),f&&(f[a]||f["default"])){var g=f[a]||f["default"];return c=f[a]?c:arguments,h._callHandler(g.callback,g.context,c)}h.debugLog("An unhandled request was fired",a,e)},reply:function(a,b,c){return h._eventsApi(this,"reply",a,[b,c])?this:(this._requests||(this._requests={}),this._requests[a]&&h.debugLog("A request was overwritten",a,this.channelName),this._requests[a]={callback:f(b),context:c||this},this)},replyOnce:function(a,c,d){if(h._eventsApi(this,"replyOnce",a,[c,d]))return this;var e=this,g=b.once(function(){return e.stopReplying(a),f(c).apply(this,arguments)});return this.reply(a,g,d)},stopReplying:function(a,b,c){return h._eventsApi(this,"stopReplying",a)?this:(a||b||c?d(this._requests,a,b,c)||h.debugLog("Attempted to remove the unregistered request",a,this.channelName):delete this._requests,this)}},h._channels={},h.channel=function(a){if(!a)throw new Error("You must provide a name for the channel.");return h._channels[a]?h._channels[a]:h._channels[a]=new h.Channel(a)},h.Channel=function(a){this.channelName=a},b.extend(h.Channel.prototype,a.Events,h.Commands,h.Requests,{reset:function(){return this.off(),this.stopListening(),this.stopComplying(),this.stopReplying(),this}});var k,l,m=[a.Events,h.Commands,h.Requests];return b.each(m,function(a){b.each(a,function(a,c){h[c]=function(a){return l=b.rest(arguments),k=this.channel(a),k[c].apply(k,l)}})}),h.reset=function(a){var c=a?[this._channels[a]]:this._channels;b.invoke(c,"reset")},h});
|
4
|
+
//# sourceMappingURL=backbone.radio.min.js.map
|
metadata
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: backbone-radio-rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.9.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alexander Schwartzberg
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-04-20 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description:
|
14
|
+
email:
|
15
|
+
- aeksco@gmail.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- ".gitignore"
|
21
|
+
- Gemfile
|
22
|
+
- LICENSE
|
23
|
+
- README.md
|
24
|
+
- VERSION
|
25
|
+
- backbone-radio-rails.gemspec
|
26
|
+
- lib/backbone-radio-rails.rb
|
27
|
+
- vendor/assets/javascripts/backbone.radio.js
|
28
|
+
- vendor/assets/javascripts/backbone.radio.min.js
|
29
|
+
homepage: https://github.com/aeksco/backbone-radio-rails
|
30
|
+
licenses:
|
31
|
+
- MIT
|
32
|
+
metadata: {}
|
33
|
+
post_install_message:
|
34
|
+
rdoc_options: []
|
35
|
+
require_paths:
|
36
|
+
- lib
|
37
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
requirements: []
|
48
|
+
rubyforge_project:
|
49
|
+
rubygems_version: 2.2.2
|
50
|
+
signing_key:
|
51
|
+
specification_version: 4
|
52
|
+
summary: Rails asset wrapper for backbone.radio
|
53
|
+
test_files: []
|