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

chooser.js ➔ add_item   A

Complexity

Conditions 2

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 3
dl 0
loc 4
rs 10
c 0
b 0
f 0
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