1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-18 16:36:15 +00:00
Files
seahub/media/scripts/app/views/dirents.js

70 lines
2.0 KiB
JavaScript
Raw Normal View History

define([
'jquery',
'underscore',
'backbone',
2015-01-25 18:47:42 +08:00
'text!' + app.config._tmplRoot + 'dirent.html'
], function($, _, Backbone, direntsTemplate) {
'use strict';
2015-01-25 18:47:42 +08:00
app = app || {};
app.globalState = app.globalState || {};
var DirentView = Backbone.View.extend({
tagName: 'tr',
template: _.template(direntsTemplate),
2015-01-25 18:47:42 +08:00
initialize: function(options) {
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);
},
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
}));
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');
}
},
});
return DirentView;
});