From b7d466c9923a116a7d476c39c1201289644e9997 Mon Sep 17 00:00:00 2001 From: Will Rossiter Date: Tue, 26 Jan 2010 20:53:55 +0000 Subject: [PATCH] ENHANCEMENT: CMS Editor Upload panel now loads the root files directly and allows the user to upload to the root assets dir git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@97601 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- javascript/HtmlEditorField.js | 57 +++++++++++++++++++++++------------ 1 file changed, 37 insertions(+), 20 deletions(-) diff --git a/javascript/HtmlEditorField.js b/javascript/HtmlEditorField.js index 4a045254f..5cccd0e05 100644 --- a/javascript/HtmlEditorField.js +++ b/javascript/HtmlEditorField.js @@ -8,7 +8,14 @@ (function($) { $(document).ready(function() { - + /** + * On page refresh load the initial images (in root) + */ + if($("#FolderImages").length > 0) loadImages(); + + /** + * Show / Hide the Upload Form + */ $("#Form_EditorToolbarImageForm .showUploadField a").click(function() { if($(this).hasClass("showing")) { $("#Form_EditorToolbarImageForm_Files-0").parents('.file').hide(); @@ -20,6 +27,9 @@ } }).show(); + /** + * On folder change - lookup the new images + */ $("#Form_EditorToolbarImageForm_Files-0").change(function() { $("#contentPanel form").ajaxForm({ url: 'admin/assets/UploadForm?action_doUpload=1', @@ -35,27 +45,34 @@ $("#FolderImages").html('

'+ ss.i18n._t('HtmlEditorField.Loading', 'Loading') + '

'); - var ajaxURL = 'admin/EditorToolbar/ImageForm'; - - $.get(ajaxURL, { - action_callfieldmethod: "1", - fieldName: "FolderImages", - ajax: "1", - methodName: "getimages", - folderID: $("#Form_EditorToolbarImageForm_FolderID").val(), - searchText: $("#Form_EditorToolbarImageForm_getimagesSearch").val(), - cacheKillerDate: parseInt((new Date()).getTime()), - cacheKillerRand: parseInt(10000 * Math.random()) - }, - function(data) { - $("#FolderImages").html(data); - - $("#FolderImages").each(function() { - Behaviour.apply(this); - }) - }); + loadImages(); } }).submit(); }); + + /** + * Loads images from getimages() to the thumbnail view. It's called on + * + * + */ + function loadImages(sel) { + $.get('admin/EditorToolbar/ImageForm', { + action_callfieldmethod: "1", + fieldName: "FolderImages", + ajax: "1", + methodName: "getimages", + folderID: $("#Form_EditorToolbarImageForm_FolderID").val(), + searchText: $("#Form_EditorToolbarImageForm_getimagesSearch").val(), + cacheKillerDate: parseInt((new Date()).getTime()), + cacheKillerRand: parseInt(10000 * Math.random()) + }, + function(data) { + $("#FolderImages").html(data); + + $("#FolderImages").each(function() { + Behaviour.apply(this); + }) + }); + } }); })(jQuery); \ No newline at end of file