1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-06-24 22:22:38 +00:00
seahub/static/scripts/app/views/shared-repo.js

67 lines
1.9 KiB
JavaScript
Raw Normal View History

2015-02-04 13:57:26 +00:00
define([
'jquery',
'underscore',
'backbone',
2015-04-03 04:15:41 +00:00
'common'
], function($, _, Backbone, Common) {
2015-02-04 13:57:26 +00:00
'use strict';
var SharedRepoView = Backbone.View.extend({
tagName: 'tr',
2015-04-03 04:15:41 +00:00
template: _.template($('#shared-repo-tmpl').html()),
2015-02-04 13:57:26 +00:00
events: {
'mouseenter': 'showAction',
'mouseleave': 'hideAction',
2015-03-06 09:53:41 +00:00
'click .unshare-btn': 'removeShare'
2015-02-04 13:57:26 +00:00
},
initialize: function() {
2015-03-06 09:53:41 +00:00
},
removeShare: function(e) {
var _this = this,
2015-03-07 07:56:10 +00:00
success_callback = function(data) {
2015-03-06 09:53:41 +00:00
Common.feedback(gettext('Success'), 'success', Common.SUCCESS_TIMOUT);
_this.$el.remove();
_this.collection.remove(_this.model, {silent: true});
if (_this.collection.length == 0) {
$('#repos-shared-to-me table').hide();
$('#repos-shared-to-me .empty-tips').show();
};
};
$.ajax({
url: Common.getUrl({name: 'ajax_repo_remove_share'}),
type: 'POST',
beforeSend: Common.prepareCSRFToken,
data: {
'repo_id': this.model.get('id'),
'from': this.model.get('owner'),
'share_type': this.model.get('share_type')
},
dataType: 'json',
success: success_callback
2015-03-06 09:53:41 +00:00
});
2015-02-04 13:57:26 +00:00
},
render: function() {
this.$el.html(this.template(this.model.toJSON()));
return this;
},
showAction: function() {
this.$el.addClass('hl');
this.$el.find('.op-icon').removeClass('vh');
},
hideAction: function() {
this.$el.removeClass('hl');
this.$el.find('.op-icon').addClass('vh');
2015-06-10 05:43:41 +00:00
}
2015-02-04 13:57:26 +00:00
});
return SharedRepoView;
});