1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-06-29 16:37:56 +00:00
seahub/static/scripts/app/views/organization-repo.js

70 lines
2.1 KiB
JavaScript
Raw Normal View History

2015-03-07 07:56:10 +00:00
define([
'jquery',
'underscore',
'backbone',
2015-04-03 04:15:41 +00:00
'common'
], function($, _, Backbone, Common) {
2015-03-07 07:56:10 +00:00
'use strict';
var OrganizationRepoView = Backbone.View.extend({
tagName: 'tr',
2015-04-11 07:14:56 +00:00
template: _.template($('#organization-repo-tmpl').html()),
2015-03-07 07:56:10 +00:00
events: {
'mouseenter': 'showAction',
'mouseleave': 'hideAction',
'click .cancel-share': 'removeShare'
},
initialize: function() {
},
removeShare: function(e) {
var _this = this,
success_callback = function(data) {
Common.feedback(gettext('Success'), 'success', Common.SUCCESS_TIMOUT);
_this.$el.remove();
_this.collection.remove(_this.model, {silent: true});
if (_this.collection.length == 0) {
$('#organization-repos table').hide();
$('#organization-repos .empty-tips').show();
};
};
Common.ajaxGet({
'get_url': Common.getUrl({name: 'ajax_repo_remove_share'}),
'data': {
'repo_id': this.model.get('id'),
'share_type': this.model.get('share_type')
},
'after_op_success': success_callback
});
},
render: function() {
var data, show_unshare_btn;
if (this.model.get('share_from') == app.pageOptions.current_user || app.pageOptions.is_staff == true) {
show_unshare_btn = true;
} else {
show_unshare_btn = false;
};
data = $.extend(this.model.toJSON(), {'show_unshare_btn': show_unshare_btn});
this.$el.html(this.template(data));
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');
}
});
return OrganizationRepoView;
});