mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-14 06:11:16 +00:00
redesigned side nav; removed 'top group nav'
This commit is contained in:
@@ -3,14 +3,14 @@ define([
|
||||
'jquery',
|
||||
'backbone',
|
||||
'common',
|
||||
'app/views/side-nav',
|
||||
'app/views/myhome',
|
||||
'app/views/groups',
|
||||
'app/views/group',
|
||||
'app/views/organization',
|
||||
'app/views/dir',
|
||||
'app/views/top-group-nav'
|
||||
], function($, Backbone, Common, MyHomeView, GroupsView, GroupView, OrgView,
|
||||
DirView, GroupNavView) {
|
||||
'app/views/dir'
|
||||
], function($, Backbone, Common, SideNavView, MyHomeView, GroupsView, GroupView,
|
||||
OrgView, DirView) {
|
||||
"use strict";
|
||||
|
||||
var Router = Backbone.Router.extend({
|
||||
@@ -39,6 +39,8 @@ define([
|
||||
Common.initAccountPopup();
|
||||
Common.initNoticePopup();
|
||||
|
||||
this.sideNavView = new SideNavView();
|
||||
|
||||
this.dirView = new DirView();
|
||||
|
||||
this.myHomeView = new MyHomeView({dirView: this.dirView});
|
||||
@@ -49,10 +51,6 @@ define([
|
||||
|
||||
this.currentView = this.myHomeView;
|
||||
|
||||
if (app.pageOptions.top_nav_groups.length > 0) {
|
||||
this.topGroupNavView = new GroupNavView();
|
||||
}
|
||||
|
||||
$('#info-bar .close').click(Common.closeTopNoticeBar);
|
||||
$('#top-browser-tip .close').click(function () {
|
||||
$('#top-browser-tip').addClass('hide');
|
||||
@@ -72,12 +70,14 @@ define([
|
||||
this.myHomeView.showMyRepos();
|
||||
} else {
|
||||
this.myHomeView.showSharedRepos();
|
||||
this.sideNavView.setCurTab('shared');
|
||||
}
|
||||
},
|
||||
|
||||
showMyRepos: function() {
|
||||
this.switchCurrentView(this.myHomeView);
|
||||
this.myHomeView.showMyRepos();
|
||||
this.sideNavView.setCurTab('mine');
|
||||
},
|
||||
|
||||
showMySubRepos: function() {
|
||||
@@ -88,16 +88,19 @@ define([
|
||||
showSharedRepos: function() {
|
||||
this.switchCurrentView(this.myHomeView);
|
||||
this.myHomeView.showSharedRepos();
|
||||
this.sideNavView.setCurTab('shared');
|
||||
},
|
||||
|
||||
showStarredFile: function() {
|
||||
this.switchCurrentView(this.myHomeView);
|
||||
this.myHomeView.showStarredFile();
|
||||
this.sideNavView.setCurTab('starred');
|
||||
},
|
||||
|
||||
showActivities: function() {
|
||||
this.switchCurrentView(this.myHomeView);
|
||||
this.myHomeView.showActivities();
|
||||
this.sideNavView.setCurTab('activities');
|
||||
},
|
||||
|
||||
showMyRepoDir: function(repo_id, path) {
|
||||
@@ -108,6 +111,7 @@ define([
|
||||
}
|
||||
this.switchCurrentView(this.myHomeView);
|
||||
this.myHomeView.showDir('my-libs', repo_id, path);
|
||||
this.sideNavView.setCurTab('mine');
|
||||
},
|
||||
|
||||
showCommonDir: function(repo_id, path) {
|
||||
@@ -128,6 +132,7 @@ define([
|
||||
}
|
||||
this.switchCurrentView(this.myHomeView);
|
||||
this.myHomeView.showDir('my-sub-libs', repo_id, path);
|
||||
this.sideNavView.setCurTab('sub-libs');
|
||||
},
|
||||
|
||||
showSharedRepoDir: function(repo_id, path) {
|
||||
@@ -138,6 +143,7 @@ define([
|
||||
}
|
||||
this.switchCurrentView(this.myHomeView);
|
||||
this.myHomeView.showDir('shared-libs', repo_id, path);
|
||||
this.sideNavView.setCurTab('shared');
|
||||
},
|
||||
|
||||
showGroups: function () {
|
||||
@@ -148,6 +154,7 @@ define([
|
||||
showGroupRepos: function(group_id) {
|
||||
this.switchCurrentView(this.groupView);
|
||||
this.groupView.showRepoList(group_id);
|
||||
this.sideNavView.setCurTab('group', {'cur_group_id': group_id});
|
||||
},
|
||||
|
||||
showGroupRepoDir: function(group_id, repo_id, path) {
|
||||
@@ -158,11 +165,13 @@ define([
|
||||
}
|
||||
this.switchCurrentView(this.groupView);
|
||||
this.groupView.showDir(group_id, repo_id, path);
|
||||
this.sideNavView.setCurTab('group', {'cur_group_id': group_id});
|
||||
},
|
||||
|
||||
showOrgRepos: function() {
|
||||
this.switchCurrentView(this.orgView);
|
||||
this.orgView.showRepoList();
|
||||
this.sideNavView.setCurTab('org');
|
||||
},
|
||||
|
||||
showOrgRepoDir: function(repo_id, path) {
|
||||
@@ -173,6 +182,7 @@ define([
|
||||
}
|
||||
this.switchCurrentView(this.orgView);
|
||||
this.orgView.showDir(repo_id, path);
|
||||
this.sideNavView.setCurTab('org');
|
||||
}
|
||||
|
||||
});
|
||||
|
@@ -1,96 +0,0 @@
|
||||
define([
|
||||
'jquery',
|
||||
'underscore',
|
||||
'backbone',
|
||||
'common'
|
||||
], function($, _, Backbone, Common) {
|
||||
'use strict';
|
||||
|
||||
var GroupSideNavView = Backbone.View.extend({
|
||||
el: '#group-side-nav',
|
||||
|
||||
template: _.template($("#group-side-nav-tmpl").html()),
|
||||
enableModTemplate: _.template($("#group-mods-enable-form-tmpl").html()),
|
||||
|
||||
initialize: function() {
|
||||
},
|
||||
|
||||
render: function (group_id) {
|
||||
this.group_id = group_id;
|
||||
var _this = this;
|
||||
$.ajax({
|
||||
url: Common.getUrl({
|
||||
'name': 'group_basic_info',
|
||||
'group_id': this.group_id
|
||||
}),
|
||||
cache: false,
|
||||
dataType: 'json',
|
||||
success: function (data) {
|
||||
_this.$el.html(_this.template(data));
|
||||
// for 'enable mod'
|
||||
_this.mods_available = data.mods_available;
|
||||
_this.mods_enabled = data.mods_enabled;
|
||||
},
|
||||
error: function(xhr) {
|
||||
var err_msg;
|
||||
if (xhr.responseText) {
|
||||
err_msg = $.parseJSON(xhr.responseText).error;
|
||||
} else {
|
||||
err_msg = gettext("Please check the network.");
|
||||
}
|
||||
_this.$el.html('<p class="error">' + err_msg + '</p>');
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
events: {
|
||||
'click #enable-mods': 'enableMods'
|
||||
},
|
||||
|
||||
enableMods: function () {
|
||||
var form = $(this.enableModTemplate({
|
||||
'mods_available': this.mods_available,
|
||||
'mods_enabled': this.mods_enabled
|
||||
}));
|
||||
form.modal();
|
||||
$('#simplemodal-container').css('height', 'auto');
|
||||
$('.checkbox-orig', form).click(function() {
|
||||
$(this).parent().toggleClass('checkbox-checked');
|
||||
});
|
||||
var checkbox = $('[name="group_wiki"]');
|
||||
var original_checked = checkbox.prop('checked');
|
||||
var _this = this;
|
||||
form.submit(function() {
|
||||
var cur_checked = checkbox.prop('checked');
|
||||
if (cur_checked == original_checked) {
|
||||
return false;
|
||||
}
|
||||
Common.ajaxPost({
|
||||
form: form,
|
||||
form_id: form.attr('id'),
|
||||
post_url: Common.getUrl({
|
||||
'name': 'toggle_group_modules',
|
||||
'group_id': _this.group_id
|
||||
}),
|
||||
post_data: {'group_wiki': cur_checked },
|
||||
after_op_success: function () {
|
||||
$.modal.close();
|
||||
_this.render(_this.group_id);
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
},
|
||||
|
||||
show: function() {
|
||||
this.$el.show();
|
||||
},
|
||||
|
||||
hide: function() {
|
||||
this.$el.hide();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
return GroupSideNavView;
|
||||
});
|
@@ -5,10 +5,9 @@ define([
|
||||
'common',
|
||||
'app/collections/group-repos',
|
||||
'app/views/group-repo',
|
||||
'app/views/add-group-repo',
|
||||
'app/views/group-side-nav'
|
||||
'app/views/add-group-repo'
|
||||
], function($, _, Backbone, Common, GroupRepos, GroupRepoView,
|
||||
AddGroupRepoView, GroupSideNavView) {
|
||||
AddGroupRepoView) {
|
||||
'use strict';
|
||||
|
||||
var GroupView = Backbone.View.extend({
|
||||
@@ -30,8 +29,6 @@ define([
|
||||
this.$loadingTip = this.$('.loading-tip');
|
||||
this.$emptyTip = this.$('.empty-tips');
|
||||
|
||||
this.sideNavView = new GroupSideNavView();
|
||||
|
||||
this.repos = new GroupRepos();
|
||||
this.listenTo(this.repos, 'add', this.addOne);
|
||||
this.listenTo(this.repos, 'reset', this.reset);
|
||||
@@ -71,19 +68,8 @@ define([
|
||||
}
|
||||
},
|
||||
|
||||
showSideNav: function () {
|
||||
var sideNavView = this.sideNavView;
|
||||
if (sideNavView.group_id && sideNavView.group_id == this.group_id) {
|
||||
sideNavView.show();
|
||||
return;
|
||||
}
|
||||
sideNavView.render(this.group_id);
|
||||
sideNavView.show();
|
||||
},
|
||||
|
||||
showRepoList: function(group_id) {
|
||||
this.group_id = group_id;
|
||||
this.showSideNav();
|
||||
this.dirView.hide();
|
||||
this.$emptyTip.hide();
|
||||
this.$tabs.show();
|
||||
@@ -122,7 +108,6 @@ define([
|
||||
|
||||
showDir: function(group_id, repo_id, path) {
|
||||
this.group_id = group_id;
|
||||
this.showSideNav();
|
||||
this.hideRepoList();
|
||||
this.dirView.showDir('group/' + this.group_id, repo_id, path);
|
||||
},
|
||||
@@ -169,7 +154,6 @@ define([
|
||||
},
|
||||
|
||||
hide: function() {
|
||||
this.sideNavView.hide();
|
||||
this.hideRepoList();
|
||||
this.dirView.hide();
|
||||
this.$emptyTip.hide();
|
||||
|
@@ -1,100 +0,0 @@
|
||||
define([
|
||||
'jquery',
|
||||
'underscore',
|
||||
'backbone',
|
||||
'common'
|
||||
], function($, _, Backbone, Common) {
|
||||
'use strict';
|
||||
|
||||
var MyhomeSideNavView = Backbone.View.extend({
|
||||
el: '#myhome-side-nav',
|
||||
|
||||
template: _.template($("#myhome-side-nav-tmpl").html()),
|
||||
enableModTemplate: _.template($("#myhome-mods-enable-form-tmpl").html()),
|
||||
|
||||
initialize: function() {
|
||||
this.default_cur_tab = 'libs';
|
||||
this.data = {
|
||||
'cur_tab': this.default_cur_tab,
|
||||
'mods_enabled': app.pageOptions.user_mods_enabled,
|
||||
'can_add_repo': app.pageOptions.can_add_repo,
|
||||
'events_enabled': app.pageOptions.events_enabled
|
||||
};
|
||||
this.render();
|
||||
},
|
||||
|
||||
render: function() {
|
||||
this.$el.html(this.template(this.data));
|
||||
return this;
|
||||
},
|
||||
|
||||
events: {
|
||||
'click #myhome-enable-mods': 'enableMods'
|
||||
},
|
||||
|
||||
enableMods: function () {
|
||||
var mods_enabled = app.pageOptions.user_mods_enabled;
|
||||
var form = $(this.enableModTemplate({
|
||||
'mods_available': app.pageOptions.user_mods_available,
|
||||
'mods_enabled': mods_enabled
|
||||
}));
|
||||
form.modal();
|
||||
$('#simplemodal-container').css('height', 'auto');
|
||||
|
||||
$('.checkbox-orig', form).click(function() {
|
||||
$(this).parent().toggleClass('checkbox-checked');
|
||||
});
|
||||
|
||||
var checkbox = $('[name="personal_wiki"]'),
|
||||
original_checked = checkbox.prop('checked'),
|
||||
_this = this;
|
||||
form.submit(function() {
|
||||
var cur_checked = checkbox.prop('checked');
|
||||
if (cur_checked == original_checked) {
|
||||
return false;
|
||||
}
|
||||
Common.ajaxPost({
|
||||
form: form,
|
||||
form_id: form.attr('id'),
|
||||
post_url: Common.getUrl({
|
||||
'name': 'toggle_personal_modules'
|
||||
}),
|
||||
post_data: {'personal_wiki': cur_checked },
|
||||
after_op_success: function () {
|
||||
if (cur_checked) {
|
||||
mods_enabled.push('personal wiki');
|
||||
} else {
|
||||
var index = mods_enabled.indexOf('personal wiki');
|
||||
if (index > -1) {
|
||||
mods_enabled.splice(index, 1); // rm the item
|
||||
}
|
||||
}
|
||||
$.modal.close();
|
||||
_this.render();
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
},
|
||||
|
||||
show: function(options) {
|
||||
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();
|
||||
},
|
||||
|
||||
hide: function() {
|
||||
this.$el.hide();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
return MyhomeSideNavView;
|
||||
});
|
@@ -7,17 +7,15 @@ define([
|
||||
'app/views/myhome-sub-repos',
|
||||
'app/views/myhome-shared-repos',
|
||||
'app/views/starred-file',
|
||||
'app/views/activities',
|
||||
'app/views/myhome-side-nav'
|
||||
'app/views/activities'
|
||||
], function($, _, Backbone, Common, ReposView, SubReposView,
|
||||
SharedReposView, StarredFileView, ActivitiesView, MyhomeSideNavView) {
|
||||
SharedReposView, StarredFileView, ActivitiesView) {
|
||||
'use strict';
|
||||
|
||||
var MyHomeView = Backbone.View.extend({
|
||||
el: '#main',
|
||||
|
||||
initialize: function(options) {
|
||||
this.sideNavView = new MyhomeSideNavView();
|
||||
this.reposView = new ReposView();
|
||||
this.subReposView = new SubReposView();
|
||||
this.sharedReposView = new SharedReposView();
|
||||
@@ -32,42 +30,36 @@ define([
|
||||
},
|
||||
|
||||
showMyRepos: function() {
|
||||
this.sideNavView.show();
|
||||
this.currentView.hide();
|
||||
this.reposView.show();
|
||||
this.currentView = this.reposView;
|
||||
},
|
||||
|
||||
showMySubRepos: function() {
|
||||
this.sideNavView.show();
|
||||
this.currentView.hide();
|
||||
this.subReposView.show();
|
||||
this.currentView = this.subReposView;
|
||||
},
|
||||
|
||||
showSharedRepos: function() {
|
||||
this.sideNavView.show();
|
||||
this.currentView.hide();
|
||||
this.sharedReposView.show();
|
||||
this.currentView = this.sharedReposView;
|
||||
},
|
||||
|
||||
showStarredFile: function() {
|
||||
this.sideNavView.show({'cur_tab': 'starred'});
|
||||
this.currentView.hide();
|
||||
this.starredFileView.show();
|
||||
this.currentView = this.starredFileView;
|
||||
},
|
||||
|
||||
showActivities: function() {
|
||||
this.sideNavView.show({'cur_tab': 'activities'});
|
||||
this.currentView.hide();
|
||||
this.activitiesView.show();
|
||||
this.currentView = this.activitiesView;
|
||||
},
|
||||
|
||||
showDir: function(category, repo_id, path) {
|
||||
this.sideNavView.show();
|
||||
var path = path || '/';
|
||||
this.currentView.hide();
|
||||
this.dirView.showDir(category, repo_id, path);
|
||||
@@ -76,7 +68,6 @@ define([
|
||||
|
||||
hide: function() {
|
||||
this.currentView.hide();
|
||||
this.sideNavView.hide();
|
||||
}
|
||||
|
||||
});
|
||||
|
@@ -18,7 +18,6 @@ define([
|
||||
|
||||
initialize: function(options) {
|
||||
|
||||
this.$sideNav = $('#org-side-nav');
|
||||
this.$reposDiv = $('#organization-repos');
|
||||
this.$table = $('#organization-repos table');
|
||||
this.$tableHead = $('thead', this.$table);
|
||||
@@ -99,7 +98,6 @@ define([
|
||||
},
|
||||
|
||||
showRepoList: function() {
|
||||
this.$sideNav.show();
|
||||
this.dirView.hide();
|
||||
this.$reposDiv.show();
|
||||
var $loadingTip = this.$loadingTip;
|
||||
@@ -133,7 +131,6 @@ define([
|
||||
},
|
||||
|
||||
showDir: function(repo_id, path) {
|
||||
this.$sideNav.show();
|
||||
var path = path || '/';
|
||||
this.hideRepoList();
|
||||
this.dirView.showDir('org', repo_id, path);
|
||||
@@ -177,7 +174,6 @@ define([
|
||||
},
|
||||
|
||||
hide: function() {
|
||||
this.$sideNav.hide();
|
||||
this.hideRepoList();
|
||||
this.$emptyTip.hide();
|
||||
this.dirView.hide();
|
||||
|
@@ -1,52 +0,0 @@
|
||||
define([
|
||||
'jquery',
|
||||
'underscore',
|
||||
'backbone',
|
||||
'common'
|
||||
], function($, _, Backbone, Common) {
|
||||
'use strict';
|
||||
|
||||
var GroupNavView = Backbone.View.extend({
|
||||
el: '.nav .nav-item-group',
|
||||
|
||||
popupTemplate: _.template($('#top-group-nav-tmpl').html()),
|
||||
|
||||
initialize: function() {
|
||||
var popup = $(this.popupTemplate({groups: app.pageOptions.top_nav_groups}));
|
||||
this.$el.append(popup);
|
||||
popup.css({'right': ($('#top-nav-grp').outerWidth() - popup.outerWidth())/6 * 5});
|
||||
this.popup = popup;
|
||||
},
|
||||
|
||||
events: {
|
||||
'mouseenter': 'showPopup',
|
||||
'mouseleave': 'hidePopup',
|
||||
'mouseenter #top-nav-grp-list .item': 'highlightGroupItem',
|
||||
'mouseleave #top-nav-grp-list .item': 'rmHighlightGroupItem',
|
||||
'click #top-nav-grp-list .item': 'visitGroup'
|
||||
},
|
||||
|
||||
showPopup: function(e) {
|
||||
this.popup.removeClass('hide');
|
||||
},
|
||||
|
||||
hidePopup: function(e) {
|
||||
this.popup.addClass('hide');
|
||||
},
|
||||
|
||||
highlightGroupItem: function(e) {
|
||||
$(e.currentTarget).addClass('hl').children('a').removeClass('vh');
|
||||
},
|
||||
|
||||
rmHighlightGroupItem: function(e) {
|
||||
$(e.currentTarget).removeClass('hl').children('a').addClass('vh');
|
||||
},
|
||||
|
||||
visitGroup: function(e) {
|
||||
this.hidePopup(e);
|
||||
location.href = $(e.currentTarget).attr('data-url');
|
||||
}
|
||||
});
|
||||
|
||||
return GroupNavView;
|
||||
});
|
Reference in New Issue
Block a user