2009-04-29 04:52:18 +02:00
|
|
|
/**
|
2010-04-12 23:54:41 +02: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-04-12 23:54:41 +02:00
|
|
|
(function($) {
|
2011-04-05 11:08:24 +02:00
|
|
|
|
2010-04-12 23:54:41 +02:00
|
|
|
$(document).ready(function() {
|
2011-04-05 11:08:24 +02:00
|
|
|
|
2011-04-25 11:49:35 +02:00
|
|
|
// Move title from headline to (jQuery compatible) title attribute
|
|
|
|
$('.htmleditorfield-form').each(function() {
|
|
|
|
var titleEl = $(this).find(':header:first');
|
|
|
|
$(this).attr('title', titleEl.text());
|
|
|
|
titleEl.remove();
|
|
|
|
});
|
|
|
|
$('.htmleditorfield-form').dialog({
|
|
|
|
autoOpen: false,
|
|
|
|
bgiframe: true,
|
|
|
|
modal: true,
|
|
|
|
height: 500,
|
|
|
|
width: 500,
|
|
|
|
ghost: true
|
|
|
|
});
|
2011-04-05 11:08:24 +02:00
|
|
|
|
2010-04-13 01:05:23 +02:00
|
|
|
/**
|
|
|
|
* On page refresh load the initial images (in root)
|
|
|
|
*/
|
2010-04-13 01:36:50 +02:00
|
|
|
if($("#FolderImages").length > 0 && $("body.CMSMain").length > 0) loadImages(false);
|
2010-04-13 01:05:23 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Show / Hide the Upload Form
|
|
|
|
*/
|
2010-04-12 23:54:41 +02: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-04-13 01:36:50 +02:00
|
|
|
return false;
|
2010-04-12 23:54:41 +02:00
|
|
|
}).show();
|
|
|
|
|
2010-04-13 01:05:23 +02:00
|
|
|
/**
|
|
|
|
* On folder change - lookup the new images
|
|
|
|
*/
|
2010-04-12 23:54:41 +02:00
|
|
|
$("#Form_EditorToolbarImageForm_Files-0").change(function() {
|
2011-04-15 01:25:47 +02:00
|
|
|
$(".cms-editor-dialogs #Form_EditorToolbarImageForm").ajaxForm({
|
2010-04-12 23:54:41 +02:00
|
|
|
url: 'admin/assets/UploadForm?action_doUpload=1',
|
|
|
|
iframe: true,
|
2010-04-13 01:36:50 +02:00
|
|
|
dataType: 'json',
|
2010-04-12 23:54:41 +02:00
|
|
|
beforeSubmit: function(data) {
|
|
|
|
$("#UploadFormResponse").text("Uploading File...").addClass("loading").show();
|
|
|
|
$("#Form_EditorToolbarImageForm_Files-0").parents('.file').hide();
|
|
|
|
},
|
|
|
|
success: function(data) {
|
2010-04-13 01:36:50 +02:00
|
|
|
$("#UploadFormResponse").text("").removeClass("loading");
|
2010-04-12 23:54:41 +02:00
|
|
|
$("#Form_EditorToolbarImageForm_Files-0").val("").parents('.file').show();
|
|
|
|
|
2010-04-13 01:36:50 +02:00
|
|
|
$("#FolderImages").html('<h2>'+ ss.i18n._t('HtmlEditorField.Loading', 'Loading') + '</h2>');
|
2010-04-12 23:54:41 +02:00
|
|
|
|
2010-04-13 01:36:50 +02:00
|
|
|
loadImages(data);
|
2010-04-12 23:54:41 +02:00
|
|
|
}
|
|
|
|
}).submit();
|
|
|
|
});
|
2010-04-13 01:05:23 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Loads images from getimages() to the thumbnail view. It's called on
|
|
|
|
*/
|
2010-04-13 01:36:50 +02:00
|
|
|
function loadImages(params) {
|
2010-04-13 01:05:23 +02: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-04-13 01:36:50 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
if(params) {
|
|
|
|
$("#FolderImages a[href*="+ params.Filename +"]").click();
|
|
|
|
}
|
2010-04-13 01:05:23 +02:00
|
|
|
});
|
|
|
|
}
|
2009-04-29 04:52:18 +02:00
|
|
|
});
|
2010-04-12 23:54:41 +02:00
|
|
|
})(jQuery);
|