[#277] add js file

This commit is contained in:
Alexander Machehin 2013-09-10 23:25:32 +06:00
parent 5ff87be8a9
commit 8e27085213
1 changed files with 43 additions and 0 deletions

View File

@ -0,0 +1,43 @@
$(document).ready(function() {
var profile_table = $('.profile-table');
var profile_path = $('#profile_path').text();
var profile_vis_buttons = $('.profile-content .span12.sub-menu nav a');
var profile_search_field = $('.profile-content .search #query_projects');
var load_profile_projects = function (page_number) {
var visibility = 'visibility=' + ($('.profile-content .span12.sub-menu nav a.active').hasClass('public-projects') ? 'open' : 'hidden');
var search = 'search=' + profile_search_field.val();
page = 'page=' + (page_number || $('.pagination .current').text());
$.ajax({
type: 'GET',
url: profile_path,
data: 'projects=show&' + visibility + '&' + search + '&' + page,
success: function(data){
profile_table.html(data);
updateTime();
},
error: function(data){
alert('error') // TODO remove
}
});
return false;
}
profile_vis_buttons.live('click', function () {
profile_vis_buttons.toggleClass('active');
return load_profile_projects();
});
$(document).on('click','.profile-table .pagination a', function(){
updatePagination($(this));
return load_profile_projects();
});
$('#query_projects').on('keyup', function() {
var visibility = 'visibility=' + ($('.profile-content .span12.sub-menu nav a.active').hasClass('public-projects') ? 'open' : 'hidden');
var search = 'search=' + profile_search_field.val();
data = 'projects=show&' + visibility + '&' + search;
return search_items(profile_path, data, profile_table);
});
});