mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-03 16:10:26 +00:00
Move scripts from media to static folder
This commit is contained in:
64
static/scripts/app/views/shared-repo.js
Normal file
64
static/scripts/app/views/shared-repo.js
Normal file
@@ -0,0 +1,64 @@
|
||||
define([
|
||||
'jquery',
|
||||
'underscore',
|
||||
'backbone',
|
||||
'common',
|
||||
'text!' + app.config._tmplRoot + 'shared-repo.html'
|
||||
], function($, _, Backbone, Common, reposTemplate) {
|
||||
'use strict';
|
||||
|
||||
var SharedRepoView = Backbone.View.extend({
|
||||
tagName: 'tr',
|
||||
|
||||
template: _.template(reposTemplate),
|
||||
|
||||
events: {
|
||||
'mouseenter': 'showAction',
|
||||
'mouseleave': 'hideAction',
|
||||
'click .unshare-btn': '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) {
|
||||
$('#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')
|
||||
},
|
||||
'after_op_success': success_callback
|
||||
});
|
||||
},
|
||||
|
||||
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');
|
||||
},
|
||||
});
|
||||
|
||||
return SharedRepoView;
|
||||
});
|
Reference in New Issue
Block a user