pdf.js增加快捷键放大缩小旋转手型拖动,并增加全屏显示工具栏

master
zengwh 6 years ago
parent 769adeb7e3
commit 2a7d53af59

File diff suppressed because it is too large Load Diff

@ -26,7 +26,7 @@ http://sourceforge.net/adobe/cmap/wiki/License/
<link rel="stylesheet" href="viewer.css"/> <link rel="stylesheet" href="viewer.css"/>
<link rel="stylesheet" href="../../../static/bootstrap-3.3.7/bower_components/font-awesome/css/font-awesome.min.css"/>
<script src="compatibility.js"></script> <script src="compatibility.js"></script>
@ -35,14 +35,11 @@ http://sourceforge.net/adobe/cmap/wiki/License/
<link rel="resource" type="application/l10n" href="locale/locale.properties"/> <link rel="resource" type="application/l10n" href="locale/locale.properties"/>
<link rel="shortcut icon" href="/emr_medical_record/favicon.ico"> <link rel="shortcut icon" href="/emr_medical_record/favicon.ico">
<script type="text/javascript" src="../../js/jquery-3.3.1.js"></script> <script type="text/javascript" src="../../js/jquery-3.3.1.js"></script>
<script type="text/javascript" src="../../bootstrap-3.3.7/bower_components/bootstrap/dist/js/bootstrap.min.js"></script> <script type="text/javascript" src="../../bootstrap-3.3.7/bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
<script src="l10n.js"></script> <script src="l10n.js"></script>
<script src="../build/pdf.js"></script> <script src="../build/pdf.js"></script>
<script src="debugger.js"></script>
<script src="viewer.js"></script>
<script src="debugger.js"></script>
<script src="viewer.js"></script>
<style> <style>
.loading { .loading {
@ -63,6 +60,32 @@ http://sourceforge.net/adobe/cmap/wiki/License/
border-radius: 20px; border-radius: 20px;
filter: progid:DXImageTransform.Microsoft.Alpha(opacity=70); filter: progid:DXImageTransform.Microsoft.Alpha(opacity=70);
} }
.fullScreamBtn{
visibility: hidden;
opacity: 0;
width: 150px;
height: 30px;
border-radius: 5px;
background: #898989;
position: fixed;
bottom: 2px;
left: calc(100vw / 2 - 75px);
z-index: 999;
transition: all 0.5s;
}
.fullScreamBtn i{
line-height: 30px;
color: white;
margin-right: 8px;
cursor: pointer;
}
.fullScreamBtn i:first-child{
margin-left: 11px;
}
.page:hover~.fullScreamBtn,.fullScreamBtn:hover{
visibility: visible;
opacity: 1;
}
</style> </style>
</head> </head>
@ -442,49 +465,5 @@ http://sourceforge.net/adobe/cmap/wiki/License/
</div> </div>
</body> </body>
<script>
$("#loading").css("background","url(../../img/load.gif) no-repeat 10px 50%");
var interval = setInterval('loadPdf()', 1000);
function loadPdf() {
if (PDFViewerApplication.pdfDocument == null) {
$('#myModal').modal('show');
} else {
clearInterval(interval);
$('#myModal').remove();
}
}
//屏蔽鼠标右键
document.oncontextmenu = function(e) {
var e = e || window.event;
e.returnValue = false;
return false;
}
//禁止快捷键打印
function disabledPrint(){
if(event.keyCode==80 && event.ctrlKey){
event.keyCode=0;
event.returnValue=false;
}
if (event.ctrlKey && event.keyCode == 83) {
event.preventDefault();
event.returnValue = false;
return false;
}
}
/*$(function() {
//PDFFindBar.prototype.open(); //optional if you want to show the search bar
var keys = ['人','心','人心'];
for (var i = 0; i < keys.length; i++) {
var event = document.createEvent('CustomEvent');
event.initCustomEvent('find' + 'again', true, true, {
query: keys[i],
highlightAll: true,
findPrevious: false
});
window.dispatchEvent(event);
}
//return window.dispatchEvent(event);
})*/
</script>
</html> </html>

@ -1839,6 +1839,36 @@ var SecondaryToolbar = {
// Event handling functions. // Event handling functions.
presentationModeClick: function secondaryToolbarPresentationModeClick(evt) { presentationModeClick: function secondaryToolbarPresentationModeClick(evt) {
PDFViewerApplication.requestPresentationMode(); PDFViewerApplication.requestPresentationMode();
$("#viewer").append("<div id='fullScreamBtn' class='fullScreamBtn'><i class='fa fa-search-plus fa-lg' id='plus' title='放大(快捷键ctrl+↑)'></i><i class='fa fa-search-minus fa-lg' id='minus' title='缩小(快捷键ctrl+↓)'></i><i class='fa fa-lg fa-undo' id='undo' title='逆时针旋转(快捷键ctrl+→)'></i><i class='fa fa-repeat fa-lg' id='repeat' title='顺时针旋转(快捷键ctrl+←)'></i><i class='fa fa-hand-paper-o fa-lg' id='hand-paper' title='启用手形工具(键盘按下Tab键)'></i></div>")
//阻止外层div鼠标点击冒泡事件
document.getElementById("fullScreamBtn").addEventListener("mousedown", function (evt) {
evt.stopPropagation();
}, false);
//图片放大
document.getElementById("plus").addEventListener("click",
function () {
PDFViewerApplication.zoomIn();
},false);
//图片缩小
document.getElementById("minus").addEventListener("click",
function () {
PDFViewerApplication.zoomOut();
},false);
//顺时针旋转
document.getElementById("repeat").addEventListener("click",
function () {
PDFViewerApplication.rotatePages(90);
},false);
//逆时针旋转
document.getElementById("undo").addEventListener("click",
function () {
PDFViewerApplication.rotatePages(-90);
},false);
//启用手型选取
document.getElementById("hand-paper").addEventListener("click",
function () {
HandTool.toggle();
},false);
this.close(); this.close();
}, },
@ -7328,7 +7358,7 @@ function handleMouseWheel(evt) {
var direction = (ticks < 0) ? 'zoomOut' : 'zoomIn'; var direction = (ticks < 0) ? 'zoomOut' : 'zoomIn';
if (PDFViewerApplication.pdfViewer.isInPresentationMode) { if (PDFViewerApplication.pdfViewer.isInPresentationMode) {
evt.preventDefault(); //evt.preventDefault();
PDFViewerApplication.scrollPresentationMode(ticks * PDFViewerApplication.scrollPresentationMode(ticks *
MOUSE_WHEEL_DELTA_FACTOR); MOUSE_WHEEL_DELTA_FACTOR);
} else if (evt.ctrlKey || evt.metaKey) { } else if (evt.ctrlKey || evt.metaKey) {

@ -26,6 +26,7 @@ http://sourceforge.net/adobe/cmap/wiki/License/
<link rel="stylesheet" href="viewer.css"/> <link rel="stylesheet" href="viewer.css"/>
<link rel="stylesheet" href="../../../static/bootstrap-3.3.7/bower_components/font-awesome/css/font-awesome.min.css"/>
<script src="compatibility.js"></script> <script src="compatibility.js"></script>
@ -37,12 +38,13 @@ http://sourceforge.net/adobe/cmap/wiki/License/
<script type="text/javascript" src="../../js/jquery-3.3.1.js"></script> <script type="text/javascript" src="../../js/jquery-3.3.1.js"></script>
<script type="text/javascript" src="../../bootstrap-3.3.7/bower_components/bootstrap/dist/js/bootstrap.min.js"></script> <script type="text/javascript" src="../../bootstrap-3.3.7/bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
<script src="l10n.js"></script> <script src="l10n.js"></script>
<script src="../build/pdf.js"></script>
<script src="debugger.js"></script> <script src="debugger.js"></script>
<script src="viewer1.js"></script> <script src="viewer1.js"></script>
<script src="../build/pdf.js"></script>
<style> <style>
.loading { .loading {
@ -63,6 +65,32 @@ http://sourceforge.net/adobe/cmap/wiki/License/
border-radius: 20px; border-radius: 20px;
filter: progid:DXImageTransform.Microsoft.Alpha(opacity=70); filter: progid:DXImageTransform.Microsoft.Alpha(opacity=70);
} }
.fullScreamBtn{
visibility: hidden;
opacity: 0;
width: 150px;
height: 30px;
border-radius: 5px;
background: #898989;
position: fixed;
bottom: 2px;
left: calc(100vw / 2 - 75px);
z-index: 999;
transition: all 0.5s;
}
.fullScreamBtn i{
line-height: 30px;
color: white;
margin-right: 8px;
cursor: pointer;
}
.fullScreamBtn i:first-child{
margin-left: 11px;
}
.page:hover~.fullScreamBtn,.fullScreamBtn:hover{
visibility: visible;
opacity: 1;
}
</style> </style>
</head> </head>
@ -440,19 +468,8 @@ http://sourceforge.net/adobe/cmap/wiki/License/
</div> </div>
</div> </div>
</div> </div>
</body> </body>
<script> <script>
$("#loading").css("background","url(../../img/load.gif) no-repeat 10px 50%");
var interval = setInterval('loadPdf()', 1000);
function loadPdf() {
if (PDFViewerApplication.pdfDocument == null) {
$('#myModal').modal('show');
} else {
clearInterval(interval);
$('#myModal').remove();
}
}
$(function(){ $(function(){
//获取父页面打印权限显示打印按钮 //获取父页面打印权限显示打印按钮
var print = parent.$("#print").val(); var print = parent.$("#print").val();
@ -460,24 +477,6 @@ http://sourceforge.net/adobe/cmap/wiki/License/
$("#print").show(); $("#print").show();
} }
}) })
//屏蔽鼠标右键
document.oncontextmenu = function(e) {
var e = e || window.event;
e.returnValue = false;
return false;
}
//禁止快捷键打印
function disabledPrint(){
if(event.keyCode==80 && event.ctrlKey){
event.keyCode=0;
event.returnValue=false;
}
if (event.ctrlKey && event.keyCode == 83) {
event.preventDefault();
event.returnValue = false;
return false;
}
}
</script> </script>
</html> </html>

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save