Commit 98d7b28c by Greg Price

Merge pull request #4318 from edx/gprice/forum-sidebar-debt

Reduce tech debt in forum sidebar
parents f9120e1d 3f6287a2
...@@ -147,7 +147,7 @@ describe "DiscussionThreadListView", -> ...@@ -147,7 +147,7 @@ describe "DiscussionThreadListView", ->
</div> </div>
</div> </div>
</script> </script>
<div class="sidebar"></div> <div class="forum-nav"></div>
""" """
@threads = [ @threads = [
makeThreadWithProps({ makeThreadWithProps({
...@@ -176,7 +176,7 @@ describe "DiscussionThreadListView", -> ...@@ -176,7 +176,7 @@ describe "DiscussionThreadListView", ->
spyOn($, "ajax") spyOn($, "ajax")
@discussion = new Discussion([]) @discussion = new Discussion([])
@view = new DiscussionThreadListView({collection: @discussion, el: $(".sidebar")}) @view = new DiscussionThreadListView({collection: @discussion, el: $(".forum-nav")})
@view.render() @view.render()
makeThreadWithProps = (props) -> makeThreadWithProps = (props) ->
...@@ -196,7 +196,7 @@ describe "DiscussionThreadListView", -> ...@@ -196,7 +196,7 @@ describe "DiscussionThreadListView", ->
makeView = (discussion) -> makeView = (discussion) ->
return new DiscussionThreadListView( return new DiscussionThreadListView(
el: $(".sidebar"), el: $(".forum-nav"),
collection: discussion collection: discussion
) )
......
...@@ -8,7 +8,7 @@ if Backbone? ...@@ -8,7 +8,7 @@ if Backbone?
@discussion = options['discussion'] @discussion = options['discussion']
@course_settings = options['course_settings'] @course_settings = options['course_settings']
@nav = new DiscussionThreadListView(collection: @discussion, el: $(".sidebar")) @nav = new DiscussionThreadListView(collection: @discussion, el: $(".forum-nav"))
@nav.on "thread:selected", @navigateToThread @nav.on "thread:selected", @navigateToThread
@nav.on "thread:removed", @navigateToAllThreads @nav.on "thread:removed", @navigateToAllThreads
@nav.on "threads:rendered", @setActiveThread @nav.on "threads:rendered", @setActiveThread
......
...@@ -89,7 +89,7 @@ if Backbone? ...@@ -89,7 +89,7 @@ if Backbone?
discussionsBodyTop = if discussionBody[0] then discussionBody.offset().top discussionsBodyTop = if discussionBody[0] then discussionBody.offset().top
discussionsBodyBottom = discussionsBodyTop + discussionBody.outerHeight() discussionsBodyBottom = discussionsBodyTop + discussionBody.outerHeight()
sidebar = $(".sidebar") sidebar = $(".forum-nav")
if scrollTop > discussionsBodyTop - @sidebar_padding if scrollTop > discussionsBodyTop - @sidebar_padding
sidebar.css('top', scrollTop - discussionsBodyTop + @sidebar_padding); sidebar.css('top', scrollTop - discussionsBodyTop + @sidebar_padding);
else else
...@@ -107,8 +107,9 @@ if Backbone? ...@@ -107,8 +107,9 @@ if Backbone?
headerHeight = @$(".forum-nav-header").outerHeight() headerHeight = @$(".forum-nav-header").outerHeight()
refineBarHeight = @$(".forum-nav-refine-bar").outerHeight() refineBarHeight = @$(".forum-nav-refine-bar").outerHeight()
browseFilterHeight = @$(".forum-nav-browse-filter").outerHeight()
@$('.forum-nav-thread-list').css('height', (sidebarHeight - headerHeight - refineBarHeight - 2) + 'px') @$('.forum-nav-thread-list').css('height', (sidebarHeight - headerHeight - refineBarHeight - 2) + 'px')
@$('.forum-nav-browse-menu-wrapper').css('height', (sidebarHeight - headerHeight - 2) + 'px') @$('.forum-nav-browse-menu').css('height', (sidebarHeight - headerHeight - browseFilterHeight - 2) + 'px')
# Because we want the behavior that when the body is clicked the menu is # Because we want the behavior that when the body is clicked the menu is
...@@ -267,6 +268,7 @@ if Backbone? ...@@ -267,6 +268,7 @@ if Backbone?
@$(".forum-nav-thread-list-wrapper").hide() @$(".forum-nav-thread-list-wrapper").hide()
$(".forum-nav-browse-filter-input").focus() $(".forum-nav-browse-filter-input").focus()
$("body").bind "click", @hideBrowseMenu $("body").bind "click", @hideBrowseMenu
@updateSidebar()
hideBrowseMenu: => hideBrowseMenu: =>
if @isBrowseMenuVisible() if @isBrowseMenuVisible()
...@@ -274,6 +276,7 @@ if Backbone? ...@@ -274,6 +276,7 @@ if Backbone?
@$(".forum-nav-browse-menu-wrapper").hide() @$(".forum-nav-browse-menu-wrapper").hide()
@$(".forum-nav-thread-list-wrapper").show() @$(".forum-nav-thread-list-wrapper").show()
$("body").unbind "click", @hideBrowseMenu $("body").unbind "click", @hideBrowseMenu
@updateSidebar()
toggleBrowseMenu: (event) => toggleBrowseMenu: (event) =>
event.preventDefault() event.preventDefault()
......
...@@ -343,7 +343,7 @@ class DiscussionUserProfilePage(CoursePage): ...@@ -343,7 +343,7 @@ class DiscussionUserProfilePage(CoursePage):
class DiscussionTabHomePage(CoursePage, DiscussionPageMixin): class DiscussionTabHomePage(CoursePage, DiscussionPageMixin):
ALERT_SELECTOR = ".discussion-body .sidebar .search-alert" ALERT_SELECTOR = ".discussion-body .forum-nav .search-alert"
def __init__(self, browser, course_id): def __init__(self, browser, course_id):
super(DiscussionTabHomePage, self).__init__(browser, course_id) super(DiscussionTabHomePage, self).__init__(browser, course_id)
......
...@@ -436,7 +436,6 @@ body.discussion { ...@@ -436,7 +436,6 @@ body.discussion {
} }
section.user-profile { section.user-profile {
@extend .sidebar;
display: table-cell; display: table-cell;
border-right: 1px solid #ddd; border-right: 1px solid #ddd;
border-radius: 3px 0 0 3px; border-radius: 3px 0 0 3px;
......
.forum-nav { .forum-nav {
@include box-sizing(border-box); @include box-sizing(border-box);
float: left; float: left;
position: relative;
width: 31%;
border: 1px solid #aaa; border: 1px solid #aaa;
border-radius: 3px; border-radius: 3px;
} }
...@@ -27,6 +29,7 @@ ...@@ -27,6 +29,7 @@
} }
.icon { .icon {
@include font-size(14);
margin-right: ($baseline/4); margin-right: ($baseline/4);
} }
} }
...@@ -64,7 +67,6 @@ ...@@ -64,7 +67,6 @@
// Browse menu // Browse menu
// ----------- // -----------
.forum-nav-browse-menu-wrapper { .forum-nav-browse-menu-wrapper {
overflow-y: scroll;
border-bottom: 1px solid $gray-l3; border-bottom: 1px solid $gray-l3;
background: $gray-l5; background: $gray-l5;
} }
...@@ -87,6 +89,27 @@ ...@@ -87,6 +89,27 @@
width: 100%; width: 100%;
} }
.forum-nav-browse-menu {
@include font-size(14);
overflow-y: scroll;
list-style: none;
}
.forum-nav-browse-submenu {
padding-left: $baseline;
list-style: none;
}
.forum-nav-browse-title {
display: block;
border-bottom: 1px solid $gray-l3;
padding: ($baseline/2) ($baseline/2);
&:hover, &:focus {
background: $forum-color-active-thread;
}
}
.forum-nav-browse-title .icon { .forum-nav-browse-title .icon {
margin-right: ($baseline/2); margin-right: ($baseline/2);
} }
...@@ -127,14 +150,25 @@ ...@@ -127,14 +150,25 @@
// ----------- // -----------
.forum-nav-thread-list { .forum-nav-thread-list {
overflow-y: scroll; overflow-y: scroll;
list-style: none;
} }
.forum-nav-thread { .forum-nav-thread {
border-bottom: 1px solid $gray-l3; border-bottom: 1px solid $gray-l3;
background-color: $gray-l5;
&.is-unread {
background-color: $white;
}
} }
.forum-nav-thread-link { .forum-nav-thread-link {
@include clearfix(); display: block;
padding: ($baseline/4) ($baseline/2);
&.is-active, &:hover, &:focus {
background-color: $forum-color-active-thread;
}
} }
%forum-nav-thread-wrapper { %forum-nav-thread-wrapper {
...@@ -162,8 +196,10 @@ ...@@ -162,8 +196,10 @@
@extend %t-weight4; @extend %t-weight4;
@include font-size(9); @include font-size(9);
display: inline; display: inline;
margin-top: ($baseline/4);
border: 1px solid; border: 1px solid;
border-radius: 3px; border-radius: 3px;
padding: 1px 6px;
text-transform: uppercase; text-transform: uppercase;
white-space: nowrap; white-space: nowrap;
...@@ -265,13 +301,25 @@ ...@@ -265,13 +301,25 @@
} }
} }
.forum-nav-load-more {
border-bottom: 1px solid $gray-l3;
background-color: $gray-l5;
}
%forum-nav-load-more-content { %forum-nav-load-more-content {
display: block;
padding: $baseline 0;
text-align: center; text-align: center;
} }
.forum-nav-load-more-link { .forum-nav-load-more-link {
@extend %forum-nav-load-more-content; @extend %forum-nav-load-more-content;
color: $link-color; color: $link-color;
&:hover, &:focus {
color: $link-color;
background-color: $forum-color-active-thread;
}
} }
.forum-nav-loading { .forum-nav-loading {
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
// -------------------- // --------------------
body.discussion { body.discussion {
.sidebar { .forum-nav {
// wrapper for multiple alerts // wrapper for multiple alerts
.search-alerts { .search-alerts {
......
...@@ -29,15 +29,6 @@ ...@@ -29,15 +29,6 @@
position: relative; position: relative;
} }
// The sidebar class does a lot of things that we don't want in the thread list;
// the following rules contain styling that is necessary and would otherwise
// reside in elements/_navigation.scss if the sidebar styling did not make the
// !important directive necessary.
.forum-nav {
width: 31% !important;
}
// ------------------------ // ------------------------
// navigation - browse menu // navigation - browse menu
// ------------------------ // ------------------------
...@@ -62,22 +53,13 @@ ...@@ -62,22 +53,13 @@
font-size: 12px !important; font-size: 12px !important;
} }
// The sidebar class does a lot of things that we don't want in the thread list; // Override global ul rules
// the following rules contain styling that is necessary and would otherwise .forum-nav-browse-menu, .forum-nav-browse-submenu {
// reside in elements/_navigation.scss if the sidebar styling did not make the margin: 0;
// !important directive necessary.
.forum-nav-browse-title {
border-bottom: 1px solid $gray-l3 !important;
padding: ($baseline/2) ($baseline/2) !important;
&:hover, &:focus {
background: $forum-color-active-thread !important;
}
} }
.forum-nav-browse-submenu { .forum-nav-browse-menu {
padding-left: $baseline !important; padding-left: 0;
} }
// -------------------------------- // --------------------------------
...@@ -93,51 +75,15 @@ ...@@ -93,51 +75,15 @@
// navigation - thread list // navigation - thread list
// -------------------------------- // --------------------------------
// The sidebar class does a lot of things that we don't want in the thread list;
// the following rules contain styling that is necessary and would otherwise
// reside in elements/_navigation.scss if the sidebar styling did not make the
// !important directive necessary.
.forum-nav-thread {
background-color: $gray-l5 !important;
&.is-unread {
background-color: $white !important;
}
}
.forum-nav-thread-link {
padding: ($baseline/4) ($baseline/2) !important;
&.is-active, &:hover, &:focus {
background-color: $forum-color-active-thread !important;
}
}
li[class*=forum-nav-thread-label-] {
margin-top: ($baseline/4) !important;
padding: 1px 6px !important;
}
.forum-nav-load-more {
border-bottom: 1px solid $gray-l3 !important;
background-color: $gray-l5 !important;
}
.forum-nav-load-more-link {
&:hover, &:focus {
color: $link-color !important;
background-color: $forum-color-active-thread !important;
}
}
.forum-nav-load-more-link, .forum-nav-loading {
padding: $baseline 0 !important;
}
// The following rules would be unnecessary but for broadly scoped rules defined // The following rules would be unnecessary but for broadly scoped rules defined
// elsewhere in our CSS. // elsewhere in our CSS.
// Override global ul rules
.forum-nav-thread-list, .forum-nav-thread-labels {
margin: 0;
padding-left: 0;
}
li[class*=forum-nav-thread-label-] { li[class*=forum-nav-thread-label-] {
// Override global span rules // Override global span rules
span { span {
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
data-user-cohort-id="${user_cohort}" data-user-cohort-id="${user_cohort}"
data-course-settings="${course_settings}"> data-course-settings="${course_settings}">
<div class="discussion-body"> <div class="discussion-body">
<div class="sidebar forum-nav"></div> <div class="forum-nav"></div>
<div class="discussion-column"> <div class="discussion-column">
</div> </div>
</div> </div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment