Issues (4542)

js/custom.js (2 issues)

1
/* 
2
 * To change this license header, choose License Headers in Project Properties.
3
 * To change this template file, choose Tools | Templates
4
 * and open the template in the editor.
5
 */
6
7
/** ******  left menu  *********************** **/
8
$(function () {
9
    $('#sidebar-menu li ul').slideUp();
10
    $('#sidebar-menu li').removeClass('active');
11
12
    $('#sidebar-menu li').click(function () {
13
        if ($(this).is('.active')) {
14
            $(this).removeClass('active');
15
            $('ul', this).slideUp();
16
            $(this).removeClass('nv');
17
            $(this).addClass('vn');
18
        } else {
19
            $('#sidebar-menu li ul').slideUp();
20
            $(this).removeClass('vn');
21
            $(this).addClass('nv');
22
            $('ul', this).slideDown();
23
            $('#sidebar-menu li').removeClass('active');
24
            $(this).addClass('active');
25
        }
26
    });
27
28
    $('#menu_toggle').click(function () {
29
        if ($('body').hasClass('nav-md')) {
30
            $('body').removeClass('nav-md');
31
            $('body').addClass('nav-sm');
32
            $('.left_col').removeClass('scroll-view');
33
            $('.left_col').removeAttr('style');
34
            $('.sidebar-footer').hide();
35
36
            if ($('#sidebar-menu li').hasClass('active')) {
37
                $('#sidebar-menu li.active').addClass('active-sm');
38
                $('#sidebar-menu li.active').removeClass('active');
39
            }
40
        } else {
41
            $('body').removeClass('nav-sm');
42
            $('body').addClass('nav-md');
43
            $('.sidebar-footer').show();
44
45
            if ($('#sidebar-menu li').hasClass('active-sm')) {
46
                $('#sidebar-menu li.active-sm').addClass('active');
47
                $('#sidebar-menu li.active-sm').removeClass('active-sm');
48
            }
49
        }
50
    });
51
});
52
53
/* Sidebar Menu active class */
54
$(function () {
55
    var url = window.location;
56
    $('#sidebar-menu a[href="' + url + '"]').parent('li').addClass('current-page');
57
    $('#sidebar-menu a').filter(function () {
58
        return this.href == url;
59
    }).parent('li').addClass('current-page').parent('ul').slideDown().parent().addClass('active');
60
});
61
62
/** ******  /left menu  *********************** **/
63
64
65
66
/** ******  tooltip  *********************** **/
67
$(function () {
68
        $('[data-toggle="tooltip"]').tooltip()
69
    })
70
    /** ******  /tooltip  *********************** **/
71
    /** ******  progressbar  *********************** **/
72
if ($(".progress .progress-bar")[0]) {
73
    $('.progress .progress-bar').progressbar(); // bootstrap 3
74
}
75
/** ******  /progressbar  *********************** **/
76
/** ******  switchery  *********************** **/
77
if ($(".js-switch")[0]) {
78
    var elems = Array.prototype.slice.call(document.querySelectorAll('.js-switch'));
79
    elems.forEach(function (html) {
80
        var switchery = new Switchery(html, {
81
            color: '#26B99A'
82
        });
83
    });
84
}
85
/** ******  /switcher  *********************** **/
86
/** ******  collapse panel  *********************** **/
87
// Close ibox function
88
$('.close-link').click(function () {
89
    var content = $(this).closest('div.x_panel');
90
    content.remove();
91
});
92
93
// Collapse ibox function
94
$('.collapse-link').click(function () {
95
    var x_panel = $(this).closest('div.x_panel');
96
    var button = $(this).find('i');
97
    var content = x_panel.find('div.x_content');
98
    content.slideToggle(200);
99
    (x_panel.hasClass('fixed_height_390') ? x_panel.toggleClass('').toggleClass('fixed_height_390') : '');
100
    (x_panel.hasClass('fixed_height_320') ? x_panel.toggleClass('').toggleClass('fixed_height_320') : '');
101
    button.toggleClass('fa-chevron-up').toggleClass('fa-chevron-down');
102
    setTimeout(function () {
103
        x_panel.resize();
104
    }, 50);
105
});
106
/** ******  /collapse panel  *********************** **/
107
/** ******  iswitch  *********************** **/
108
if ($("input.flat")[0]) {
109
    $(document).ready(function () {
110
        $('input.flat').iCheck({
111
            checkboxClass: 'icheckbox_flat-green',
112
            radioClass: 'iradio_flat-green'
113
        });
114
    });
115
}
116
/** ******  /iswitch  *********************** **/
117
/** ******  star rating  *********************** **/
118
// Starrr plugin (https://github.com/dobtco/starrr)
119
var __slice = [].slice;
120
121
(function ($, window) {
122
    var Starrr;
123
124
    Starrr = (function () {
125
        Starrr.prototype.defaults = {
126
            rating: void 0,
0 ignored issues
show
Consider using undefined instead of void(0). It is equivalent and more straightforward to read.
Loading history...
127
            numStars: 5,
128
            change: function (e, value) {}
129
        };
130
131
        function Starrr($el, options) {
132
            var i, _, _ref,
133
                _this = this;
134
135
            this.options = $.extend({}, this.defaults, options);
136
            this.$el = $el;
137
            _ref = this.defaults;
138
            for (i in _ref) {
139
                _ = _ref[i];
140
                if (this.$el.data(i) != null) {
141
                    this.options[i] = this.$el.data(i);
142
                }
143
            }
144
            this.createStars();
145
            this.syncRating();
146
            this.$el.on('mouseover.starrr', 'span', function (e) {
147
                return _this.syncRating(_this.$el.find('span').index(e.currentTarget) + 1);
148
            });
149
            this.$el.on('mouseout.starrr', function () {
150
                return _this.syncRating();
151
            });
152
            this.$el.on('click.starrr', 'span', function (e) {
153
                return _this.setRating(_this.$el.find('span').index(e.currentTarget) + 1);
154
            });
155
            this.$el.on('starrr:change', this.options.change);
156
        }
157
158
        Starrr.prototype.createStars = function () {
159
            var _i, _ref, _results;
160
161
            _results = [];
162
            for (_i = 1, _ref = this.options.numStars; 1 <= _ref ? _i <= _ref : _i >= _ref; 1 <= _ref ? _i++ : _i--) {
163
                _results.push(this.$el.append("<span class='glyphicon .glyphicon-star-empty'></span>"));
164
            }
165
            return _results;
166
        };
167
168
        Starrr.prototype.setRating = function (rating) {
169
            if (this.options.rating === rating) {
170
                rating = void 0;
0 ignored issues
show
Consider using undefined instead of void(0). It is equivalent and more straightforward to read.
Loading history...
171
            }
172
            this.options.rating = rating;
173
            this.syncRating();
174
            return this.$el.trigger('starrr:change', rating);
175
        };
176
177
        Starrr.prototype.syncRating = function (rating) {
178
            var i, _i, _j, _ref;
179
180
            rating || (rating = this.options.rating);
181
            if (rating) {
182
                for (i = _i = 0, _ref = rating - 1; 0 <= _ref ? _i <= _ref : _i >= _ref; i = 0 <= _ref ? ++_i : --_i) {
183
                    this.$el.find('span').eq(i).removeClass('glyphicon-star-empty').addClass('glyphicon-star');
184
                }
185
            }
186
            if (rating && rating < 5) {
187
                for (i = _j = rating; rating <= 4 ? _j <= 4 : _j >= 4; i = rating <= 4 ? ++_j : --_j) {
188
                    this.$el.find('span').eq(i).removeClass('glyphicon-star').addClass('glyphicon-star-empty');
189
                }
190
            }
191
            if (!rating) {
192
                return this.$el.find('span').removeClass('glyphicon-star').addClass('glyphicon-star-empty');
193
            }
194
        };
195
196
        return Starrr;
197
198
    })();
199
    return $.fn.extend({
200
        starrr: function () {
201
            var args, option;
202
203
            option = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
204
            return this.each(function () {
205
                var data;
206
207
                data = $(this).data('star-rating');
208
                if (!data) {
209
                    $(this).data('star-rating', (data = new Starrr($(this), option)));
210
                }
211
                if (typeof option === 'string') {
212
                    return data[option].apply(data, args);
213
                }
214
            });
215
        }
216
    });
217
})(window.jQuery, window);
218
219
$(function () {
220
    return $(".starrr").starrr();
221
});
222
223
$(document).ready(function () {
224
225
    $('#stars').on('starrr:change', function (e, value) {
226
        $('#count').html(value);
227
    });
228
229
230
    $('#stars-existing').on('starrr:change', function (e, value) {
231
        $('#count-existing').html(value);
232
    });
233
234
});
235
/** ******  /star rating  *********************** **/
236
/** ******  table  *********************** **/
237
$('table input').on('ifChecked', function () {
238
    check_state = '';
239
    $(this).parent().parent().parent().addClass('selected');
240
    countChecked();
241
});
242
$('table input').on('ifUnchecked', function () {
243
    check_state = '';
244
    $(this).parent().parent().parent().removeClass('selected');
245
    countChecked();
246
});
247
248
var check_state = '';
249
$('.bulk_action input').on('ifChecked', function () {
250
    check_state = '';
251
    $(this).parent().parent().parent().addClass('selected');
252
    countChecked();
253
});
254
$('.bulk_action input').on('ifUnchecked', function () {
255
    check_state = '';
256
    $(this).parent().parent().parent().removeClass('selected');
257
    countChecked();
258
});
259
$('.bulk_action input#check-all').on('ifChecked', function () {
260
    check_state = 'check_all';
261
    countChecked();
262
});
263
$('.bulk_action input#check-all').on('ifUnchecked', function () {
264
    check_state = 'uncheck_all';
265
    countChecked();
266
});
267
268
function countChecked() {
269
        if (check_state == 'check_all') {
270
            $(".bulk_action input[name='table_records']").iCheck('check');
271
        }
272
        if (check_state == 'uncheck_all') {
273
            $(".bulk_action input[name='table_records']").iCheck('uncheck');
274
        }
275
        var n = $(".bulk_action input[name='table_records']:checked").length;
276
        if (n > 0) {
277
            $('.column-title').hide();
278
            $('.bulk-actions').show();
279
            $('.action-cnt').html(n + ' Records Selected');
280
        } else {
281
            $('.column-title').show();
282
            $('.bulk-actions').hide();
283
        }
284
    }
285
    /** ******  /table  *********************** **/
286
    /** ******    *********************** **/
287
    /** ******    *********************** **/
288
    /** ******    *********************** **/
289
    /** ******    *********************** **/
290
    /** ******    *********************** **/
291
    /** ******    *********************** **/
292
    /** ******  Accordion  *********************** **/
293
294
$(function () {
295
    $(".expand").on("click", function () {
296
        $(this).next().slideToggle(200);
297
        $expand = $(this).find(">:first-child");
298
299
        if ($expand.text() == "+") {
300
            $expand.text("-");
301
        } else {
302
            $expand.text("+");
303
        }
304
    });
305
});
306
307
/** ******  Accordion  *********************** **/
308
/** ******  scrollview  *********************** **/
309
$(document).ready(function () {
310
  
311
            $(".scroll-view").niceScroll({
312
                touchbehavior: true,
313
                cursorcolor: "rgba(42, 63, 84, 0.35)"
314
            });
315
316
});
317
/** ******  /scrollview  *********************** **/