Skip to content

Commit

Permalink
BUGFIX: SSF-38 making the entwine selector for the upload field more …
Browse files Browse the repository at this point in the history
…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
Julian Seidenberg committed Mar 30, 2012
1 parent 98e197a commit 2110906
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions javascript/HtmlEditorField.js
Expand Up @@ -699,7 +699,7 @@ ss.editorWrappers['default'] = ss.editorWrappers.tinyMCE;
/**
* Show the second step after uploading an image
*/
$('.ss-assetuploadfield').entwine({
$('form.htmleditorfield-form.htmleditorfield-mediaform div.ss-assetuploadfield').entwine({
onmatch: function() {
this._super();

Expand All @@ -708,13 +708,23 @@ ss.editorWrappers['default'] = ss.editorWrappers.tinyMCE;

},
onfileuploadstop: function(e) {
//get the uploaded file ID when this event triggers, signaling the upload has compeleted successfully
//always use the last one uploaded
var uploadedFileID = $('ul.ss-uploadfield-files').children('li.ss-uploadfield-item').last().data('fileid');

//trigger the detail view for filling out details about the file we are about to insert into TinyMCE
var form = this.closest('form');
form.closest('form').showFileView(uploadedFileID);

//update the editFields to show those Files that are newly uploaded
var editFieldIDs = [];
form.find('div.content-edit').find('div.ss-htmleditorfield-file').each(function(){
//get the uploaded file ID when this event triggers, signaling the upload has compeleted successfully
editFieldIDs.push($(this).data('id'));
});
var uploadedFiles = $('ul.ss-uploadfield-files').children('li.ss-uploadfield-item');
uploadedFiles.each(function(){
var uploadedID = $(this).data('fileid');
if ($.inArray(uploadedID, editFieldIDs) == -1) {
//trigger the detail view for filling out details about the file we are about to insert into TinyMCE
form.showFileView(uploadedID);
}
});

form.redraw();
}

Expand Down

0 comments on commit 2110906

Please sign in to comment.