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

Do Not Allow Uploading More Files Until First Operation is Finished

own3mall 8 лет назад
Родитель
Сommit
f7c2c20d06
2 измененных файлов с 25 добавлено и 14 удалено
  1. 5 0
      css/global.css
  2. 20 14
      js/modules/litefm.js

+ 5 - 0
css/global.css

@@ -75,3 +75,8 @@ table.tablesorter thead tr .header.sorter-false{ /* No background image for non-
 table.hundred{
 	width: 100%;
 }
+
+.disabled{
+	cursor: not-allowed;
+	opacity: .6;
+}

+ 20 - 14
js/modules/litefm.js

@@ -795,7 +795,7 @@ $(document).ready(function(){
 		$('#dialog').html('<div class="status"></div>\
 						  <form id="upload" action="home.php?m=litefm&home_id='+home_id+'&type=cleared&data_type=json" method="post" enctype="multipart/form-data">\
 							<input type="file" name="files[]" multiple="multiple" id="files">\
-							<input type="submit" name="upload" value="'+upload+'" >\
+							<input type="submit" name="upload" id="uploadsubmit" value="'+upload+'" >\
 						  </form>\
 						  <div class="progress">\
 							'+upload_to_web+':<br><progress class="bar" max="100" style="width:100%;" ></progress><div class="percent"></div >\
@@ -824,20 +824,24 @@ $(document).ready(function(){
 			/* set data type json */
 			dataType:'json',
 			beforeSubmit : function(arr, $form, options){
-				var i = 0;
-				$.each(arr, function(index, input) {
-					if(typeof input.value.name !== 'undefined')
+				if(!$("form#upload input#uploadsubmit").hasClass('disabled')){	
+					var i = 0;
+					$.each(arr, function(index, input) {
+						if(typeof input.value.name !== 'undefined')
+						{
+							i++;
+						}
+					});
+					if( i > max_file_uploads )
 					{
-						i++;
+						alert("The upload exceeds the max_file_uploads directive in php.ini ("+max_file_uploads+" files).");
+						return false;
 					}
-				});
-				if( i > max_file_uploads )
-				{
-					alert("The upload exceeds the max_file_uploads directive in php.ini ("+max_file_uploads+" files).");
-					return false;
-				}
-				if( i == 0)
-				{
+					if( i == 0)
+					{
+						return false;
+					}
+				}else{
 					return false;
 				}
 			},
@@ -846,6 +850,7 @@ $(document).ready(function(){
 				progress.show();
 				percent.html('0%');
 				percent2.html('0%');
+				$("form#upload input#files, form#upload input#uploadsubmit").removeClass('disabled').addClass('disabled').prop('disabled', true);				
 			},
 			/* progress bar call back*/
 			uploadProgress: function(event, position, total, percentComplete) {
@@ -904,6 +909,7 @@ $(document).ready(function(){
 						
 						if(stop_refresh == true)
 						{
+							$("form#upload input#files, form#upload input#uploadsubmit").removeClass('disabled').prop('disabled', false);
 							clearInterval(refresh);
 						}
 					}, 2000);
@@ -1040,4 +1046,4 @@ $(document).ready(function(){
 			alert(select_at_least_one_item);
 		}
 	});
-});
+});