File tree Expand file tree Collapse file tree 3 files changed +19
-4
lines changed
Expand file tree Collapse file tree 3 files changed +19
-4
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ type Translation struct {
1313 UploadingLabel string
1414 UploadSuccessLabel string
1515 UploadFailLabel string
16+ UploadDirFailMessage string
1617
1718 ListDirLabel string
1819 ListNameLabel string
@@ -49,6 +50,7 @@ var translationEnUs = Translation{
4950 UploadingLabel : "Uploading..." ,
5051 UploadSuccessLabel : "Upload success" ,
5152 UploadFailLabel : "Upload failed" ,
53+ UploadDirFailMessage : "Cannot upload directory. Make sure mkdir is enabled, and using a supported browser." ,
5254
5355 ListDirLabel : "Dir" ,
5456 ListNameLabel : "Name" ,
@@ -85,6 +87,7 @@ var translationZhSimp = Translation{
8587 UploadingLabel : "上传中……" ,
8688 UploadSuccessLabel : "上传成功" ,
8789 UploadFailLabel : "上传失败" ,
90+ UploadDirFailMessage : "无法上传目录。 请确保mkdir已启用,并使用受支持的浏览器。" ,
8891
8992 ListDirLabel : "目录" ,
9093 ListNameLabel : "名称" ,
@@ -121,6 +124,7 @@ var translationZhTrad = Translation{
121124 UploadingLabel : "上傳中……" ,
122125 UploadSuccessLabel : "上傳成功" ,
123126 UploadFailLabel : "上傳失敗" ,
127+ UploadDirFailMessage : "無法上傳目錄。 請確保mkdir已啟用,並使用受支援的流覽器。" ,
124128
125129 ListDirLabel : "目錄" ,
126130 ListNameLabel : "名稱" ,
Original file line number Diff line number Diff line change 4545{{end}}
4646
4747{{if .CanUpload}}
48+ < script type ="text/javascript ">
49+ function showUploadDirFailMessage ( ) {
50+ alert ( '{{.Trans.UploadDirFailMessage}}' ) ;
51+ }
52+ </ script >
4853< div class ="tab upload-type ">
4954 < label class ="file active " tabindex ="0 " role ="button " title ="{{.Trans.UploadFilesHint}} "> {{.Trans.UploadFilesLabel}}</ label >
50- {{if .CanMkdir}}< label class ="dirfile hidden " tabindex ="0 " role ="button " title ="{{.Trans.UploadDirHint}} "> {{.Trans.UploadDirLabel}}</ label > {{end}}
51- < label class ="innerdirfile hidden " tabindex ="0 " role ="button " title ="{{.Trans.UploadDirContentsHint}} "> {{.Trans.UploadDirContentsLabel}}</ label >
55+ {{if .CanMkdir}}< label class ="dirfile hidden " tabindex ="0 " role ="button " title ="{{.Trans.UploadDirHint}} "> {{.Trans.UploadDirLabel}}</ label >
56+ < label class ="innerdirfile hidden " tabindex ="0 " role ="button " title ="{{.Trans.UploadDirContentsHint}} "> {{.Trans.UploadDirContentsLabel}}</ label > {{end}}
5257</ div >
5358< div class ="panel upload ">
5459 < form method ="POST " action ="{{.SubItemPrefix}}?upload " enctype ="multipart/form-data ">
Original file line number Diff line number Diff line change 511511 var optDirFile = uploadType . querySelector ( '.' + dirFile ) ;
512512 var optInnerDirFile = uploadType . querySelector ( '.' + innerDirFile ) ;
513513 var optActive = optFile ;
514+ var canMkdir = Boolean ( optDirFile ) ;
514515
515516 var padStart = String . prototype . padStart ? function ( sourceString , targetLength , padTemplate ) {
516517 return sourceString . padStart ( targetLength , padTemplate ) ;
935936
936937 var items = e . dataTransfer . items ;
937938 if ( itemsHasDir ( items ) ) {
938- if ( ! uploadProgressively ) {
939- // must use progressive upload by JS if has directory
939+ // must use progressive upload by JS if has directory
940+ if ( ! canMkdir || ! uploadProgressively ) {
941+ typeof showUploadDirFailMessage !== strUndef && showUploadDirFailMessage ( ) ;
940942 return ;
941943 }
942944 itemsToFiles ( items , function ( files ) {
10651067 return ;
10661068 }
10671069 var hasDir = itemsHasDir ( items ) ;
1070+ if ( hasDir && ! canMkdir ) {
1071+ typeof showUploadDirFailMessage !== strUndef && showUploadDirFailMessage ( ) ;
1072+ return ;
1073+ }
10681074 itemsToFiles ( items , function ( files ) {
10691075 if ( ! files . length ) {
10701076 // for pasted text
You can’t perform that action at this time.
0 commit comments