@@ -35,7 +35,7 @@ var eventSplitter = /\s+/;
35
35
// Commands. It's borrowed from Backbone.Events. It differs from Backbone's overload
36
36
// API (which is used in Backbone.Events) in that it doesn't support space-separated
37
37
// event names.
38
- function eventsApi ( obj , action , name , rest ) {
38
+ Radio . _eventsApi = function ( obj , action , name , rest ) {
39
39
if ( ! name ) {
40
40
return false ;
41
41
}
@@ -60,10 +60,10 @@ function eventsApi(obj, action, name, rest) {
60
60
}
61
61
62
62
return false ;
63
- }
63
+ } ;
64
64
65
65
// An optimized way to execute callbacks.
66
- function callHandler ( callback , context , args ) {
66
+ Radio . _callHandler = function ( callback , context , args ) {
67
67
var a1 = args [ 0 ] , a2 = args [ 1 ] , a3 = args [ 2 ] ;
68
68
switch ( args . length ) {
69
69
case 0 : return callback . call ( context ) ;
@@ -72,7 +72,7 @@ function callHandler(callback, context, args) {
72
72
case 3 : return callback . call ( context , a1 , a2 , a3 ) ;
73
73
default : return callback . apply ( context , args ) ;
74
74
}
75
- }
75
+ } ;
76
76
77
77
// A helper used by `off` methods to the handler from the store
78
78
function removeHandler ( store , name , callback , context ) {
@@ -163,7 +163,7 @@ Radio.Commands = {
163
163
// Issue a command
164
164
command : function ( name ) {
165
165
var args = _ . rest ( arguments ) ;
166
- if ( eventsApi ( this , 'command' , name , args ) ) {
166
+ if ( Radio . _eventsApi ( this , 'command' , name , args ) ) {
167
167
return this ;
168
168
}
169
169
var channelName = this . channelName ;
@@ -178,7 +178,7 @@ Radio.Commands = {
178
178
if ( commands && ( commands [ name ] || commands [ 'default' ] ) ) {
179
179
var handler = commands [ name ] || commands [ 'default' ] ;
180
180
args = commands [ name ] ? args : arguments ;
181
- callHandler ( handler . callback , handler . context , args ) ;
181
+ Radio . _callHandler ( handler . callback , handler . context , args ) ;
182
182
} else {
183
183
Radio . debugLog ( 'An unhandled command was fired' , name , channelName ) ;
184
184
}
@@ -188,7 +188,7 @@ Radio.Commands = {
188
188
189
189
// Register a handler for a command.
190
190
comply : function ( name , callback , context ) {
191
- if ( eventsApi ( this , 'comply' , name , [ callback , context ] ) ) {
191
+ if ( Radio . _eventsApi ( this , 'comply' , name , [ callback , context ] ) ) {
192
192
return this ;
193
193
}
194
194
this . _commands || ( this . _commands = { } ) ;
@@ -207,7 +207,7 @@ Radio.Commands = {
207
207
208
208
// Register a handler for a command that happens just once.
209
209
complyOnce : function ( name , callback , context ) {
210
- if ( eventsApi ( this , 'complyOnce' , name , [ callback , context ] ) ) {
210
+ if ( Radio . _eventsApi ( this , 'complyOnce' , name , [ callback , context ] ) ) {
211
211
return this ;
212
212
}
213
213
var self = this ;
@@ -222,7 +222,7 @@ Radio.Commands = {
222
222
223
223
// Remove handler(s)
224
224
stopComplying : function ( name , callback , context ) {
225
- if ( eventsApi ( this , 'stopComplying' , name ) ) {
225
+ if ( Radio . _eventsApi ( this , 'stopComplying' , name ) ) {
226
226
return this ;
227
227
}
228
228
@@ -253,7 +253,7 @@ Radio.Requests = {
253
253
// Make a request
254
254
request : function ( name ) {
255
255
var args = _ . rest ( arguments ) ;
256
- var results = eventsApi ( this , 'request' , name , args ) ;
256
+ var results = Radio . _eventsApi ( this , 'request' , name , args ) ;
257
257
if ( results ) {
258
258
return results ;
259
259
}
@@ -269,15 +269,15 @@ Radio.Requests = {
269
269
if ( requests && ( requests [ name ] || requests [ 'default' ] ) ) {
270
270
var handler = requests [ name ] || requests [ 'default' ] ;
271
271
args = requests [ name ] ? args : arguments ;
272
- return callHandler ( handler . callback , handler . context , args ) ;
272
+ return Radio . _callHandler ( handler . callback , handler . context , args ) ;
273
273
} else {
274
274
Radio . debugLog ( 'An unhandled request was fired' , name , channelName ) ;
275
275
}
276
276
} ,
277
277
278
278
// Set up a handler for a request
279
279
reply : function ( name , callback , context ) {
280
- if ( eventsApi ( this , 'reply' , name , [ callback , context ] ) ) {
280
+ if ( Radio . _eventsApi ( this , 'reply' , name , [ callback , context ] ) ) {
281
281
return this ;
282
282
}
283
283
@@ -297,7 +297,7 @@ Radio.Requests = {
297
297
298
298
// Set up a handler that can only be requested once
299
299
replyOnce : function ( name , callback , context ) {
300
- if ( eventsApi ( this , 'replyOnce' , name , [ callback , context ] ) ) {
300
+ if ( Radio . _eventsApi ( this , 'replyOnce' , name , [ callback , context ] ) ) {
301
301
return this ;
302
302
}
303
303
@@ -313,7 +313,7 @@ Radio.Requests = {
313
313
314
314
// Remove handler(s)
315
315
stopReplying : function ( name , callback , context ) {
316
- if ( eventsApi ( this , 'stopReplying' , name ) ) {
316
+ if ( Radio . _eventsApi ( this , 'stopReplying' , name ) ) {
317
317
return this ;
318
318
}
319
319
0 commit comments