Merge pull request #8646 from owncloud/publicshare-fixes

[master] Fixed for public link page
This commit is contained in:
Björn Schießle 2014-05-21 05:41:35 -04:00
commit 319942bccb
3 changed files with 31 additions and 24 deletions

View File

@ -244,7 +244,7 @@
this.register(downloadScope, 'Download', OC.PERMISSION_READ, function () { this.register(downloadScope, 'Download', OC.PERMISSION_READ, function () {
return OC.imagePath('core', 'actions/download'); return OC.imagePath('core', 'actions/download');
}, function (filename) { }, function (filename) {
var url = OCA.Files.Files.getDownloadUrl(filename, fileList.getCurrentDirectory()); var url = fileList.getDownloadUrl(filename, fileList.getCurrentDirectory());
if (url) { if (url) {
OC.redirect(url); OC.redirect(url);
} }

View File

@ -18,12 +18,15 @@ OCA.Sharing.PublicApp = {
_initialized: false, _initialized: false,
initialize: function($el) { initialize: function($el) {
var self = this;
if (this._initialized) { if (this._initialized) {
return; return;
} }
this._initialized = true; this._initialized = true;
this.initialDir = $('#dir').val();
// file list mode ? // file list mode ?
if ($el.find('#filestable')) { if ($el.find('#filestable').length) {
this.fileList = new OCA.Files.FileList( this.fileList = new OCA.Files.FileList(
$el, $el,
{ {
@ -55,7 +58,7 @@ OCA.Sharing.PublicApp = {
var params = { var params = {
x: $(document).width() * window.devicePixelRatio, x: $(document).width() * window.devicePixelRatio,
a: 'true', a: 'true',
file: encodeURIComponent($('#dir').val() + $('#filename').val()), file: encodeURIComponent(this.initialDir + $('#filename').val()),
t: $('#sharingToken').val() t: $('#sharingToken').val()
}; };
@ -112,7 +115,7 @@ OCA.Sharing.PublicApp = {
data.formData = { data.formData = {
requesttoken: $('#publicUploadRequestToken').val(), requesttoken: $('#publicUploadRequestToken').val(),
dirToken: $('#dirToken').val(), dirToken: $('#dirToken').val(),
subdir: $('input#dir').val(), subdir: self.fileList.getCurrentDirectory(),
file_directory: fileDirectory file_directory: fileDirectory
}; };
}); });
@ -122,7 +125,7 @@ OCA.Sharing.PublicApp = {
delete this.fileActions.actions.all.Share; delete this.fileActions.actions.all.Share;
this.fileList.setFileActions(this.fileActions); this.fileList.setFileActions(this.fileActions);
this.fileList.changeDirectory($('#dir').val() || '/', false, true); this.fileList.changeDirectory(this.initialDir || '/', false, true);
// URL history handling // URL history handling
this.fileList.$el.on('changeDirectory', _.bind(this._onDirectoryChanged, this)); this.fileList.$el.on('changeDirectory', _.bind(this._onDirectoryChanged, this));
@ -156,16 +159,18 @@ $(document).ready(function() {
var App = OCA.Sharing.PublicApp; var App = OCA.Sharing.PublicApp;
App.initialize($('#preview')); App.initialize($('#preview'));
// HACK: for oc-dialogs previews that depends on Files: if (window.Files) {
Files.lazyLoadPreview = function(path, mime, ready, width, height, etag) { // HACK: for oc-dialogs previews that depends on Files:
return App.fileList.lazyLoadPreview({ Files.lazyLoadPreview = function(path, mime, ready, width, height, etag) {
path: path, return App.fileList.lazyLoadPreview({
mime: mime, path: path,
callback: ready, mime: mime,
width: width, callback: ready,
height: height, width: width,
etag: etag height: height,
}); etag: etag
}; });
};
}
}); });

View File

@ -15,14 +15,16 @@ $(document).ready(function() {
if (typeof OC.Share !== 'undefined' && typeof FileActions !== 'undefined') { if (typeof OC.Share !== 'undefined' && typeof FileActions !== 'undefined') {
// TODO: make a separate class for this or a hook or jQuery event ? // TODO: make a separate class for this or a hook or jQuery event ?
var oldCreateRow = OCA.Files.FileList.prototype._createRow; if (OCA.Files.FileList) {
OCA.Files.FileList.prototype._createRow = function(fileData) { var oldCreateRow = OCA.Files.FileList.prototype._createRow;
var tr = oldCreateRow.apply(this, arguments); OCA.Files.FileList.prototype._createRow = function(fileData) {
if (fileData.shareOwner) { var tr = oldCreateRow.apply(this, arguments);
tr.attr('data-share-owner', fileData.shareOwner); if (fileData.shareOwner) {
} tr.attr('data-share-owner', fileData.shareOwner);
return tr; }
}; return tr;
};
}
$('#fileList').on('fileActionsReady',function(){ $('#fileList').on('fileActionsReady',function(){
var $fileList = $(this); var $fileList = $(this);