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();
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
Common.ajaxGet({
|
|
|
|
'get_url': Common.getUrl({name: 'ajax_repo_remove_share'}),
|
|
|
|
'data': {
|
|
|
|
'repo_id': this.model.get('id'),
|
|
|
|
'from': this.model.get('owner'),
|
|
|
|
'share_type': this.model.get('share_type')
|
|
|
|
},
|
2015-03-07 07:56:10 +00:00
|
|
|
'after_op_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;
|
|
|
|
});
|