ENHANCEMENT: Select the uploaded image after uploading by default. #4962 (from r97765)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@102531 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2010-04-12 23:36:50 +00:00
parent d294c0f755
commit 73ba193ad6
2 changed files with 15 additions and 11 deletions

View File

@ -293,7 +293,8 @@ class HtmlEditorField_Toolbar extends RequestHandler {
new CompositeField(new FieldSet(
new LiteralField('ShowUpload', '<p class="showUploadField"><a href="#">'. _t('HtmlEditorField.SHOWUPLOADFORM', 'Upload File') .'</a></p>'),
new FileField("Files[0]" , _t('AssetAdmin.CHOOSEFILE','Choose file: ')),
new LiteralField('Response', '<div id="UploadFormResponse"></div>')
new LiteralField('Response', '<div id="UploadFormResponse"></div>'),
new HiddenField('UploadMode', 'Upload Mode', 'CMSEditor') // used as a hook for doUpload switching
)),
new TextField('getimagesSearch', _t('HtmlEditorField.SEARCHFILENAME', 'Search by file name')),
new ThumbnailStripField('FolderImages', 'FolderID', 'getimages'),

View File

@ -11,7 +11,7 @@
/**
* On page refresh load the initial images (in root)
*/
if($("#FolderImages").length > 0 && $("body.CMSMain").length > 0) loadImages();
if($("#FolderImages").length > 0 && $("body.CMSMain").length > 0) loadImages(false);
/**
* Show / Hide the Upload Form
@ -25,37 +25,36 @@
$("#Form_EditorToolbarImageForm_Files-0").parents('.file').show();
$(this).text(ss.i18n._t('HtmlEditorField.HideUploadForm', 'Hide Upload Form')).addClass("showing");
}
return false;
}).show();
/**
* On folder change - lookup the new images
*/
$("#Form_EditorToolbarImageForm_Files-0").change(function() {
$("#contentPanel form").ajaxForm({
$("#contentPanel #Form_EditorToolbarImageForm").ajaxForm({
url: 'admin/assets/UploadForm?action_doUpload=1',
iframe: true,
dataType: 'json',
beforeSubmit: function(data) {
$("#UploadFormResponse").text("Uploading File...").addClass("loading").show();
$("#Form_EditorToolbarImageForm_Files-0").parents('.file').hide();
},
success: function(data) {
$("#UploadFormResponse").text(data).removeClass("loading");
$("#UploadFormResponse").text("").removeClass("loading");
$("#Form_EditorToolbarImageForm_Files-0").val("").parents('.file').show();
$("#FolderImages").html('<h2>'+ ss.i18n._t('HtmlEditorField.Loading', 'Loading') + '</h2>');
$("#FolderImages").html('<h2>'+ ss.i18n._t('HtmlEditorField.Loading', 'Loading') + '</h2>');
loadImages();
loadImages(data);
}
}).submit();
});
/**
* Loads images from getimages() to the thumbnail view. It's called on
*
*
*/
function loadImages() {
function loadImages(params) {
console.debug(this);
$.get('admin/EditorToolbar/ImageForm', {
action_callfieldmethod: "1",
@ -72,7 +71,11 @@
$("#FolderImages").each(function() {
Behaviour.apply(this);
})
});
if(params) {
$("#FolderImages a[href*="+ params.Filename +"]").click();
}
});
}
});