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
b2e4c189
Commit
b2e4c189
authored
Feb 03, 2015
by
E. Kolpakov
Committed by
Jonathan Piacenti
Aug 20, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added ability to set custom css classes on search messages
parent
d804f637
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
7 deletions
+33
-7
common/static/coffee/spec/discussion/discussion_spec_helper.coffee
+1
-1
common/static/coffee/spec/discussion/view/discussion_thread_list_view_spec.coffee
+22
-0
common/static/coffee/src/discussion/views/discussion_thread_list_view.coffee
+9
-5
common/templates/discussion/_underscore_templates.html
+1
-1
No files found.
common/static/coffee/spec/discussion/discussion_spec_helper.coffee
View file @
b2e4c189
...
...
@@ -303,7 +303,7 @@ browser and pasting the output. When that file changes, this one should be rege
</script>
<script aria-hidden="true" type="text/template" id="search-alert-template">
<div class="search-alert" id="search-alert-<%- cid %>">
<div class="search-alert
<%= css_class %>
" id="search-alert-<%- cid %>">
<div class="search-alert-content">
<p class="message"><%= message %></p>
</div>
...
...
common/static/coffee/spec/discussion/view/discussion_thread_list_view_spec.coffee
View file @
b2e4c189
...
...
@@ -274,6 +274,11 @@ describe "DiscussionThreadListView", ->
$
(
@
).
html
()
).
get
()).
toEqual
(
expectedMessages
)
getAlertMessagesAndClasses
=
()
->
$
(
".search-alert"
).
map
(
->
{
text
:
$
(
'.message'
,
@
).
html
(),
'css_class'
:
$
(
@
).
attr
(
'class'
)
}
).
get
()
it
"renders and removes search alerts"
,
->
testAlertMessages
[]
foo
=
@
view
.
addSearchAlert
(
"foo"
)
...
...
@@ -285,6 +290,23 @@ describe "DiscussionThreadListView", ->
@
view
.
removeSearchAlert
(
bar
.
cid
)
testAlertMessages
[]
it
"renders search alert with custom class"
,
->
testAlertMessages
[]
foo
=
@
view
.
addSearchAlert
(
"foo"
,
"custom-class"
)
messages
=
getAlertMessagesAndClasses
()
expect
(
messages
.
length
).
toEqual
(
1
);
expect
(
messages
[
0
].
text
).
toEqual
(
"foo"
)
expect
(
messages
[
0
].
css_class
).
toEqual
(
"search-alert custom-class"
)
foo
=
@
view
.
addSearchAlert
(
"bar"
,
"other-class"
)
messages
=
getAlertMessagesAndClasses
()
expect
(
messages
.
length
).
toEqual
(
2
);
expect
(
messages
[
0
].
text
).
toEqual
(
"foo"
)
expect
(
messages
[
0
].
css_class
).
toEqual
(
"search-alert custom-class"
)
expect
(
messages
[
1
].
text
).
toEqual
(
"bar"
)
expect
(
messages
[
1
].
css_class
).
toEqual
(
"search-alert other-class"
)
it
"clears all search alerts"
,
->
@
view
.
addSearchAlert
(
"foo"
)
@
view
.
addSearchAlert
(
"bar"
)
...
...
common/static/coffee/src/discussion/views/discussion_thread_list_view.coffee
View file @
b2e4c189
...
...
@@ -42,8 +42,12 @@ if Backbone?
@
searchAlertCollection
.
on
"add"
,
(
searchAlert
)
=>
content
=
_
.
template
(
$
(
"#search-alert-template"
).
html
(),
{
'message'
:
searchAlert
.
attributes
.
message
,
'cid'
:
searchAlert
.
cid
}
)
{
'message'
:
searchAlert
.
attributes
.
message
,
'cid'
:
searchAlert
.
cid
,
'css_class'
:
searchAlert
.
attributes
.
css_class
}
)
@
$
(
".search-alerts"
).
append
(
content
)
@
$
(
"#search-alert-"
+
searchAlert
.
cid
+
" a.dismiss"
).
bind
"click"
,
searchAlert
,
(
event
)
=>
@
removeSearchAlert
(
event
.
data
.
cid
)
...
...
@@ -54,8 +58,8 @@ if Backbone?
@
searchAlertCollection
.
on
"reset"
,
=>
@
$
(
".search-alerts"
).
empty
()
addSearchAlert
:
(
message
)
=>
m
=
new
Backbone
.
Model
({
"message"
:
message
})
addSearchAlert
:
(
message
,
css_class
=
""
)
=>
m
=
new
Backbone
.
Model
({
"message"
:
message
,
"css_class"
:
css_class
})
@
searchAlertCollection
.
add
(
m
)
m
...
...
@@ -497,7 +501,7 @@ if Backbone?
},
true
)
@
addSearchAlert
(
message
)
@
addSearchAlert
(
message
,
'search-by-user'
)
clearSearch
:
->
@
$
(
".forum-nav-search-input"
).
val
(
""
)
...
...
common/templates/discussion/_underscore_templates.html
View file @
b2e4c189
...
...
@@ -378,7 +378,7 @@ from django_comment_client.permissions import has_permission
</script>
<script
aria-hidden=
"true"
type=
"text/template"
id=
"search-alert-template"
>
<
div
class
=
"search-alert"
id
=
"search-alert-${'<%- cid %>'}"
>
<
div
class
=
"search-alert
${'<%= css_class %>'}
"
id
=
"search-alert-${'<%- cid %>'}"
>
<
div
class
=
"search-alert-content"
>
<
p
class
=
"message"
>
$
{
'<%= message %>'
}
<
/p
>
<
/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