1
|
|
|
$(document).ready(function () { |
2
|
|
|
// script needed for the autocompletion search engine |
3
|
|
|
$('#auto').autocomplete({ |
4
|
|
|
source: '../../../php/includes/autocomplete.php?extraParams=title', |
5
|
|
|
minLength: 2 |
6
|
|
|
}); |
7
|
|
|
|
8
|
|
|
$('#search_text_side').autocomplete({ |
9
|
|
|
source: '../../../php/includes/autocomplete.php?extraParams=title', |
10
|
|
|
minLength: 2, |
11
|
|
|
position: { |
12
|
|
|
my: 'left top', |
13
|
|
|
at: 'right top', |
14
|
|
|
of: $('#skin_side'), |
15
|
|
|
collision: 'flipfit none' |
16
|
|
|
} |
17
|
|
|
}); |
18
|
|
|
|
19
|
|
|
// Hide the auto-completion list when the window is resized, |
20
|
|
|
// as it won't follow the new position of the search box |
21
|
|
|
$(window).resize(function () { |
22
|
|
|
$('.ui-autocomplete').css('display', 'none'); |
23
|
|
|
}); |
24
|
|
|
|
25
|
|
|
// Skin switcher |
26
|
|
|
$('.clearfix li a').click(function () { |
27
|
|
|
var skin = $(this).data('skin'); |
28
|
|
|
var cssPath = '../../../themes/styles/' + skin + '/css/style.css'; |
29
|
|
|
var logoImgPath = '../../../themes/styles/' + skin + '/images/logos/top_logo01.png'; |
30
|
|
|
var logoImg480Path = '../../../themes/styles/' + skin + '/images/logos/top_logo01_480.png'; |
31
|
|
|
var logoBeePath = '../../../themes/styles/' + skin + '/images/top_right01.png'; |
32
|
|
|
|
33
|
|
|
$('link#main_stylesheet').attr('href', cssPath); |
34
|
|
|
$('#logo_img').attr('src', logoImgPath); |
35
|
|
|
$('#logo_img_480').attr('src', logoImg480Path); |
36
|
|
|
$('#img_bee').attr('src', logoBeePath); |
37
|
|
|
$.post('../../../php/main/front/skin_switcher.php?action=skinswitch&skin=' + skin); |
38
|
|
|
return false; |
39
|
|
|
}); |
40
|
|
|
|
41
|
|
|
// script needed for the side menu |
42
|
|
|
$('[data-toggle]').click(function () { |
43
|
|
|
var toggleEl = $(this).data('toggle'); |
44
|
|
|
$(toggleEl).toggleClass('open-sidebar'); |
45
|
|
|
}); |
46
|
|
|
|
47
|
|
|
// script needed log in menu |
48
|
|
|
$('#login-trigger').click(function () { |
49
|
|
|
$(this).next('#login-content').slideToggle(); |
50
|
|
|
$(this).toggleClass('active'); |
51
|
|
|
|
52
|
|
|
if ($(this).hasClass('active')) $(this).find('span').html('▲') |
|
|
|
|
53
|
|
|
else $(this).find('span').html('▼') |
54
|
|
|
}) |
55
|
|
|
|
56
|
|
|
// The 'go to the top' button |
57
|
|
|
$(document).on('scroll', function () { |
58
|
|
|
if ($(window).scrollTop() > 100) { |
59
|
|
|
$('.scroll-top-wrapper').addClass('show'); |
60
|
|
|
} else { |
61
|
|
|
$('.scroll-top-wrapper').removeClass('show'); |
62
|
|
|
} |
63
|
|
|
}); |
64
|
|
|
|
65
|
|
|
$('.scroll-top-wrapper').on('click', function () { |
66
|
|
|
var element = $('body'); |
67
|
|
|
var offset = element.offset(); |
68
|
|
|
var offsetTop = offset.top; |
69
|
|
|
$('html, body').animate({ |
70
|
|
|
scrollTop: offsetTop |
71
|
|
|
}, 500, 'linear'); |
72
|
|
|
}); |
73
|
|
|
}); |
74
|
|
|
|
75
|
|
|
window.OSDMessageDisplay = function (message) { |
76
|
|
|
$.notify_osd.create({ |
77
|
|
|
'text': message, // notification message |
78
|
|
|
'icon': '../../../themes/styles/1/images/osd_icons/star.png', // icon path, 48x48 |
79
|
|
|
'sticky': false, // if true, timeout is ignored |
80
|
|
|
'timeout': 4, // disappears after 6 seconds |
81
|
|
|
'dismissable': true // can be dismissed manually |
82
|
|
|
}); |
83
|
|
|
} |
84
|
|
|
|
Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.
Consider:
If you or someone else later decides to put another statement in, only the first statement will be executed.
In this case the statement
b = 42
will always be executed, while the logging statement will be executed conditionally.ensures that the proper code will be executed conditionally no matter how many statements are added or removed.