static/midgard.admin.asgard/object_browser.js   A
last analyzed

Complexity

Total Complexity 5
Complexity/F 2.5

Size

Lines of Code 28
Function Count 2

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 15
c 0
b 0
f 0
dl 0
loc 28
rs 10
wmc 5
mnd 3
bc 3
fnc 2
bpm 1.5
cpm 2.5
noi 0
1
$(document).ready(function() {
2
    $('#content').on('click', 'a.thickbox', function(event) {
3
        if (!this.dataset.initialized) {
4
            event.preventDefault();
5
6
            // Add ajax to each colorbox link. This will tell to Asgard that it
7
            // should show only the object view style and nothing else.
8
            var link = this.href;
9
10
            if (!link) {
11
                link = '';
12
            }
13
14
            if (link.match(/\?/)) {
15
                link = link.replace(/\?/, '?ajax&');
16
            } else {
17
                link += '?ajax';
18
            }
19
20
            // Convert the link to use thickbox
21
            this.href = link;
22
            this.target = '_self';
23
24
            $(this).colorbox({maxHeight: '90%', maxWidth: '90%', fixed: true});
25
            this.dataset.initialized = true;
26
        }
27
    });
28
});
29