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
074ba9ce
Commit
074ba9ce
authored
Aug 30, 2012
by
Matthew Mongeau
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Sorting
parent
6ee27d02
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
40 additions
and
4 deletions
+40
-4
lms/static/coffee/src/discussion/discussion.coffee
+14
-0
lms/static/coffee/src/discussion/discussion_router.coffee
+4
-2
lms/static/coffee/src/discussion/views/discussion_thread_list_view.coffee
+16
-1
lms/templates/discussion/single_thread.html
+6
-1
No files found.
lms/static/coffee/src/discussion/discussion.coffee
View file @
074ba9ce
...
...
@@ -6,6 +6,7 @@ if Backbone?
DiscussionUtil
.
addDiscussion
@
id
,
@
@
bind
"add"
,
(
item
)
=>
item
.
discussion
=
@
@
comparator
=
@
sortByDate
find
:
(
id
)
->
_
.
first
@
where
(
id
:
id
)
...
...
@@ -16,6 +17,19 @@ if Backbone?
@
add
model
model
sortByDate
:
(
thread
)
->
thread
.
get
(
"created_at"
)
sortByVotes
:
(
thread1
,
thread2
)
->
thread1_count
=
parseInt
(
thread1
.
get
(
"votes"
)[
'up_count'
])
thread2_count
=
parseInt
(
thread2
.
get
(
"votes"
)[
'up_count'
])
thread2_count
-
thread1_count
sortByComments
:
(
thread1
,
thread2
)
->
thread1_count
=
parseInt
(
thread1
.
get
(
"comments_count"
))
thread2_count
=
parseInt
(
thread2
.
get
(
"comments_count"
))
thread2_count
-
thread1_count
class
@
DiscussionView
extends
Backbone
.
View
$
:
(
selector
)
->
...
...
lms/static/coffee/src/discussion/discussion_router.coffee
View file @
074ba9ce
...
...
@@ -8,7 +8,6 @@ class @DiscussionRouter extends Backbone.Router
@
nav
=
new
DiscussionThreadListView
(
collection
:
@
discussion
,
el
:
$
(
".sidebar"
))
@
nav
.
on
"thread:selected"
,
@
navigateToThread
@
nav
.
render
()
@
main
=
new
DiscussionThreadView
(
el
:
$
(
".discussion-column"
))
allThreads
:
->
true
...
...
@@ -16,7 +15,10 @@ class @DiscussionRouter extends Backbone.Router
showThread
:
(
forum_name
,
thread_id
)
->
@
nav
.
setActiveThread
(
thread_id
)
thread
=
@
discussion
.
get
(
thread_id
)
@
main
.
model
=
thread
if
(
@
main
)
@
main
.
undelegateEvents
()
@
main
=
new
DiscussionThreadView
(
el
:
$
(
".discussion-column"
),
model
:
thread
)
@
main
.
render
()
navigateToThread
:
(
thread_id
)
=>
...
...
lms/static/coffee/src/discussion/views/discussion_thread_list_view.coffee
View file @
074ba9ce
...
...
@@ -3,6 +3,7 @@ class @DiscussionThreadListView extends Backbone.View
events
:
"click .search"
:
"showSearch"
"keyup .post-search-field"
:
"performSearch"
"click .sort-bar a"
:
"sortThreads"
render
:
->
@
timer
=
0
;
...
...
@@ -26,7 +27,7 @@ class @DiscussionThreadListView extends Backbone.View
@
trigger
(
"thread:selected"
,
thread_id
)
setActiveThread
:
(
thread_id
)
->
@
$
(
"a"
).
removeClass
(
"active"
)
@
$
(
"
.post-list
a"
).
removeClass
(
"active"
)
@
$
(
"a[data-id='
#{
thread_id
}
']"
).
addClass
(
"active"
)
showSearch
:
->
...
...
@@ -34,6 +35,20 @@ class @DiscussionThreadListView extends Backbone.View
@
$
(
".browse"
).
removeClass
(
'is-open'
);
setTimeout
(
->
@
$
(
".post-search-field"
).
focus
()),
200
sortThreads
:
(
event
)
->
@
$
(
".sort-bar a"
).
removeClass
(
"active"
)
$
(
event
.
target
).
addClass
(
"active"
)
sortBy
=
$
(
event
.
target
).
data
(
"sort"
)
if
sortBy
==
"date"
@
collection
.
comparator
=
@
collection
.
sortByDate
else
if
sortBy
==
"votes"
@
collection
.
comparator
=
@
collection
.
sortByVotes
else
if
sortBy
==
"comments"
@
collection
.
comparator
=
@
collection
.
sortByComments
@
collection
.
sort
()
delay
:
(
callback
,
ms
)
=>
clearTimeout
(
@
timer
)
@
timer
=
setTimeout
(
callback
,
ms
)
...
...
lms/templates/discussion/single_thread.html
View file @
074ba9ce
...
...
@@ -18,12 +18,17 @@
$$contents
=
{};
$$discussions
=
{};
$$course_id
=
"${course_id}"
;
$
(
document
).
ready
(
function
()
{
DiscussionApp
=
{
start
:
function
()
{
window
.
user
=
new
DiscussionUser
(
JSON
.
parse
(
"${user_info | escapejs}"
));
var
discussion
=
new
Discussion
(
JSON
.
parse
(
"${threads | escapejs}"
));
new
DiscussionRouter
({
discussion
:
discussion
});
Backbone
.
history
.
start
({
pushState
:
true
,
root
:
"/courses/${course_id}/discussion/forum/"
});
}
}
$
(
document
).
ready
(
function
()
{
DiscussionApp
.
start
();
});
</script>
</
%
block>
...
...
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