From 4bfbdcc2f14a7c1f11f67d7454ada8ea36e130ff Mon Sep 17 00:00:00 2001 From: Aaron Lidman Date: Tue, 12 Nov 2013 11:20:23 -0800 Subject: [PATCH] Loading indicator for notes --- app/assets/javascripts/index/browse.js | 4 +++- app/assets/javascripts/index/note.js.erb | 13 +++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/index/browse.js b/app/assets/javascripts/index/browse.js index a0bb42685..3ebe9531d 100644 --- a/app/assets/javascripts/index/browse.js +++ b/app/assets/javascripts/index/browse.js @@ -135,7 +135,9 @@ function initializeBrowse(map) { } function setStatus(status) { - $('#browse_status').append($('

').text(status)); + if($('#browse_status').is(':empty')) { + $('#browse_status').append($('

').text(status)); + } } function clearStatus() { diff --git a/app/assets/javascripts/index/note.js.erb b/app/assets/javascripts/index/note.js.erb index 9e92c9a1f..a11f6a72c 100644 --- a/app/assets/javascripts/index/note.js.erb +++ b/app/assets/javascripts/index/note.js.erb @@ -68,13 +68,26 @@ OSM.Note = function(map) { }; page.load = function() { + var loadTimer = setTimeout(setLoading, 250); $('#sidebar_content').load(window.location.pathname + "?xhr=1", function(a, b, xhr) { if (xhr.getResponseHeader('X-Page-Title')) { document.title = xhr.getResponseHeader('X-Page-Title'); } bind(); + clearTimeout(loadTimer); + clearLoading(); }); }; + function setLoading() { + if($('#browse_status').is(':empty')) { + $('#browse_status').append($('

').text(I18n.t('browse.start_rjs.loading'))); + } + } + + function clearLoading() { + $('#browse_status').empty(); + } + return page; }; -- 2.43.2