Completed
Push — master ( 9e79e0...3fae1e )
by Andreas
38:47
created

static/org.openpsa.helpers/chooser.js   A

Complexity

Total Complexity 4
Complexity/F 2

Size

Lines of Code 19
Function Count 2

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 19
rs 10
c 0
b 0
f 0
wmc 4
mnd 2
bc 2
fnc 2
bpm 1
cpm 2
noi 1

1 Function

Rating   Name   Duplication   Size   Complexity  
A chooser.js ➔ add_item 0 4 2
1
if (self !== parent) {
2
    /*
3
     * we need to determine the correct widget_id prefix here, loading from the parent
4
     * frame breaks when multiple choosers with creation support exist
5
     */
6
    var widget_id = window.parent.jQuery('iframe[src^="' + window.location.pathname + '"]:visible').attr("id");
7
    widget_id = widget_id.replace(/_creation_dialog_content/, '');
8
9
    function add_item(data) {
0 ignored issues
show
Bug introduced by
The function add_item is declared conditionally. This is not supported by all runtimes. Consider moving it to root scope or using var add_item = function() { /* ... */ }; instead.
Loading history...
10
        window.parent.midcom_helper_datamanager2_autocomplete.add_result_item(widget_id, data);
11
        window.parent.jQuery('#' + widget_id + '_creation_dialog').remove();
12
    }
13
14
    if (window.parent.$('#' + widget_id + '_creation_dialog').length > 0) {
15
        window.addEventListener('DOMContentLoaded', function() {
16
            attach_to_parent_dialog(window.parent.$('#' + widget_id + '_creation_dialog'));
17
        });
18
    }
19
}
20