Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Completed
Push — master ( d3ad00...acd091 )
by Pierre
04:27
created

modal.js ➔ ... ➔ Mn.View.extend.templateContext   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
1
define(['jquery', 'marionette', 'handlebars.runtime', 'template', 'lodash'], function($, Mn, Handlebars, Template, _) {
2
    "use strict";
3
4
    return Mn.View.extend({
5
        el: $('#modal-container').clone(),
6
        ui: {
7
            'save': '.btn-save'
8
        },
9
        triggers: {
10
            'click @ui.save': 'save'
11
        },
12
        constructor: function(options) {
13
            this.listenTo(this, 'render', this.listeners.render);
14
            this.listenTo(this, 'save', this.listeners.save);
15
16
            Mn.View.call(this, options);
17
18
            var modal = _.result(this, 'modal'),
19
                defaults = {
20
                    'titleClose': true
21
                };
22
23
            if (modal) {
24
                this.templateContext = _.extend(defaults, modal);
25
            }
26
27
            this._bindModalEvents(modal);
28
            this._attachListeners();
29
        },
30
        templateContext: function () {
31
            return {
32
                "modalContent": this.getOption('template')
33
            };
34
        },
35
        getTemplate: function() {
36
            this.templateContext = _.extend(this.templateContext, {"modalContent": this.getOption('template')});
37
            return Template.core.modal;
38
        },
39
        listeners: {
40
            render: function() {
41
                this.$el.modal();
42
            },
43
            save: function(context) {
44
                if (false === this.triggerMethod('before:modal:save', context)) {
45
                    return;
46
                }
47
48
                Mn.triggerMethod(this, 'modal:save', context)
0 ignored issues
show
Coding Style introduced by
There should be a semicolon.

Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers.

Further Readings:

Loading history...
49
            }
50
        },
51
        _bindModalEvents: function(modal) {
52
            _.each(_.result(modal, 'events'), function(action, event) {
53
                if (_.isFunction(action)) {
54
                    this.listenTo(this, event, action);
55
                } else if (-1 !== _.indexOf(_.functions(this), action)) {
56
                    this.listenTo(this, event, this[action])
0 ignored issues
show
Coding Style introduced by
There should be a semicolon.

Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers.

Further Readings:

Loading history...
57
                } else {
58
                    throw "Callback specified for event " + event + " is not a valid callback"
0 ignored issues
show
Coding Style introduced by
There should be a semicolon.

Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers.

Further Readings:

Loading history...
59
                }
60
            }, this);
61
        },
62
        _attachListeners: function() {
63
            var view = this;
64
65
            this.$el.on('show.bs.modal', function() {
66
                view.trigger('modal:show');
67
            });
68
69
            this.$el.on('hide.bs.modal', function() {
70
                view.trigger('modal:hide');
71
            });
72
73
            this.$el.on('hidden.bs.modal', function() {
74
                view.destroy();
75
            });
76
        },
77
        _removeElement: function() {
78
            this.$el.empty();
79
        },
80
        showLoader: function() {
81
            this.$el.modal('loading');
82
        },
83
        hideLoader: function() {
84
            this.$el.modal('removeLoading');
85
        }
86
    });
87
});