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
38b9b53a
Commit
38b9b53a
authored
Sep 05, 2012
by
Matthew Mongeau
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Redo how rendering of list items is done. Better memory, faster rendering.
parent
a2cdd012
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
61 deletions
+35
-61
lms/static/coffee/src/discussion/content.coffee
+2
-4
lms/static/coffee/src/discussion/views/discussion_thread_list_view.coffee
+31
-9
lms/static/coffee/src/discussion/views/discussion_thread_view.coffee
+2
-2
lms/static/coffee/src/discussion/views/thread_list_item_view.coffee
+0
-46
No files found.
lms/static/coffee/src/discussion/content.coffee
View file @
38b9b53a
...
...
@@ -454,19 +454,17 @@ if Backbone?
follow
:
->
@
set
(
'subscribed'
,
true
)
@
trigger
"thread:follow"
unfollow
:
->
@
set
(
'subscribed'
,
false
)
@
trigger
"thread:unfollow"
vote
:
->
@
get
(
"votes"
)[
"up_count"
]
=
parseInt
(
@
get
(
"votes"
)[
"up_count"
])
+
1
@
trigger
"change"
@
trigger
"change"
,
@
unvote
:
->
@
get
(
"votes"
)[
"up_count"
]
=
parseInt
(
@
get
(
"votes"
)[
"up_count"
])
-
1
@
trigger
"change"
@
trigger
"change"
,
@
display_body
:
->
if
@
has
(
"highlighted_body"
)
...
...
lms/static/coffee/src/discussion/views/discussion_thread_list_view.coffee
View file @
38b9b53a
...
...
@@ -7,6 +7,7 @@ class @DiscussionThreadListView extends Backbone.View
"click .sort-bar a"
:
"sortThreads"
"click .browse-topic-drop-menu"
:
"filterTopic"
"click .browse-topic-drop-search-input"
:
"ignoreClick"
"click .post-list a"
:
"threadSelected"
initialize
:
->
@
displayedCollection
=
new
Discussion
(
@
collection
.
models
)
...
...
@@ -14,9 +15,14 @@ class @DiscussionThreadListView extends Backbone.View
@
sidebar_padding
=
10
@
sidebar_header_height
=
87
reloadDisplayedCollection
:
=>
@
displayedCollection
.
reset
(
@
collection
.
models
)
@
updateSidebar
()
reloadDisplayedCollection
:
(
thread
)
=>
thread_id
=
thread
.
get
(
'id'
)
content
=
@
renderThread
(
thread
)
current_el
=
@
$
(
"a[data-id=
#{
thread_id
}
]"
)
active
=
current_el
.
hasClass
(
"active"
)
current_el
.
replaceWith
(
content
)
if
active
@
setActiveThread
(
thread_id
)
updateSidebar
:
=>
...
...
@@ -71,9 +77,25 @@ class @DiscussionThreadListView extends Backbone.View
renderThreads
:
=>
@
$
(
".post-list"
).
html
(
""
)
@
displayedCollection
.
each
@
renderThreadListItem
rendered
=
$
(
"<div></div>"
)
for
thread
in
@
displayedCollection
.
models
content
=
@
renderThread
(
thread
)
rendered
.
append
content
content
.
wrap
(
"<li data-id='
#{
thread
.
get
(
'id'
)
}
' />"
)
@
$
(
".post-list"
).
html
(
rendered
.
html
())
@
trigger
"threads:rendered"
renderThread
:
(
thread
)
=>
content
=
$
(
_
.
template
(
$
(
"#thread-list-item-template"
).
html
())(
thread
.
toJSON
()))
if
thread
.
get
(
'subscribed'
)
content
.
addClass
(
"followed"
)
@
highlight
(
content
)
highlight
:
(
el
)
->
el
.
html
(
el
.
html
().
replace
(
/<mark>/g
,
"<mark>"
).
replace
(
/<\/mark>/g
,
"</mark>"
))
renderThreadListItem
:
(
thread
)
=>
view
=
new
ThreadListItemView
(
model
:
thread
)
view
.
on
"thread:selected"
,
@
threadSelected
...
...
@@ -81,15 +103,17 @@ class @DiscussionThreadListView extends Backbone.View
view
.
render
()
@
$
(
".post-list"
).
append
(
view
.
el
)
threadSelected
:
(
thread_id
)
=>
threadSelected
:
(
e
)
=>
thread_id
=
$
(
e
.
target
).
closest
(
"a"
).
data
(
"id"
)
@
setActiveThread
(
thread_id
)
@
trigger
(
"thread:selected"
,
thread_id
)
false
threadRemoved
:
(
thread_id
)
=>
@
trigger
(
"thread:removed"
,
thread_id
)
setActiveThread
:
(
thread_id
)
->
@
$
(
"
.post-list a
"
).
removeClass
(
"active"
)
@
$
(
"
a[data-id!='
#{
thread_id
}
']
"
).
removeClass
(
"active"
)
@
$
(
"a[data-id='
#{
thread_id
}
']"
).
addClass
(
"active"
)
showSearch
:
->
...
...
@@ -175,7 +199,7 @@ class @DiscussionThreadListView extends Backbone.View
firstShownIndex
=
$
(
$
(
".browse-topic-drop-menu-wrapper a"
).
not
(
'.hidden'
)[
0
]).
parent
().
index
()
if
event
.
which
==
40
index
=
index
+
1
index
=
index
+
1
else
if
event
.
which
==
38
index
=
index
-
1
while
$
(
".browse-topic-drop-menu-wrapper li"
).
eq
(
index
).
find
(
'a'
).
hasClass
(
'hidden'
)
...
...
@@ -189,5 +213,3 @@ class @DiscussionThreadListView extends Backbone.View
$
(
".browse-topic-drop-menu-wrapper .focused"
).
removeClass
(
"focused"
)
$
(
".browse-topic-drop-menu-wrapper li"
).
eq
(
index
).
find
(
'a'
).
addClass
(
"focused"
)
$
(
".browse-topic-drop-menu-wrapper"
).
attr
(
"data-focused"
,
index
)
lms/static/coffee/src/discussion/views/discussion_thread_view.coffee
View file @
38b9b53a
...
...
@@ -103,7 +103,7 @@ class @DiscussionThreadView extends DiscussionContentView
type
:
"POST"
success
:
(
response
,
textStatus
)
=>
if
textStatus
==
'success'
@
model
.
set
(
response
)
@
model
.
set
(
response
,
{
silent
:
true
}
)
unvote
:
->
window
.
user
.
unvote
(
@
model
)
...
...
@@ -114,7 +114,7 @@ class @DiscussionThreadView extends DiscussionContentView
type
:
"POST"
success
:
(
response
,
textStatus
)
=>
if
textStatus
==
'success'
@
model
.
set
(
response
)
@
model
.
set
(
response
,
{
silent
:
true
}
)
submitComment
:
(
event
)
->
event
.
preventDefault
()
...
...
lms/static/coffee/src/discussion/views/thread_list_item_view.coffee
deleted
100644 → 0
View file @
a2cdd012
class
@
ThreadListItemView
extends
Backbone
.
View
tagName
:
"li"
template
:
_
.
template
(
$
(
"#thread-list-item-template"
).
html
())
events
:
"click a"
:
"threadSelected"
initialize
:
->
@
model
.
on
"change"
,
@
render
@
model
.
on
"thread:remove"
,
@
threadRemoved
@
model
.
on
"thread:follow"
,
@
follow
@
model
.
on
"thread:unfollow"
,
@
unfollow
@
model
.
on
"comment:add"
,
@
addComment
@
model
.
on
"comment:remove"
,
@
removeComment
render
:
=>
@
$el
.
html
(
@
template
(
@
model
.
toJSON
()))
if
window
.
user
.
following
(
@
model
)
@
follow
()
@
highlight
@
$
(
".title"
)
@
threadSelected
:
(
event
)
->
event
.
preventDefault
()
@
trigger
(
"thread:selected"
,
@
model
.
id
)
threadRemoved
:
=>
@
trigger
(
"thread:removed"
,
@
model
.
id
)
follow
:
=>
@
$
(
"a"
).
addClass
(
"followed"
)
unfollow
:
=>
@
$
(
"a"
).
removeClass
(
"followed"
)
addComment
:
(
comment
)
=>
@
$
(
".comments-count"
).
html
(
@
model
.
get
(
'comments_count'
))
removeComment
:
(
comment
)
=>
@
$
(
".comments-count"
).
html
(
@
model
.
get
(
'comments_count'
))
#addComment: =>
# @$(".comments-count").html(parseInt(@$(".comments-count").html()) + 1)
highlight
:
(
el
)
->
el
.
html
(
el
.
html
().
replace
(
/<mark>/g
,
"<mark>"
).
replace
(
/<\/mark>/g
,
"</mark>"
))
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