Permalink
Browse files

BUG Fixed issue where file upload via the HTML Editor media dialogue …

…would not prompt users to overwrite existing files
  • Loading branch information...
tractorcow committed Jun 20, 2013
1 parent a4189a6 commit f47383f52e885ec526da7a5649e8d6e9a1d97294
Showing with 23 additions and 10 deletions.
  1. +1 −1 admin/css/screen.css
  2. +8 −3 admin/scss/_style.scss
  3. +0 −2 forms/HtmlEditorField.php
  4. +3 −2 javascript/HtmlEditorField.js
  5. +11 −2 javascript/UploadField.js
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -1535,9 +1535,14 @@ body.cms-dialog {
}
}
- .ss-uploadfield-editandorganize {
- display: none;
- }
+ .ss-assetuploadfield .ss-uploadfield-editandorganize {
+ .ss-uploadfield-files {
+ .ss-uploadfield-item-info {
+ background-color: grayscale(#5db4df);
+ @include background-image(linear-gradient(top, grayscale(#5db4df) 0%, grayscale(#5db1dd) 8%, grayscale(#439bcb) 50%, grayscale(#3f99cd) 54%, grayscale(#207db6) 96%, grayscale(#1e7cba) 100%));
+ }
+ }
+ }
}
/** --------------------------------------------
@@ -428,8 +428,6 @@ public function MediaForm() {
$computerUploadField->removeExtraClass('ss-uploadfield');
$computerUploadField->setTemplate('HtmlEditorField_UploadField');
$computerUploadField->setFolderName(Config::inst()->get('Upload', 'uploads_folder'));
- // @todo - Remove this once this field supports display and recovery of file upload validation errors
- $computerUploadField->setOverwriteWarning(false);
$tabSet = new TabSet(
"MediaFormInsertMediaTabs",
@@ -808,7 +808,7 @@ ss.editorWrappers['default'] = ss.editorWrappers.tinyMCE;
});
ed.repaint();
- })
+ });
this.getDialog().close();
return false;
@@ -926,8 +926,9 @@ ss.editorWrappers['default'] = ss.editorWrappers.tinyMCE;
var uploadedFiles = $('.ss-uploadfield-files', this).children('.ss-uploadfield-item');
uploadedFiles.each(function(){
var uploadedID = $(this).data('fileid');
- if ($.inArray(uploadedID, editFieldIDs) == -1) {
+ if (uploadedID && $.inArray(uploadedID, editFieldIDs) == -1) {
//trigger the detail view for filling out details about the file we are about to insert into TinyMCE
+ $(this).remove(); // Remove successfully added item from the queue
form.showFileView(uploadedID);
}
});
View
@@ -64,13 +64,16 @@
.addClass('ui-state-warning-text');
data.context.find('.ss-uploadfield-item-progress').hide();
data.context.find('.ss-uploadfield-item-overwrite').show();
- data.context.find('.ss-uploadfield-item-overwrite-warning').on('click', function(){
+ data.context.find('.ss-uploadfield-item-overwrite-warning').on('click', function(e){
data.context.find('.ss-uploadfield-item-progress').show();
data.context.find('.ss-uploadfield-item-overwrite').hide();
data.context.find('.ss-uploadfield-item-status')
.removeClass('ui-state-warning-text');
//upload only if the "overwrite" button is clicked
$.blueimpUI.fileupload.prototype._onSend.call(that, e, data);
+
+ e.preventDefault(); // Avoid a form submit
+ return false;
});
} else { //regular file upload
return $.blueimpUI.fileupload.prototype._onSend.call(that, e, data);
@@ -319,12 +322,14 @@
$('div.ss-upload .ss-uploadfield-startall').entwine({
onclick: function(e) {
this.closest('.ss-upload').find('.ss-uploadfield-item-start button').click();
+ e.preventDefault(); // Avoid a form submit
return false;
}
});
$('div.ss-upload .ss-uploadfield-item-cancelfailed').entwine({
onclick: function(e) {
this.closest('.ss-uploadfield-item').remove();
+ e.preventDefault(); // Avoid a form submit
return false;
}
});
@@ -349,6 +354,7 @@
fileupload._trigger('destroy', e, {context: item});
}
+ e.preventDefault(); // Avoid a form submit
return false;
}
});
@@ -371,6 +377,7 @@
}
e.preventDefault(); // Avoid a form submit
+ return false;
}
});
$( 'div.ss-upload:not(.disabled):not(.readonly) .ss-uploadfield-item-edit').entwine({
@@ -403,6 +410,7 @@
editform.toggleEditForm();
}
e.preventDefault(); // Avoid a form submit
+ return false;
}
});
@@ -486,8 +494,9 @@
});
$('div.ss-upload .ss-uploadfield-fromfiles').entwine({
onclick: function(e) {
- e.preventDefault();
this.getUploadField().openSelectDialog(this.closest('.ss-uploadfield-item'));
+ e.preventDefault(); // Avoid a form submit
+ return false;
}
});
});

0 comments on commit f47383f

Please sign in to comment.