Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0f19883

Browse files
committed
tweak(recordPrinter): update HTML pdf viewer
1 parentd2ab4dd commit0f19883

File tree

5 files changed

+334
-63
lines changed

5 files changed

+334
-63
lines changed

‎sonorancad/submodules/recordPrinter/cl_recordPrinter.lua‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
44
Plugin Name: ersintegration
55
Creator: Sonoran Software
6-
Description: IntegratesKnight ERS callouts to SonoranCAD
6+
Description: IntegratesSonoranCAD PDFs in-game.
77
]]
88
CreateThread(function()Config.LoadPlugin("recordPrinter",function(pluginConfig)
99
localprintQueue= {}
Lines changed: 163 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,166 @@
1-
varimage_link;
2-
varfirst=null;
1+
varpdfLink='';
2+
varfirstView=false;
3+
varisOpen=false;
4+
varisMinimized=false;
5+
varisFullscreen=false;
6+
37
$(function(){
4-
window.onload=(e)=>{
5-
window.addEventListener('message',function(event){
6-
if(event.data.length>4||event.data.length<=10){
7-
length=event.data.length;
8-
}
9-
if(event.data.link!=null)image_link=event.data.link;
10-
if(event.data.first!=null)first=event.data.first;
11-
show=event.data.show;
12-
switch(event.data.action){
13-
case'openui':
14-
this.document.getElementById('p1').src=event.data.link;
15-
$('body').fadeIn();
16-
break;
17-
case'closeui':
18-
$('body').fadeOut();
19-
this.document.getElementById('p1').src='';
20-
$.post(
21-
'https://sonorancad/CloseUI',
22-
JSON.stringify({link:image_link,first:first})
23-
);
24-
break;
25-
default:
26-
break;
27-
}
8+
var$wrapper=$('#wrapper');
9+
var$pdfWindow=$('#pdfWindow');
10+
var$pdfFrame=$('#pdfFrame');
11+
var$statusText=$('#statusText');
12+
var$minimizeBtn=$('#minimizeBtn');
13+
var$fullscreenBtn=$('#fullscreenBtn');
14+
var$closeBtn=$('#closeBtn');
15+
16+
functionupdateStatusText(){
17+
if(!isOpen){
18+
$statusText.text('');
19+
return;
20+
}
21+
22+
if(isMinimized){
23+
$statusText.text('Press Backspace to restore.');
24+
}elseif(isFullscreen){
25+
$statusText.text('Scroll to view the record. Backspace to minimize, ESC to close.');
26+
}else{
27+
$statusText.text('Press Backspace to minimize, ESC to close.');
28+
}
29+
}
30+
31+
functionapplyWindowState(){
32+
varshouldFullscreen=isFullscreen&&!isMinimized;
33+
$pdfWindow.toggleClass('minimized',isMinimized);
34+
$pdfWindow.toggleClass('fullscreen',shouldFullscreen);
35+
36+
$minimizeBtn.text(isMinimized ?'Restore' :'Min');
37+
$minimizeBtn.attr('title',isMinimized ?'Restore' :'Minimize');
38+
$fullscreenBtn.text(shouldFullscreen ?'Exit Full' :'Full');
39+
$fullscreenBtn.attr('title',shouldFullscreen ?'Exit Fullscreen' :'Toggle Fullscreen');
40+
41+
updateStatusText();
42+
}
43+
44+
functionopenUI(link,firstFlag){
45+
if(link){
46+
pdfLink=link;
47+
$pdfFrame.attr('src',link);
48+
}
49+
firstView=!!firstFlag;
50+
isOpen=true;
51+
isMinimized=false;
52+
isFullscreen=false;
53+
54+
applyWindowState();
55+
56+
$wrapper.removeClass('hidden');
57+
$wrapper.stop(true,true).fadeIn(120);
58+
}
59+
60+
functioncloseUI(sendMessage){
61+
if(!isOpen){
62+
return;
63+
}
64+
65+
isOpen=false;
66+
isMinimized=false;
67+
isFullscreen=false;
68+
69+
$wrapper.stop(true,true).fadeOut(120,function(){
70+
$pdfFrame.attr('src','');
71+
$wrapper.addClass('hidden');
72+
updateStatusText();
2873
});
29-
};
30-
document.onkeyup=function(event){
31-
if(event.key=='Escape'){
32-
$('body').fadeOut();
33-
$.post(
34-
'https://sonorancad/CloseUI',
35-
JSON.stringify({link:image_link,first:first})
36-
);
37-
}
38-
};
74+
75+
if(sendMessage!==false){
76+
$.post('https://sonorancad/CloseUI',JSON.stringify({link:pdfLink,first:firstView}));
77+
}
78+
}
79+
80+
functiontoggleMinimize(force){
81+
if(!isOpen){
82+
return;
83+
}
84+
85+
if(typeofforce==='boolean'){
86+
isMinimized=force;
87+
}else{
88+
isMinimized=!isMinimized;
89+
}
90+
91+
if(isMinimized){
92+
isFullscreen=false;
93+
}
94+
95+
applyWindowState();
96+
}
97+
98+
functiontoggleFullscreen(force){
99+
if(!isOpen){
100+
return;
101+
}
102+
103+
if(isMinimized){
104+
isMinimized=false;
105+
}
106+
107+
if(typeofforce==='boolean'){
108+
isFullscreen=force;
109+
}else{
110+
isFullscreen=!isFullscreen;
111+
}
112+
113+
applyWindowState();
114+
}
115+
116+
$minimizeBtn.on('click',function(){
117+
toggleMinimize();
118+
});
119+
120+
$fullscreenBtn.on('click',function(){
121+
toggleFullscreen();
122+
});
123+
124+
$closeBtn.on('click',function(){
125+
closeUI(true);
126+
});
127+
128+
window.addEventListener('message',function(event){
129+
vardata=event.data||{};
130+
131+
if(data.link){
132+
pdfLink=data.link;
133+
}
134+
if(typeofdata.first!=='undefined'){
135+
firstView=!!data.first;
136+
}
137+
138+
switch(data.action){
139+
case'openui':
140+
openUI(pdfLink,firstView);
141+
break;
142+
case'closeui':
143+
closeUI(true);
144+
break;
145+
case'toggleFullscreen':
146+
toggleFullscreen();
147+
break;
148+
default:
149+
break;
150+
}
151+
});
152+
153+
$(document).on('keydown',function(event){
154+
if(!isOpen){
155+
return;
156+
}
157+
158+
if(event.key==='Escape'){
159+
event.preventDefault();
160+
closeUI(true);
161+
}elseif(event.key==='Backspace'){
162+
event.preventDefault();
163+
toggleMinimize();
164+
}
165+
});
39166
});
Lines changed: 141 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,146 @@
1-
body{
2-
display: none;
3-
position:absolute;
4-
width: auto;
5-
height:400px;
6-
bottom:1px;
7-
right:1%;
8-
padding: none;
1+
html,
2+
body {
3+
width:100%;
4+
height:100%;
95
margin:0;
6+
padding:0;
7+
background: transparent;
8+
font-family:"Segoe UI", Tahoma, Arial, sans-serif;
9+
color:#f5f5f5;
10+
overflow: hidden;
1011
}
1112

12-
html{
13-
padding:none;
14-
margin:0;
13+
body {
14+
display: block;
15+
}
16+
17+
#wrapper {
18+
display: none;
19+
position: fixed;
20+
inset:0;
21+
pointer-events: none;
22+
background: transparent;
23+
}
24+
25+
.pdf-window {
26+
position: absolute;
27+
bottom:4%;
28+
right:4%;
29+
width:420px;
30+
height:520px;
31+
display: flex;
32+
flex-direction: column;
33+
border-radius:10px;
34+
background:rgba(18,18,18,0.95);
35+
border:1px solidrgba(255,255,255,0.08);
36+
box-shadow:020px45pxrgba(0,0,0,0.55);
37+
overflow: hidden;
38+
pointer-events: auto;
39+
transition: all0.25s ease;
40+
}
41+
42+
.pdf-window.fullscreen {
43+
top:6vh;
44+
left:10vw;
45+
right: auto;
46+
bottom: auto;
47+
width:80vw;
48+
height:88vh;
49+
}
50+
51+
.pdf-window.minimized {
52+
width:280px;
53+
height:96px;
54+
bottom:3%;
55+
right:3%;
56+
}
57+
58+
.pdf-window.minimized .window-body {
59+
display: none;
60+
}
61+
62+
.pdf-window.minimized .window-footer {
63+
padding-top:12px;
64+
padding-bottom:12px;
65+
}
66+
67+
.window-header {
68+
display: flex;
69+
align-items: center;
70+
justify-content: space-between;
71+
padding:10px16px;
72+
background:rgba(0,0,0,0.65);
73+
border-bottom:1px solidrgba(255,255,255,0.08);
74+
letter-spacing:0.5px;
75+
text-transform: uppercase;
76+
font-size:14px;
77+
}
78+
79+
.window-title {
80+
font-weight:600;
81+
}
82+
83+
.window-actions {
84+
display: flex;
85+
gap:8px;
86+
}
87+
88+
.control-btn {
89+
min-width:70px;
90+
height:32px;
91+
padding:4px12px;
92+
border: none;
93+
border-radius:5px;
94+
background:rgba(255,255,255,0.14);
95+
color:#f5f5f5;
96+
font-size:12px;
97+
font-weight:600;
98+
cursor: pointer;
99+
transition: background0.2s ease, color0.2s ease;
15100
}
16101

17-
img{
18-
width: auto;
19-
height:85%;
20-
}
102+
.control-btn:hover {
103+
background:rgba(255,255,255,0.24);
104+
}
105+
106+
.control-btn:active {
107+
background:rgba(255,255,255,0.34);
108+
}
109+
110+
.window-body {
111+
flex:1;
112+
background:#101010;
113+
overflow: hidden;
114+
}
115+
116+
#pdfFrame {
117+
width:100%;
118+
height:100%;
119+
border: none;
120+
background:#1c1c1c;
121+
}
122+
123+
.window-footer {
124+
padding:10px16px;
125+
font-size:12px;
126+
color:rgba(255,255,255,0.75);
127+
background:rgba(0,0,0,0.55);
128+
border-top:1px solidrgba(255,255,255,0.08);
129+
}
130+
131+
.hidden {
132+
display: none!important;
133+
}
134+
135+
@media (max-width:1024px) {
136+
.pdf-window {
137+
width:90vw;
138+
right:5%;
139+
bottom:5%;
140+
}
141+
142+
.pdf-window.fullscreen {
143+
width:92vw;
144+
left:4vw;
145+
}
146+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp