diff --git a/common/static/common/js/discussion/views/discussion_inline_view.js b/common/static/common/js/discussion/views/discussion_inline_view.js index 057a7995e6..276c82cbee 100644 --- a/common/static/common/js/discussion/views/discussion_inline_view.js +++ b/common/static/common/js/discussion/views/discussion_inline_view.js @@ -141,7 +141,7 @@ this.threadView = new DiscussionThreadView({ el: this.$('.forum-content'), model: thread, - mode: 'tab', + mode: 'inline', course_settings: this.course_settings }); this.threadView.render(); diff --git a/common/static/common/js/discussion/views/discussion_thread_view.js b/common/static/common/js/discussion/views/discussion_thread_view.js index deb2dac105..5544e8fb52 100644 --- a/common/static/common/js/discussion/views/discussion_thread_view.js +++ b/common/static/common/js/discussion/views/discussion_thread_view.js @@ -152,14 +152,7 @@ }); }); } - if (this.mode === 'tab') { - setTimeout(function() { - return self.loadInitialResponses(); - }, 100); - return this.$('.post-tools').hide(); - } else { - return this.collapse(); - } + this.loadInitialResponses(); }; DiscussionThreadView.prototype.attrRenderer = $.extend({}, DiscussionContentView.prototype.attrRenderer, { @@ -221,9 +214,7 @@ }; DiscussionThreadView.prototype.loadResponses = function(responseLimit, $elem, firstLoad) { - var takeFocus, - self = this; - takeFocus = this.mode === 'tab' ? false : true; + var self = this; this.responsesRequest = DiscussionUtil.safeAjax({ url: DiscussionUtil.urlFor( 'retrieve_single_thread', this.model.get('commentable_id'), this.model.id @@ -234,7 +225,7 @@ }, $elem: $elem, $loading: $elem, - takeFocus: takeFocus, + takeFocus: false, complete: function() { self.responsesRequest = null; }, @@ -253,7 +244,6 @@ ); self.trigger('thread:responses:rendered'); self.loadedResponses = true; - return self.$el.find('.discussion-article[data-id="' + self.model.id + '"]').focus(); }, error: function(xhr, textStatus) { if (textStatus === 'abort') { diff --git a/common/static/common/js/spec/discussion/view/discussion_inline_view_spec.js b/common/static/common/js/spec/discussion/view/discussion_inline_view_spec.js index 09a2b55a59..5e7b906ef2 100644 --- a/common/static/common/js/spec/discussion/view/discussion_inline_view_spec.js +++ b/common/static/common/js/spec/discussion/view/discussion_inline_view_spec.js @@ -52,7 +52,12 @@ title: TEST_THREAD_TITLE }), page: 1, - num_pages: 1 + num_pages: 1, + content: { + endorsed_responses: [], + non_endorsed_responses: [], + children: [] + } }); testView.$('.discussion-show').click(); }; diff --git a/common/static/common/js/spec/discussion/view/discussion_thread_view_spec.js b/common/static/common/js/spec/discussion/view/discussion_thread_view_spec.js index 3a35cfdbc5..5e99c20913 100644 --- a/common/static/common/js/spec/discussion/view/discussion_thread_view_spec.js +++ b/common/static/common/js/spec/discussion/view/discussion_thread_view_spec.js @@ -118,7 +118,7 @@ }; describe('closed and open Threads', function() { var checkCommentForm, checkVoteDisplay, createDiscussionThreadView; - createDiscussionThreadView = function(originallyClosed, mode) { + createDiscussionThreadView = function(originallyClosed) { var discussion, thread, threadData, view; threadData = DiscussionViewSpecHelper.makeThreadWithProps({ closed: originallyClosed @@ -128,63 +128,58 @@ view = new DiscussionThreadView({ model: thread, el: $('#fixture-element'), - mode: mode, course_settings: DiscussionSpecHelper.createTestCourseSettings() }); renderWithTestResponses(view, 1); - if (mode === 'inline') { - view.expand(); - } spyOn(DiscussionUtil, 'updateWithUndo').and.callFake(function(model, updates) { return model.set(updates); }); return view; }; - checkCommentForm = function(originallyClosed, mode) { + checkCommentForm = function(originallyClosed) { var view; - view = createDiscussionThreadView(originallyClosed, mode); + view = createDiscussionThreadView(originallyClosed); expect(view.$('.comment-form').closest('li').is(':visible')).toBe(!originallyClosed); expect(view.$('.discussion-reply-new').is(':visible')).toBe(!originallyClosed); view.$('.action-close').click(); expect(view.$('.comment-form').closest('li').is(':visible')).toBe(originallyClosed); return expect(view.$('.discussion-reply-new').is(':visible')).toBe(originallyClosed); }; - checkVoteDisplay = function(originallyClosed, mode) { + checkVoteDisplay = function(originallyClosed) { var view; - view = createDiscussionThreadView(originallyClosed, mode); + view = createDiscussionThreadView(originallyClosed); expect(view.$('.thread-main-wrapper .action-vote').is(':visible')).toBe(!originallyClosed); expect(view.$('.thread-main-wrapper .display-vote').is(':visible')).toBe(originallyClosed); view.$('.action-close').click(); expect(view.$('.action-vote').is(':visible')).toBe(originallyClosed); return expect(view.$('.display-vote').is(':visible')).toBe(!originallyClosed); }; - return _.each(['tab', 'inline'], function(mode) { + return function() { it( - 'Test that in ' + mode + ' mode when a closed thread is opened the comment form is displayed', - function() { return checkCommentForm(true, mode); } + 'Test that when a closed thread is opened the comment form is displayed', + function() { return checkCommentForm(true); } ); it( - 'Test that in ' + mode + ' mode when a open thread is closed the comment form is hidden', - function() { return checkCommentForm(false, mode); } + 'Test that when a open thread is closed the comment form is hidden', + function() { return checkCommentForm(false); } ); it( - 'Test that in ' + mode + ' mode when a closed thread is opened the vote button is displayed and ' + + 'Test that when a closed thread is opened the vote button is displayed and ' + 'vote count is hidden', - function() { return checkVoteDisplay(true, mode); } + function() { return checkVoteDisplay(true); } ); it( - 'Test that in ' + mode + ' mode when a open thread is closed the vote button is hidden and ' + + 'Test that when a open thread is closed the vote button is hidden and ' + 'vote count is displayed', - function() { return checkVoteDisplay(false, mode); } + function() { return checkVoteDisplay(false); } ); - }); + }; }); - describe('tab mode', function() { + describe('thread responses', function() { beforeEach(function() { this.view = new DiscussionThreadView({ model: this.thread, el: $('#fixture-element'), - mode: 'tab', course_settings: DiscussionSpecHelper.createTestCourseSettings() }); }); @@ -276,119 +271,6 @@ }); }); }); - describe('inline mode', function() { - beforeEach(function() { - this.view = new DiscussionThreadView({ - model: this.thread, - el: $('#fixture-element'), - mode: 'inline', - course_settings: DiscussionSpecHelper.createTestCourseSettings() - }); - }); - describe('render', function() { - it('shows content that should be visible when collapsed', function() { - this.view.render(); - return assertExpandedContentVisible(this.view, false); - }); - it('does not render any responses by default', function() { - this.view.render(); - expect($.ajax).not.toHaveBeenCalled(); - return expect(this.view.$el.find('.responses li').length).toEqual(0); - }); - }); - describe('focus', function() { - it('sends focus to the conversation when opened', function(done) { - var self; - DiscussionViewSpecHelper.setNextResponseContent({ - resp_total: 0, - children: [] - }); - this.view.render(); - this.view.expand(); - self = this; - return jasmine.waitUntil(function() { - var article; - article = self.view.$el.find('.discussion-article'); - return article[0] === article[0].ownerDocument.activeElement; - }).then(function() { - return done(); - }); - }); - }); - describe('expand/collapse', function() { - it('shows/hides appropriate content', function() { - DiscussionViewSpecHelper.setNextResponseContent({ - resp_total: 0, - children: [] - }); - this.view.render(); - this.view.expand(); - assertExpandedContentVisible(this.view, true); - this.view.collapse(); - return assertExpandedContentVisible(this.view, false); - }); - it('switches between the abbreviated and full body', function() { - var expectedAbbreviation, longBody; - DiscussionViewSpecHelper.setNextResponseContent({ - resp_total: 0, - children: [] - }); - longBody = new Array(100).join('test '); - expectedAbbreviation = DiscussionUtil.abbreviateString(longBody, 140); - this.thread.set('body', longBody); - this.view.render(); - expect($('.post-body').text()).toEqual(expectedAbbreviation); - expect(DiscussionThreadShowView.prototype.convertMath).toHaveBeenCalled(); - DiscussionThreadShowView.prototype.convertMath.calls.reset(); - this.view.expand(); - expect($('.post-body').text()).toEqual(longBody); - expect(DiscussionThreadShowView.prototype.convertMath).toHaveBeenCalled(); - DiscussionThreadShowView.prototype.convertMath.calls.reset(); - this.view.collapse(); - expect($('.post-body').text()).toEqual(expectedAbbreviation); - return expect(DiscussionThreadShowView.prototype.convertMath).toHaveBeenCalled(); - }); - it('strips script tags appropriately', function() { - var longMaliciousBody, maliciousAbbreviation; - DiscussionViewSpecHelper.setNextResponseContent({ - resp_total: 0, - children: [] - }); - longMaliciousBody = new Array(100).join( - "\n" - ); - this.thread.set('body', longMaliciousBody); - maliciousAbbreviation = DiscussionUtil.abbreviateString(this.thread.get('body'), 140); - this.view.render(); - expect($('.post-body').html()).not.toEqual(maliciousAbbreviation); - expect($('.post-body').text()).toEqual(maliciousAbbreviation); - expect($('.post-body').html()).not.toContain('<%- body %>
- <% if (mode == "tab" && obj.courseware_url) { %> + <% if (mode === "tab" && obj.courseware_url) { %> <% var courseware_title_linked = interpolate( '%(courseware_title)s', diff --git a/common/static/common/templates/discussion/thread.underscore b/common/static/common/templates/discussion/thread.underscore index e2881e01fe..305575a160 100644 --- a/common/static/common/templates/discussion/thread.underscore +++ b/common/static/common/templates/discussion/thread.underscore @@ -32,8 +32,4 @@ <% } %>
-
- - -
diff --git a/lms/djangoapps/discussion/static/discussion/js/views/discussion_user_profile_view.js b/lms/djangoapps/discussion/static/discussion/js/views/discussion_user_profile_view.js index 3b014a2b63..3dea86abe8 100644 --- a/lms/djangoapps/discussion/static/discussion/js/views/discussion_user_profile_view.js +++ b/lms/djangoapps/discussion/static/discussion/js/views/discussion_user_profile_view.js @@ -51,7 +51,7 @@ this.threadView = new DiscussionThreadView({ el: this.$('.forum-content'), model: thread, - mode: 'tab', + mode: 'inline', course_settings: this.courseSettings }); this.threadView.render();