ENHANCEMENT: Select the uploaded image after uploading by default. #4962

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@97765 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Will Rossiter 2010-01-28 21:56:38 +00:00 committed by Sam Minnee
parent b285c68d5c
commit b853c1ce47
2 changed files with 15 additions and 11 deletions

View File

@ -280,7 +280,8 @@ class HtmlEditorField_Toolbar extends RequestHandler {
new CompositeField(new FieldSet( new CompositeField(new FieldSet(
new LiteralField('ShowUpload', '<p class="showUploadField"><a href="#">'. _t('HtmlEditorField.SHOWUPLOADFORM', 'Upload File') .'</a></p>'), 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 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 TextField('getimagesSearch', _t('HtmlEditorField.SEARCHFILENAME', 'Search by file name')),
new ThumbnailStripField('FolderImages', 'FolderID', 'getimages'), new ThumbnailStripField('FolderImages', 'FolderID', 'getimages'),

View File

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