Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

side nav #1202

Merged
merged 3 commits into from May 20, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 4 additions & 3 deletions media/css/seahub.css
Expand Up @@ -747,14 +747,15 @@ textarea:-moz-placeholder {/* for FF */
transition: all 0.3s ease;
}
.home-side-nav {
display:flex;
flex-direction:column;
padding:0;
}
.home-side-nav:hover {
overflow:hidden;
}
.side-nav-con {
overflow:hidden;
padding:20px;
flex-grow:1;
height:calc(100% - 50px);
}
.side-nav-con:hover {
overflow-y:auto;
Expand Down
30 changes: 25 additions & 5 deletions static/scripts/app/views/side-nav.js
Expand Up @@ -27,7 +27,6 @@ define([
'mods_enabled': app.pageOptions.user_mods_enabled,
'can_add_repo': app.pageOptions.can_add_repo,
};
this.render();
var _this = this;
$('#js-toggle-side-nav').click(function() {
_this.show();
Expand Down Expand Up @@ -61,8 +60,10 @@ define([

if ($icon.hasClass('icon-caret-down')) {
Cookie.set('group_expanded', 'true');
this.data.show_group_list = true;
} else {
Cookie.set('group_expanded', 'false');
this.data.show_group_list = false;
}
return false;
},
Expand Down Expand Up @@ -119,8 +120,23 @@ define([
if (options) {
$.extend(this.data, options);
}
this.data.show_group_list = $('#group-nav .grp-list:visible').length ? true : false;
this.render();

if (this.$clickedTab) {
// The user click a link and this.$clickedTab is set by visitLink()
this.$('.tab-cur').removeClass('tab-cur');
this.$clickedTab.addClass('tab-cur');
this.$clickedTab = null;
} else {
// the first time the side nav is rendered or the side nav is re-rendered
// when dismiss a group, leave a group
this.render();
var curTabTop = this.$('.tab-cur').offset().top;
var visibleHeight = $(window).height() - this.$('.side-nav-footer').outerHeight(true);
if (curTabTop > visibleHeight) {
this.$('.side-nav-con').css({'overflow':'auto'}).scrollTop(curTabTop - visibleHeight + this.$('.tab-cur').outerHeight(true) + 10).removeAttr('style');
}
}

},

updateGroups: function() {
Expand Down Expand Up @@ -166,9 +182,13 @@ define([
return false;
},

visitLink: function(event) {
visitLink: function(e) {
if ($(e.target).attr('href') !== "#") {
this.$clickedTab = $(e.target).parent();
}

if ($(window).width() < 768) {
if ($(event.target).attr('href') !== "#") {
if ($(e.target).attr('href') !== "#") {
// except for groups toggle link
this.hide();
}
Expand Down