Просмотр исходного кода

Fix https://github.com/PrivateBin/PrivateBin/issues/315

Fixes some display issues related to file display.
rugk 8 лет назад
Родитель
Сommit
14a7fd7091
3 измененных файлов с 18 добавлено и 4 удалено
  1. 16 2
      js/privatebin.js
  2. 1 1
      tpl/bootstrap.php
  3. 1 1
      tpl/page.php

+ 16 - 2
js/privatebin.js

@@ -2022,6 +2022,17 @@ jQuery.PrivateBin = (function($, sjcl, Base64, RawDeflate) {
             attachmentData = undefined;
         };
 
+        /**
+         * Cleares the drag & drop data.
+         *
+         * @name AttachmentViewer.clearDragAndDrop
+         * @function
+         */
+        me.clearDragAndDrop = function()
+        {
+            $dragAndDropFileName.text('');
+        };
+
         /**
          * hides the attachment
          *
@@ -2137,6 +2148,7 @@ jQuery.PrivateBin = (function($, sjcl, Base64, RawDeflate) {
                 loadedFile = $fileInput[0].files[0];
                 $dragAndDropFileName.text('');
             } else {
+                // TODO: cannot set original $fileWrap here for security reasons…
                 $dragAndDropFileName.text(loadedFile.name);
             }
 
@@ -2206,7 +2218,7 @@ jQuery.PrivateBin = (function($, sjcl, Base64, RawDeflate) {
                     // Firefox crashes with files that are about 1.5MB
                     // The performance with 1MB files is bearable
                     if (data.length > 1398488) {
-                        Alert.showError('File too large, to display a preview. Please download the attachment.');
+                        Alert.showError('File too large, to display a preview. Please download the attachment.'); //TODO: is this error really neccessary?
                         return;
                     }
 
@@ -2262,7 +2274,7 @@ jQuery.PrivateBin = (function($, sjcl, Base64, RawDeflate) {
             $(document).on('drop', drop);
             $(document).on('dragenter', ignoreDragDrop);
             $(document).on('dragover', ignoreDragDrop);
-            $fileInput.on("change", function () {
+            $fileInput.on('change', function () {
                 me.readFileData();
             });
         };
@@ -2842,8 +2854,10 @@ jQuery.PrivateBin = (function($, sjcl, Base64, RawDeflate) {
             // in any case, remove saved attachment data
             AttachmentViewer.removeAttachmentData();
 
+            // hide UI for selected files
             // our up-to-date jQuery can handle it :)
             $fileWrap.find('input').val('');
+            AttachmentViewer.clearDragAndDrop();
 
             // pevent '#' from appearing in the URL
             event.preventDefault();

+ 1 - 1
tpl/bootstrap.php

@@ -75,7 +75,7 @@ if ($MARKDOWN):
 <?php
 endif;
 ?>
-		<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-mJnXRlEN4mKPZWcq3Vwsql3hHa8X9EqsePjAGKadlbD4gF5m7MhwCreA9LQ/SOfoVGQQWG5xgTiuPEXLzs1D2g==" crossorigin="anonymous"></script>
+		<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-LRFZwcWQnCdUV6n97QiIW+Jm4p6FKPaeHGofcf124gWx1mxVjEAWEn5NgNnJaAT0cgNZaZBnmv+/eF4dCyWjyg==" crossorigin="anonymous"></script>
 		<!--[if lt IE 10]>
 		<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
 		<![endif]-->

+ 1 - 1
tpl/page.php

@@ -54,7 +54,7 @@ if ($QRCODE):
 <?php
 endif;
 ?>
-		<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-mJnXRlEN4mKPZWcq3Vwsql3hHa8X9EqsePjAGKadlbD4gF5m7MhwCreA9LQ/SOfoVGQQWG5xgTiuPEXLzs1D2g==" crossorigin="anonymous"></script>
+		<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-LRFZwcWQnCdUV6n97QiIW+Jm4p6FKPaeHGofcf124gWx1mxVjEAWEn5NgNnJaAT0cgNZaZBnmv+/eF4dCyWjyg==" crossorigin="anonymous"></script>
 		<!--[if lt IE 10]>
 		<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
 		<![endif]-->