Permalink
Browse files

Add loading indicator

  • Loading branch information...
1 parent ce42a92 commit 0368d43529cc8f5cfcb6fea2a8f4a16edf5de11d @rwdaigle committed Oct 19, 2012
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -1,4 +1,4 @@
-// Initial page load b/f Turbolinks kicks in
+ // Initial page load b/f Turbolinks kicks in
$(function() {
wireSearch();
displayResults();
@@ -30,21 +30,35 @@ var wireSearch = function() {
searchField().select();
// Live search
+
searchField().typeWatch({
- callback: function() { $("#top_search_form").submit(); },
+ callback: function() { submitSearch(); },
wait: 250,
highlight: false,
captureLength: 2
});
// Pass form submits through PJAX
$("#top_search_form").submit(function() {
- form = $(this);
+ submitSearch();
+ return false;
+ });
+
+ var submitSearch = function() {
+ console.log("Submitting search form");
+ form = $("#top_search_form");
$.pjax({
url: form.attr('action') + '?' + form.serialize(),
container: '#results'
- })
- return false;
+ });
+ };
+
+ $(window).bind('pjax:start', function() {
+ $(".indicator").css("visibility", "visible");
+ });
+
+ $(window).bind('pjax:end', function() {
+ $(".indicator").css("visibility", "hidden");
});
// Keyboard nav
@@ -6,6 +6,9 @@
margin-right: 5px
width: auto
+.topsearch
+ padding: 10px 0px 10px 10px
+
#header
width: 715px
margin: -20px 0 0 -360px
@@ -42,3 +45,7 @@
.command_bar_form
padding-right: 0px
+
+.indicator
+ display: inline
+ vertical-align: middle
@@ -8,6 +8,10 @@
#results.display(style="display: #{!params[:q].blank? ? "block" : "none"};")
= render :partial => 'results'
+.indicator(style="visibility: hidden;")
+ %span.loading
+ %img(src="#{image_path("loader.gif")}")
+
.avatar
%a(href="#{current_user.gh_url}")
%img(src="#{current_user.gh_avatar_url}&s=20")

0 comments on commit 0368d43

Please sign in to comment.