Skip to content
This repository
Browse code

BUGFIX: SSF-38 making the entwine selector for the upload field more …

…specific, so it doesn't apply to every upload field in the CMS. Also, handling the case of uploading multiple files at once
  • Loading branch information...
commit 21109067152bda636d4217d565222c989e6a1350 1 parent 98e197a
Julian Seidenberg authored March 30, 2012

Showing 1 changed file with 17 additions and 7 deletions. Show diff stats Hide diff stats

  1. 24  javascript/HtmlEditorField.js
24  javascript/HtmlEditorField.js
@@ -699,7 +699,7 @@ ss.editorWrappers['default'] = ss.editorWrappers.tinyMCE;
699 699
 		/**
700 700
 		 * Show the second step after uploading an image
701 701
 		 */
702  
-		$('.ss-assetuploadfield').entwine({
  702
+		$('form.htmleditorfield-form.htmleditorfield-mediaform div.ss-assetuploadfield').entwine({
703 703
 			onmatch: function() {
704 704
 				this._super();
705 705
 
@@ -708,13 +708,23 @@ ss.editorWrappers['default'] = ss.editorWrappers.tinyMCE;
708 708
 
709 709
 			},
710 710
 			onfileuploadstop: function(e) {
711  
-				//get the uploaded file ID when this event triggers, signaling the upload has compeleted successfully
712  
-				//always use the last one uploaded
713  
-				var uploadedFileID = $('ul.ss-uploadfield-files').children('li.ss-uploadfield-item').last().data('fileid');
714  
-
715  
-				//trigger the detail view for filling out details about the file we are about to insert into TinyMCE
716 711
 				var form = this.closest('form');
717  
-				form.closest('form').showFileView(uploadedFileID);
  712
+
  713
+				//update the editFields to show those Files that are newly uploaded
  714
+				var editFieldIDs = [];
  715
+				form.find('div.content-edit').find('div.ss-htmleditorfield-file').each(function(){
  716
+					//get the uploaded file ID when this event triggers, signaling the upload has compeleted successfully
  717
+					editFieldIDs.push($(this).data('id'));
  718
+				});
  719
+				var uploadedFiles = $('ul.ss-uploadfield-files').children('li.ss-uploadfield-item');
  720
+				uploadedFiles.each(function(){
  721
+					var uploadedID = $(this).data('fileid');
  722
+					if ($.inArray(uploadedID, editFieldIDs) == -1) {
  723
+						//trigger the detail view for filling out details about the file we are about to insert into TinyMCE
  724
+						form.showFileView(uploadedID);
  725
+					}
  726
+				});
  727
+
718 728
 				form.redraw();
719 729
 			}
720 730
 

0 notes on commit 2110906

Please sign in to comment.
Something went wrong with that request. Please try again.