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
82d05c6e
Commit
82d05c6e
authored
Nov 21, 2016
by
alisan617
Committed by
Brian Jacobel
Dec 12, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make new post view overlay-ish
parent
5dad2afa
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
92 additions
and
34 deletions
+92
-34
common/static/common/js/discussion/views/discussion_inline_view.js
+20
-9
common/static/common/js/discussion/views/discussion_thread_list_view.js
+1
-1
common/static/common/js/discussion/views/new_post_view.js
+13
-3
common/static/common/js/spec/discussion/view/discussion_inline_view_spec.js
+8
-0
common/static/common/js/spec/discussion/view/discussion_thread_list_view_spec.js
+4
-7
common/static/common/templates/discussion/inline-discussion.underscore
+12
-10
common/static/common/templates/discussion/new-post.underscore
+7
-0
lms/djangoapps/discussion/static/discussion/js/views/discussion_board_view.js
+1
-3
lms/static/sass/discussion/_discussion.scss
+2
-0
lms/static/sass/discussion/elements/_navigation.scss
+3
-1
lms/static/sass/discussion/views/_inline.scss
+21
-0
No files found.
common/static/common/js/discussion/views/discussion_inline_view.js
View file @
82d05c6e
...
@@ -14,6 +14,7 @@
...
@@ -14,6 +14,7 @@
},
},
'click .new-post-btn'
:
'toggleNewPost'
,
'click .new-post-btn'
:
'toggleNewPost'
,
'click .all-posts-btn'
:
'navigateToAllPosts'
,
'click .all-posts-btn'
:
'navigateToAllPosts'
,
keydown
:
'handleKeydown'
,
'keydown .new-post-btn'
:
function
(
event
)
{
'keydown .new-post-btn'
:
function
(
event
)
{
return
DiscussionUtil
.
activateOnSpace
(
event
,
this
.
toggleNewPost
);
return
DiscussionUtil
.
activateOnSpace
(
event
,
this
.
toggleNewPost
);
}
}
...
@@ -28,6 +29,7 @@
...
@@ -28,6 +29,7 @@
this
.
showByDefault
=
options
.
showByDefault
||
false
;
this
.
showByDefault
=
options
.
showByDefault
||
false
;
this
.
toggleDiscussionBtn
=
this
.
$
(
'.discussion-show'
);
this
.
toggleDiscussionBtn
=
this
.
$
(
'.discussion-show'
);
this
.
listenTo
(
this
.
model
,
'change'
,
this
.
render
);
this
.
listenTo
(
this
.
model
,
'change'
,
this
.
render
);
this
.
escKey
=
27
;
match
=
this
.
page_re
.
exec
(
window
.
location
.
href
);
match
=
this
.
page_re
.
exec
(
window
.
location
.
href
);
if
(
match
)
{
if
(
match
)
{
...
@@ -89,6 +91,7 @@
...
@@ -89,6 +91,7 @@
if
(
this
.
$
(
'section.discussion'
).
length
)
{
if
(
this
.
$
(
'section.discussion'
).
length
)
{
edx
.
HtmlUtils
.
setHtml
(
this
.
$el
,
discussionHtml
);
edx
.
HtmlUtils
.
setHtml
(
this
.
$el
,
discussionHtml
);
this
.
$
(
'section.discussion'
).
replaceWith
(
edx
.
HtmlUtils
.
ensureHtml
(
discussionHtml
).
toString
());
}
else
{
}
else
{
edx
.
HtmlUtils
.
append
(
this
.
$el
,
discussionHtml
);
edx
.
HtmlUtils
.
append
(
this
.
$el
,
discussionHtml
);
}
}
...
@@ -117,6 +120,7 @@
...
@@ -117,6 +120,7 @@
this
.
newPostView
.
render
();
this
.
newPostView
.
render
();
this
.
listenTo
(
this
.
newPostView
,
'newPost:createPost'
,
this
.
hideNewPost
);
this
.
listenTo
(
this
.
newPostView
,
'newPost:cancel'
,
this
.
hideNewPost
);
this
.
listenTo
(
this
.
newPostView
,
'newPost:cancel'
,
this
.
hideNewPost
);
this
.
discussion
.
on
(
'add'
,
this
.
addThread
);
this
.
discussion
.
on
(
'add'
,
this
.
addThread
);
...
@@ -124,7 +128,7 @@
...
@@ -124,7 +128,7 @@
this
.
showed
=
true
;
this
.
showed
=
true
;
if
(
this
.
isWaitingOnNewPost
)
{
if
(
this
.
isWaitingOnNewPost
)
{
this
.
newPostForm
.
show
(
).
focus
();
this
.
newPostForm
.
removeClass
(
'is-hidden'
).
focus
();
}
}
// Hide the thread view initially
// Hide the thread view initially
...
@@ -169,7 +173,6 @@
...
@@ -169,7 +173,6 @@
this
.
toggleDiscussionBtn
.
addClass
(
'shown'
);
this
.
toggleDiscussionBtn
.
addClass
(
'shown'
);
this
.
toggleDiscussionBtn
.
find
(
'.button-text'
).
text
(
gettext
(
'Hide Discussion'
));
this
.
toggleDiscussionBtn
.
find
(
'.button-text'
).
text
(
gettext
(
'Hide Discussion'
));
if
(
this
.
retrieved
)
{
if
(
this
.
retrieved
)
{
this
.
$
(
'section.discussion'
).
slideDown
();
this
.
$
(
'section.discussion'
).
removeClass
(
'is-hidden'
);
this
.
$
(
'section.discussion'
).
removeClass
(
'is-hidden'
);
this
.
showed
=
true
;
this
.
showed
=
true
;
}
else
{
}
else
{
...
@@ -185,7 +188,6 @@
...
@@ -185,7 +188,6 @@
},
},
hideDiscussion
:
function
()
{
hideDiscussion
:
function
()
{
this
.
$
(
'section.discussion'
).
slideUp
();
this
.
$
(
'section.discussion'
).
addClass
(
'is-hidden'
);
this
.
$
(
'section.discussion'
).
addClass
(
'is-hidden'
);
this
.
toggleDiscussionBtn
.
removeClass
(
'shown'
);
this
.
toggleDiscussionBtn
.
removeClass
(
'shown'
);
this
.
toggleDiscussionBtn
.
find
(
'.button-text'
).
text
(
gettext
(
'Show Discussion'
));
this
.
toggleDiscussionBtn
.
find
(
'.button-text'
).
text
(
gettext
(
'Show Discussion'
));
...
@@ -200,20 +202,29 @@
...
@@ -200,20 +202,29 @@
return
;
return
;
}
}
if
(
this
.
showed
)
{
if
(
this
.
showed
)
{
this
.
newPostForm
.
slideDown
(
300
);
this
.
$
(
'section.discussion'
).
find
(
'.inline-discussion-thread-container'
).
addClass
(
'is-hidden'
);
}
else
{
this
.
$
(
'section.discussion'
).
find
(
'.new-post-btn'
).
addClass
(
'is-hidden'
);
this
.
newPostForm
.
show
(
).
focus
();
this
.
newPostForm
.
removeClass
(
'is-hidden'
).
find
(
'.js-post-title'
).
focus
();
}
}
this
.
newPostView
.
$el
.
removeClass
(
'is-hidden'
);
this
.
newPostView
.
$el
.
removeClass
(
'is-hidden'
);
this
.
toggleDiscussionBtn
.
addClass
(
'shown'
);
this
.
toggleDiscussionBtn
.
addClass
(
'shown'
);
this
.
toggleDiscussionBtn
.
find
(
'.button-text'
).
text
(
gettext
(
'Hide Discussion'
));
this
.
toggleDiscussionBtn
.
find
(
'.button-text'
).
text
(
gettext
(
'Hide Discussion'
));
this
.
$
(
'section.discussion'
).
slideDown
();
this
.
showed
=
true
;
this
.
showed
=
true
;
},
},
hideNewPost
:
function
()
{
hideNewPost
:
function
()
{
this
.
newPostView
.
$el
.
addClass
(
'is-hidden'
);
this
.
$
(
'section.discussion'
).
find
(
'.inline-discussion-thread-container'
).
removeClass
(
'is-hidden'
);
return
this
.
newPostForm
.
slideUp
(
300
);
this
.
$
(
'section.discussion'
).
find
(
'.new-post-btn'
)
.
removeClass
(
'is-hidden'
)
.
focus
();
this
.
newPostForm
.
addClass
(
'is-hidden'
);
},
handleKeydown
:
function
(
event
)
{
var
keyCode
=
event
.
keyCode
;
if
(
keyCode
===
this
.
escKey
)
{
this
.
$
(
'section.discussion'
).
find
(
'.cancel'
).
trigger
(
'click'
);
}
}
}
});
});
}).
call
(
window
);
}).
call
(
window
);
common/static/common/js/discussion/views/discussion_thread_list_view.js
View file @
82d05c6e
...
@@ -107,7 +107,7 @@
...
@@ -107,7 +107,7 @@
this
.
boardName
=
null
;
this
.
boardName
=
null
;
this
.
current_search
=
''
;
this
.
current_search
=
''
;
this
.
mode
=
'all'
;
this
.
mode
=
'all'
;
this
.
showThreadPreview
=
options
.
showThreadPreview
;
this
.
showThreadPreview
=
true
;
this
.
searchAlertCollection
=
new
Backbone
.
Collection
([],
{
this
.
searchAlertCollection
=
new
Backbone
.
Collection
([],
{
model
:
Backbone
.
Model
model
:
Backbone
.
Model
});
});
...
...
common/static/common/js/discussion/views/new_post_view.js
View file @
82d05c6e
...
@@ -100,6 +100,7 @@
...
@@ -100,6 +100,7 @@
'submit .forum-new-post-form'
:
'createPost'
,
'submit .forum-new-post-form'
:
'createPost'
,
'change .post-option-input'
:
'postOptionChange'
,
'change .post-option-input'
:
'postOptionChange'
,
'click .cancel'
:
'cancel'
,
'click .cancel'
:
'cancel'
,
'click .add-post-cancel'
:
'cancel'
,
'reset .forum-new-post-form'
:
'updateStyles'
'reset .forum-new-post-form'
:
'updateStyles'
};
};
...
@@ -156,17 +157,26 @@
...
@@ -156,17 +157,26 @@
success
:
function
(
response
)
{
success
:
function
(
response
)
{
var
thread
;
var
thread
;
thread
=
new
Thread
(
response
.
content
);
thread
=
new
Thread
(
response
.
content
);
self
.
$el
.
hide
(
);
self
.
$el
.
addClass
(
'is-hidden'
);
self
.
resetForm
();
self
.
resetForm
();
self
.
trigger
(
'newPost:createPost'
);
return
self
.
collection
.
add
(
thread
);
return
self
.
collection
.
add
(
thread
);
}
}
});
});
};
};
NewPostView
.
prototype
.
formModified
=
function
()
{
var
postBodyHasContent
=
this
.
$
(
'.js-post-body'
).
find
(
'.wmd-input'
).
val
()
!==
''
,
titleHasContent
=
this
.
$
(
'.js-post-title'
).
val
()
!==
''
;
return
postBodyHasContent
||
titleHasContent
;
};
NewPostView
.
prototype
.
cancel
=
function
(
event
)
{
NewPostView
.
prototype
.
cancel
=
function
(
event
)
{
event
.
preventDefault
();
event
.
preventDefault
();
if
(
!
confirm
(
gettext
(
'Your post will be discarded.'
)))
{
if
(
this
.
formModified
())
{
return
;
if
(
!
confirm
(
gettext
(
'Your post will be discarded.'
)))
{
// eslint-disable-line no-alert
return
;
}
}
}
this
.
trigger
(
'newPost:cancel'
);
this
.
trigger
(
'newPost:cancel'
);
return
this
.
resetForm
();
return
this
.
resetForm
();
...
...
common/static/common/js/spec/discussion/view/discussion_inline_view_spec.js
View file @
82d05c6e
...
@@ -114,6 +114,14 @@
...
@@ -114,6 +114,14 @@
testView
.
$
(
'.forum-new-post-form .cancel'
).
click
();
testView
.
$
(
'.forum-new-post-form .cancel'
).
click
();
expect
(
testView
.
$
(
'.new-post-article'
)).
toHaveClass
(
'is-hidden'
);
expect
(
testView
.
$
(
'.new-post-article'
)).
toHaveClass
(
'is-hidden'
);
});
});
it
(
'should be hidden when the "close" button is clicked'
,
function
()
{
var
testView
=
createTestView
(
this
);
showDiscussion
(
this
,
testView
);
testView
.
$
(
'.new-post-btn'
).
click
();
testView
.
$
(
'.forum-new-post-form .add-post-cancel'
).
click
();
expect
(
testView
.
$
(
'.new-post-article'
)).
toHaveClass
(
'is-hidden'
);
});
});
});
describe
(
'thread listing'
,
function
()
{
describe
(
'thread listing'
,
function
()
{
...
...
common/static/common/js/spec/discussion/view/discussion_thread_list_view_spec.js
View file @
82d05c6e
...
@@ -188,12 +188,11 @@
...
@@ -188,12 +188,11 @@
renderSingleThreadWithProps
=
function
(
props
)
{
renderSingleThreadWithProps
=
function
(
props
)
{
return
makeView
(
new
Discussion
([
new
Thread
(
DiscussionViewSpecHelper
.
makeThreadWithProps
(
props
))])).
render
();
return
makeView
(
new
Discussion
([
new
Thread
(
DiscussionViewSpecHelper
.
makeThreadWithProps
(
props
))])).
render
();
};
};
makeView
=
function
(
discussion
,
options
)
{
makeView
=
function
(
discussion
)
{
var
opts
=
options
||
{};
return
new
DiscussionThreadListView
({
return
new
DiscussionThreadListView
({
el
:
$
(
'#fixture-element'
),
el
:
$
(
'#fixture-element'
),
collection
:
discussion
,
collection
:
discussion
,
showThreadPreview
:
opts
.
showThreadPreview
||
true
,
showThreadPreview
:
true
,
courseSettings
:
new
DiscussionCourseSettings
({
courseSettings
:
new
DiscussionCourseSettings
({
is_cohorted
:
true
is_cohorted
:
true
})
})
...
@@ -676,10 +675,8 @@
...
@@ -676,10 +675,8 @@
it
(
'should not be shown when showThreadPreview is false'
,
function
()
{
it
(
'should not be shown when showThreadPreview is false'
,
function
()
{
var
view
,
var
view
,
discussion
=
new
Discussion
([]),
discussion
=
new
Discussion
([]),
options
=
{
showThreadPreview
=
false
;
showThreadPreview
:
false
view
=
makeView
(
discussion
,
showThreadPreview
);
};
view
=
makeView
(
discussion
,
options
);
view
.
render
();
view
.
render
();
expect
(
view
.
$el
.
find
(
'.thread-preview-body'
).
length
).
toEqual
(
0
);
expect
(
view
.
$el
.
find
(
'.thread-preview-body'
).
length
).
toEqual
(
0
);
});
});
...
...
common/static/common/templates/discussion/inline-discussion.underscore
View file @
82d05c6e
...
@@ -5,17 +5,19 @@
...
@@ -5,17 +5,19 @@
<article class="new-post-article is-hidden"></article>
<article class="new-post-article is-hidden"></article>
<section class="inline-threads">
<div class="inline-discussion-thread-container">
</section>
<section class="inline-threads">
</section>
<div class="inline-thread">
<div class="inline-thread">
<div class="forum-nav-bar">
<div class="forum-nav-bar">
<button class="btn-link all-posts-btn">
<button class="btn-link all-posts-btn">
<span class="icon fa fa-chevron-prev" aria-hidden="true"></span>
<span class="icon fa fa-chevron-prev" aria-hidden="true"></span>
<span><%- gettext('All Posts') %></span>
<span><%- gettext('All Posts') %></span>
</button>
</button>
</div>
</div>
<div class="forum-content">
<div class="forum-content">
</div>
</div>
</div>
</div>
</div>
</section>
</section>
...
...
common/static/common/templates/discussion/new-post.underscore
View file @
82d05c6e
<form class="forum-new-post-form">
<form class="forum-new-post-form">
<% if (mode === 'inline') { %>
<h3 class="thread-title"><%- gettext("Add a Post") %></h3>
<button class="btn-default add-post-cancel">
<span class="sr"><%- gettext('Cancel') %></span>
<span class="fa fa-close" aria-hidden="true"></span>
</button>
<% } %>
<ul class="post-errors" style="display: none"></ul>
<ul class="post-errors" style="display: none"></ul>
<div class="forum-new-post-form-wrapper"></div>
<div class="forum-new-post-form-wrapper"></div>
<% if (cohort_options) { %>
<% if (cohort_options) { %>
...
...
lms/djangoapps/discussion/static/discussion/js/views/discussion_board_view.js
View file @
82d05c6e
...
@@ -32,7 +32,6 @@
...
@@ -32,7 +32,6 @@
initialize
:
function
(
options
)
{
initialize
:
function
(
options
)
{
this
.
courseSettings
=
options
.
courseSettings
;
this
.
courseSettings
=
options
.
courseSettings
;
this
.
showThreadPreview
=
true
;
this
.
sidebar_padding
=
10
;
this
.
sidebar_padding
=
10
;
this
.
current_search
=
''
;
this
.
current_search
=
''
;
this
.
mode
=
'all'
;
this
.
mode
=
'all'
;
...
@@ -46,8 +45,7 @@
...
@@ -46,8 +45,7 @@
this
.
discussionThreadListView
=
new
DiscussionThreadListView
({
this
.
discussionThreadListView
=
new
DiscussionThreadListView
({
collection
:
this
.
discussion
,
collection
:
this
.
discussion
,
el
:
this
.
$
(
'.discussion-thread-list-container'
),
el
:
this
.
$
(
'.discussion-thread-list-container'
),
courseSettings
:
this
.
courseSettings
,
courseSettings
:
this
.
courseSettings
showThreadPreview
:
this
.
showThreadPreview
}).
render
();
}).
render
();
this
.
searchView
=
new
DiscussionSearchView
({
this
.
searchView
=
new
DiscussionSearchView
({
el
:
this
.
$
(
'.forum-search'
)
el
:
this
.
$
(
'.forum-search'
)
...
...
lms/static/sass/discussion/_discussion.scss
View file @
82d05c6e
...
@@ -356,6 +356,7 @@ section.discussion {
...
@@ -356,6 +356,7 @@ section.discussion {
}
}
.new-post-article
{
.new-post-article
{
.inner-wrapper
{
.inner-wrapper
{
max-width
:
1180px
;
max-width
:
1180px
;
min-width
:
760px
;
min-width
:
760px
;
...
@@ -369,6 +370,7 @@ section.discussion {
...
@@ -369,6 +370,7 @@ section.discussion {
color
:
$gray-d3
;
color
:
$gray-d3
;
font-weight
:
700
;
font-weight
:
700
;
}
}
}
}
.edit-post-form
{
.edit-post-form
{
...
...
lms/static/sass/discussion/elements/_navigation.scss
View file @
82d05c6e
...
@@ -385,7 +385,9 @@
...
@@ -385,7 +385,9 @@
&
:hover
,
&
:hover
,
&
:focus
{
&
:focus
{
color
:
$forum-color-active-text
;
color
:
$forum-color-active-text
;
background-color
:
$forum-color-active-thread
;
// !important overrides the one set here:
// https://github.com/edx/edx-platform/blob/master/lms/static/sass/elements/_controls.scss#L472
background-color
:
$forum-color-active-thread
!
important
;
}
}
}
}
...
...
lms/static/sass/discussion/views/_inline.scss
View file @
82d05c6e
...
@@ -39,4 +39,25 @@
...
@@ -39,4 +39,25 @@
.wmd-preview
{
.wmd-preview
{
@include
discussion-wmd-preview
;
@include
discussion-wmd-preview
;
}
}
.new-post-article
{
position
:
relative
;
border
:
1px
solid
$forum-color-border
;
.add-post-cancel
{
@include
right
(
$baseline
/
2
);
top
:
$baseline
/
2
;
position
:
absolute
;
color
:
$uxpl-primary-blue
;
&
:hover
,
&
:focus
{
border-color
:
transparent
;
box-shadow
:
none
;
background-color
:
transparent
;
background-image
:
none
;
}
}
}
}
}
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