All files / web/bundles/pimui/js mediator.js

100% Statements 10/10
50% Branches 2/4
100% Functions 5/5
100% Lines 10/10

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29  1183x               1183x   6217x 137430x     6217x 126342x 126342x 517416x 517416x       126342x          
/* global define */
define(['underscore', 'backbone'],
function (_, Backbone) {
    'use strict';
 
    /**
     * @export oro/mediator
     * @name   oro.mediator
     */
    return _.extend({
        clear: function (namespace) {
            this._events = _.omit(this._events, function (events, code) {
                return 0 === code.indexOf(namespace);
            });
 
            _.each(this._events, _.bind(function (events, index) {
                var filtredEvents = [];
                _.each(events, function (event) {
                    Eif (!_.isString(event.context) || 0 !== event.context.indexOf(namespace)) {
                        filtredEvents.push(event);
                    }
                });
 
                this._events[index] = filtredEvents;
            }, this));
        }
    }, Backbone.Events);
});