|
3309 | 3309 | sendOutputHiddenStateDebouncer.immediateCall();
|
3310 | 3310 | });
|
3311 | 3311 |
|
| 3312 | + // Given a namespace and a handler function, return a function that invokes |
| 3313 | + // the handler only when e's namespace matches. For example, if the |
| 3314 | + // namespace is "bs", it would match when e.namespace is "bs" or "bs.tab". |
| 3315 | + // If the namespace is "bs.tab", it would match for "bs.tab", but not "bs". |
3312 | 3316 | function filterEventsByNamespace(namespace, handler) {
|
| 3317 | + namespace = namespace.split("."); |
| 3318 | + |
3313 | 3319 | return function(e) {
|
3314 |
| - if (e.namespace.indexOf(namespace) === 0) { |
3315 |
| - handler.apply(this, arguments); |
| 3320 | + var eventNamespace = e.namespace.split("."); |
| 3321 | + |
| 3322 | + // If any of the namespace strings aren't present in this event, quit. |
| 3323 | + for (var i=0; i<namespace.length; i++) { |
| 3324 | + if (eventNamespace.indexOf(namespace[i]) === -1) |
| 3325 | + return; |
3316 | 3326 | }
|
| 3327 | + |
| 3328 | + handler.apply(this, arguments); |
3317 | 3329 | };
|
3318 | 3330 | }
|
3319 | 3331 |
|
|
3326 | 3338 | var bs3classes = ['modal', 'dropdown', 'tab', 'tooltip', 'popover', 'collapse'];
|
3327 | 3339 | $.each(bs3classes, function(idx, classname) {
|
3328 | 3340 | $('body').on('shown.bs.' + classname + '.sendImageSize', '*',
|
3329 |
| - filterEventsByNamespace('bs.', sendImageSize)); |
| 3341 | + filterEventsByNamespace('bs', sendImageSize)); |
3330 | 3342 | $('body').on('shown.bs.' + classname + '.sendOutputHiddenState ' +
|
3331 | 3343 | 'hidden.bs.' + classname + '.sendOutputHiddenState',
|
3332 |
| - '*', filterEventsByNamespace('bs.', sendOutputHiddenState)); |
| 3344 | + '*', filterEventsByNamespace('bs', sendOutputHiddenState)); |
3333 | 3345 | });
|
3334 | 3346 |
|
3335 | 3347 | // This is needed for Bootstrap 2 compatibility and for non-Bootstrap
|
|
0 commit comments