Completed
Pull Request — develop (#233)
by Wachter
45:40 queued 30:46
created

main.js ➔ ... ➔ defaults.options.selectCallback   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
c 1
b 0
f 1
nc 1
nop 1
dl 0
loc 2
rs 10
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
            data: {from: null, to: null},
17
            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...
18
            }
19
        },
20
        translations: {
21
            title: 'sulu_article.authored',
22
            reset: 'smart-content.choose-data-source.reset'
23
        },
24
    };
25
26
    return {
27
28
        defaults: defaults,
29
30
        initialize: function() {
31
            this.$overlayContainer = $('<div/>');
32
            this.$componentContainer = $('<div/>');
33
            this.$el.append(this.$overlayContainer);
34
35
            // start overlay
36
            this.sandbox.start([{
37
                name: 'overlay@husky',
38
                options: {
39
                    el: this.$overlayContainer,
40
                    instanceName: 'authored-selection',
41
                    openOnStart: true,
42
                    removeOnClose: true,
43
                    skin: 'medium',
44
                    slides: [
45
                        {
46
                            title: this.translations.title,
47
                            data: this.$componentContainer,
48
                            okCallback: this.okCallbackOverlay.bind(this),
49
                            buttons: [
50
                                {
51
                                    type: 'cancel',
52
                                    align: 'left'
53
                                },
54
                                {
55
                                    classes: 'just-text',
56
                                    text: this.translations.reset,
57
                                    align: 'center',
58
                                    callback: function() {
59
                                        this.options.selectCallback({from: null, to: null});
60
                                        this.sandbox.stop();
61
                                    }.bind(this)
62
                                },
63
                                {
64
                                    type: 'ok',
65
                                    align: 'right'
66
                                }
67
                            ]
68
                        }
69
                    ]
70
                }
71
            }]);
72
73
            // start search and datagrid
74
            this.sandbox.once('husky.overlay.authored-selection.opened', function() {
75
                this.sandbox.start([{
76
                    name: 'articles/list/authored-selection/form@suluarticle',
77
                    options: {
78
                        el: this.$componentContainer,
79
                        data: this.options.data,
80
                        selectCallback: function(data) {
81
                            this.options.selectCallback(data);
82
                            this.sandbox.stop();
83
                        }.bind(this)
84
                    }
85
                }]);
86
            }.bind(this));
87
        },
88
89
        /**
90
         * OK callback of the overlay.
91
         */
92
        okCallbackOverlay: function() {
93
            this.sandbox.emit('sulu_article.authored-selection.form.get');
94
        }
95
    };
96
});
97