Completed
Pull Request — develop (#236)
by Wachter
21:30 queued 06:18
created

main.js ➔ define   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 69

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 69
rs 9.2083
c 1
b 0
f 0
cc 1
nc 1
nop 1

3 Functions

Rating   Name   Duplication   Size   Complexity  
A main.js ➔ ... ➔ defaults.options.selectCallback 0 2 1
B main.js ➔ ... ➔ .initialize 0 39 1
A main.js ➔ ... ➔ .okCallbackOverlay 0 3 1

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
/*
2
 * This file is part of Sulu.
3
 *
4
 * (c) MASSIVE ART WebServices GmbH
5
 *
6
 * This source file is subject to the MIT license that is bundled
7
 * with this source code in the file LICENSE.
8
 */
9
10
define(['jquery'], function($) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
11
12
    'use strict';
13
14
    var defaults = {
15
        options: {
16
            data: {
17
                contact: null
18
            },
19
            selectCallback: function(data) {
0 ignored issues
show
Unused Code introduced by
The parameter data 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...
20
            }
21
        },
22
        translations: {
23
            title: 'sulu_article.contact-selection-overlay.title'
24
        }
25
    };
26
27
    return {
28
29
        defaults: defaults,
30
31
        initialize: function() {
32
            var $overlayContainer = $('<div/>');
33
            var $componentContainer = $('<div/>');
34
            this.$el.append($overlayContainer);
35
36
            // start overlay
37
            this.sandbox.start([{
38
                name: 'overlay@husky',
39
                options: {
40
                    el: $overlayContainer,
41
                    instanceName: 'contact-selection',
42
                    openOnStart: true,
43
                    removeOnClose: true,
44
                    skin: 'medium',
45
                    slides: [
46
                        {
47
                            title: this.translations.title,
48
                            data: $componentContainer,
49
                            okCallback: this.okCallbackOverlay.bind(this)
50
                        }
51
                    ]
52
                }
53
            }]);
54
55
            // start search and datagrid
56
            this.sandbox.once('husky.overlay.contact-selection.opened', function() {
57
                this.sandbox.start([{
58
                    name: 'articles/list/contact-selection/form@suluarticle',
59
                    options: {
60
                        el: $componentContainer,
61
                        data: this.options.data,
62
                        selectCallback: function(data) {
63
                            this.options.selectCallback(data);
64
                            this.sandbox.stop();
65
                        }.bind(this)
66
                    }
67
                }]);
68
            }.bind(this));
69
        },
70
71
        /**
72
         * OK callback of the overlay.
73
         */
74
        okCallbackOverlay: function() {
75
            this.sandbox.emit('sulu_article.contact-selection.form.get');
76
        }
77
    };
78
});
79