2015-03-07 07:56:10 +00:00
|
|
|
define([
|
|
|
|
'jquery',
|
|
|
|
'underscore',
|
|
|
|
'backbone',
|
|
|
|
'common',
|
|
|
|
'app/collections/repos',
|
2015-03-07 08:40:30 +00:00
|
|
|
'app/views/organization-repo',
|
|
|
|
'app/views/dir',
|
2015-03-08 12:47:42 +00:00
|
|
|
'app/views/group-nav',
|
2015-03-07 08:40:30 +00:00
|
|
|
], function($, _, Backbone, Common, RepoCollection, OrganizationRepoView,
|
2015-03-08 12:47:42 +00:00
|
|
|
DirView, GroupNavView) {
|
2015-03-07 07:56:10 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var OrganizationView = Backbone.View.extend({
|
|
|
|
el: '#main',
|
|
|
|
|
|
|
|
initialize: function() {
|
2015-03-07 08:40:30 +00:00
|
|
|
this.$reposDiv = $('#organization-repos');
|
2015-03-07 07:56:10 +00:00
|
|
|
this.$table = $('#organization-repos table');
|
|
|
|
this.$tableBody = $('tbody', this.$table);
|
|
|
|
this.$loadingTip = $('#organization-repos .loading-tip');
|
|
|
|
this.$emptyTip = $('#organization-repos .empty-tips');
|
|
|
|
|
|
|
|
this.repos = new RepoCollection({type: 'org'});
|
|
|
|
this.listenTo(this.repos, 'add', this.addOne);
|
|
|
|
this.listenTo(this.repos, 'reset', this.reset);
|
2015-03-07 08:40:30 +00:00
|
|
|
|
|
|
|
this.dirView = new DirView();
|
2015-03-08 12:47:42 +00:00
|
|
|
|
|
|
|
this.groupView = new GroupNavView();
|
|
|
|
Common.initAccountPopup();
|
2015-03-20 05:55:50 +00:00
|
|
|
Common.initNoticePopup();
|
2015-03-07 07:56:10 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
events: {
|
|
|
|
'click #repo-create': 'createRepo'
|
|
|
|
},
|
|
|
|
|
|
|
|
createRepo: function() {
|
|
|
|
alert('todo');
|
|
|
|
},
|
|
|
|
|
|
|
|
addOne: function(repo, collection, options) {
|
|
|
|
var view = new OrganizationRepoView({model: repo, collection: this.repos});
|
|
|
|
if (options.prepend) {
|
|
|
|
this.$tableBody.prepend(view.render().el);
|
|
|
|
} else {
|
|
|
|
this.$tableBody.append(view.render().el);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
reset: function() {
|
|
|
|
this.$tableBody.empty();
|
|
|
|
this.repos.each(this.addOne, this);
|
|
|
|
if (this.repos.length) {
|
|
|
|
this.$emptyTip.hide();
|
|
|
|
this.$table.show();
|
|
|
|
} else {
|
|
|
|
this.$emptyTip.show();
|
|
|
|
this.$table.hide();
|
|
|
|
}
|
|
|
|
this.$loadingTip.hide();
|
|
|
|
},
|
|
|
|
|
|
|
|
showPublicRepos: function() {
|
2015-03-07 08:40:30 +00:00
|
|
|
this.dirView.hide();
|
|
|
|
this.$reposDiv.show();
|
2015-03-07 07:56:10 +00:00
|
|
|
this.repos.fetch({reset: true});
|
2015-03-07 08:40:30 +00:00
|
|
|
this.$loadingTip.show();
|
|
|
|
},
|
|
|
|
|
|
|
|
hideRepos: function() {
|
|
|
|
this.$reposDiv.hide();
|
|
|
|
},
|
|
|
|
|
|
|
|
showDir: function(repo_id, path) {
|
|
|
|
var path = path || '/';
|
|
|
|
this.hideRepos();
|
|
|
|
this.dirView.showDir('', repo_id, path);
|
|
|
|
// this.dirent_list = new app.DirentListView({id: id, path: path});
|
|
|
|
// $('#my-own-repos table').children().remove();
|
|
|
|
// $('#my-own-repos table').append(this.dirent_list.render().el);
|
2015-03-07 07:56:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
return OrganizationView;
|
|
|
|
});
|