From 40f18681948d4662812f342700533c1a99991927 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 6 Mar 2013 17:12:28 +0200 Subject: [PATCH] Fix loading animation while browsing tree --- app/assets/javascripts/tree.js.coffee | 14 +++++++------- app/views/tree/_tree.html.haml | 5 ++--- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/app/assets/javascripts/tree.js.coffee b/app/assets/javascripts/tree.js.coffee index 5003f9b0..2603b9a9 100644 --- a/app/assets/javascripts/tree.js.coffee +++ b/app/assets/javascripts/tree.js.coffee @@ -11,12 +11,7 @@ $ -> # Make the entire tree-item row clickable, but not if clicking another link (like a commit message) $("#tree-slider .tree-item").live 'click', (e) -> $('.tree-item-file-name a', this).trigger('click') if (e.target.nodeName != "A") - - # Show/Hide the loading spinner - $('#tree-slider .tree-item-file-name a, .breadcrumb a, .project-refs-form').live - "ajax:beforeSend": -> $('.tree_progress').addClass("loading") - "ajax:complete": -> $('.tree_progress').removeClass("loading") - + # Maintain forward/back history while browsing the file tree ((window) -> History = window.History @@ -33,7 +28,12 @@ $ -> History.Adapter.bind window, 'statechange', -> state = History.getState() - window.ajaxGet(state.url) + $.ajax({ + url: state.url, + dataType: 'script', + beforeSend: -> $('.tree_progress').addClass("loading"), + complete: -> $('.tree_progress').removeClass("loading") + }) )(window) # See if there are lines selected diff --git a/app/views/tree/_tree.html.haml b/app/views/tree/_tree.html.haml index 29a2ed02..dc3a8440 100644 --- a/app/views/tree/_tree.html.haml +++ b/app/views/tree/_tree.html.haml @@ -11,9 +11,6 @@ - else = link_to title, '#' -.clear -%div.tree_progress - %div#tree-content-holder.tree-content-holder - if tree.is_blob? = render "tree/blob", blob: tree @@ -40,6 +37,8 @@ - if tree.readme = render "tree/readme", readme: tree.readme +%div.tree_progress + - unless tree.is_blob? :javascript // Load last commit log for each file in tree