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 72

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 72
rs 9.102
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 41 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($) {
11
12
    'use strict';
13
14
    var defaults = {
15
        options: {
16
            locale: null,
17
            data: {
18
                category: null
19
            },
20
            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...
21
            }
22
        },
23
        translations: {
24
            title: 'sulu_article.category-selection-overlay.title'
25
        }
26
    };
27
28
    return {
29
30
        defaults: defaults,
31
32
        initialize: function() {
33
            var $overlayContainer = $('<div/>');
34
            var $componentContainer = $('<div/>');
35
            this.$el.append($overlayContainer);
36
37
            this.data = this.options.data;
38
39
            // start overlay
40
            this.sandbox.start([{
41
                name: 'overlay@husky',
42
                options: {
43
                    el: $overlayContainer,
44
                    instanceName: 'category-selection',
45
                    openOnStart: true,
46
                    removeOnClose: true,
47
                    skin: 'medium',
48
                    slides: [
49
                        {
50
                            title: this.translations.title,
51
                            data: $componentContainer,
52
                            okCallback: this.okCallbackOverlay.bind(this)
53
                        }
54
                    ]
55
                }
56
            }]);
57
58
            this.sandbox.once('husky.overlay.category-selection.opened', function() {
59
                this.sandbox.start([{
60
                    name: 'articles/list/category-selection/form@suluarticle',
61
                    options: {
62
                        el: $componentContainer,
63
                        locale: this.options.locale,
64
                        data: this.options.data,
65
                        selectCallback: function(data) {
66
                            this.options.selectCallback(data);
67
                            this.sandbox.stop();
68
                        }.bind(this)
69
                    }
70
                }]);
71
            }.bind(this));
72
        },
73
74
        /**
75
         * OK callback of the overlay.
76
         */
77
        okCallbackOverlay: function() {
78
            this.sandbox.emit('sulu_article.category-selection.form.get');
79
        }
80
    };
81
});
82