Ver código fonte

Added Folder Remove button to explorer, Fixed firefox image upload

Manuel Gall 3 anos atrás
pai
commit
f3c49c8627
4 arquivos alterados com 50 adições e 15 exclusões
  1. 26 0
      ui/css/ustore.css
  2. 6 0
      ui/index.html
  3. 13 14
      ui/js/Upload.js
  4. 5 1
      ui/js/ustore.js

+ 26 - 0
ui/css/ustore.css

@@ -31,6 +31,21 @@
   margin-top: -2.1em;
 }
 
+
+.HiddenremoveLink{
+  padding-top:1em;
+  visibility: hidden;
+}
+
+.FolderImageLink:hover ~ div{
+  visibility: visible;
+}
+
+.HiddenremoveLink:hover{
+  visibility: visible;
+}
+
+
 #detailcolumn{
   position: relative;
   min-height: 95%;
@@ -136,6 +151,17 @@
   max-width: 100%;  
 }
 
+
+
+
+
+
+
+
+
+
+
+
 /*Image Upload CSS*/
 
 

+ 6 - 0
ui/index.html

@@ -83,10 +83,16 @@
         
         <template id="cpyFolder">
           <div class="Folder">
+          
             <a  class="FolderImageLink" data-class='link' style="text-decoration: none;" href="#" onclick="">
               <span class="FolderImage" >🗀</span></br>
               <span class="FolderText" data-class='text'></span>
             </a>
+            <div class="HiddenremoveLink">
+              <a data-class='removefolder' href="#" onclick="">
+                Remove Folder
+              </a>
+            </div>
           </div>
         </template>
         

+ 13 - 14
ui/js/Upload.js

@@ -25,9 +25,10 @@ function imageInit(){
 				},
 				triggerFormSubmit = function()
 				{
-					var event = document.createEvent( 'HTMLEvents' );
-					event.initEvent( 'submit', true, false );
-					form.dispatchEvent( event );
+          $('#imgUpload').submit(); 
+					//var event = document.createEvent( 'HTMLEvents' );
+					//event.initEvent( 'submit', true, false );
+					//form.dispatchEvent( event );
 				};
 
 			// letting the server side to know we are going to make an Ajax request
@@ -41,11 +42,7 @@ function imageInit(){
 			input.addEventListener( 'change', function( e )
 			{
 				showFiles( e.target.files );
-
-				
 				triggerFormSubmit();
-
-				
 			});
 
 			// drag&drop files if the feature is available
@@ -83,15 +80,13 @@ function imageInit(){
 
 					
 					triggerFormSubmit();
-
+          e.dataTransfer.files = [];
 									});
 			}
 
 
 			// if the form was submitted
-			form.addEventListener( 'submit', function( e )
-			{
-				
+      $('#imgUpload').submit(function(e){
 				// preventing the duplicate submissions if the current one is in progress
 				if( form.classList.contains( 'is-uploading' ) ) return false;
 
@@ -127,7 +122,7 @@ function imageInit(){
 					
 					// ajax request
 					var ajax = new XMLHttpRequest();
-					ajax.open( form.getAttribute( 'method' ), form.getAttribute( 'action' ), true );
+					ajax.open( form.getAttribute( 'method' ), form.getAttribute( 'action' ), false );
 
 					ajax.onload = function()
 					{
@@ -155,9 +150,13 @@ function imageInit(){
 						form.classList.remove( 'is-uploading' );
 						alert( 'Error. Please, try again!' );
 					};
-
 					ajax.send( ajaxData );
-		            imageInit();
+          form.classList.remove( 'is-uploading' );
+					form.classList.remove( 'is-error', 'is-success' );
+          
+          e.target.files = [];
+					input.value = "";
+          droppedFiles = false;
 				}
 				else // fallback Ajax solution upload for older browsers
 				{

+ 5 - 1
ui/js/ustore.js

@@ -41,7 +41,9 @@ function listFolders(folder = ""){
       if(folder != "" && folder != "." && folder != ".."){
         var clone = document.importNode(document.querySelector('#cpyFolder').content,true);
         $('[data-class=text]',clone).text("..");
-        $('[data-class=link]',clone).attr('onclick','listFolders("' + folder.substr(0, folder.lastIndexOf("/")) + '")');
+        $('[data-class=link]',clone).attr('onclick','listFolders("' + folder.substr(0, folder.lastIndexOf("/")) + '")'); 
+        // dont show remove link on .. folder
+        $('[data-class=removefolder]',clone).remove()
         $('#Folders').append(clone);
       }
       
@@ -56,9 +58,11 @@ function listFolders(folder = ""){
         
         if(folder == ""){
           $('[data-class=link]',clone).attr('onclick','listFolders("' + value + '")');
+          $('[data-class=removefolder]',clone).attr('onclick','deleteFolder("' + value + '")');
         }
         else{
           $('[data-class=link]',clone).attr('onclick','listFolders("' + folder + "/" + value + '")');
+          $('[data-class=removefolder]',clone).attr('onclick','deleteFolder("' + folder + "/" + value + '")');
         }
         $('#Folders').append(clone);
       });