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
This commit is contained in:
Will Rossiter 2010-01-26 20:53:55 +00:00 committed by Sam Minnee
parent afa1b74f3e
commit b7d466c992

View File

@ -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('<h2>'+ ss.i18n._t('HtmlEditorField.Loading', 'Loading') + '</h2>');
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);