Total Complexity | 8 |
Complexity/F | 1.33 |
Lines of Code | 38 |
Function Count | 6 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | var $ = window.jQuery; |
||
2 | |||
3 | exports.settings = { |
||
4 | haveBeenModified: false, |
||
5 | init: function() { |
||
6 | |||
7 | Amarkal.settings.fields.init(); |
||
|
|||
8 | Amarkal.settings.search.init(); |
||
9 | Amarkal.settings.sections.init(); |
||
10 | |||
11 | $('.amarkal-ui-component').on('amarkal.change',function(e, component){ |
||
12 | Amarkal.settings.notifier.notice("Settings have changed, click \"Save\" to apply them."); |
||
13 | Amarkal.settings.sections.flag('notice', component.props.section); |
||
14 | Amarkal.settings.fields.flag('notice', component.props.name); |
||
15 | Amarkal.settings.haveBeenModified = true; |
||
16 | }).on('amarkal.hide', function(){ |
||
17 | Amarkal.settings.fields.hide($(this).parents('.amarkal-settings-field')); |
||
18 | }).on('amarkal.show', function(){ |
||
19 | if($(this).parents('.amarkal-settings-field').attr('data-section') === Amarkal.settings.sections.activeSection) { |
||
20 | Amarkal.settings.fields.show($(this).parents('.amarkal-settings-field')); |
||
21 | } |
||
22 | }); |
||
23 | |||
24 | // This is called after the onChange/hide/show event listeners are added since some events |
||
25 | // are triggered when the form is instantiated |
||
26 | $('#amarkal-settings-form').amarkalUIForm(); |
||
27 | |||
28 | $(window).on('beforeunload',function(){ |
||
29 | if(Amarkal.settings.haveBeenModified) { |
||
30 | return 'Are you sure you want to leave this page?'; |
||
31 | } |
||
32 | }); |
||
33 | } |
||
34 | }; |
||
35 | |||
36 | $(document).ready(function(){ |
||
37 | Amarkal.settings.init(); |
||
38 | }); |
||
39 |
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.