All files / web/bundles/pimui/js/controller base.js

87.5% Statements 7/8
100% Branches 0/0
80% Functions 4/5
87.5% Lines 7/8

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 30 31 32 33 34 35 36 37 38 39 40    1183x 1183x                               2718x       6597x                 835x 835x   835x        
'use strict';
 
define(['backbone'], function (Backbone) {
    return Backbone.View.extend({
        active: false,
 
        /**
         * Render the route given in parameter
         *
         * @param {String} route
         * @param {String} path
         *
         * @return {Promise}
         */
        renderRoute: function () {
            throw new Error('Method renderRoute is abstract and must be implemented!');
        },
 
        remove: function () {
            this.setActive(false);
        },
 
        setActive: function (active) {
            this.active = active;
        },
 
        /**
         * Return if whether or not the user can leave the page
         *
         * @return {boolean}
         */
        canLeave: function () {
            var event = {canLeave: true};
            this.trigger('pim:controller:can-leave', event);
 
            return event.canLeave;
        }
    });
});