[Pkg-owncloud-commits] [owncloud] 10/122: Show a text preview instead of a bitmap preview of text + fix the preview height
David Prévot
taffit at moszumanska.debian.org
Sat May 9 00:00:01 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch stable8
in repository owncloud.
commit 8d3f88cf16f86212861db996023dadf1fb3e310f
Author: Olivier Paroz <github at oparoz.com>
Date: Thu Apr 16 15:28:04 2015 +0200
Show a text preview instead of a bitmap preview of text
+ fix the preview height
---
apps/files_sharing/css/public.css | 17 ++++++++++++++++-
apps/files_sharing/js/public.js | 31 ++++++++++++++++++++++++++-----
2 files changed, 42 insertions(+), 6 deletions(-)
diff --git a/apps/files_sharing/css/public.css b/apps/files_sharing/css/public.css
index ef013ca..b3d2aae 100644
--- a/apps/files_sharing/css/public.css
+++ b/apps/files_sharing/css/public.css
@@ -2,7 +2,6 @@
background: #fff;
text-align: center;
margin: 45px auto 0;
- min-height: 600px;
}
#preview .notCreatable {
@@ -28,6 +27,22 @@
max-width:100%;
}
+#imgframe .text-preview {
+ display: inline-block;
+ text-align: left;
+ white-space: pre-wrap;
+ overflow-y: auto;
+ height: auto;
+ min-height: 200px;
+ max-height: 800px;
+ -webkit-touch-callout: none;
+ -webkit-user-select: none;
+ -khtml-user-select: none;
+ -moz-user-select: none;
+ -ms-user-select: none;
+ user-select: none;
+}
+
/* fix multiselect bar offset on shared page */
thead {
left: 0 !important;
diff --git a/apps/files_sharing/js/public.js b/apps/files_sharing/js/public.js
index 41bfeba..59ef971 100644
--- a/apps/files_sharing/js/public.js
+++ b/apps/files_sharing/js/public.js
@@ -87,9 +87,13 @@ OCA.Sharing.PublicApp = {
// dynamically load image previews
+ var bottomMargin = 350;
+ var previewWidth = $(window).width() * window.devicePixelRatio;
+ var previewHeight = $(window).height() - bottomMargin * window.devicePixelRatio;
+ previewHeight = Math.max(200, previewHeight);
var params = {
- x: $(document).width() * window.devicePixelRatio,
- y: $(document).height() * window.devicePixelRatio,
+ x: previewWidth,
+ y: previewHeight,
a: 'true',
file: encodeURIComponent(this.initialDir + $('#filename').val()),
t: $('#sharingToken').val(),
@@ -105,6 +109,23 @@ OCA.Sharing.PublicApp = {
(maxGifSize === -1 || fileSize <= (maxGifSize * 1024 * 1024))) {
img.attr('src', $('#downloadURL').val());
img.appendTo('#imgframe');
+ } else if (mimetype.substr(0, mimetype.indexOf('/')) === 'text') {
+ $.ajax({
+ url: $('#downloadURL').val(),
+ headers: {Range: "bytes=0-1000"}
+ }).then(function (data) {
+ var textDiv = $('<span/>').addClass('text-preview');
+ textDiv.text(data);
+ textDiv.appendTo('#imgframe');
+ var divHeight = textDiv.height();
+ if (data.length > 999) {
+ textDiv.append('</br></br><strong>(...)</strong>');
+ divHeight += 50;
+ }
+ if (divHeight > previewHeight) {
+ textDiv.height(previewHeight);
+ }
+ });
} else if (previewSupported === 'true' ||
mimetype.substr(0, mimetype.indexOf('/')) === 'image' &&
mimetype !== 'image/svg+xml') {
@@ -128,7 +149,7 @@ OCA.Sharing.PublicApp = {
path: path,
files: filename
};
- return OC.generateUrl('/s/'+token+'/download') + '?' + OC.buildQueryString(params);
+ return OC.generateUrl('/s/' + token + '/download') + '?' + OC.buildQueryString(params);
};
this.fileList.getAjaxUrl = function (action, params) {
@@ -142,7 +163,7 @@ OCA.Sharing.PublicApp = {
var params = {
dir: dir
};
- return OC.generateUrl('/s/'+token+'') + '?' + OC.buildQueryString(params);
+ return OC.generateUrl('/s/' + token + '') + '?' + OC.buildQueryString(params);
};
this.fileList.generatePreviewUrl = function (urlSpec) {
@@ -225,7 +246,7 @@ OCA.Sharing.PublicApp = {
this.fileList.changeDirectory(params.path || params.dir, false, true);
},
- _saveToOwnCloud: function(remote, token, owner, name, isProtected) {
+ _saveToOwnCloud: function (remote, token, owner, name, isProtected) {
var location = window.location.protocol + '//' + window.location.host + OC.webroot;
var url = remote + '/index.php/apps/files#' + 'remote=' + encodeURIComponent(location) // our location is the remote for the other server
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git
More information about the Pkg-owncloud-commits
mailing list