Issues (79)

templates/jqueryconfirm/alert.js (10 issues)

1
jaxon.dialogs.jconfirm = {
0 ignored issues
show
The variable jaxon seems to be never declared. If this is a global, consider adding a /** global: jaxon */ 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...
2
    dialog: null,
3
    show: function(args) {
4
        // Add buttons
5
        for(key in args.data.buttons)
0 ignored issues
show
The variable key seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.key.
Loading history...
6
        {
7
            button = args.data.buttons[key];
0 ignored issues
show
The variable button seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.button.
Loading history...
8
            if(button.action === 'close')
9
            {
10
                button.action = function(){jaxon.dialogs.jconfirm.dialog.close();};
0 ignored issues
show
The variable jaxon seems to be never declared. If this is a global, consider adding a /** global: jaxon */ 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...
11
            }
12
            else
13
            {
14
                button.action = new Function(button.action);
0 ignored issues
show
Performance Best Practice introduced by
Using new Function() to create a function is slow and difficult to debug. Such functions do not create a closure. Consider using another way to define your function.
Loading history...
15
            }
16
        }
17
        args.data.closeIcon = true;
18
        if((jaxon.dialogs.jconfirm.dialog))
0 ignored issues
show
The variable jaxon seems to be never declared. If this is a global, consider adding a /** global: jaxon */ 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...
19
        {
20
            jaxon.dialogs.jconfirm.dialog.close();
21
        }
22
        jaxon.dialogs.jconfirm.dialog = $.confirm(args.data);
23
    },
24
    hide: function(args) {
0 ignored issues
show
The parameter args is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
25
        if((jaxon.dialogs.jconfirm.dialog))
0 ignored issues
show
The variable jaxon seems to be never declared. If this is a global, consider adding a /** global: jaxon */ 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...
26
        {
27
            jaxon.dialogs.jconfirm.dialog.close();
28
        }
29
        jaxon.dialogs.jconfirm.dialog = null;
30
    },
31
    success: function(content, title) {
32
        $.alert({content: content, title: title, type: 'green', icon: 'fa fa-success'});
33
    },
34
    info: function(content, title) {
35
        $.alert({content: content, title: title, type: 'blue', icon: 'fa fa-info'});
36
    },
37
    warning: function(content, title) {
38
        $.alert({content: content, title: title, type: 'orange', icon: 'fa fa-warning'});
39
    },
40
    error: function(content, title) {
41
        $.alert({content: content, title: title, type: 'red', icon: 'fa fa-error'});
42
    },
43
    confirm: function(question, title, yesCallback, noCallback) {
44
        if(noCallback == undefined)
0 ignored issues
show
Comparing noCallback to undefined using the == operator is not safe. Consider using === instead.
Loading history...
45
            noCallback = function(){};
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
46
        $.confirm({
47
            title: title,
48
            content: question,
49
            buttons: {
50
                yes: {
51
                    btnClass: "btn-blue",
52
                    text: "<?php echo $this->yes ?>",
53
                    action: yesCallback
54
                },
55
                no: {
56
                    text: "<?php echo $this->no ?>",
57
                    action: noCallback
58
                }
59
            }
60
        });
61
    }
62
};
63