summaryrefslogtreecommitdiff
path: root/app/assets
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dzaporozhets@sphereconsultinginc.com>2011-12-20 08:24:14 +0200
committerDmitriy Zaporozhets <dzaporozhets@sphereconsultinginc.com>2011-12-20 08:24:14 +0200
commitcff951912734a5aeea0ebb3e4ca01f704004a466 (patch)
tree38e064b2551458052f7962efa615c2e4e0b4075c /app/assets
parent6d5c9698726e268a9cd392a5782c055031bb1bb9 (diff)
downloadgitlab-ce-cff951912734a5aeea0ebb3e4ca01f704004a466.tar.gz
Dashboard perfomance improved. Filter for projects page
Diffstat (limited to 'app/assets')
-rw-r--r--app/assets/javascripts/application.js44
-rw-r--r--app/assets/javascripts/commits.js93
-rw-r--r--app/assets/javascripts/projects.js97
-rw-r--r--app/assets/stylesheets/projects.css.scss6
4 files changed, 153 insertions, 87 deletions
diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js
index 93dbd7dd19c..04d4f0bc6cf 100644
--- a/app/assets/javascripts/application.js
+++ b/app/assets/javascripts/application.js
@@ -16,7 +16,7 @@
//= require branch-graph
//= require_tree .
-$(function(){
+$(document).ready(function(){
$(".one_click_select").live("click", function(){
$(this).select();
});
@@ -27,8 +27,50 @@ $(function(){
$(".account-box").mouseenter(showMenu);
$(".account-box").mouseleave(resetMenu);
+ $("#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;
+ }
+ });
+
+ $("#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;
+ });
+}
+
function updatePage(data){
$.ajax({type: "GET", url: location.href, data: data, dataType: "script"});
}
diff --git a/app/assets/javascripts/commits.js b/app/assets/javascripts/commits.js
index 6e5b2102a68..bb06df55c6e 100644
--- a/app/assets/javascripts/commits.js
+++ b/app/assets/javascripts/commits.js
@@ -1,55 +1,52 @@
-$(document).ready(function(){
- $(".day-commits-table li.commit").live('click', function(e){
- if(e.target.nodeName != "A") {
- location.href = $(this).attr("url");
- e.stopPropagation();
- return false;
- }
- });
-});
-
var CommitsList = {
+ ref:null,
+ limit:0,
+ offset:0,
-ref:null,
-limit:0,
-offset:0,
-
-init:
- function(ref, limit) {
- this.ref=ref;
- this.limit=limit;
- this.offset=limit;
- this.initLoadMore();
- $('.loading').show();
- },
-
-getOld:
- function() {
- $('.loading').show();
- $.ajax({
- type: "GET",
- url: location.href,
- data: "limit=" + this.limit + "&offset=" + this.offset + "&ref=" + this.ref,
- complete: function(){ $('.loading').hide()},
- dataType: "script"});
- },
+ init:
+ function(ref, limit) {
+ $(".day-commits-table li.commit").live('click', function(e){
+ if(e.target.nodeName != "A") {
+ location.href = $(this).attr("url");
+ e.stopPropagation();
+ return false;
+ }
+ });
-append:
- function(count, html) {
- $("#commits_list").append(html);
- if(count > 0) {
- this.offset += count;
+ this.ref=ref;
+ this.limit=limit;
+ this.offset=limit;
this.initLoadMore();
- }
- },
+ $('.loading').show();
+ },
+
+ getOld:
+ function() {
+ $('.loading').show();
+ $.ajax({
+ type: "GET",
+ url: location.href,
+ data: "limit=" + this.limit + "&offset=" + this.offset + "&ref=" + this.ref,
+ complete: function(){ $('.loading').hide()},
+ dataType: "script"});
+ },
-initLoadMore:
- function() {
- $(window).bind('scroll', function(){
- if($(window).scrollTop() == $(document).height() - $(window).height()){
- $(window).unbind('scroll');
- CommitsList.getOld();
+ append:
+ function(count, html) {
+ $("#commits_list").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');
+ CommitsList.getOld();
+ }
+ });
+ }
}
diff --git a/app/assets/javascripts/projects.js b/app/assets/javascripts/projects.js
index 7d21f061703..a80e593f003 100644
--- a/app/assets/javascripts/projects.js
+++ b/app/assets/javascripts/projects.js
@@ -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,
- $("#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;
- }
- });
+ init:
+ function(limit) {
+ this.limit=limit;
+ this.offset=limit;
+ this.initLoadMore();
- $(document).keypress(function(e) {
- if( $(e.target).is(":input") ) return;
- switch(e.which) {
- case 115: focusSearch();
- e.preventDefault();
- }
- });
+ $('.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"});
+ },
-function focusSearch() {
- $("#search").focus();
-}
+ replace:
+ function(count, html) {
+ $(".tile").html(html);
+ if(count == ProjectsList.limit) {
+ this.offset = count;
+ this.initLoadMore();
+ } else {
+ this.offset = 0;
+ }
+ },
-function taggifyForm(){
- var tag_field = $('#tag_field').tagify();
+ append:
+ function(count, html) {
+ $(".tile").append(html);
+ if(count > 0) {
+ this.offset += count;
+ this.initLoadMore();
+ }
+ },
- 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;
- });
+ initLoadMore:
+ function() {
+ $(window).bind('scroll', function(){
+ if($(window).scrollTop() == $(document).height() - $(window).height()){
+ $(window).unbind('scroll');
+ $('.loading').show();
+ ProjectsList.getOld();
+ }
+ });
+ }
}
-
diff --git a/app/assets/stylesheets/projects.css.scss b/app/assets/stylesheets/projects.css.scss
index 366a0d84a40..f1b7ac09b21 100644
--- a/app/assets/stylesheets/projects.css.scss
+++ b/app/assets/stylesheets/projects.css.scss
@@ -647,3 +647,9 @@ h4.middle-panel {
border-radius:3px;
float:left;
}
+
+.project_search {
+ margin: 1.5em 0;
+ padding: 8px !important;
+ width: 300px;
+}