Code Duplication    Length = 288-288 lines in 2 locations

src/web/assets/inspinia/dist/js/inspinia.js 1 location

@@ 9-296 (lines=288) @@
6
 *
7
 */
8
9
$(document).ready(function () {
10
11
12
    // Add body-small class if window less than 768px
13
    if ($(this).width() < 769) {
14
        $('body').addClass('body-small')
15
    } else {
16
        $('body').removeClass('body-small')
17
    }
18
19
    // MetisMenu
20
    $('#side-menu').metisMenu();
21
22
    // Collapse ibox function
23
    $('.collapse-link').on('click', function () {
24
        var ibox = $(this).closest('div.ibox');
25
        var button = $(this).find('i');
26
        var content = ibox.children('.ibox-content');
27
        content.slideToggle(200);
28
        button.toggleClass('fa-chevron-up').toggleClass('fa-chevron-down');
29
        ibox.toggleClass('').toggleClass('border-bottom');
30
        setTimeout(function () {
31
            ibox.resize();
32
            ibox.find('[id^=map-]').resize();
33
        }, 50);
34
    });
35
36
    // Close ibox function
37
    $('.close-link').on('click', function () {
38
        var content = $(this).closest('div.ibox');
39
        content.remove();
40
    });
41
42
    // Fullscreen ibox function
43
    $('.fullscreen-link').on('click', function () {
44
        var ibox = $(this).closest('div.ibox');
45
        var button = $(this).find('i');
46
        $('body').toggleClass('fullscreen-ibox-mode');
47
        button.toggleClass('fa-expand').toggleClass('fa-compress');
48
        ibox.toggleClass('fullscreen');
49
        setTimeout(function () {
50
            $(window).trigger('resize');
51
        }, 100);
52
    });
53
54
    // Close menu in canvas mode
55
    $('.close-canvas-menu').on('click', function () {
56
        $("body").toggleClass("mini-navbar");
57
        SmoothlyMenu();
58
    });
59
60
    // Run menu of canvas
61
    $('body.canvas-menu .sidebar-collapse').slimScroll({
62
        height: '100%',
63
        railOpacity: 0.9
64
    });
65
66
    // Open close right sidebar
67
    $('.right-sidebar-toggle').on('click', function () {
68
        $('#right-sidebar').toggleClass('sidebar-open');
69
    });
70
71
    // Initialize slimscroll for right sidebar
72
    $('.sidebar-container').slimScroll({
73
        height: '100%',
74
        railOpacity: 0.4,
75
        wheelStep: 10
76
    });
77
78
    // Open close small chat
79
    $('.open-small-chat').on('click', function () {
80
        $(this).children().toggleClass('fa-comments').toggleClass('fa-remove');
81
        $('.small-chat-box').toggleClass('active');
82
    });
83
84
    // Initialize slimscroll for small chat
85
    $('.small-chat-box .content').slimScroll({
86
        height: '234px',
87
        railOpacity: 0.4
88
    });
89
90
    // Small todo handler
91
    $('.check-link').on('click', function () {
92
        var button = $(this).find('i');
93
        var label = $(this).next('span');
94
        button.toggleClass('fa-check-square').toggleClass('fa-square-o');
95
        label.toggleClass('todo-completed');
96
        return false;
97
    });
98
99
    // Append config box / Only for demo purpose
100
    // Uncomment on server mode to enable XHR calls
101
    // $.get("skin-config.html", function (data) {
102
    //     if (!$('body').hasClass('no-skin-config'))
103
    //         $('body').append(data);
104
    // });
105
106
    // Minimalize menu
107
    $('.navbar-minimalize').on('click', function () {
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
299

src/web/assets/inspinia/src/js/inspinia.js 1 location

@@ 8-295 (lines=288) @@
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 () {
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
181
182
// Minimalize menu when screen is less than 768px
183
$(window).bind("resize", function () {
184
    if ($(this).width() < 769) {
185
        $('body').addClass('body-small')
186
    } else {
187
        $('body').removeClass('body-small')
188
    }
189
});
190
191
// Local Storage functions
192
// Set proper body class and plugins based on user configuration
193
$(document).ready(function () {
194
    if (localStorageSupport()) {
195
196
        var collapse = localStorage.getItem("collapse_menu");
197
        var fixedsidebar = localStorage.getItem("fixedsidebar");
198
        var fixednavbar = localStorage.getItem("fixednavbar");
199
        var boxedlayout = localStorage.getItem("boxedlayout");
200
        var fixedfooter = localStorage.getItem("fixedfooter");
201
202
        var body = $('body');
203
204
        if (fixedsidebar == 'on') {
205
            body.addClass('fixed-sidebar');
206
            $('.sidebar-collapse').slimScroll({
207
                height: '100%',
208
                railOpacity: 0.9
209
            });
210
        }
211
212
        if (collapse == 'on') {
213
            if (body.hasClass('fixed-sidebar')) {
214
                if (!body.hasClass('body-small')) {
215
                    body.addClass('mini-navbar');
216
                }
217
            } else {
218
                if (!body.hasClass('body-small')) {
219
                    body.addClass('mini-navbar');
220
                }
221
222
            }
223
        }
224
225
        if (fixednavbar == 'on') {
226
            $(".navbar-static-top").removeClass('navbar-static-top').addClass('navbar-fixed-top');
227
            body.addClass('fixed-nav');
228
        }
229
230
        if (boxedlayout == 'on') {
231
            body.addClass('boxed-layout');
232
        }
233
234
        if (fixedfooter == 'on') {
235
            $(".footer").addClass('fixed');
236
        }
237
    }
238
});
239
240
// check if browser support HTML5 local storage
241
function localStorageSupport() {
242
    return (('localStorage' in window) && window['localStorage'] !== null)
243
}
244
245
// For demo purpose - animation css script
246
function animationHover(element, animation) {
247
    element = $(element);
248
    element.hover(
249
        function () {
250
            element.addClass('animated ' + animation);
251
        },
252
        function () {
253
            //wait for animation to finish before removing classes
254
            window.setTimeout(function () {
255
                element.removeClass('animated ' + animation);
256
            }, 2000);
257
        });
258
}
259
260
function SmoothlyMenu() {
261
    if (!$('body').hasClass('mini-navbar') || $('body').hasClass('body-small')) {
262
        // Hide menu in order to smoothly turn on when maximize menu
263
        $('#side-menu').hide();
264
        // For smoothly turn on menu
265
        setTimeout(
266
            function () {
267
                $('#side-menu').fadeIn(400);
268
            }, 200);
269
    } else if ($('body').hasClass('fixed-sidebar')) {
270
        $('#side-menu').hide();
271
        setTimeout(
272
            function () {
273
                $('#side-menu').fadeIn(400);
274
            }, 100);
275
    } else {
276
        // Remove all inline style from jquery fadeIn function to reset menu state
277
        $('#side-menu').removeAttr('style');
278
    }
279
}
280
281
// Dragable panels
282
function WinMove() {
283
    var element = "[class*=col]";
284
    var handle = ".ibox-title";
285
    var connect = "[class*=col]";
286
    $(element).sortable(
287
        {
288
            handle: handle,
289
            connectWith: connect,
290
            tolerance: 'pointer',
291
            forcePlaceholderSize: true,
292
            opacity: 0.8
293
        })
294
        .disableSelection();
295
}
296
297
298