2015-01-20 18:25:10 +08:00
|
|
|
define([
|
|
|
|
'jquery',
|
|
|
|
'underscore',
|
|
|
|
'backbone',
|
2015-01-25 18:47:42 +08:00
|
|
|
'text!' + app.config._tmplRoot + 'dirent.html'
|
2015-01-20 18:25:10 +08:00
|
|
|
], function($, _, Backbone, direntsTemplate) {
|
|
|
|
'use strict';
|
|
|
|
|
2015-01-25 18:47:42 +08:00
|
|
|
app = app || {};
|
|
|
|
app.globalState = app.globalState || {};
|
|
|
|
|
2015-01-20 18:25:10 +08:00
|
|
|
var DirentView = Backbone.View.extend({
|
|
|
|
tagName: 'tr',
|
|
|
|
|
|
|
|
template: _.template(direntsTemplate),
|
|
|
|
|
2015-01-25 18:47:42 +08:00
|
|
|
initialize: function(options) {
|
2015-01-20 18:25:10 +08:00
|
|
|
console.log('init DirentView');
|
2015-01-25 18:47:42 +08:00
|
|
|
this.options = options || {};
|
|
|
|
this.model = options.model;
|
|
|
|
this.dirView = options.dirView;
|
|
|
|
|
|
|
|
app.globalState.noFileOpPopup = true;
|
|
|
|
this.listenTo(this.model, "change", this.render);
|
|
|
|
//Backbone.View.prototype.initialize.apply(this, arguments);
|
2015-01-20 18:25:10 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
render: function() {
|
2015-01-25 18:47:42 +08:00
|
|
|
this.$el.html(this.template({
|
|
|
|
dirent: this.model.attributes,
|
|
|
|
repo_id: this.dirView.dir.repo_id,
|
|
|
|
path: this.dirView.dir.path,
|
|
|
|
user_perm: this.dirView.dir.user_perm,
|
|
|
|
repo_encrypted: this.dirView.dir.encrypted
|
|
|
|
}));
|
2015-01-20 18:25:10 +08:00
|
|
|
return this;
|
2015-01-25 18:47:42 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
events: {
|
|
|
|
'mouseenter': 'highlight',
|
|
|
|
'mouseleave': 'rmHighlight',
|
|
|
|
'click .select': 'select',
|
|
|
|
'click .file-star': 'starFile',
|
|
|
|
'click .dir-link': 'visitDir',
|
|
|
|
'click .more-op-icon': 'togglePopup',
|
|
|
|
'click .share': 'share',
|
|
|
|
'click .del': 'delete',
|
|
|
|
'click .rename': 'rename',
|
|
|
|
'click .mv': 'mvcp',
|
|
|
|
'click .cp': 'mvcp',
|
|
|
|
'click .file-update': 'updateFile'
|
|
|
|
},
|
|
|
|
|
|
|
|
highlight: function() {
|
|
|
|
if (app.globalState.noFileOpPopup) {
|
|
|
|
this.$el.addClass('hl').find('.repo-file-op').removeClass('vh');
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
rmHighlight: function() {
|
|
|
|
if (app.globalState.noFileOpPopup) {
|
|
|
|
this.$el.removeClass('hl').find('.repo-file-op').addClass('vh');
|
|
|
|
}
|
|
|
|
},
|
2015-01-20 18:25:10 +08:00
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
return DirentView;
|
|
|
|
});
|