1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-01 23:20:51 +00:00

Restructure views

Conflicts:
	seahub/templates/libraries.html
	static/scripts/app/router.js
	static/scripts/app/views/group.js
	static/scripts/app/views/organization.js
This commit is contained in:
Daniel Pan
2016-03-24 14:43:20 +08:00
parent dd906d7f68
commit 45a7ba13e7
16 changed files with 460 additions and 483 deletions

View File

@@ -11,18 +11,49 @@ define([
'use strict';
var StarredFileView = Backbone.View.extend({
id: 'starred-file',
el: $('#starred-file'),
template: _.template($('#starred-file-tmpl').html()),
initialize: function() {
this.starredFiles = new StarredFilesCollection();
this.listenTo(this.starredFiles, 'reset', this.reset);
this.render();
},
addOne: function(starredFile) {
var view = new StarredFileItem({model: starredFile});
this.$tableBody.append(view.render().el);
},
reset: function() {
this.$tableBody.empty();
this.$loadingTip.hide();
this.starredFiles.each(this.addOne, this);
if (this.starredFiles.length) {
this.$emptyTip.hide();
this.$table.show();
} else {
this.$emptyTip.show();
this.$table.hide();
}
},
showStarredFiles: function() {
this.$table.hide();
this.$loadingTip.show();
this.starredFiles.fetch({reset: true});
},
render: function() {
this.$el.html(this.template());
$("#right-panel").html(this.$el);
this.$table = this.$('table');
this.$tableBody = this.$('tbody');
this.$loadingTip = this.$('.loading-tip');
this.$emptyTip = this.$('.empty-tips');
this.starredFiles = new StarredFilesCollection();
this.listenTo(this.starredFiles, 'reset', this.reset);
this.$el.magnificPopup({
type: 'image',
delegate: '.img-name-link',
@@ -44,36 +75,15 @@ define([
tError: gettext('<a href="%url%" target="_blank">The image</a> could not be loaded.') // Error message when image could not be loaded
}
});
},
addOne: function(starredFile) {
var view = new StarredFileItem({model: starredFile});
this.$tableBody.append(view.render().el);
},
reset: function() {
this.$tableBody.empty();
this.$loadingTip.hide();
this.starredFiles.each(this.addOne, this);
if (this.starredFiles.length) {
this.$emptyTip.hide();
this.$table.show();
} else {
this.$emptyTip.show();
this.$table.hide();
}
},
hide: function() {
this.$el.hide();
},
show: function() {
this.$el.show();
this.$table.hide();
this.$loadingTip.show();
this.starredFiles.fetch({reset: true});
$("#right-panel").html(this.$el);
this.showStarredFiles();
},
hide: function() {
this.$el.detach();
}
});