Commit 52e780e0 by Arjun Singh

add all filter

parent 629a8e7e
......@@ -6,10 +6,17 @@ class @DiscussionThreadListView extends Backbone.View
"keyup .post-search-field": "performSearch"
"click .sort-bar a": "sortThreads"
"click .browse-topic-drop-menu": "filterTopic"
"click .browse-topic-drop-search-input": "ignoreClick"
initialize: ->
@displayedCollection = new Discussion(@collection.models)
# Because we want the behavior that when the body is clicked the menu is
# closed, we need to ignore clicks in the search field and stop propagation.
# Without this, clicking the search field would also close the menu.
ignoreClick: (event) ->
event.stopPropagation()
render: ->
@timer = 0
@$el.html(@template())
......@@ -41,16 +48,15 @@ class @DiscussionThreadListView extends Backbone.View
@$(".browse").removeClass('is-open')
setTimeout (-> @$(".post-search-field").focus()), 200
toggleTopicDrop: =>
toggleTopicDrop: (event) =>
event.stopPropagation()
@$(".browse").toggleClass('is-dropped')
if @$(".browse").hasClass('is-dropped')
@$(".browse-topic-drop-menu-wrapper").show()
setTimeout((=>
$("body").bind("click", @toggleTopicDrop)
), 0)
$('body').bind 'click', @toggleTopicDrop
else
@$(".browse-topic-drop-menu-wrapper").hide()
$("body").unbind("click", @toggleTopicDrop)
$('body').unbind 'click', @toggleTopicDrop
setTopic: (event) ->
item = $(event.target).closest('a')
......@@ -70,6 +76,8 @@ class @DiscussionThreadListView extends Backbone.View
filterTopic: (event) ->
@setTopic(event)
item = $(event.target).closest('li')
if item.find("span.board-name").data("discussion_id") == "#all"
item = item.parent()
discussionIds = _.compact _.map item.find("span.board-name"), (board) -> $(board).data("discussion_id")
discussionIds = _.map discussionIds, (info) -> info.id
filtered = @collection.filter (thread) =>
......
......@@ -28,6 +28,11 @@
<input type="text" class="browse-topic-drop-search-input" placeholder="filter topics">
</div>
<ul class="browse-topic-drop-menu">
<li>
<a href="#">
<span class="board-name" data-discussion_id='#all'>All</span> <span class="unread">1,248</span>
</a>
</li>
${render_dropdown(category_map)}
</ul>
</div>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment