From 8914aaf8d46a4e6e233d118dee5f500d0c886901 Mon Sep 17 00:00:00 2001 From: Andy Armstrong Date: Thu, 3 Sep 2015 13:12:26 -0400 Subject: [PATCH] Refactor discussions code to address flaky test TNL-3247 Removed remaining synchronous AJAX calls from discussions Updated the profile view tests to use an attached view for testing Removed one-time JQuery intiialization that could fail and break multiple tests --- .../static/coffee/src/discussion/utils.coffee | 31 +++++++++---------- .../views/discussion_thread_edit_view.js | 2 -- .../views/thread_response_view.coffee | 2 -- .../teams/js/spec/views/team_profile_spec.js | 5 ++- 4 files changed, 18 insertions(+), 22 deletions(-) diff --git a/common/static/coffee/src/discussion/utils.coffee b/common/static/coffee/src/discussion/utils.coffee index dd6e126e6f..976966d525 100644 --- a/common/static/coffee/src/discussion/utils.coffee +++ b/common/static/coffee/src/discussion/utils.coffee @@ -1,16 +1,3 @@ -$ -> - if !window.$$contents - window.$$contents = {} - $.fn.extend - loading: (takeFocus) -> - @$_loading = $("
" + gettext("Loading content") + "
") - $(this).after(@$_loading) - if takeFocus - DiscussionUtil.makeFocusTrap(@$_loading) - @$_loading.focus() - loaded: -> - @$_loading.remove() - class @DiscussionUtil @wmdEditors: {} @@ -111,6 +98,16 @@ class @DiscussionUtil event.preventDefault() ) + @showLoadingIndicator: (element, takeFocus) -> + @$_loading = $("
" + gettext("Loading content") + "
") + element.after(@$_loading) + if takeFocus + @makeFocusTrap(@$_loading) + @$_loading.focus() + + @hideLoadingIndicator: () -> + @$_loading.remove() + @discussionAlert: (header, body) -> if $("#discussion-alert").length == 0 alertDiv = $("