Conditions | 2 |
Paths | 4 |
Total Lines | 172 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | /* |
||
8 | $(document).ready(function () { |
||
9 | |||
10 | |||
11 | // Add body-small class if window less than 768px |
||
12 | if ($(this).width() < 769) { |
||
13 | $('body').addClass('body-small') |
||
14 | } else { |
||
15 | $('body').removeClass('body-small') |
||
16 | } |
||
17 | |||
18 | // MetisMenu |
||
19 | $('#side-menu').metisMenu(); |
||
20 | |||
21 | // Collapse ibox function |
||
22 | $('.collapse-link').on('click', function () { |
||
23 | var ibox = $(this).closest('div.ibox'); |
||
24 | var button = $(this).find('i'); |
||
25 | var content = ibox.children('.ibox-content'); |
||
26 | content.slideToggle(200); |
||
27 | button.toggleClass('fa-chevron-up').toggleClass('fa-chevron-down'); |
||
28 | ibox.toggleClass('').toggleClass('border-bottom'); |
||
29 | setTimeout(function () { |
||
30 | ibox.resize(); |
||
31 | ibox.find('[id^=map-]').resize(); |
||
32 | }, 50); |
||
33 | }); |
||
34 | |||
35 | // Close ibox function |
||
36 | $('.close-link').on('click', function () { |
||
37 | var content = $(this).closest('div.ibox'); |
||
38 | content.remove(); |
||
39 | }); |
||
40 | |||
41 | // Fullscreen ibox function |
||
42 | $('.fullscreen-link').on('click', function () { |
||
43 | var ibox = $(this).closest('div.ibox'); |
||
44 | var button = $(this).find('i'); |
||
45 | $('body').toggleClass('fullscreen-ibox-mode'); |
||
46 | button.toggleClass('fa-expand').toggleClass('fa-compress'); |
||
47 | ibox.toggleClass('fullscreen'); |
||
48 | setTimeout(function () { |
||
49 | $(window).trigger('resize'); |
||
50 | }, 100); |
||
51 | }); |
||
52 | |||
53 | // Close menu in canvas mode |
||
54 | $('.close-canvas-menu').on('click', function () { |
||
55 | $("body").toggleClass("mini-navbar"); |
||
56 | SmoothlyMenu(); |
||
57 | }); |
||
58 | |||
59 | // Run menu of canvas |
||
60 | $('body.canvas-menu .sidebar-collapse').slimScroll({ |
||
61 | height: '100%', |
||
62 | railOpacity: 0.9 |
||
63 | }); |
||
64 | |||
65 | // Open close right sidebar |
||
66 | $('.right-sidebar-toggle').on('click', function () { |
||
67 | $('#right-sidebar').toggleClass('sidebar-open'); |
||
68 | }); |
||
69 | |||
70 | // Initialize slimscroll for right sidebar |
||
71 | $('.sidebar-container').slimScroll({ |
||
72 | height: '100%', |
||
73 | railOpacity: 0.4, |
||
74 | wheelStep: 10 |
||
75 | }); |
||
76 | |||
77 | // Open close small chat |
||
78 | $('.open-small-chat').on('click', function () { |
||
79 | $(this).children().toggleClass('fa-comments').toggleClass('fa-remove'); |
||
80 | $('.small-chat-box').toggleClass('active'); |
||
81 | }); |
||
82 | |||
83 | // Initialize slimscroll for small chat |
||
84 | $('.small-chat-box .content').slimScroll({ |
||
85 | height: '234px', |
||
86 | railOpacity: 0.4 |
||
87 | }); |
||
88 | |||
89 | // Small todo handler |
||
90 | $('.check-link').on('click', function () { |
||
91 | var button = $(this).find('i'); |
||
92 | var label = $(this).next('span'); |
||
93 | button.toggleClass('fa-check-square').toggleClass('fa-square-o'); |
||
94 | label.toggleClass('todo-completed'); |
||
95 | return false; |
||
96 | }); |
||
97 | |||
98 | // Append config box / Only for demo purpose |
||
99 | // Uncomment on server mode to enable XHR calls |
||
100 | // $.get("skin-config.html", function (data) { |
||
101 | // if (!$('body').hasClass('no-skin-config')) |
||
102 | // $('body').append(data); |
||
103 | // }); |
||
104 | |||
105 | // Minimalize menu |
||
106 | $('.navbar-minimalize').on('click', function () { |
||
107 | $("body").toggleClass("mini-navbar"); |
||
108 | SmoothlyMenu(); |
||
109 | |||
110 | }); |
||
111 | |||
112 | // Tooltips demo |
||
113 | $('.tooltip-demo').tooltip({ |
||
114 | selector: "[data-toggle=tooltip]", |
||
115 | container: "body" |
||
116 | }); |
||
117 | |||
118 | |||
119 | // Full height of sidebar |
||
120 | function fix_height() { |
||
121 | var heightWithoutNavbar = $("body > #wrapper").height() - 61; |
||
122 | $(".sidebar-panel").css("min-height", heightWithoutNavbar + "px"); |
||
123 | |||
124 | var navbarheight = $('nav.navbar-default').height(); |
||
125 | var wrapperHeight = $('#page-wrapper').height(); |
||
126 | |||
127 | if (navbarheight > wrapperHeight) { |
||
128 | $('#page-wrapper').css("min-height", navbarheight + "px"); |
||
129 | } |
||
130 | |||
131 | if (navbarheight < wrapperHeight) { |
||
132 | $('#page-wrapper').css("min-height", $(window).height() + "px"); |
||
133 | } |
||
134 | |||
135 | if ($('body').hasClass('fixed-nav')) { |
||
136 | if (navbarheight > wrapperHeight) { |
||
137 | $('#page-wrapper').css("min-height", navbarheight + "px"); |
||
138 | } else { |
||
139 | $('#page-wrapper').css("min-height", $(window).height() - 60 + "px"); |
||
140 | } |
||
141 | } |
||
142 | |||
143 | } |
||
144 | |||
145 | fix_height(); |
||
146 | |||
147 | // Fixed Sidebar |
||
148 | $(window).bind("load", function () { |
||
149 | if ($("body").hasClass('fixed-sidebar')) { |
||
150 | $('.sidebar-collapse').slimScroll({ |
||
151 | height: '100%', |
||
152 | railOpacity: 0.9 |
||
153 | }); |
||
154 | } |
||
155 | }); |
||
156 | |||
157 | // Move right sidebar top after scroll |
||
158 | $(window).scroll(function () { |
||
159 | if ($(window).scrollTop() > 0 && !$('body').hasClass('fixed-nav')) { |
||
160 | $('#right-sidebar').addClass('sidebar-top'); |
||
161 | } else { |
||
162 | $('#right-sidebar').removeClass('sidebar-top'); |
||
163 | } |
||
164 | }); |
||
165 | |||
166 | $(window).bind("load resize scroll", function () { |
||
167 | if (!$("body").hasClass('body-small')) { |
||
168 | fix_height(); |
||
169 | } |
||
170 | }); |
||
171 | |||
172 | $("[data-toggle=popover]") |
||
173 | .popover(); |
||
174 | |||
175 | // Add slimscroll to element |
||
176 | $('.full-height-scroll').slimscroll({ |
||
177 | height: '100%' |
||
178 | }) |
||
179 | }); |
||
180 | |||
298 |
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.