mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-01 23:20:51 +00:00
[org admin] added 'address-book'
This commit is contained in:
6
static/scripts/orgadmin-app/main.js
Normal file
6
static/scripts/orgadmin-app/main.js
Normal file
@@ -0,0 +1,6 @@
|
||||
define([
|
||||
'orgadmin-app/router'
|
||||
], function(Router){
|
||||
app.router = new Router();
|
||||
Backbone.history.start();
|
||||
});
|
76
static/scripts/orgadmin-app/router.js
Normal file
76
static/scripts/orgadmin-app/router.js
Normal file
@@ -0,0 +1,76 @@
|
||||
/*global define*/
|
||||
define([
|
||||
'jquery',
|
||||
'backbone',
|
||||
'common',
|
||||
|
||||
'orgadmin-app/views/side-nav',
|
||||
|
||||
'sysadmin-app/views/address-book',
|
||||
'sysadmin-app/views/address-book-group',
|
||||
|
||||
'app/views/account'
|
||||
], function($, Backbone, Common, SideNavView,
|
||||
AddressBookView, AddressBookGroupView,
|
||||
AccountView) {
|
||||
|
||||
"use strict";
|
||||
|
||||
var Router = Backbone.Router.extend({
|
||||
routes: {
|
||||
'': 'showAddressBook',
|
||||
|
||||
'address-book/': 'showAddressBook',
|
||||
'address-book/groups/:group_id/': 'showAddressBookGroup',
|
||||
|
||||
// Default
|
||||
'*actions': 'showAddressBook',
|
||||
},
|
||||
|
||||
initialize: function() {
|
||||
$('#initial-loading').hide()
|
||||
.next('.row').removeClass('hide');
|
||||
|
||||
Common.prepareApiCsrf();
|
||||
Common.initLocale();
|
||||
|
||||
this.accountView = new AccountView();
|
||||
this.sideNavView = new SideNavView();
|
||||
app.ui = {
|
||||
sideNavView: this.sideNavView,
|
||||
accountView: this.accountView
|
||||
};
|
||||
|
||||
$('#info-bar .close').on('click', Common.closeTopNoticeBar);
|
||||
|
||||
this.addressBookView = new AddressBookView();
|
||||
this.addressBookGroupView = new AddressBookGroupView();
|
||||
},
|
||||
|
||||
switchCurrentView: function(newView) {
|
||||
if (!this.currentView) {
|
||||
this.currentView = newView;
|
||||
} else {
|
||||
if (this.currentView != newView) {
|
||||
this.currentView.hide();
|
||||
this.currentView = newView;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
showAddressBook: function() {
|
||||
this.switchCurrentView(this.addressBookView);
|
||||
this.sideNavView.setCurTab('address-book');
|
||||
this.addressBookView.show();
|
||||
},
|
||||
|
||||
showAddressBookGroup: function(group_id) {
|
||||
this.switchCurrentView(this.addressBookGroupView);
|
||||
this.sideNavView.setCurTab('address-book');
|
||||
this.addressBookGroupView.show({'group_id': group_id});
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
return Router;
|
||||
});
|
74
static/scripts/orgadmin-app/views/side-nav.js
Normal file
74
static/scripts/orgadmin-app/views/side-nav.js
Normal file
@@ -0,0 +1,74 @@
|
||||
define([
|
||||
'jquery',
|
||||
'underscore',
|
||||
'backbone',
|
||||
'common'
|
||||
], function($, _, Backbone, Common) {
|
||||
'use strict';
|
||||
|
||||
var sideNavView = Backbone.View.extend({
|
||||
el: '#side-nav',
|
||||
|
||||
template: _.template($("#side-nav-tmpl").html()),
|
||||
|
||||
initialize: function() {
|
||||
this.default_cur_tab = 'address-book';
|
||||
this.data = {
|
||||
'cur_tab': this.default_cur_tab
|
||||
};
|
||||
this.render();
|
||||
|
||||
var _this = this;
|
||||
$('#js-toggle-side-nav').on('click', function() {
|
||||
_this.show();
|
||||
return false;
|
||||
});
|
||||
$(window).on('resize', function() {
|
||||
if ($(window).width() >= 768) {
|
||||
_this.show();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
render: function() {
|
||||
this.$el.html(this.template(this.data));
|
||||
return this;
|
||||
},
|
||||
|
||||
setCurTab: function(cur_tab, options) {
|
||||
this.data.cur_tab = cur_tab || this.default_cur_tab;
|
||||
if (options) {
|
||||
$.extend(this.data, options);
|
||||
}
|
||||
this.render();
|
||||
},
|
||||
|
||||
show: function() {
|
||||
this.$el.css({ 'left':'0px' });
|
||||
},
|
||||
|
||||
hide: function() {
|
||||
this.$el.css({ 'left':'-300px' });
|
||||
},
|
||||
|
||||
events: {
|
||||
'click .js-close-side-nav': 'closeNav',
|
||||
'click li a': 'visitLink'
|
||||
},
|
||||
|
||||
closeNav: function() {
|
||||
this.hide();
|
||||
return false;
|
||||
},
|
||||
|
||||
visitLink: function(e) {
|
||||
if ($(window).width() < 768) {
|
||||
this.hide();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
return sideNavView;
|
||||
});
|
Reference in New Issue
Block a user