Completed
Push — master ( 2e195b...9e660e )
by
unknown
02:50
created

src/Resources/public/js/confirm.js   A

Complexity

Total Complexity 9
Complexity/F 3

Size

Lines of Code 44
Function Count 3

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 9
c 1
b 1
f 0
dl 0
loc 44
rs 10
cc 0
nc 2
mnd 2
bc 4
fnc 3
bpm 1.3333
cpm 3
noi 2
1
$(document).ready(function() {
2
    $(document).on('mousedown', '.confirmable', function(e) {
3
        var button = $(e.target);
4
5
        e.preventDefault();
6
        e.stopPropagation();
7
        e.stopImmediatePropagation();
8
9
        var title = typeof button.attr('data-confirm-text') == !'undefined' ? button.attr('data-confirm-text') : "Confirmez-vous l'action ?";
10
11
        bootbox.confirm({
0 ignored issues
show
Bug introduced by
The variable bootbox seems to be never declared. If this is a global, consider adding a /** global: bootbox */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
12
            message: title,
13
            buttons: {
14
                confirm: {
15
                    label: 'Oui',
16
                    className: 'btn-success'
17
                },
18
                cancel: {
19
                    label: 'Non',
20
                    className: 'btn-danger'
21
                }
22
            },
23
            callback: function(result) {
24
                if (result === true) {
25
                    var action = button.attr('data-confirm-action');
26
27
                    switch (action) {
28
                        case 'followHref':
29
                        default:
0 ignored issues
show
Coding Style Comprehensibility introduced by
The default case is not the last statement in this switch statement. For the sake of readability, you might want to move it to the end of the statement.
Loading history...
30
                            window.location.href = button.attr('href');
31
                            break;
32
                        case 'callAction':
33
                            var functionName = button.attr('data-confirm-function');
34
                            functionName(button);
35
                            break;
36
                        case 'triggerClick':
37
                            button[0].click();
38
                            break;
39
                    }
40
                }
41
            }
42
        });
43
    });
44
});
45