1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-13 22:01:06 +00:00

improved pdf/doc view

This commit is contained in:
llj
2012-07-26 16:07:39 +08:00
parent 2aedd5dbbf
commit cc4211d284
4 changed files with 991 additions and 3550 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -957,6 +957,10 @@ zoom.title=缩放
thumb_page_title=页码 {{page}}
thumb_page_canvas=页面 {{page}} 的缩略图
request_password=PDF 被密码保护:
search_panel.title=搜索文档
search_panel_label=搜索文档
search=查找
open_file_label=打开
[zh-TW]
# 主工具列按鍵 (工具提示和圖像的替代文字)

View File

@@ -781,7 +781,7 @@ var PDFView = {
// 2 if last scrolled up page before the visible pages
var numVisible = visibleViews.length;
if (numVisible === 0) {
info('No visible views.');
//info('No visible views.');
return false;
}
for (var i = 0; i < numVisible; ++i) {

View File

@@ -22,7 +22,6 @@
$('#file-view').html('<iframe src="{{ raw_path }}" frameborder="0" width="940" id="svg-view"></iframe>');
{% endif %}
{% if filetype == 'Document' %}
var tid= 0;
var uuid = '';
var obj_id = '';
function create_session() {
@@ -42,9 +41,6 @@
}
});
}
function abortTimer () {
clearTimeout(tid);
}
function check_status () {
$.ajax({
url: '{{ SITE_ROOT }}crocodoc/status/?uuids='+ uuid + '&obj_id=' + obj_id,
@@ -53,26 +49,22 @@
contentType: 'application/json; charset=utf-8',
success: function(data) {
if (data.length > 0) {
var status = data[0]['status']
var status = data[0]['status'];
if (status == 'QUEUED') {
$('#file-view').html('<p class="msg">' + '文档转换任务正在排队,请稍后...' + '</p>');
tid = setTimeout(check_status, 1000);
setTimeout(check_status, 1000);
} else if (status == 'PROCESSING') {
$('#file-view').html('<p class="msg">' + '文档正在转换,请稍候...' + '</p>');
tid = setTimeout(check_status, 1000);
} else if (status == 'DONE') {
$('#file-view').html('<p class="msg">' + '文档转换成功。正在打开...' + '</p>');
abortTimer();
create_session();
setTimeout(check_status, 1000);
} else {
abortTimer();
$('#file-view').html('<p class="msg">' + '文档转换成功。正在打开...' + '</p>');
create_session();
}
}
},
error: function(xhr, ajaxOptions, thrownError) {
var jsonVal = jQuery.parseJSON(xhr.responseText);
$('#file-view').html('<p class="error">' + jsonVal[0]['error'] + '</p>');
abortTimer();
return false;
}
});
@@ -87,7 +79,7 @@
uuid = data[0]['uuid'];
obj_id = data[0]['obj_id'];
$('#file-view').html('<p class="msg">文档内容读取成功,开始转换...</p>');
tid = setTimeout(check_status, 1000);
check_status();
}
},
error: function(xhr, ajaxOptions, thrownError) {
@@ -97,6 +89,7 @@
});
{% endif %}
{% if filetype == 'PDF' %}
$.ajaxSetup({cache:true});
$.getScript('{{MEDIA_URL}}js/pdf.js', function() {
PDFJS.workerSrc = '{{MEDIA_URL}}js/pdf.js';
$('#file-view').html('<div id="pdf"><img src="{{ MEDIA_URL }}pdf_full_view/images/loading-icon.gif" alt="加载中..." id="pdf-loading" style="margin-top:20px;" /><div id="pdf-op-bar" class="vh"><button id="prev">上一页</button><button id="next">下一页</button><span id="pdf-page"><label for="page-number"></label> <input type="number" id="page-number" value="1" min="1"></input> / <span id="page-nums"></span></span><button id="full-screen">全屏</button></div><canvas data="{{ raw_path }}" id="pdf-view" class="vh"></canvas></div>').css({'text-align':'center', 'padding':'3px'});