aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files/js/filelist.js
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2015-07-15 16:09:00 +0200
committerArthur Schiwon <blizzz@owncloud.com>2015-08-07 01:22:42 +0200
commit12e5f310ddb784c0ed1248020b770d93040918da (patch)
tree6bfc053ff77ba25f238fef59fe3eb0c358269dc8 /apps/files/js/filelist.js
parent9854e71d2c83bd5f74a4798be1547e75112d5a41 (diff)
downloadnextcloud-server-12e5f310ddb784c0ed1248020b770d93040918da.tar.gz
nextcloud-server-12e5f310ddb784c0ed1248020b770d93040918da.zip
Improved right sidebar
Added owner info. Added animation, but causes scrollbal. Default file action now when clicking on name directly. Fixed icon. Added empty share tab.
Diffstat (limited to 'apps/files/js/filelist.js')
-rw-r--r--apps/files/js/filelist.js118
1 files changed, 85 insertions, 33 deletions
diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js
index cbf946974eb..355c76f9c64 100644
--- a/apps/files/js/filelist.js
+++ b/apps/files/js/filelist.js
@@ -221,6 +221,13 @@
this.updateSearch();
+ this.$el.on('click', function(event) {
+ var $target = $(event.target);
+ // click outside file row ?
+ if (!$target.closest('tbody').length) {
+ self._updateDetailsView(null);
+ }
+ });
this.$fileList.on('click','td.filename>a.name', _.bind(this._onClickFile, this));
this.$fileList.on('change', 'td.filename>.selectCheckBox', _.bind(this._onClickFileCheckbox, this));
this.$el.on('urlChanged', _.bind(this._onUrlChanged, this));
@@ -273,17 +280,35 @@
* @param {OCA.Files.FileInfo} fileInfo file info to display
*/
_updateDetailsView: function(fileInfo) {
+ var self = this;
+ if (!fileInfo) {
+ if (this._detailsView) {
+ // hide it
+ this._detailsView.$el.addClass('disappear');
+ this._detailsView.setFileInfo(null);
+ }
+ return;
+ }
+
if (!this._detailsView) {
this._detailsView = new OCA.Files.DetailsView();
- this.$el.append(this._detailsView.$el);
-
this._detailsView.addDetailView(new OCA.Files.MainFileInfoDetailView());
-
+ _.each(this._detailFileInfoViews, function(view) {
+ self._detailsView.addDetailView(view);
+ });
+ _.each(this._tabViews, function(view) {
+ self._detailsView.addTabView(view);
+ });
+ this.$el.append(this._detailsView.$el);
+ this._detailsView.$el.addClass('disappear');
this._detailsView.render();
}
this._detailsView.setFileInfo(_.extend({
path: this.getCurrentDirectory()
}, fileInfo));
+ _.defer(function() {
+ self._detailsView.$el.removeClass('disappear');
+ });
},
/**
@@ -374,36 +399,34 @@
this._selectFileEl($tr, !$checkbox.prop('checked'));
this.updateSelectionSummary();
} else {
- var currentIndex = $tr.index();
- var fileInfo = this.files[currentIndex];
-
- this._updateDetailsView(fileInfo);
- event.preventDefault();
- return;
-
- // FIXME: disabled for testing details view
-
- var filename = $tr.attr('data-file');
- var renaming = $tr.data('renaming');
- if (!renaming) {
- this.fileActions.currentFile = $tr.find('td');
- var mime = this.fileActions.getCurrentMimeType();
- var type = this.fileActions.getCurrentType();
- var permissions = this.fileActions.getCurrentPermissions();
- var action = this.fileActions.getDefault(mime,type, permissions);
- if (action) {
- event.preventDefault();
- // also set on global object for legacy apps
- window.FileActions.currentFile = this.fileActions.currentFile;
- action(filename, {
- $file: $tr,
- fileList: this,
- fileActions: this.fileActions,
- dir: $tr.attr('data-path') || this.getCurrentDirectory()
- });
+ // clicked directly on the name
+ if ($(event.target).is('.nametext') || $(event.target).closest('.nametext').length) {
+ var filename = $tr.attr('data-file');
+ var renaming = $tr.data('renaming');
+ if (!renaming) {
+ this.fileActions.currentFile = $tr.find('td');
+ var mime = this.fileActions.getCurrentMimeType();
+ var type = this.fileActions.getCurrentType();
+ var permissions = this.fileActions.getCurrentPermissions();
+ var action = this.fileActions.getDefault(mime,type, permissions);
+ if (action) {
+ event.preventDefault();
+ // also set on global object for legacy apps
+ window.FileActions.currentFile = this.fileActions.currentFile;
+ action(filename, {
+ $file: $tr,
+ fileList: this,
+ fileActions: this.fileActions,
+ dir: $tr.attr('data-path') || this.getCurrentDirectory()
+ });
+ }
+ // deselect row
+ $(event.target).closest('a').blur();
}
- // deselect row
- $(event.target).closest('a').blur();
+ } else {
+ var fileInfo = this.files[$tr.index()];
+ this._updateDetailsView(fileInfo);
+ event.preventDefault();
}
}
},
@@ -858,7 +881,7 @@
var formatted;
var text;
if (mtime > 0) {
- formatted = formatDate(mtime);
+ formatted = OC.Util.formatDate(mtime);
text = OC.Util.relativeModifiedDate(mtime);
} else {
formatted = t('files', 'Unable to determine date');
@@ -1554,6 +1577,7 @@
tr.remove();
tr = self.add(fileInfo, {updateSummary: false, silent: true});
self.$fileList.trigger($.Event('fileActionsReady', {fileList: self, $files: $(tr)}));
+ self._updateDetailsView(fileInfo);
}
});
} else {
@@ -2261,6 +2285,34 @@
};
/**
+ * Globally registered tab views
+ *
+ * @type OCA.Files.DetailTabView
+ */
+ FileList.prototype._tabViews = [];
+
+ /**
+ * Globally registered detail views
+ *
+ * @type OCA.Files.DetailFileInfoView
+ */
+ FileList.prototype._detailFileInfoViews = [];
+
+ /**
+ * Register a tab view to be added to all views
+ */
+ FileList.prototype.registerTabView = function(tabView) {
+ this._tabViews.push(tabView);
+ };
+
+ /**
+ * Register a detail view to be added to all views
+ */
+ FileList.prototype.registerDetailView = function(detailView) {
+ this._detailFileInfoViews.push(detailView);
+ };
+
+ /**
* File info attributes.
*
* @todo make this a real class in the future