1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- $(function() {
- $('#suggestions').hide();
- $('#nav-toggle').click(function() {
- $('#nav-toggle').toggleClass('is-active');
- $('#nav-menu').toggleClass('is-active');
- });
- $('#search_button').click(function () {
- var query = $('#search_field').val().trim();
- if (query.length == 0)
- return;
- document.location.href = '/search?q=' + query;
- });
-
- $('#search_field').on('keyup', function (event) {
- if (event.keyCode == 13) {
- $('#search_button').click();
- return;
- }
- var query = $('#search_field').val();
- query = query.trim();
- if (query.length == 0) {
- $('#suggestions').hide();
- return;
- }
- suggest('#suggestions', '#suggestions_content', '#search_field', query);
- });
- if (window.my_user_id >= 0) {
- $('#navbar_user_link').attr('href', '/user/' + String(window.my_user_id));
- api('user', {user_id: window.my_user_id}, function (data) {
- $('#navbar_avatar').attr('src', data.avatar128);
- var username = data.username;
- if (username.length > 10)
- username = username.slice(0, 10) + '...';
- $('#navbar_username').text(username);
- });
- $('#logout_button').click(function () {
- api('logout', {}, function () {
- popup('primary', 'Successfully logged out!');
- setTimeout(function () {
- document.location.href = '/';
- }, 1500);
- });
- });
- }
- });
|