Dashboard perfomance improved. Filter for projects page

This commit is contained in:
Dmitriy Zaporozhets 2011-12-20 08:24:14 +02:00
parent 6d5c969872
commit cff9519127
16 changed files with 215 additions and 112 deletions

View file

@ -1,45 +1,66 @@
$(document).ready(function(){
$("#projects-list .project").live('click', function(e){
if(e.target.nodeName != "A" && e.target.nodeName != "INPUT") {
location.href = $(this).attr("url");
e.stopPropagation();
return false;
var ProjectsList = {
limit:0,
offset:0,
init:
function(limit) {
this.limit=limit;
this.offset=limit;
this.initLoadMore();
$('.project_search').keyup(function() {
var terms = $(this).val();
if (terms.length >= 2 || terms.length == 0) {
url = $('.project_search').parent().attr('action');
$.ajax({
type: "GET",
url: location.href,
data: { 'terms': terms, 'replace': true },
dataType: "script"
});
}
});
},
getOld:
function() {
$('.loading').show();
$.ajax({
type: "GET",
url: location.href,
data: "limit=" + this.limit + "&offset=" + this.offset,
complete: function(){ $('.loading').hide()},
dataType: "script"});
},
replace:
function(count, html) {
$(".tile").html(html);
if(count == ProjectsList.limit) {
this.offset = count;
this.initLoadMore();
} else {
this.offset = 0;
}
},
append:
function(count, html) {
$(".tile").append(html);
if(count > 0) {
this.offset += count;
this.initLoadMore();
}
},
initLoadMore:
function() {
$(window).bind('scroll', function(){
if($(window).scrollTop() == $(document).height() - $(window).height()){
$(window).unbind('scroll');
$('.loading').show();
ProjectsList.getOld();
}
});
}
});
$("#issues-table .issue").live('click', function(e){
if(e.target.nodeName != "A" && e.target.nodeName != "INPUT") {
location.href = $(this).attr("url");
e.stopPropagation();
return false;
}
});
$(document).keypress(function(e) {
if( $(e.target).is(":input") ) return;
switch(e.which) {
case 115: focusSearch();
e.preventDefault();
}
});
});
function focusSearch() {
$("#search").focus();
}
function taggifyForm(){
var tag_field = $('#tag_field').tagify();
tag_field.tagify('inputField').autocomplete({
source: '/tags.json'
});
$('form').submit( function() {
var tag_field = $('#tag_field')
tag_field.val( tag_field.tagify('serialize') );
return true;
});
}