diff --git a/lms/djangoapps/django_comment_client/forum/views.py b/lms/djangoapps/django_comment_client/forum/views.py index c71cad1583..3195937305 100644 --- a/lms/djangoapps/django_comment_client/forum/views.py +++ b/lms/djangoapps/django_comment_client/forum/views.py @@ -20,7 +20,7 @@ import django_comment_client.utils as utils import comment_client as cc -THREADS_PER_PAGE = 5 +THREADS_PER_PAGE = 50000 PAGES_NEARBY_DELTA = 2 diff --git a/lms/static/coffee/src/discussion/content.coffee b/lms/static/coffee/src/discussion/content.coffee index da46d81a83..77d57a9e9b 100644 --- a/lms/static/coffee/src/discussion/content.coffee +++ b/lms/static/coffee/src/discussion/content.coffee @@ -427,6 +427,22 @@ if Backbone? unfollow: -> @trigger "thread:unfollow" + display_body: -> + if @has("highlighted_body") + @get("highlighted_body") + else + @get("body") + + display_title: -> + if @has("highlighted_title") + @get("highlighted_title") + else + @get("title") + + toJSON: -> + json_attributes = _.clone(@attributes) + _.extend(json_attributes, { title: @display_title(), body: @display_body() }) + class @ThreadView extends @ContentView class @Comment extends @Content diff --git a/lms/static/coffee/src/discussion/discussion_router.coffee b/lms/static/coffee/src/discussion/discussion_router.coffee index 194e5ef2df..82cc0b66e2 100644 --- a/lms/static/coffee/src/discussion/discussion_router.coffee +++ b/lms/static/coffee/src/discussion/discussion_router.coffee @@ -5,9 +5,10 @@ class @DiscussionRouter extends Backbone.Router initialize: (options) -> @discussion = options['discussion'] - @nav = new DiscussionThreadListView(collection: @discussion, el: $(".post-list")) + @nav = new DiscussionThreadListView(collection: @discussion, el: $(".sidebar")) @nav.on "thread:selected", @navigateToThread @nav.render() + @main = new DiscussionThreadView(el: $(".discussion-column")) allThreads: -> true @@ -15,8 +16,8 @@ class @DiscussionRouter extends Backbone.Router showThread: (forum_name, thread_id) -> @nav.setActiveThread(thread_id) thread = @discussion.get(thread_id) - view = new DiscussionThreadView(el: $(".discussion-column"), model: thread) - view.render() + @main.model = thread + @main.render() navigateToThread: (thread_id) => thread = @discussion.get(thread_id) diff --git a/lms/static/coffee/src/discussion/views/discussion_thread_list_view.coffee b/lms/static/coffee/src/discussion/views/discussion_thread_list_view.coffee index 1bca105aeb..a434f1424e 100644 --- a/lms/static/coffee/src/discussion/views/discussion_thread_list_view.coffee +++ b/lms/static/coffee/src/discussion/views/discussion_thread_list_view.coffee @@ -1,12 +1,25 @@ class @DiscussionThreadListView extends Backbone.View + template: _.template($("#thread-list-template").html()) + events: + "click .search": "showSearch" + "keyup .post-search-field": "performSearch" + render: -> - @collection.each @renderThreadListItem + @timer = 0; + @$el.html(@template()) + @collection.on "reset", @renderThreads + @renderThreads() @ + + renderThreads: => + @$(".post-list").html("") + @collection.each @renderThreadListItem + renderThreadListItem: (thread) => view = new ThreadListItemView(model: thread) view.on "thread:selected", @threadSelected view.render() - @$el.append(view.el) + @$(".post-list").append(view.el) threadSelected: (thread_id) => @setActiveThread(thread_id) @@ -16,3 +29,28 @@ class @DiscussionThreadListView extends Backbone.View @$("a").removeClass("active") @$("a[data-id='#{thread_id}']").addClass("active") + showSearch: -> + @$(".search").addClass('is-open'); + @$(".browse").removeClass('is-open'); + setTimeout (-> @$(".post-search-field").focus()), 200 + + delay: (callback, ms) => + clearTimeout(@timer) + @timer = setTimeout(callback, ms) + + performSearch: -> + callback = => + url = DiscussionUtil.urlFor("search") + text = @$(".post-search-field").val() + DiscussionUtil.safeAjax + $elem: @$(".post-search-field") + data: { text: text } + url: url + type: "GET" + success: (response, textStatus) => + console.log textStatus + if textStatus == 'success' + @collection.reset(response.discussion_data) + console.log(@collection) + + @delay(callback, 300) diff --git a/lms/static/coffee/src/discussion/views/discussion_thread_view.coffee b/lms/static/coffee/src/discussion/views/discussion_thread_view.coffee index bbe8fd1c18..688c1b1fe3 100644 --- a/lms/static/coffee/src/discussion/views/discussion_thread_view.coffee +++ b/lms/static/coffee/src/discussion/views/discussion_thread_view.coffee @@ -5,14 +5,9 @@ class @DiscussionThreadView extends Backbone.View "click .discussion-submit-post": "submitComment" template: _.template($("#thread-template").html()) - initialize: (options) -> - @model.bind "change", @updateModelDetails - @$el.html(@template(@model.toJSON())) - - updateModelDetails: => - @$(".discussion-vote .votes-count-number").html(@model.get("votes")["up_count"]) - render: -> + @$el.html(@template(@model.toJSON())) + @model.bind "change", @updateModelDetails if window.user.following(@model) @$(".dogear").addClass("is-followed") @@ -24,6 +19,9 @@ class @DiscussionThreadView extends Backbone.View @renderResponses() @ + updateModelDetails: => + @$(".discussion-vote .votes-count-number").html(@model.get("votes")["up_count"]) + convertMath: -> element = @$(".post-body") element.html DiscussionUtil.postMathJaxProcessor DiscussionUtil.markdownWithHighlight element.html() diff --git a/lms/static/js/discussions-temp.js b/lms/static/js/discussions-temp.js index 78add011cf..273e946585 100644 --- a/lms/static/js/discussions-temp.js +++ b/lms/static/js/discussions-temp.js @@ -20,13 +20,14 @@ var scrollTop; var tooltipTimer; var tooltipCoords; var SIDEBAR_PADDING = -1; +var SIDEBAR_HEADER_HEIGHT = 87; $(document).ready(function() { $body = $('body'); $browse = $('.browse-search .browse'); - $search = $('.browse-search .search'); - $searchField = $('.post-search-field'); + // $search = $('.browse-search .search'); + // $searchField = $('.post-search-field'); $topicDrop = $('.board-drop-menu'); $currentBoard = $('.current-board'); $tooltip = $('
'); @@ -39,11 +40,10 @@ $(document).ready(function() { $body.append($sidebarWidthStyles); sidebarWidth = $('.sidebar').width(); - sidebarHeaderHeight = $sidebar.find('.browse-search').height() + $sidebar.find('.sort-bar').height(); sidebarXOffset = $sidebar.offset().top; $browse.bind('click', showTopicDrop); - $search.bind('click', showSearch); + // $search.bind('click', showSearch); $topicDrop.bind('click', setTopic); $formTopicDropBtn.bind('click', showFormTopicDrop); $formTopicDropMenu.bind('click', setFormTopic); @@ -111,13 +111,13 @@ function showBrowse(e) { $searchField.val(''); } -function showSearch(e) { - $search.addClass('is-open'); - $browse.removeClass('is-open'); - setTimeout(function() { - $searchField.focus(); - }, 200); -} +// function showSearch(e) { +// $search.addClass('is-open'); +// $browse.removeClass('is-open'); +// setTimeout(function() { +// $searchField.focus(); +// }, 200); +// } function showTopicDrop(e) { e.preventDefault(); @@ -200,10 +200,6 @@ function setFormTopic(e) { $formTopicDropBtn.html(boardName + ' ▾'); } - - - - function updateSidebarCoordinates(e) { scrollTop = $(window).scrollTop(); @@ -226,12 +222,11 @@ function updateSidebarDimensions(e) { var titleWidth = sidebarWidth - 115; $sidebar.css('height', sidebarHeight + 'px'); - $postListWrapper.css('height', (sidebarHeight - sidebarHeaderHeight - 4) + 'px'); + + if(!$postListWrapper[0]) { + $postListWrapper = $('.post-list-wrapper'); + } + + $postListWrapper.css('height', (sidebarHeight - SIDEBAR_HEADER_HEIGHT - 4) + 'px'); $sidebarWidthStyles.html('.discussion-body .post-list a .title { width: ' + titleWidth + 'px !important; }'); -} - - - - - - +} \ No newline at end of file diff --git a/lms/static/sass/_discussion.scss b/lms/static/sass/_discussion.scss index 0235a3a95c..b827dee089 100644 --- a/lms/static/sass/_discussion.scss +++ b/lms/static/sass/_discussion.scss @@ -756,7 +756,7 @@ body.discussion { display: block; position: absolute; top: -1px; - right: -1px; + right: -2px; width: 52px; height: 51px; background: url(../images/follow-dog-ear.png) 0 -52px no-repeat; diff --git a/lms/templates/discussion/single_thread.html b/lms/templates/discussion/single_thread.html index 2365b893f5..b44821bfcd 100644 --- a/lms/templates/discussion/single_thread.html +++ b/lms/templates/discussion/single_thread.html @@ -116,56 +116,54 @@