Completed
Push — master ( 108b89...0a9573 )
by Craig
06:27
created

src/lib/Zikula/Bundle/CoreBundle/Resources/public/js/jquery_config.js   A

Complexity

Total Complexity 10
Complexity/F 2

Size

Lines of Code 37
Function Count 5

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
nc 8
dl 0
loc 37
rs 10
c 1
b 0
f 0
wmc 10
mnd 2
bc 8
fnc 5
bpm 1.6
cpm 2
noi 2

2 Functions

Rating   Name   Duplication   Size   Complexity  
A jquery_config.js ➔ disablePrototypeJS 0 11 1
A 0 15 4
1
// Copyright Zikula Foundation, licensed MIT.
2
3
jQuery.noConflict();
4
/*
5
 Fix provided by http://softec.lu/site/DevelopersCorner/BootstrapPrototypeConflict
6
 */
7
if (typeof Prototype !== 'undefined' && Prototype.BrowserFeatures.ElementExtensions) {
0 ignored issues
show
Bug introduced by
The variable Prototype seems to be never declared. If this is a global, consider adding a /** global: Prototype */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
8
    var disablePrototypeJS = function (method, pluginsToDisable) {
9
            var handler = function (event) {
10
                event.target[method] = undefined;
11
                setTimeout(function () {
12
                    delete event.target[method];
13
                }, 0);
14
            };
15
            pluginsToDisable.each(function (plugin) {
16
                jQuery(window).on(method + '.bs.' + plugin, handler);
17
            });
18
        },
19
        pluginsToDisable = ['collapse', 'dropdown', 'modal', 'tooltip', 'popover', 'tab'];
20
    disablePrototypeJS('show', pluginsToDisable);
21
    disablePrototypeJS('hide', pluginsToDisable);
22
}
23
24
// setup ajax for jQuery
25
(function($) {
26
    var defaultOptions = {
27
        type: 'POST',
28
        timeout: Zikula.Config.ajaxtimeout || 5000
0 ignored issues
show
Bug introduced by
The variable Zikula seems to be never declared. If this is a global, consider adding a /** global: Zikula */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
29
    };
30
    if (Zikula.Config.sessionName) {
31
        var sessionId = new RegExp(Zikula.Config.sessionName + '=(.*?)(;|$)').exec(document.cookie);
32
        if (sessionId && sessionId[1]) {
33
            defaultOptions.headers = {
34
                'X-ZIKULA-AJAX-TOKEN': sessionId[1]
35
            };
36
        }
37
    }
38
    $.ajaxSetup(defaultOptions);
39
})(jQuery);
40