Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
cae338a4
Commit
cae338a4
authored
Sep 02, 2012
by
Rocky Duan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dropdown filter
parent
fd31ab30
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
26 deletions
+38
-26
lms/static/coffee/src/discussion/views/discussion_thread_list_view.coffee
+34
-23
lms/templates/discussion/_filter_dropdown.html
+4
-3
No files found.
lms/static/coffee/src/discussion/views/discussion_thread_list_view.coffee
View file @
cae338a4
...
...
@@ -5,18 +5,23 @@ class @DiscussionThreadListView extends Backbone.View
"click .browse"
:
"toggleTopicDrop"
"keyup .post-search-field"
:
"performSearch"
"click .sort-bar a"
:
"sortThreads"
"click .board-drop-menu"
:
"setTopic"
"click .browse-topic-drop-menu"
:
"filterTopic"
initialize
:
->
@
displayedCollection
=
new
Discussion
(
@
collection
.
models
)
console
.
log
@
displayedCollection
render
:
->
@
timer
=
0
;
@
timer
=
0
@
$el
.
html
(
@
template
())
@
c
ollection
.
on
"reset"
,
@
renderThreads
@
displayedC
ollection
.
on
"reset"
,
@
renderThreads
@
renderThreads
()
@
renderThreads
:
=>
console
.
log
"rendering"
@
$
(
".post-list"
).
html
(
""
)
@
c
ollection
.
each
@
renderThreadListItem
@
displayedC
ollection
.
each
@
renderThreadListItem
@
trigger
"threads:rendered"
renderThreadListItem
:
(
thread
)
=>
...
...
@@ -38,47 +43,52 @@ class @DiscussionThreadListView extends Backbone.View
@
$
(
".browse"
).
removeClass
(
'is-open'
)
setTimeout
(
->
@
$
(
".post-search-field"
).
focus
()),
200
toggleTopicDrop
:
=>
toggleTopicDrop
:
=>
@
$
(
".browse"
).
toggleClass
(
'is-dropped'
)
if
@
$
(
".browse"
).
hasClass
(
'is-dropped'
)
@
$
(
".b
oard-drop-menu
"
).
show
()
@
$
(
".b
rowse-topic-drop-menu-wrapper
"
).
show
()
setTimeout
((
=>
$
(
"body"
).
bind
(
"click"
,
@
toggleTopicDrop
)
),
0
)
else
@
$
(
".b
oard-drop-menu
"
).
hide
()
@
$
(
".b
rowse-topic-drop-menu-wrapper
"
).
hide
()
$
(
"body"
).
unbind
(
"click"
,
@
toggleTopicDrop
)
setTopic
:
(
e
)
->
item
=
$
(
e
.
target
).
closest
(
'a'
)
setTopic
:
(
e
vent
)
->
item
=
$
(
e
vent
.
target
).
closest
(
'a'
)
boardName
=
item
.
find
(
".board-name"
).
html
()
_
.
each
item
.
parents
(
'ul'
).
not
(
'.board-drop-menu'
),
(
parent
)
->
console
.
log
(
parent
)
_
.
each
item
.
parents
(
'ul'
).
not
(
'.browse-topic-drop-menu'
),
(
parent
)
->
boardName
=
$
(
parent
).
siblings
(
'a'
).
find
(
'.board-name'
).
html
()
+
' / '
+
boardName
@
$
(
".current-board"
).
html
(
boardName
)
fontSize
=
16
;
@
$
(
".current-board"
).
css
(
'font-size'
,
'16px'
)
;
fontSize
=
16
@
$
(
".current-board"
).
css
(
'font-size'
,
'16px'
)
while
@
$
(
".current-board"
).
width
()
>
(
@
$el
.
width
()
*
.
8
)
-
40
fontSize
--
;
fontSize
--
if
fontSize
<
11
break
;
@
$
(
".current-board"
).
css
(
'font-size'
,
fontSize
+
'px'
);
break
@
$
(
".current-board"
).
css
(
'font-size'
,
fontSize
+
'px'
)
filterTopic
:
(
event
)
->
@
setTopic
(
event
)
item
=
$
(
event
.
target
).
closest
(
'li'
)
discussionIds
=
_
.
compact
_
.
map
item
.
find
(
"span.board-name"
),
(
board
)
->
$
(
board
).
data
(
"discussion_id"
)
discussionIds
=
_
.
map
discussionIds
,
(
info
)
->
info
.
id
filtered
=
@
collection
.
filter
(
thread
)
=>
_
.
include
(
discussionIds
,
thread
.
get
(
'commentable_id'
))
@
displayedCollection
.
reset
filtered
sortThreads
:
(
event
)
->
@
$
(
".sort-bar a"
).
removeClass
(
"active"
)
$
(
event
.
target
).
addClass
(
"active"
)
sortBy
=
$
(
event
.
target
).
data
(
"sort"
)
if
sortBy
==
"date"
@
collection
.
comparator
=
@
c
ollection
.
sortByDate
@
displayedCollection
.
comparator
=
@
displayedC
ollection
.
sortByDate
else
if
sortBy
==
"votes"
@
collection
.
comparator
=
@
c
ollection
.
sortByVotes
@
displayedCollection
.
comparator
=
@
displayedC
ollection
.
sortByVotes
else
if
sortBy
==
"comments"
@
collection
.
comparator
=
@
collection
.
sortByComments
@
collection
.
sort
()
@
displayedCollection
.
comparator
=
@
displayedCollection
.
sortByComments
@
displayedCollection
.
sort
()
delay
:
(
callback
,
ms
)
=>
clearTimeout
(
@
timer
)
...
...
@@ -96,5 +106,6 @@ class @DiscussionThreadListView extends Backbone.View
success
:
(
response
,
textStatus
)
=>
if
textStatus
==
'success'
@
collection
.
reset
(
response
.
discussion_data
)
@
displayedCollection
.
reset
(
@
collection
)
@
delay
(
callback
,
300
)
lms/templates/discussion/_filter_dropdown.html
View file @
cae338a4
<
%!
import
json
%
>
<
%
def
name=
"render_dropdown(map)"
>
% for child in map["children"]:
% if child in map["entries"]:
...
...
@@ -9,7 +11,7 @@
</
%
def>
<
%
def
name=
"render_entry(entries, entry)"
>
<li><a
href=
"#"
><span
class=
"board-name"
data-discussion_id=
"${entries[entry]}"
>
${entry}
</span>
<span
class=
"unread"
>
1,248
</span></a></li>
<li><a
href=
"#"
><span
class=
"board-name"
data-discussion_id=
'${json.dumps(entries[entry])}'
>
${entry}
</span>
<span
class=
"unread"
>
1,248
</span></a></li>
</
%
def>
<
%
def
name=
"render_category(categories, category)"
>
...
...
@@ -28,4 +30,4 @@
<ul
class=
"browse-topic-drop-menu"
>
${render_dropdown(category_map)}
</ul>
</div>
\ No newline at end of file
</div>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment