Change naming and veriy test-scheduler function
[bottlenecks.git] / test-scheduler / ui / src / assets / js / inspinia.js
1 /*
2  *
3  *   INSPINIA - Responsive Admin Theme
4  *   version 2.7.1
5  *
6  */
7
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 (event) {
107         event.preventDefault();
108         $("body").toggleClass("mini-navbar");
109         SmoothlyMenu();
110
111     });
112
113     // Tooltips demo
114     $('.tooltip-demo').tooltip({
115         selector: "[data-toggle=tooltip]",
116         container: "body"
117     });
118
119
120     // Full height of sidebar
121     function fix_height() {
122         var heightWithoutNavbar = $("body > #wrapper").height() - 61;
123         $(".sidebar-panel").css("min-height", heightWithoutNavbar + "px");
124
125         var navbarheight = $('nav.navbar-default').height();
126         var wrapperHeight = $('#page-wrapper').height();
127
128         if (navbarheight > wrapperHeight) {
129             $('#page-wrapper').css("min-height", navbarheight + "px");
130         }
131
132         if (navbarheight < wrapperHeight) {
133             $('#page-wrapper').css("min-height", $(window).height() + "px");
134         }
135
136         if ($('body').hasClass('fixed-nav')) {
137             if (navbarheight > wrapperHeight) {
138                 $('#page-wrapper').css("min-height", navbarheight + "px");
139             } else {
140                 $('#page-wrapper').css("min-height", $(window).height() - 60 + "px");
141             }
142         }
143
144     }
145
146     fix_height();
147
148     // Fixed Sidebar
149     $(window).bind("load", function () {
150         if ($("body").hasClass('fixed-sidebar')) {
151             $('.sidebar-collapse').slimScroll({
152                 height: '100%',
153                 railOpacity: 0.9
154             });
155         }
156     });
157
158     // Move right sidebar top after scroll
159     $(window).scroll(function () {
160         if ($(window).scrollTop() > 0 && !$('body').hasClass('fixed-nav')) {
161             $('#right-sidebar').addClass('sidebar-top');
162         } else {
163             $('#right-sidebar').removeClass('sidebar-top');
164         }
165     });
166
167     $(window).bind("load resize scroll", function () {
168         if (!$("body").hasClass('body-small')) {
169             fix_height();
170         }
171     });
172
173     $("[data-toggle=popover]")
174         .popover();
175
176     // Add slimscroll to element
177     $('.full-height-scroll').slimscroll({
178         height: '100%'
179     })
180 });
181
182
183 // Minimalize menu when screen is less than 768px
184 $(window).bind("resize", function () {
185     if ($(this).width() < 769) {
186         $('body').addClass('body-small')
187     } else {
188         $('body').removeClass('body-small')
189     }
190 });
191
192 // Local Storage functions
193 // Set proper body class and plugins based on user configuration
194 $(document).ready(function () {
195     if (localStorageSupport()) {
196
197         var collapse = localStorage.getItem("collapse_menu");
198         var fixedsidebar = localStorage.getItem("fixedsidebar");
199         var fixednavbar = localStorage.getItem("fixednavbar");
200         var boxedlayout = localStorage.getItem("boxedlayout");
201         var fixedfooter = localStorage.getItem("fixedfooter");
202
203         var body = $('body');
204
205         if (fixedsidebar == 'on') {
206             body.addClass('fixed-sidebar');
207             $('.sidebar-collapse').slimScroll({
208                 height: '100%',
209                 railOpacity: 0.9
210             });
211         }
212
213         if (collapse == 'on') {
214             if (body.hasClass('fixed-sidebar')) {
215                 if (!body.hasClass('body-small')) {
216                     body.addClass('mini-navbar');
217                 }
218             } else {
219                 if (!body.hasClass('body-small')) {
220                     body.addClass('mini-navbar');
221                 }
222
223             }
224         }
225
226         if (fixednavbar == 'on') {
227             $(".navbar-static-top").removeClass('navbar-static-top').addClass('navbar-fixed-top');
228             body.addClass('fixed-nav');
229         }
230
231         if (boxedlayout == 'on') {
232             body.addClass('boxed-layout');
233         }
234
235         if (fixedfooter == 'on') {
236             $(".footer").addClass('fixed');
237         }
238     }
239 });
240
241 // check if browser support HTML5 local storage
242 function localStorageSupport() {
243     return (('localStorage' in window) && window['localStorage'] !== null)
244 }
245
246 // For demo purpose - animation css script
247 function animationHover(element, animation) {
248     element = $(element);
249     element.hover(
250         function () {
251             element.addClass('animated ' + animation);
252         },
253         function () {
254             //wait for animation to finish before removing classes
255             window.setTimeout(function () {
256                 element.removeClass('animated ' + animation);
257             }, 2000);
258         });
259 }
260
261 function SmoothlyMenu() {
262     if (!$('body').hasClass('mini-navbar') || $('body').hasClass('body-small')) {
263         // Hide menu in order to smoothly turn on when maximize menu
264         $('#side-menu').hide();
265         // For smoothly turn on menu
266         setTimeout(
267             function () {
268                 $('#side-menu').fadeIn(400);
269             }, 200);
270     } else if ($('body').hasClass('fixed-sidebar')) {
271         $('#side-menu').hide();
272         setTimeout(
273             function () {
274                 $('#side-menu').fadeIn(400);
275             }, 100);
276     } else {
277         // Remove all inline style from jquery fadeIn function to reset menu state
278         $('#side-menu').removeAttr('style');
279     }
280 }
281
282 // Dragable panels
283 function WinMove() {
284     var element = "[class*=col]";
285     var handle = ".ibox-title";
286     var connect = "[class*=col]";
287     $(element).sortable(
288         {
289             handle: handle,
290             connectWith: connect,
291             tolerance: 'pointer',
292             forcePlaceholderSize: true,
293             opacity: 0.8
294         })
295         .disableSelection();
296 }
297
298