@@ -32,31 +32,34 @@ class ImageViewerDialog {
3232 element : "div" ,
3333 className : "whiteBox centerMiddle popupDialogAnimation" ,
3434 style : {
35- overflowY : "auto" ,
36- maxHeight : "calc(100vh - 100px)" ,
37- maxWidth : "calc(100vw - 300px)" ,
38- minWidth : "360px" ,
39- minHeight : "360px" ,
35+ maxHeight : "calc(100svh - 100px)" ,
36+ maxWidth : "calc(100svw - 300px)" ,
37+ minWidth : "50px" ,
38+ minHeight : "50px" ,
4039 } ,
4140 children : [
4241 {
4342 element : "div" ,
4443 style : {
4544 display : "flex" ,
4645 flexDirection : "column" ,
46+ width : "100%" ,
47+ height : "100%" ,
4748 } ,
4849 children : [
4950 {
5051 element : "div" ,
5152 style : {
5253 display : "block" ,
54+ width : "100%" ,
5355 } ,
5456 children : [
5557 {
5658 element : "span" ,
5759 style : {
5860 fontSize : "30px" ,
5961 fontWeight : "bold" ,
62+ textAlign : "center" ,
6063 } ,
6164 textContent : "Attached image" ,
6265 } ,
@@ -66,36 +69,59 @@ class ImageViewerDialog {
6669 {
6770 element : "div" ,
6871 style : {
69- margin : "8px 0" ,
7072 padding : "8px" ,
71- backgroundColor : "#fffae6" ,
72- border : "1px solid #f0e68c" ,
7373 borderRadius : "6px" ,
74- fontSize : "14px" ,
75- color : "#665500" ,
74+ background : "black" ,
7675 flexGrow : "1" ,
76+ flexShrink : "0" ,
77+ overflow : "auto" ,
78+ maxHeight : "calc(100svh - 250px)" ,
79+ minHeight : "300px" ,
80+ justifyContent : "center" ,
7781 } ,
78- children : [ ] ,
82+ children : [
83+ {
84+ element : "img" ,
85+ src : "" ,
86+ style : {
87+ pointerEvents : "none" ,
88+ objectFit : "contain" ,
89+ minWidth : "300px" ,
90+ minHeight : "300px" ,
91+ position : "relative" ,
92+ } ,
93+ GPWhenCreated : function ( elm ) {
94+ _this . imageElement = elm ;
95+ } ,
96+ } ,
97+ ] ,
7998 } ,
8099
81100 {
82101 element : "div" ,
83102 style : {
84103 display : "flex" ,
104+ alignItems : "center" ,
85105 } ,
86106 children : [
87107 {
88108 element : "div" ,
89109 className : "divButton roundborder" ,
90110 textContent : "Download" ,
91111 style : {
92- flexGrow : "1 " ,
112+ margin : "2px " ,
93113 } ,
94114 eventListeners : [
95115 {
96116 event : "click" ,
97117 func : function ( ) {
98- _this . dialogElement . hidden = true ;
118+ var a = document . createElement ( "a" ) ;
119+ a . href = _this . imageElement . src ;
120+ a . download = _this . imageElement . src
121+ . slice ( "/" )
122+ . pop ( ) ;
123+ a . click ( ) ;
124+ a . remove ( ) ;
99125 } ,
100126 } ,
101127 ] ,
@@ -105,7 +131,7 @@ class ImageViewerDialog {
105131 className : "divButton roundborder" ,
106132 textContent : "Close" ,
107133 style : {
108- flexGrow : "1 " ,
134+ margin : "2px " ,
109135 } ,
110136 eventListeners : [
111137 {
@@ -126,8 +152,9 @@ class ImageViewerDialog {
126152 } ,
127153 ] ) [ 0 ] ;
128154 }
129- showImage ( ) {
130- dialogElement . hidden = true ;
155+ showImage ( src ) {
156+ this . imageElement . src = src ;
157+ this . dialogElement . hidden = false ;
131158 }
132159}
133160
0 commit comments