mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-02 07:27:04 +00:00
Improve nav
This commit is contained in:
@@ -27,7 +27,6 @@ define([
|
|||||||
'mods_enabled': app.pageOptions.user_mods_enabled,
|
'mods_enabled': app.pageOptions.user_mods_enabled,
|
||||||
'can_add_repo': app.pageOptions.can_add_repo,
|
'can_add_repo': app.pageOptions.can_add_repo,
|
||||||
};
|
};
|
||||||
this.render();
|
|
||||||
var _this = this;
|
var _this = this;
|
||||||
$('#js-toggle-side-nav').click(function() {
|
$('#js-toggle-side-nav').click(function() {
|
||||||
_this.show();
|
_this.show();
|
||||||
@@ -115,24 +114,28 @@ define([
|
|||||||
},
|
},
|
||||||
|
|
||||||
setCurTab: function(cur_tab, options) {
|
setCurTab: function(cur_tab, options) {
|
||||||
if (this.$curTab) {
|
|
||||||
this.$('.tab-cur').removeClass('tab-cur');
|
|
||||||
this.$curTab.addClass('tab-cur');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.data.cur_tab = cur_tab || this.default_cur_tab;
|
this.data.cur_tab = cur_tab || this.default_cur_tab;
|
||||||
if (options) {
|
if (options) {
|
||||||
$.extend(this.data, options);
|
$.extend(this.data, options);
|
||||||
}
|
}
|
||||||
this.data.show_group_list = $('#group-nav .grp-list:visible').length ? true : false;
|
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;
|
||||||
|
return;
|
||||||
|
} 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 curTabTop = this.$('.tab-cur').offset().top;
|
||||||
var visibleHeight = $(window).height() - this.$('.side-nav-footer').outerHeight(true);
|
var visibleHeight = $(window).height() - this.$('.side-nav-footer').outerHeight(true);
|
||||||
if (curTabTop > visibleHeight) {
|
if (curTabTop > visibleHeight) {
|
||||||
this.$('.side-nav-con').css({'overflow':'auto'}).scrollTop(curTabTop - visibleHeight + this.$('.tab-cur').outerHeight(true) + 10).removeAttr('style');
|
this.$('.side-nav-con').css({'overflow':'auto'}).scrollTop(curTabTop - visibleHeight + this.$('.tab-cur').outerHeight(true) + 10).removeAttr('style');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -181,7 +184,7 @@ define([
|
|||||||
|
|
||||||
visitLink: function(e) {
|
visitLink: function(e) {
|
||||||
if ($(e.target).attr('href') !== "#") {
|
if ($(e.target).attr('href') !== "#") {
|
||||||
this.$curTab = $(e.target).parent();
|
this.$clickedTab = $(e.target).parent();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($(window).width() < 768) {
|
if ($(window).width() < 768) {
|
||||||
|
Reference in New Issue
Block a user