2010-05-08 04:45:05 +02:00
|
|
|
/**
|
|
|
|
* File: LeftAndMain.EditForm.js
|
|
|
|
*/
|
2009-11-21 03:38:20 +01:00
|
|
|
(function($) {
|
2010-04-13 07:55:56 +02:00
|
|
|
$.entwine('ss', function($){
|
2009-11-21 03:38:20 +01:00
|
|
|
|
2009-11-21 04:19:59 +01:00
|
|
|
/**
|
2010-05-08 04:45:05 +02:00
|
|
|
* Class: #Form_EditForm
|
|
|
|
*
|
|
|
|
* Base edit form, provides ajaxified saving
|
2009-11-21 04:19:59 +01:00
|
|
|
* and reloading itself through the ajax return values.
|
|
|
|
* Takes care of resizing tabsets within the layout container.
|
|
|
|
* @name ss.Form_EditForm
|
|
|
|
* @require jquery.changetracker
|
|
|
|
*
|
2010-05-08 04:45:05 +02:00
|
|
|
* Events:
|
|
|
|
* ajaxsubmit - Form is about to be submitted through ajax
|
|
|
|
* validate - Contains validation result
|
|
|
|
* removeform - A form is about to be removed from the DOM
|
|
|
|
* load - Form is about to be loaded through ajax
|
2009-11-21 04:19:59 +01:00
|
|
|
*/
|
2010-04-13 07:55:56 +02:00
|
|
|
$('#Form_EditForm').entwine(/** @lends ss.Form_EditForm */{
|
2009-11-21 03:38:31 +01:00
|
|
|
/**
|
2010-05-08 04:45:05 +02:00
|
|
|
* Variable: PlaceholderHtml
|
|
|
|
* (String_ HTML text to show when no form content is chosen.
|
|
|
|
* Will show inside the <form> tag.
|
2009-11-21 03:38:31 +01:00
|
|
|
*/
|
2009-11-21 04:14:22 +01:00
|
|
|
PlaceholderHtml: '',
|
2009-11-21 04:19:59 +01:00
|
|
|
|
2009-11-21 04:14:08 +01:00
|
|
|
/**
|
2010-05-08 04:45:05 +02:00
|
|
|
* Variable: ChangeTrackerOptions
|
|
|
|
* (Object)
|
2009-11-21 04:14:08 +01:00
|
|
|
*/
|
|
|
|
ChangeTrackerOptions: {},
|
2009-11-21 04:19:59 +01:00
|
|
|
|
2010-05-08 04:45:05 +02:00
|
|
|
/**
|
|
|
|
* Constructor: onmatch
|
|
|
|
*/
|
2009-11-21 03:38:46 +01:00
|
|
|
onmatch: function() {
|
2009-11-21 04:14:14 +01:00
|
|
|
var self = this;
|
2009-11-21 04:19:59 +01:00
|
|
|
|
2009-11-21 04:14:08 +01:00
|
|
|
this._setupChangeTracker();
|
2009-11-21 04:14:22 +01:00
|
|
|
|
2009-11-21 04:14:14 +01:00
|
|
|
// Can't bind this through jQuery
|
|
|
|
window.onbeforeunload = function(e) {return self._checkChangeTracker(false);};
|
2009-11-21 04:19:59 +01:00
|
|
|
|
2009-11-21 04:15:23 +01:00
|
|
|
this._super();
|
2009-11-21 04:14:08 +01:00
|
|
|
},
|
2009-11-21 04:19:59 +01:00
|
|
|
|
2010-05-08 04:45:05 +02:00
|
|
|
/**
|
|
|
|
* Function: _setupChangeTracker
|
|
|
|
*/
|
2009-11-21 04:14:08 +01:00
|
|
|
_setupChangeTracker: function() {
|
2009-11-21 03:38:46 +01:00
|
|
|
// Don't bind any events here, as we dont replace the
|
|
|
|
// full <form> tag by any ajax updates they won't automatically reapply
|
2009-11-21 04:19:59 +01:00
|
|
|
this.changetracker(this.getChangeTrackerOptions());
|
2009-11-21 04:14:14 +01:00
|
|
|
},
|
2009-11-21 04:19:59 +01:00
|
|
|
|
2009-11-21 04:14:14 +01:00
|
|
|
/**
|
2010-05-08 04:45:05 +02:00
|
|
|
* Function: _checkChangeTracker
|
|
|
|
*
|
2009-11-21 04:14:14 +01:00
|
|
|
* Checks the jquery.changetracker plugin status for this form.
|
|
|
|
* Usually bound to window.onbeforeunload.
|
|
|
|
*
|
2010-05-08 04:45:05 +02:00
|
|
|
* Parameters:
|
|
|
|
* {boolean} isUnloadEvent - ..
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* (String) Either a string with a confirmation message, or the result of a confirm() dialog,
|
2009-11-21 04:14:38 +01:00
|
|
|
* based on the isUnloadEvent parameter.
|
2009-11-21 04:14:14 +01:00
|
|
|
*/
|
2009-11-21 04:14:38 +01:00
|
|
|
_checkChangeTracker: function(isUnloadEvent) {
|
2009-11-21 04:14:14 +01:00
|
|
|
var self = this;
|
2009-11-21 04:19:59 +01:00
|
|
|
|
2009-11-21 04:14:14 +01:00
|
|
|
// @todo TinyMCE coupling
|
|
|
|
if(typeof tinyMCE != 'undefined') tinyMCE.triggerSave();
|
2009-11-21 04:19:59 +01:00
|
|
|
|
2009-11-21 04:14:17 +01:00
|
|
|
// check for form changes
|
2009-11-21 04:14:14 +01:00
|
|
|
if(self.is('.changed')) {
|
|
|
|
// returned string will trigger a confirm() dialog,
|
|
|
|
// but only if the method is triggered by an event
|
2009-11-21 04:14:38 +01:00
|
|
|
if(isUnloadEvent) {
|
|
|
|
return confirm(ss.i18n._t('LeftAndMain.CONFIRMUNSAVED'));
|
|
|
|
} else {
|
|
|
|
return ss.i18n._t('LeftAndMain.CONFIRMUNSAVEDSHORT');
|
|
|
|
}
|
2009-11-21 04:14:08 +01:00
|
|
|
}
|
2009-11-21 03:38:46 +01:00
|
|
|
},
|
2009-11-21 04:19:59 +01:00
|
|
|
|
2009-11-21 03:38:31 +01:00
|
|
|
/**
|
2010-05-08 04:45:05 +02:00
|
|
|
* Function: onsubmit
|
2009-11-21 04:14:14 +01:00
|
|
|
*
|
2010-05-08 04:45:05 +02:00
|
|
|
* Suppress submission unless it is handled through ajaxSubmit().
|
2009-11-21 03:38:31 +01:00
|
|
|
*/
|
2009-11-21 04:19:59 +01:00
|
|
|
onsubmit: function(e) {
|
2009-11-21 04:17:55 +01:00
|
|
|
this.ajaxSubmit();
|
2009-11-21 04:19:59 +01:00
|
|
|
|
2009-11-21 03:38:31 +01:00
|
|
|
return false;
|
|
|
|
},
|
2009-11-21 04:19:59 +01:00
|
|
|
|
2009-11-21 03:38:31 +01:00
|
|
|
/**
|
2010-05-08 04:45:05 +02:00
|
|
|
* Function: ajaxSubmit
|
|
|
|
*
|
|
|
|
* Parameters:
|
|
|
|
* {DOMElement} button - The pressed button (optional)
|
|
|
|
* {Function} callback - Called in complete() handler of jQuery.ajax()
|
|
|
|
* {Object} ajaxOptions - Object literal to merge into $.ajax() call
|
|
|
|
* {boolean} loadResponse - Render response through _loadResponse() (Default: true)
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* (boolean)
|
2009-11-21 03:38:31 +01:00
|
|
|
*/
|
2009-11-21 04:14:14 +01:00
|
|
|
ajaxSubmit: function(button, callback, ajaxOptions, loadResponse) {
|
2009-11-21 04:17:55 +01:00
|
|
|
var self = this;
|
2009-11-21 04:19:59 +01:00
|
|
|
|
2009-11-21 04:14:05 +01:00
|
|
|
// look for save button
|
|
|
|
if(!button) button = this.find('.Actions :submit[name=action_save]');
|
2009-11-21 03:38:31 +01:00
|
|
|
// default to first button if none given - simulates browser behaviour
|
2009-11-21 04:14:05 +01:00
|
|
|
if(!button) button = this.find('.Actions :submit:first');
|
2009-11-21 04:19:59 +01:00
|
|
|
|
2009-11-21 03:38:31 +01:00
|
|
|
this.trigger('ajaxsubmit', {button: button});
|
2009-11-21 04:19:59 +01:00
|
|
|
|
2009-11-21 03:38:31 +01:00
|
|
|
// set button to "submitting" state
|
|
|
|
$(button).addClass('loading');
|
2009-11-21 04:19:59 +01:00
|
|
|
|
2009-11-21 03:38:31 +01:00
|
|
|
// @todo TinyMCE coupling
|
|
|
|
if(typeof tinyMCE != 'undefined') tinyMCE.triggerSave();
|
2009-11-21 04:19:59 +01:00
|
|
|
|
2009-11-21 03:38:31 +01:00
|
|
|
// validate if required
|
|
|
|
if(!this.validate()) {
|
|
|
|
// TODO Automatically switch to the tab/position of the first error
|
|
|
|
statusMessage("Validation failed.", "bad");
|
2009-11-21 03:38:20 +01:00
|
|
|
|
2009-11-21 03:38:31 +01:00
|
|
|
$(button).removeClass('loading');
|
2009-11-21 03:38:20 +01:00
|
|
|
|
2009-11-21 03:38:31 +01:00
|
|
|
return false;
|
|
|
|
}
|
2009-11-21 03:38:20 +01:00
|
|
|
|
2009-11-21 03:38:31 +01:00
|
|
|
// get all data from the form
|
2009-11-21 03:39:06 +01:00
|
|
|
var formData = this.serializeArray();
|
2009-11-21 03:38:31 +01:00
|
|
|
// add button action
|
2009-11-21 03:39:06 +01:00
|
|
|
formData.push({name: $(button).attr('name'), value:'1'});
|
2009-11-21 04:14:14 +01:00
|
|
|
jQuery.ajax(jQuery.extend({
|
2009-11-21 03:39:06 +01:00
|
|
|
url: this.attr('action'),
|
|
|
|
data: formData,
|
|
|
|
type: 'POST',
|
|
|
|
complete: function(xmlhttp, status) {
|
2009-11-21 03:38:31 +01:00
|
|
|
$(button).removeClass('loading');
|
2009-11-21 04:19:59 +01:00
|
|
|
|
2009-11-21 04:14:14 +01:00
|
|
|
// TODO This should be using the plugin API
|
|
|
|
self.removeClass('changed');
|
2009-11-21 04:19:59 +01:00
|
|
|
|
2009-11-21 04:14:05 +01:00
|
|
|
if(callback) callback(xmlhttp, status);
|
2009-11-21 04:19:59 +01:00
|
|
|
|
2009-11-21 03:39:06 +01:00
|
|
|
// pass along original form data to enable old/new comparisons
|
2009-11-21 04:14:14 +01:00
|
|
|
if(loadResponse !== false) {
|
|
|
|
self._loadResponse(xmlhttp.responseText, status, xmlhttp, formData);
|
|
|
|
}
|
2009-11-21 03:38:31 +01:00
|
|
|
},
|
2009-11-21 03:39:06 +01:00
|
|
|
dataType: 'html'
|
2009-11-21 04:14:05 +01:00
|
|
|
}, ajaxOptions));
|
2009-11-21 04:19:59 +01:00
|
|
|
|
2009-11-21 03:38:31 +01:00
|
|
|
return false;
|
|
|
|
},
|
2009-11-21 04:19:59 +01:00
|
|
|
|
2009-11-21 03:38:31 +01:00
|
|
|
/**
|
2010-05-08 04:45:05 +02:00
|
|
|
* Function: validate
|
|
|
|
*
|
2009-11-21 03:38:31 +01:00
|
|
|
* Hook in (optional) validation routines.
|
|
|
|
* Currently clientside validation is not supported out of the box in the CMS.
|
|
|
|
*
|
2010-05-08 04:45:05 +02:00
|
|
|
* Todo:
|
|
|
|
* Placeholder implementation
|
2009-11-21 03:38:31 +01:00
|
|
|
*
|
2010-05-08 04:45:05 +02:00
|
|
|
* Returns:
|
|
|
|
* {boolean}
|
2009-11-21 03:38:31 +01:00
|
|
|
*/
|
|
|
|
validate: function() {
|
|
|
|
var isValid = true;
|
|
|
|
this.trigger('validate', {isValid: isValid});
|
2009-11-21 04:19:59 +01:00
|
|
|
|
2009-11-21 03:38:31 +01:00
|
|
|
return isValid;
|
|
|
|
},
|
2009-11-21 04:19:59 +01:00
|
|
|
|
2009-11-21 03:38:31 +01:00
|
|
|
/**
|
2010-05-08 04:45:05 +02:00
|
|
|
* Function: loadForm
|
|
|
|
*
|
|
|
|
* Parameters:
|
|
|
|
* (String) url - ..
|
|
|
|
* (Function) callback - (Optional) Called after the form content as been loaded
|
|
|
|
* (Object) ajaxOptions - Object literal merged into the jQuery.ajax() call (Optional)
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* (XMLHTTPRequest)
|
2009-11-21 03:38:31 +01:00
|
|
|
*/
|
2009-11-21 04:15:23 +01:00
|
|
|
loadForm: function(url, callback, ajaxOptions) {
|
2009-11-21 04:15:04 +01:00
|
|
|
var self = this;
|
|
|
|
|
2009-11-21 04:14:17 +01:00
|
|
|
// Alert when unsaved changes are present
|
|
|
|
if(this._checkChangeTracker(true) == false) return false;
|
2009-11-21 04:19:59 +01:00
|
|
|
|
2009-11-21 04:17:04 +01:00
|
|
|
// hide existing form - shown again through _loadResponse()
|
|
|
|
this.addClass('loading');
|
2009-11-21 04:17:36 +01:00
|
|
|
|
|
|
|
this.trigger('load', {url: url});
|
2009-11-21 04:19:59 +01:00
|
|
|
|
2009-11-21 04:17:25 +01:00
|
|
|
this.cleanup();
|
2009-11-21 04:14:17 +01:00
|
|
|
|
2009-11-21 04:14:14 +01:00
|
|
|
return jQuery.ajax(jQuery.extend({
|
2009-11-21 03:39:06 +01:00
|
|
|
url: url,
|
|
|
|
complete: function(xmlhttp, status) {
|
2009-11-21 04:14:14 +01:00
|
|
|
// TODO This should be using the plugin API
|
|
|
|
self.removeClass('changed');
|
2009-11-21 04:15:23 +01:00
|
|
|
|
2009-11-21 04:14:14 +01:00
|
|
|
self._loadResponse(xmlhttp.responseText, status, xmlhttp);
|
2009-11-21 04:19:59 +01:00
|
|
|
|
2009-11-21 04:17:04 +01:00
|
|
|
self.removeClass('loading');
|
2009-11-21 04:15:23 +01:00
|
|
|
|
2009-11-21 04:15:04 +01:00
|
|
|
if(callback) callback.apply(self, arguments);
|
2009-11-21 03:38:31 +01:00
|
|
|
},
|
2009-11-21 03:39:06 +01:00
|
|
|
dataType: 'html'
|
2009-11-21 04:14:14 +01:00
|
|
|
}, ajaxOptions));
|
2009-11-21 03:38:31 +01:00
|
|
|
},
|
2009-11-21 04:19:59 +01:00
|
|
|
|
2009-11-21 03:38:31 +01:00
|
|
|
/**
|
2010-05-08 04:45:05 +02:00
|
|
|
* Function: removeForm
|
|
|
|
*
|
2009-11-21 03:38:31 +01:00
|
|
|
* Remove everying inside the <form> tag
|
|
|
|
* with a custom HTML fragment. Useful e.g. for deleting a page in the CMS.
|
2009-11-21 04:14:17 +01:00
|
|
|
* Checks for unsaved changes before removing the form
|
2009-11-21 03:38:31 +01:00
|
|
|
*
|
2010-05-08 04:45:05 +02:00
|
|
|
* Parameters:
|
|
|
|
* {String} placeholderHtml - Short note why the form has been removed, displayed in <p> tags.
|
2009-11-21 03:38:46 +01:00
|
|
|
* Falls back to the default RemoveText() option (Optional)
|
2009-11-21 03:38:31 +01:00
|
|
|
*/
|
2009-11-21 04:14:17 +01:00
|
|
|
removeForm: function(placeholderHtml) {
|
2009-11-21 04:19:59 +01:00
|
|
|
if(!placeholderHtml) placeholderHtml = this.getPlaceholderHtml();
|
2009-11-21 04:14:17 +01:00
|
|
|
// Alert when unsaved changes are present
|
2009-11-21 04:19:59 +01:00
|
|
|
if(this._checkChangeTracker(true) == false) return;
|
2009-11-21 04:14:17 +01:00
|
|
|
this.trigger('removeform');
|
|
|
|
this.html(placeholderHtml);
|
|
|
|
// TODO This should be using the plugin API
|
|
|
|
this.removeClass('changed');
|
2009-11-21 03:38:31 +01:00
|
|
|
},
|
2009-11-21 04:19:59 +01:00
|
|
|
|
2009-11-21 03:38:31 +01:00
|
|
|
/**
|
2010-05-08 04:45:05 +02:00
|
|
|
* Function: cleanup
|
|
|
|
*
|
2009-11-21 03:38:31 +01:00
|
|
|
* Remove all the currently active TinyMCE editors.
|
|
|
|
* Note: Everything that calls this externally has an inappropriate coupling to TinyMCE.
|
|
|
|
*/
|
|
|
|
cleanup: function() {
|
|
|
|
if((typeof tinymce != 'undefined') && tinymce.EditorManager) {
|
|
|
|
var id;
|
|
|
|
for(id in tinymce.EditorManager.editors) {
|
|
|
|
tinymce.EditorManager.editors[id].remove();
|
|
|
|
}
|
|
|
|
tinymce.EditorManager.editors = {};
|
2009-11-21 03:38:20 +01:00
|
|
|
}
|
2009-11-21 03:38:31 +01:00
|
|
|
},
|
2009-11-21 04:19:59 +01:00
|
|
|
|
2009-11-21 03:38:31 +01:00
|
|
|
/**
|
2010-05-08 04:45:05 +02:00
|
|
|
* Function: _loadResponse
|
|
|
|
*
|
|
|
|
* Parameters:
|
|
|
|
* {String} data - Either HTML for straight insertion, or eval'ed JavaScript.
|
2009-11-21 03:38:31 +01:00
|
|
|
* If passed as HTML, it is assumed that everying inside the <form> tag is replaced,
|
|
|
|
* but the old <form> tag itself stays intact.
|
2010-05-08 04:45:05 +02:00
|
|
|
* {String} status
|
|
|
|
* {XMLHTTPRequest} xmlhttp - ..
|
|
|
|
* {Array} origData - The original submitted data, useful to do comparisons of changed
|
2009-11-21 03:39:06 +01:00
|
|
|
* values in new form output, e.g. to detect a URLSegment being changed on the serverside.
|
|
|
|
* Array in jQuery serializeArray() notation.
|
2009-11-21 03:38:31 +01:00
|
|
|
*/
|
2009-11-21 03:39:06 +01:00
|
|
|
_loadResponse: function(data, status, xmlhttp, origData) {
|
|
|
|
if(status == 'success') {
|
|
|
|
this.cleanup();
|
2009-11-21 04:19:59 +01:00
|
|
|
|
2009-11-21 03:39:06 +01:00
|
|
|
var html = data;
|
2009-11-21 03:38:20 +01:00
|
|
|
|
2009-11-21 03:39:06 +01:00
|
|
|
// Rewrite # links
|
|
|
|
html = html.replace(/(<a[^>]+href *= *")#/g, '$1' + window.location.href.replace(/#.*$/,'') + '#');
|
2009-11-21 03:38:20 +01:00
|
|
|
|
2009-11-21 03:39:06 +01:00
|
|
|
// Rewrite iframe links (for IE)
|
|
|
|
html = html.replace(/(<iframe[^>]*src=")([^"]+)("[^>]*>)/g, '$1' + $('base').attr('href') + '$2$3');
|
2009-11-21 03:38:20 +01:00
|
|
|
|
2009-11-21 03:39:06 +01:00
|
|
|
// Prepare iframes for removal, otherwise we get loading bugs
|
|
|
|
this.find('iframe').each(function() {
|
|
|
|
this.contentWindow.location.href = 'about:blank';
|
2009-11-21 04:18:04 +01:00
|
|
|
$(this).remove();
|
2009-11-21 03:39:06 +01:00
|
|
|
});
|
2009-11-21 03:38:20 +01:00
|
|
|
|
2009-11-21 03:39:06 +01:00
|
|
|
// update form content
|
|
|
|
if(html) {
|
|
|
|
this.html(html);
|
|
|
|
} else {
|
|
|
|
this.removeForm();
|
2009-11-21 03:38:48 +01:00
|
|
|
}
|
2009-11-21 04:19:59 +01:00
|
|
|
|
2010-04-13 07:55:56 +02:00
|
|
|
// @todo Coupling to avoid FOUC (entwine applies to late)
|
2009-11-21 04:17:08 +01:00
|
|
|
this.find('.ss-tabset').tabs();
|
2009-11-21 03:39:06 +01:00
|
|
|
|
2009-11-21 04:19:59 +01:00
|
|
|
this._setupChangeTracker();
|
|
|
|
|
2009-11-21 03:39:06 +01:00
|
|
|
// Optionally get the form attributes from embedded fields, see Form->formHtmlContent()
|
|
|
|
for(var overrideAttr in {'action':true,'method':true,'enctype':true,'name':true}) {
|
|
|
|
var el = this.find(':input[name='+ '_form_' + overrideAttr + ']');
|
|
|
|
if(el) {
|
|
|
|
this.attr(overrideAttr, el.val());
|
|
|
|
el.remove();
|
|
|
|
}
|
|
|
|
}
|
2009-11-21 04:19:59 +01:00
|
|
|
|
2009-11-21 03:39:06 +01:00
|
|
|
Behaviour.apply(); // refreshes ComplexTableField
|
|
|
|
|
|
|
|
// focus input on first form element
|
|
|
|
this.find(':input:visible:first').focus();
|
|
|
|
|
|
|
|
this.trigger('loadnewpage', {data: data, origData: origData});
|
2009-11-21 03:38:48 +01:00
|
|
|
}
|
2009-11-21 03:38:20 +01:00
|
|
|
|
2009-11-21 03:39:06 +01:00
|
|
|
// set status message based on response
|
|
|
|
var _statusMessage = (xmlhttp.getResponseHeader('X-Status')) ? xmlhttp.getResponseHeader('X-Status') : xmlhttp.statusText;
|
2009-11-21 03:38:31 +01:00
|
|
|
if(this.hasClass('validationerror')) {
|
2009-11-21 03:39:06 +01:00
|
|
|
// TODO validation shouldnt need a special case
|
2009-11-21 03:38:31 +01:00
|
|
|
statusMessage(ss.i18n._t('ModelAdmin.VALIDATIONERROR', 'Validation Error'), 'bad');
|
|
|
|
}
|
|
|
|
}
|
2009-11-21 04:19:59 +01:00
|
|
|
});
|
2009-11-21 03:38:20 +01:00
|
|
|
|
2009-11-21 04:19:59 +01:00
|
|
|
/**
|
2010-05-08 04:45:05 +02:00
|
|
|
* Class: #Form_EditForm .Actions :submit
|
|
|
|
*
|
|
|
|
* All buttons in the right CMS form go through here by default.
|
2009-11-21 04:19:59 +01:00
|
|
|
* We need this onclick overloading because we can't get to the
|
|
|
|
* clicked button from a form.onsubmit event.
|
|
|
|
*/
|
2010-05-08 04:45:05 +02:00
|
|
|
$('#Form_EditForm .Actions :submit').entwine({
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function: onclick
|
|
|
|
*/
|
2009-11-21 04:19:59 +01:00
|
|
|
onclick: function(e) {
|
2010-04-13 07:55:56 +02:00
|
|
|
jQuery('#Form_EditForm').entwine('ss').ajaxSubmit(this);
|
2009-11-21 03:38:33 +01:00
|
|
|
return false;
|
|
|
|
}
|
2009-11-21 04:19:59 +01:00
|
|
|
});
|
2009-11-21 04:14:40 +01:00
|
|
|
|
2009-11-21 04:19:59 +01:00
|
|
|
/**
|
2010-05-08 04:45:05 +02:00
|
|
|
* Class: #Form_EditForm textarea.htmleditor
|
|
|
|
*
|
|
|
|
* Add tinymce to HtmlEditorFields within the CMS.
|
2009-11-21 04:19:59 +01:00
|
|
|
*/
|
2010-05-08 04:45:05 +02:00
|
|
|
$('#Form_EditForm textarea.htmleditor').entwine({
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructor: onmatch
|
|
|
|
*/
|
2009-11-21 04:14:40 +01:00
|
|
|
onmatch : function() {
|
|
|
|
tinyMCE.execCommand("mceAddControl", true, this.attr('id'));
|
|
|
|
this.isChanged = function() {
|
|
|
|
return tinyMCE.getInstanceById(this.attr('id')).isDirty();
|
2009-11-21 04:19:59 +01:00
|
|
|
};
|
2009-11-21 04:14:40 +01:00
|
|
|
this.resetChanged = function() {
|
|
|
|
var inst = tinyMCE.getInstanceById(this.attr('id'));
|
|
|
|
if (inst) inst.startContent = tinymce.trim(inst.getContent({format : 'raw', no_events : 1}));
|
2009-11-21 04:19:59 +01:00
|
|
|
};
|
2009-11-21 04:14:40 +01:00
|
|
|
}
|
2009-11-21 04:19:59 +01:00
|
|
|
});
|
2009-11-21 04:14:40 +01:00
|
|
|
});
|
2009-11-21 03:38:20 +01:00
|
|
|
}(jQuery));
|