mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-05 08:53:14 +00:00
clean sub-library related code
This commit is contained in:
@@ -88,21 +88,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
{% if sub_lib_enabled %}
|
|
||||||
<form id="sublib-create-form" class="file-choose-form hide">
|
|
||||||
<h3>{% trans "Choose a directory:" %}</h3>
|
|
||||||
<div class="dir-tree-cont">
|
|
||||||
<span class="loading-icon loading-tip"></span>
|
|
||||||
</div>
|
|
||||||
<input type="hidden" name="dst_repo" value="" />
|
|
||||||
<input type="hidden" name="dst_path" value="" />
|
|
||||||
<p class="error hide"></p>
|
|
||||||
<input type="button" value="{% trans "Submit" %}" class="submit" />
|
|
||||||
<button class="simplemodal-close">{% trans "Cancel"%}</button>
|
|
||||||
</form>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
<div id="group" class="hide">
|
<div id="group" class="hide">
|
||||||
<div id="group-top"></div>
|
<div id="group-top"></div>
|
||||||
|
|
||||||
|
@@ -18,8 +18,6 @@ define([
|
|||||||
'': 'showRepos',
|
'': 'showRepos',
|
||||||
'my-libs/': 'showMyRepos',
|
'my-libs/': 'showMyRepos',
|
||||||
'my-libs/lib/:repo_id(/*path)': 'showMyRepoDir',
|
'my-libs/lib/:repo_id(/*path)': 'showMyRepoDir',
|
||||||
'my-sub-libs/': 'showMySubRepos',
|
|
||||||
'my-sub-libs/lib/:repo_id(/*path)': 'showMySubRepoDir',
|
|
||||||
'shared-libs/': 'showSharedRepos',
|
'shared-libs/': 'showSharedRepos',
|
||||||
'shared-libs/lib/:repo_id(/*path)': 'showSharedRepoDir',
|
'shared-libs/lib/:repo_id(/*path)': 'showSharedRepoDir',
|
||||||
'groups/': 'showGroups',
|
'groups/': 'showGroups',
|
||||||
@@ -86,11 +84,6 @@ define([
|
|||||||
this.sideNavView.setCurTab('mine');
|
this.sideNavView.setCurTab('mine');
|
||||||
},
|
},
|
||||||
|
|
||||||
showMySubRepos: function() {
|
|
||||||
this.switchCurrentView(this.myHomeView);
|
|
||||||
this.myHomeView.showMySubRepos();
|
|
||||||
},
|
|
||||||
|
|
||||||
showSharedRepos: function() {
|
showSharedRepos: function() {
|
||||||
this.switchCurrentView(this.myHomeView);
|
this.switchCurrentView(this.myHomeView);
|
||||||
this.myHomeView.showSharedRepos();
|
this.myHomeView.showSharedRepos();
|
||||||
@@ -130,17 +123,6 @@ define([
|
|||||||
this.myHomeView.showDir('common', repo_id, path);
|
this.myHomeView.showDir('common', repo_id, path);
|
||||||
},
|
},
|
||||||
|
|
||||||
showMySubRepoDir: function(repo_id, path) {
|
|
||||||
if (path) {
|
|
||||||
path = '/' + path;
|
|
||||||
} else {
|
|
||||||
path = '/';
|
|
||||||
}
|
|
||||||
this.switchCurrentView(this.myHomeView);
|
|
||||||
this.myHomeView.showDir('my-sub-libs', repo_id, path);
|
|
||||||
this.sideNavView.setCurTab('sub-libs');
|
|
||||||
},
|
|
||||||
|
|
||||||
showSharedRepoDir: function(repo_id, path) {
|
showSharedRepoDir: function(repo_id, path) {
|
||||||
if (path) {
|
if (path) {
|
||||||
path = '/' + path;
|
path = '/' + path;
|
||||||
|
@@ -1,92 +0,0 @@
|
|||||||
define([
|
|
||||||
'jquery',
|
|
||||||
'underscore',
|
|
||||||
'backbone',
|
|
||||||
'common'
|
|
||||||
], function($, _, Backbone, Common) {
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
var RepoView = Backbone.View.extend({
|
|
||||||
tagName: 'tr',
|
|
||||||
|
|
||||||
template: _.template($('#sub-lib-tmpl').html()),
|
|
||||||
repoDelConfirmTemplate: _.template($('#repo-del-confirm-template').html()),
|
|
||||||
|
|
||||||
events: {
|
|
||||||
'mouseenter': 'highlight',
|
|
||||||
'mouseleave': 'rmHighlight',
|
|
||||||
'click .repo-delete-btn': 'del'
|
|
||||||
},
|
|
||||||
|
|
||||||
initialize: function() {
|
|
||||||
},
|
|
||||||
|
|
||||||
render: function() {
|
|
||||||
this.$el.html(this.template(this.model.toJSON()));
|
|
||||||
return this;
|
|
||||||
},
|
|
||||||
|
|
||||||
// disable 'hover' when 'repo-del-confirm' popup is shown
|
|
||||||
highlight: function() {
|
|
||||||
if ($('#my-sub-repos .repo-del-confirm').length == 0) {
|
|
||||||
this.$el.addClass('hl').find('.op-icon').removeClass('vh');
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
rmHighlight: function() {
|
|
||||||
if ($('#my-sub-repos .repo-del-confirm').length == 0) {
|
|
||||||
this.$el.removeClass('hl').find('.op-icon').addClass('vh');
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
del: function() {
|
|
||||||
var del_icon = this.$('.repo-delete-btn');
|
|
||||||
var op_container = this.$('.op-container').css({'position': 'relative'});
|
|
||||||
|
|
||||||
var confirm_msg = gettext("Really want to delete {lib_name}?")
|
|
||||||
.replace('{lib_name}', '<span class="op-target">' + Common.HTMLescape(this.model.get('name')) + '</span>');
|
|
||||||
var confirm_popup = $(this.repoDelConfirmTemplate({
|
|
||||||
content: confirm_msg
|
|
||||||
}))
|
|
||||||
.appendTo(op_container)
|
|
||||||
.css({
|
|
||||||
'left': del_icon.position().left,
|
|
||||||
'top': del_icon.position().top + del_icon.height() + 2,
|
|
||||||
'width': 180
|
|
||||||
});
|
|
||||||
|
|
||||||
var _this = this;
|
|
||||||
$('.no', confirm_popup).click(function() {
|
|
||||||
confirm_popup.addClass('hide').remove(); // `addClass('hide')`: to rm cursor
|
|
||||||
_this.rmHighlight();
|
|
||||||
});
|
|
||||||
$('.yes', confirm_popup).click(function() {
|
|
||||||
$.ajax({
|
|
||||||
url: Common.getUrl({'name':'repo_del', 'repo_id': _this.model.get('id')}),
|
|
||||||
type: 'POST',
|
|
||||||
dataType: 'json',
|
|
||||||
beforeSend: Common.prepareCSRFToken,
|
|
||||||
success: function(data) {
|
|
||||||
_this.remove();
|
|
||||||
Common.feedback(gettext("Delete succeeded."), 'success');
|
|
||||||
},
|
|
||||||
error: function(xhr) {
|
|
||||||
confirm_popup.addClass('hide').remove();
|
|
||||||
_this.rmHighlight();
|
|
||||||
|
|
||||||
var err;
|
|
||||||
if (xhr.responseText) {
|
|
||||||
err = $.parseJSON(xhr.responseText).error;
|
|
||||||
} else {
|
|
||||||
err = gettext("Failed. Please check the network.");
|
|
||||||
}
|
|
||||||
Common.feedback(err, 'error');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
return RepoView;
|
|
||||||
});
|
|
Reference in New Issue
Block a user