2009-04-29 04:52:18 +02:00
|
|
|
/**
|
2010-01-25 22:10:43 +01:00
|
|
|
* Functions for HtmlEditorFields in the back end.
|
|
|
|
* Includes the JS for the ImageUpload forms.
|
|
|
|
*
|
|
|
|
* Relies on the jquery.form.js plugin to power the
|
|
|
|
* ajax / iframe submissions
|
2009-04-29 04:52:18 +02:00
|
|
|
*/
|
|
|
|
|
2010-01-25 22:10:43 +01:00
|
|
|
(function($) {
|
|
|
|
$(document).ready(function() {
|
2010-01-26 21:53:55 +01:00
|
|
|
/**
|
|
|
|
* On page refresh load the initial images (in root)
|
|
|
|
*/
|
2010-01-28 22:56:38 +01:00
|
|
|
if($("#FolderImages").length > 0 && $("body.CMSMain").length > 0) loadImages(false);
|
2010-01-26 21:53:55 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Show / Hide the Upload Form
|
|
|
|
*/
|
2010-01-25 22:10:43 +01:00
|
|
|
$("#Form_EditorToolbarImageForm .showUploadField a").click(function() {
|
|
|
|
if($(this).hasClass("showing")) {
|
|
|
|
$("#Form_EditorToolbarImageForm_Files-0").parents('.file').hide();
|
|
|
|
$(this).text(ss.i18n._t('HtmlEditorField.ShowUploadForm', 'Upload File')).removeClass("showing");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$("#Form_EditorToolbarImageForm_Files-0").parents('.file').show();
|
|
|
|
$(this).text(ss.i18n._t('HtmlEditorField.HideUploadForm', 'Hide Upload Form')).addClass("showing");
|
|
|
|
}
|
2010-01-28 22:56:38 +01:00
|
|
|
return false;
|
2010-01-25 22:10:43 +01:00
|
|
|
}).show();
|
|
|
|
|
2010-01-26 21:53:55 +01:00
|
|
|
/**
|
|
|
|
* On folder change - lookup the new images
|
|
|
|
*/
|
2010-01-25 22:10:43 +01:00
|
|
|
$("#Form_EditorToolbarImageForm_Files-0").change(function() {
|
2010-01-28 22:56:38 +01:00
|
|
|
$("#contentPanel #Form_EditorToolbarImageForm").ajaxForm({
|
2010-01-25 22:10:43 +01:00
|
|
|
url: 'admin/assets/UploadForm?action_doUpload=1',
|
|
|
|
iframe: true,
|
2010-01-28 22:56:38 +01:00
|
|
|
dataType: 'json',
|
2010-01-25 22:10:43 +01:00
|
|
|
beforeSubmit: function(data) {
|
|
|
|
$("#UploadFormResponse").text("Uploading File...").addClass("loading").show();
|
|
|
|
$("#Form_EditorToolbarImageForm_Files-0").parents('.file').hide();
|
|
|
|
},
|
|
|
|
success: function(data) {
|
2010-01-28 22:56:38 +01:00
|
|
|
$("#UploadFormResponse").text("").removeClass("loading");
|
2010-01-25 22:10:43 +01:00
|
|
|
$("#Form_EditorToolbarImageForm_Files-0").val("").parents('.file').show();
|
|
|
|
|
2010-01-28 22:56:38 +01:00
|
|
|
$("#FolderImages").html('<h2>'+ ss.i18n._t('HtmlEditorField.Loading', 'Loading') + '</h2>');
|
2010-01-25 22:10:43 +01:00
|
|
|
|
2010-01-28 22:56:38 +01:00
|
|
|
loadImages(data);
|
2010-01-25 22:10:43 +01:00
|
|
|
}
|
|
|
|
}).submit();
|
|
|
|
});
|
2010-01-26 21:53:55 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Loads images from getimages() to the thumbnail view. It's called on
|
|
|
|
*/
|
2010-01-28 22:56:38 +01:00
|
|
|
function loadImages(params) {
|
2010-01-26 21:53:55 +01:00
|
|
|
$.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);
|
2010-01-28 22:56:38 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
if(params) {
|
|
|
|
$("#FolderImages a[href*="+ params.Filename +"]").click();
|
|
|
|
}
|
2010-01-26 21:53:55 +01:00
|
|
|
});
|
|
|
|
}
|
2009-04-29 04:52:18 +02:00
|
|
|
});
|
2010-01-25 22:10:43 +01:00
|
|
|
})(jQuery);
|