1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-17 15:53:28 +00:00

[myhome side nav] bugfix for 'cur tab'

This commit is contained in:
llj
2015-07-22 11:59:50 +08:00
parent f9e28022fd
commit ebf1d7f8d0
3 changed files with 26 additions and 21 deletions

View File

@@ -528,8 +528,8 @@
<% } %> <% } %>
</div> </div>
<ul class="side-tabnav-tabs"> <ul class="side-tabnav-tabs">
<li class="tab tab-cur"><a href="{{ SITE_ROOT }}#" class="lib">{% trans "Libraries" %}</a></li> <li class="tab<% if (cur_tab == 'libs') { %> tab-cur<% } %>"><a href="{{ SITE_ROOT }}#" class="lib">{% trans "Libraries" %}</a></li>
<li class="tab"><a href="{{ SITE_ROOT }}#starred/" class="star">{% trans "Starred" %}</a></li> <li class="tab<% if (cur_tab == 'starred') { %> tab-cur<% } %>"><a href="{{ SITE_ROOT }}#starred/" class="star">{% trans "Starred" %}</a></li>
<% if (events_enabled) { %> <% if (events_enabled) { %>
<li class="tab"><a href="{{ SITE_ROOT }}activities/" class="activity">{% trans "Activities" %}</a></li> <li class="tab"><a href="{{ SITE_ROOT }}activities/" class="activity">{% trans "Activities" %}</a></li>

View File

@@ -13,21 +13,18 @@ define([
enableModTemplate: _.template($("#myhome-mods-enable-form-tmpl").html()), enableModTemplate: _.template($("#myhome-mods-enable-form-tmpl").html()),
initialize: function() { initialize: function() {
}, this.default_cur_tab = 'libs';
this.data = {
render: function(cur_tab) { 'cur_tab': this.default_cur_tab,
this.$el.html(this.template({
'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,
'events_enabled': app.pageOptions.events_enabled 'events_enabled': app.pageOptions.events_enabled
})); };
this.$el.find('li').removeClass('tab-cur'); this.render();
this.$el.find('a').each(function () { },
if ($(this).attr('href').match(cur_tab)) {
$(this).parent().addClass('tab-cur'); render: function() {
return; this.$el.html(this.template(this.data));
}
});
return this; return this;
}, },
@@ -80,8 +77,16 @@ define([
}); });
}, },
show: function(cur_tab) { show: function(options) {
this.render(cur_tab); if (options && options.cur_tab) {
this.data.cur_tab = options.cur_tab;
this.render();
} else {
if (this.data.cur_tab != this.default_cur_tab) {
this.data.cur_tab = this.default_cur_tab;
this.render();
}
}
this.$el.show(); this.$el.show();
}, },

View File

@@ -31,35 +31,35 @@ define([
}, },
showMyRepos: function() { showMyRepos: function() {
this.sideNavView.show('my-libs'); this.sideNavView.show();
this.currentView.hide(); this.currentView.hide();
this.reposView.show(); this.reposView.show();
this.currentView = this.reposView; this.currentView = this.reposView;
}, },
showMySubRepos: function() { showMySubRepos: function() {
this.sideNavView.show('my-libs'); this.sideNavView.show();
this.currentView.hide(); this.currentView.hide();
this.subReposView.show(); this.subReposView.show();
this.currentView = this.subReposView; this.currentView = this.subReposView;
}, },
showSharedRepos: function() { showSharedRepos: function() {
this.sideNavView.show('my-libs'); this.sideNavView.show();
this.currentView.hide(); this.currentView.hide();
this.sharedReposView.show(); this.sharedReposView.show();
this.currentView = this.sharedReposView; this.currentView = this.sharedReposView;
}, },
showStarredFile: function() { showStarredFile: function() {
this.sideNavView.show('starred'); this.sideNavView.show({'cur_tab': 'starred'});
this.currentView.hide(); this.currentView.hide();
this.starredFileView.show(); this.starredFileView.show();
this.currentView = this.starredFileView; this.currentView = this.starredFileView;
}, },
showDir: function(category, repo_id, path) { showDir: function(category, repo_id, path) {
this.sideNavView.show('my-libs'); this.sideNavView.show();
var path = path || '/'; var path = path || '/';
this.currentView.hide(); this.currentView.hide();
this.dirView.showDir(category, repo_id, path); this.dirView.showDir(category, repo_id, path);