2007-07-19 12:40:05 +02:00
|
|
|
|
|
|
|
CMSForm = Class.extend('ChangeTracker').extend('Observable');
|
|
|
|
CMSForm.prototype = {
|
|
|
|
initialize : function(fn) {
|
|
|
|
this.ChangeTracker.initialize();
|
|
|
|
this.formName = fn;
|
|
|
|
this.prepareForm();
|
|
|
|
},
|
|
|
|
|
2008-07-04 01:17:55 +02:00
|
|
|
/**
|
|
|
|
* Trigger normal save event, helpful e.g. when enter key is pressed in
|
|
|
|
* single line input fields.
|
|
|
|
*/
|
|
|
|
onsubmit: function(e) {
|
|
|
|
this.save();
|
|
|
|
|
|
|
|
Event.stop(e);
|
|
|
|
return false;
|
|
|
|
},
|
|
|
|
|
2007-07-19 12:40:05 +02:00
|
|
|
/**
|
|
|
|
* Processing called whenever a page is loaded in the right - including the initial one
|
|
|
|
*/
|
|
|
|
prepareForm : function() {
|
|
|
|
ajaxActionsAtTop(this.id, 'form_actions_' + this.formName, this.formName);
|
2010-02-16 04:45:20 +01:00
|
|
|
|
|
|
|
// Update the nav items down the bottom
|
2010-07-25 23:00:15 +02:00
|
|
|
if($('SwitchView') && $('AjaxSwitchView')) {
|
2010-02-16 04:45:20 +01:00
|
|
|
$('SwitchView').innerHTML = $('AjaxSwitchView').innerHTML;
|
|
|
|
$('AjaxSwitchView').innerHTML = '';
|
|
|
|
Behaviour.apply('SwitchView'); // This is needed so calendar still works
|
|
|
|
}
|
2007-07-19 12:40:05 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Load actions from a string containing the HTML content
|
|
|
|
*/
|
|
|
|
loadActionsFromString : function(actionHTML) {
|
|
|
|
var actionHolder = $('form_actions_' + this.formName);
|
|
|
|
actionHolder.innerHTML = actionHTML;
|
|
|
|
prepareAjaxActions(actionHolder, this.id, this.formName);
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Close the form down without any corrective action, after its been deleted.
|
|
|
|
*/
|
|
|
|
closeIfSetTo: function(id) {
|
|
|
|
if(this.elements.ID && this.elements.ID.value == id) {
|
2008-10-28 05:32:30 +01:00
|
|
|
// Note: TinyMCE coupling
|
2009-04-29 03:44:28 +02:00
|
|
|
tinymce_removeAll();
|
|
|
|
this.innerHTML = "<p>" + ss.i18n._t('LeftAndMain.PAGEWASDELETED') + "</p>";
|
2007-07-19 12:40:05 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reload lose the form if the current page is open.
|
|
|
|
*/
|
|
|
|
reloadIfSetTo: function(id) {
|
|
|
|
if(this.elements.ID && this.elements.ID.value == id) {
|
|
|
|
this.getPageFromServer(id);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
close: function() {
|
|
|
|
this.innerHTML = "<p> </p>";
|
|
|
|
var actions;
|
|
|
|
if(actions = $('form_actions_' + this.formName)) {
|
|
|
|
actions.parentNode.removeChild(actions);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
updateStatus: function( newStatus ) {
|
|
|
|
|
|
|
|
if( $('Form_EditForm_Status') )
|
|
|
|
$('Form_EditForm_Status').innerHTML = "STATUS: " + newStatus;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Load a new page into the right-hand form.
|
|
|
|
*
|
|
|
|
* @param formContent string
|
|
|
|
* @param response object (optional)
|
|
|
|
* @param evalResponse boolean (optional)
|
|
|
|
*/
|
|
|
|
loadNewPage : function(formContent, response, evalResponse) {
|
|
|
|
//alert('here: ' + formContent);
|
|
|
|
var rightHTML = formContent;
|
|
|
|
|
|
|
|
// Rewrite # links
|
2008-04-26 08:36:52 +02:00
|
|
|
rightHTML = rightHTML.replace(/(<a[^>]+href *= *")#/g, '$1' + window.location.href.replace(/#.*$/,'') + '#');
|
2007-07-19 12:40:05 +02:00
|
|
|
|
|
|
|
// Rewrite iframe links (for IE)
|
|
|
|
rightHTML = rightHTML.replace(/(<iframe[^>]*src=")([^"]+)("[^>]*>)/g, '$1' + baseHref() + '$2$3');
|
|
|
|
|
2009-04-29 03:44:28 +02:00
|
|
|
// Note: TinyMCE coupling
|
|
|
|
tinymce_removeAll();
|
|
|
|
|
2007-07-19 12:40:05 +02:00
|
|
|
// Prepare iframes for removal, otherwise we get loading bugs
|
|
|
|
var i, allIframes = this.getElementsByTagName('iframe');
|
|
|
|
if(allIframes) for(i=0;i<allIframes.length;i++) {
|
|
|
|
allIframes[i].contentWindow.location.href = 'about:blank';
|
|
|
|
allIframes[i].parentNode.removeChild(allIframes[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(response && evalResponse) {
|
|
|
|
Ajax.Evaluator(response);
|
|
|
|
} else {
|
|
|
|
this.innerHTML = rightHTML;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get the form attributes from embedded fields
|
|
|
|
var attr;
|
|
|
|
|
|
|
|
for(attr in {'action':true ,'method':true,'enctype':true,'name':true}) {
|
|
|
|
if(this.elements['_form_' + attr]) {
|
|
|
|
this[attr] = this.elements['_form_' + attr].value;
|
|
|
|
this.elements['_form_' + attr].parentNode.removeChild(this.elements['_form_' + attr]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
allIframes = this.getElementsByTagName('iframe');
|
|
|
|
if(allIframes) for(i=0;i<allIframes.length;i++) {
|
|
|
|
try {
|
|
|
|
allIframes[i].contentWindow.location.href = allIframes[i].src;
|
2007-09-15 23:59:34 +02:00
|
|
|
} catch(er) { alert('Error in LeftAndMain_right.js CMSForm.loadNewPage: ' + er.message); }
|
2007-07-19 12:40:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
_TAB_DIVS_ON_PAGE = [];
|
|
|
|
|
2009-04-29 03:44:28 +02:00
|
|
|
//initTabstripe() become livequery in tabstrip.js, so we don't need to call it for each tab strip here.
|
2007-07-19 12:40:05 +02:00
|
|
|
|
2009-04-29 03:44:28 +02:00
|
|
|
|
2008-10-16 04:09:46 +02:00
|
|
|
// We assume that an evaluated response is generated by FormResponse
|
|
|
|
// which takes care of calling these method it
|
|
|
|
if (!evalResponse) {
|
|
|
|
if (this.prepareForm) this.prepareForm();
|
|
|
|
Behaviour.apply(this);
|
|
|
|
}
|
2007-07-19 12:40:05 +02:00
|
|
|
|
|
|
|
if(this.resetElements) this.resetElements();
|
|
|
|
|
|
|
|
window.ontabschanged();
|
2008-10-02 12:11:08 +02:00
|
|
|
|
|
|
|
// If there's a title field and it's got a "new XX" value, focus/select that first
|
|
|
|
// This is really a little too CMS-specific (as opposed to LeftAndMain), but the cleanup can happen after jQuery refactoring
|
2008-11-03 14:53:23 +01:00
|
|
|
if($('input#Form_EditForm_Title') && $('input#Form_EditForm_Title').value.match(/^new/i)) {
|
|
|
|
$('input#Form_EditForm_Title').select();
|
2008-10-02 12:11:08 +02:00
|
|
|
}
|
2007-07-19 12:40:05 +02:00
|
|
|
},
|
|
|
|
/**
|
|
|
|
* Save the contens of the form, by submitting it and resetting is changed checker
|
|
|
|
* on success.
|
2007-09-15 03:00:03 +02:00
|
|
|
*
|
2010-07-27 06:26:06 +02:00
|
|
|
* @param ifChanged boolean if true, only save changed fields
|
|
|
|
* @param callAfter function (optional) callback function to run after the AJAX request.
|
|
|
|
* @param action string (optional, default is 'save') action to call via AJAX.
|
2007-09-15 03:00:03 +02:00
|
|
|
* @param publish boolean (optional) whether to publish in addition to saving
|
2007-07-19 12:40:05 +02:00
|
|
|
*/
|
2009-03-18 11:51:34 +01:00
|
|
|
save: function(ifChanged, callAfter, action, publish) {
|
2007-07-19 12:40:05 +02:00
|
|
|
_AJAX_LOADING = true;
|
2008-10-28 05:32:30 +01:00
|
|
|
// Note: TinyMCE coupling
|
2007-07-19 12:40:05 +02:00
|
|
|
if(typeof tinyMCE != 'undefined') tinyMCE.triggerSave();
|
|
|
|
if(!action) action = "save";
|
|
|
|
|
|
|
|
var __callAfter = callAfter;
|
|
|
|
var __form = this;
|
|
|
|
|
2009-02-03 04:26:44 +01:00
|
|
|
if(__form.notify && __form.elements.ID != undefined) __form.notify('BeforeSave', __form.elements.ID.value);
|
2007-07-19 12:40:05 +02:00
|
|
|
|
|
|
|
// validate if required
|
|
|
|
if(this.validate && !this.validate()) {
|
|
|
|
// TODO Automatically switch to the tab/position of the first error
|
|
|
|
statusMessage("Validation failed.", "bad");
|
2008-10-08 04:00:39 +02:00
|
|
|
|
|
|
|
if($('Form_EditForm_action_save') && $('Form_EditForm_action_save').stopLoading) $('Form_EditForm_action_save').stopLoading();
|
|
|
|
|
2007-07-19 12:40:05 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
var success = function(response) {
|
|
|
|
Ajax.Evaluator(response);
|
2009-03-18 11:51:34 +01:00
|
|
|
|
2007-07-19 12:40:05 +02:00
|
|
|
__form.resetElements();
|
|
|
|
if(__callAfter) __callAfter();
|
2009-02-03 04:26:44 +01:00
|
|
|
if(__form.notify && __form.elements.ID != undefined) __form.notify('PageSaved', __form.elements.ID.value);
|
2008-10-08 04:00:39 +02:00
|
|
|
if($('Form_EditForm_action_save') && $('Form_EditForm_action_save').stopLoading) $('Form_EditForm_action_save').stopLoading();
|
2007-07-19 12:40:05 +02:00
|
|
|
_AJAX_LOADING = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(ifChanged) {
|
|
|
|
var data = this.serializeChangedFields('ID') + '&ajax=1&action_' + action + '=1';
|
|
|
|
} else {
|
|
|
|
var data = this.serializeAllFields() + '&ajax=1&action_' + action + '=1';
|
|
|
|
}
|
2007-09-15 03:00:03 +02:00
|
|
|
if(publish)
|
|
|
|
{
|
|
|
|
data += '&publish=1';
|
|
|
|
}
|
2007-07-19 12:40:05 +02:00
|
|
|
|
2008-10-03 02:48:34 +02:00
|
|
|
statusMessage(ss.i18n._t('CMSMAIN.SAVING'), null, true);
|
2008-11-18 02:48:50 +01:00
|
|
|
|
2007-07-19 12:40:05 +02:00
|
|
|
new Ajax.Request(this.action, {
|
|
|
|
method : this.method,
|
|
|
|
postBody: data,
|
|
|
|
onSuccess : success,
|
|
|
|
onFailure : function(response) {
|
|
|
|
errorMessage('Error saving content', response);
|
2008-10-08 04:00:39 +02:00
|
|
|
if($('Form_EditForm_action_save') && $('Form_EditForm_action_save').stopLoading) $('Form_EditForm_action_save').stopLoading();
|
2007-07-19 12:40:05 +02:00
|
|
|
_AJAX_LOADING = false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
loadPage_url : 'admin/getpage'
|
|
|
|
}
|
|
|
|
|
|
|
|
CMSRightForm = Class.extend('CMSForm');
|
|
|
|
CMSRightForm.prototype = {
|
|
|
|
intialize: function() {
|
|
|
|
this.CMSForm.initialize('right');
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Load the given URL (with &ajax=1) into this form
|
|
|
|
*/
|
|
|
|
loadURLFromServer : function(url) {
|
|
|
|
var urlParts = url.match( /ID=(\d+)/ );
|
|
|
|
var id = urlParts ? urlParts[1] : null;
|
|
|
|
|
|
|
|
if( !url.match( /^https?:\/\/.*/ ) )
|
|
|
|
url = document.getElementsByTagName('base')[0].href + url;
|
|
|
|
|
|
|
|
new Ajax.Request( url + '&ajax=1', {
|
|
|
|
asynchronous : true,
|
|
|
|
onSuccess : function( response ) {
|
|
|
|
$('Form_EditForm').successfullyReceivedPage(response,id);
|
|
|
|
},
|
|
|
|
onFailure : function(response) {
|
|
|
|
alert(response.responseText);
|
|
|
|
errorMessage('error loading page',response);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
successfullyReceivedPage : function(response,pageID) {
|
|
|
|
var loadingNode = $('sitetree').loadingNode;
|
|
|
|
|
|
|
|
if( loadingNode && pageID && parseInt( $('sitetree').getIdxOf( loadingNode ) ) != pageID ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// must wait until the javascript has finished
|
|
|
|
document.body.style.cursor = 'wait';
|
|
|
|
|
|
|
|
this.loadNewPage(response.responseText);
|
|
|
|
|
|
|
|
var subform;
|
|
|
|
if(subform = $('Form_MemberForm')) subform.close();
|
|
|
|
if(subform = $('Form_SubForm')) subform.close();
|
|
|
|
|
|
|
|
if(this.elements.ID) {
|
|
|
|
this.notify('PageLoaded', this.elements.ID.value);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(this.receivingID) {
|
|
|
|
// Treenode might not exist if that part of the tree is closed
|
|
|
|
var treeNode = loadingNode ? loadingNode : $('sitetree').getTreeNodeByIdx(this.receivingID);
|
|
|
|
if(treeNode) {
|
|
|
|
$('sitetree').setCurrentByIdx(treeNode.getIdx());
|
|
|
|
treeNode.removeNodeClass('loading');
|
|
|
|
}
|
|
|
|
statusMessage('');
|
|
|
|
}
|
2010-01-07 03:01:16 +01:00
|
|
|
|
2007-07-19 12:40:05 +02:00
|
|
|
// must wait until the javascript has finished
|
|
|
|
document.body.style.cursor = 'default';
|
|
|
|
|
|
|
|
},
|
|
|
|
didntReceivePage : function(response) {
|
|
|
|
errorMessage('error loading page', response);
|
|
|
|
$('sitetree').getTreeNodeByIdx(this.elements.ID.value).removeNodeClass('loading');
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Request a page from the server via Ajax
|
|
|
|
*/
|
|
|
|
getPageFromServer : function(id, treeNode) {
|
|
|
|
// if(id && id.match(/^[A-Za-z0-9_]+$/)) {
|
|
|
|
if(id && (id == 'root' || parseInt(id) == id || (id.substr && id.substr(0,3) == 'new') )) {
|
|
|
|
this.receivingID = id;
|
|
|
|
|
|
|
|
// Treenode might not exist if that part of the tree is closed
|
|
|
|
if(!treeNode) treeNode = $('sitetree').getTreeNodeByIdx(id);
|
|
|
|
|
|
|
|
if(treeNode) {
|
|
|
|
$('sitetree').loadingNode = treeNode;
|
|
|
|
treeNode.addNodeClass('loading');
|
|
|
|
url = treeNode.aTag.href + (treeNode.aTag.href.indexOf('?')==-1?'?':'&') + 'ajax=1';
|
|
|
|
}
|
|
|
|
if(SiteTreeHandlers.loadPage_url) {
|
|
|
|
var sep = (SiteTreeHandlers.loadPage_url.indexOf('?') == -1) ? '?' : '&';
|
|
|
|
url = SiteTreeHandlers.loadPage_url + sep + 'ID=' + id;
|
|
|
|
}
|
2009-01-10 12:36:30 +01:00
|
|
|
|
|
|
|
// used to set language in CMSMain->init()
|
|
|
|
var lang = $('LangSelector') ? $F('LangSelector') : null;
|
|
|
|
if(lang) {
|
2009-03-20 09:49:27 +01:00
|
|
|
url += '&locale='+lang;
|
2009-01-10 12:36:30 +01:00
|
|
|
}
|
2007-07-19 12:40:05 +02:00
|
|
|
|
|
|
|
statusMessage("loading...");
|
|
|
|
this.loadURLFromServer(url);
|
|
|
|
} else {
|
|
|
|
throw("getPageFromServer: Bad page ID: " + id);
|
|
|
|
}
|
2007-11-01 23:39:25 +01:00
|
|
|
}
|
2007-07-19 12:40:05 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the status field
|
|
|
|
*/
|
2007-11-01 23:31:27 +01:00
|
|
|
/*setStatus: function(newStatus) {
|
2007-07-19 12:40:05 +02:00
|
|
|
var statusLabel = document.getElementsBySelector('label.pageStatusMessage')[0];
|
|
|
|
if(statusLabel) statusLabel.innerHTML = "STATUS: " + newStatus;
|
2007-11-01 23:31:27 +01:00
|
|
|
}*/
|
2007-07-19 12:40:05 +02:00
|
|
|
}
|
|
|
|
|
2008-12-04 23:38:58 +01:00
|
|
|
CMSForm.applyTo('#Form_SubForm');
|
2007-07-19 12:40:05 +02:00
|
|
|
CMSRightForm.applyTo('#Form_EditForm', 'right');
|
|
|
|
|
|
|
|
function action_save_right() {
|
|
|
|
_AJAX_LOADING = true;
|
2008-10-03 02:48:34 +02:00
|
|
|
$('Form_EditForm_action_save').value = ss.i18n._t('CMSMAIN.SAVING');
|
2007-09-15 03:11:50 +02:00
|
|
|
$('Form_EditForm_action_save').className = 'action loading';
|
2008-10-08 04:00:39 +02:00
|
|
|
$('Form_EditForm_action_save').stopLoading = function() {
|
|
|
|
if($('Form_EditForm_action_save') && $('Form_EditForm_action_save').className.indexOf('loading') != -1) {
|
|
|
|
$('Form_EditForm_action_save').value = 'Save';
|
|
|
|
Element.removeClassName($('Form_EditForm_action_save'), 'loading');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-07-19 12:40:05 +02:00
|
|
|
$('Form_EditForm').save(false);
|
|
|
|
}
|
|
|
|
|
2010-04-07 06:10:32 +02:00
|
|
|
function action_save_siteconfig_right() {
|
|
|
|
_AJAX_LOADING = true;
|
|
|
|
if(typeof tinyMCE != 'undefined') tinyMCE.triggerSave();
|
|
|
|
$('Form_EditForm_action_save_siteconfig').value = ss.i18n._t('CMSMAIN.SAVING');
|
|
|
|
$('Form_EditForm_action_save_siteconfig').className = 'action loading';
|
|
|
|
|
|
|
|
$('Form_EditForm').save(null, function() {
|
|
|
|
if($('Form_EditForm_action_save_siteconfig') && $('Form_EditForm_action_save_siteconfig').className.indexOf('loading') != -1) {
|
|
|
|
$('Form_EditForm_action_save_siteconfig').value = 'Save';
|
|
|
|
Element.removeClassName($('Form_EditForm_action_save_siteconfig'), 'loading');
|
|
|
|
}
|
|
|
|
}, 'save_siteconfig');
|
|
|
|
}
|
|
|
|
|
2007-07-19 12:40:05 +02:00
|
|
|
/**
|
|
|
|
* Handle auto-saving. Detects if changes have been made, and if so save everything on the page.
|
|
|
|
* If confirmation is true it will ask for confirmation.
|
|
|
|
*/
|
|
|
|
function autoSave(confirmation, callAfter) {
|
2008-10-28 05:32:30 +01:00
|
|
|
// Note: TinyMCE coupling
|
2007-07-19 12:40:05 +02:00
|
|
|
if(typeof tinyMCE != 'undefined') tinyMCE.triggerSave();
|
|
|
|
|
|
|
|
var __forms = []
|
|
|
|
if($('Form_EditForm')) __forms.push($('Form_EditForm'));
|
|
|
|
if($('Form_SubForm')) __forms.push($('Form_SubForm'));
|
|
|
|
if($('Form_MemberForm')) __forms.push($('Form_MemberForm'));
|
|
|
|
|
|
|
|
var __somethingHasChanged = false;
|
|
|
|
var __callAfter = callAfter;
|
|
|
|
|
|
|
|
__forms.each(function(form) {
|
|
|
|
if(form.isChanged && form.isChanged()) {
|
|
|
|
__somethingHasChanged = true;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
if(__somethingHasChanged) {
|
2007-09-14 21:29:12 +02:00
|
|
|
// Note: discard and cancel options are no longer used since switching to confirm dialog.
|
|
|
|
// save is still used if confirmation = false
|
|
|
|
var options = {
|
|
|
|
save: function() {
|
2008-10-03 02:48:34 +02:00
|
|
|
statusMessage(ss.i18n._t('CMSMAIN.SAVING'), '', true);
|
2007-09-14 21:29:12 +02:00
|
|
|
var i;
|
|
|
|
for(i=0;i<__forms.length;i++) {
|
|
|
|
if(__forms[i].isChanged && __forms[i].isChanged()) {
|
|
|
|
if(i == 0) __forms[i].save(true, __callAfter);
|
|
|
|
else __forms[i].save(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
discard: function() {
|
|
|
|
__forms.each(function(form) { form.resetElements(false); });
|
|
|
|
if(__callAfter) __callAfter();
|
|
|
|
},
|
|
|
|
cancel: function() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-09-14 21:28:41 +02:00
|
|
|
if(confirmation ) {
|
2009-01-05 07:17:59 +01:00
|
|
|
if(confirm(ss.i18n._t('LeftAndMain.CONFIRMUNSAVED')))
|
2007-09-14 21:28:41 +02:00
|
|
|
{
|
|
|
|
// OK was pressed, call function for what was clicked on
|
2007-07-19 12:40:05 +02:00
|
|
|
if(__callAfter) __callAfter();
|
2007-09-14 21:28:41 +02:00
|
|
|
} else {
|
2007-09-14 21:29:12 +02:00
|
|
|
// Cancel was pressed, stay on the current page
|
2007-09-14 21:30:11 +02:00
|
|
|
return false;
|
2007-07-19 12:40:05 +02:00
|
|
|
}
|
2007-09-14 21:28:41 +02:00
|
|
|
} else {
|
|
|
|
options.save();
|
2007-07-19 12:40:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
if(__callAfter) __callAfter();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
window.name = windowName('cms');
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return a unique window name that contains the URL
|
|
|
|
*/
|
|
|
|
function windowName(suffix) {
|
2009-02-03 04:22:20 +01:00
|
|
|
var base = document.getElementsByTagName('base')[0].href.replace('~','').replace('http://','').replace(/\//g,'_').replace(/\./g,'_');
|
2007-07-19 12:40:05 +02:00
|
|
|
return base + suffix;
|
2009-04-29 03:44:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove all the currently active TinyMCE editors.
|
|
|
|
* Note: everything that calls this has an inappropriate coupling to TinyMCE.
|
|
|
|
* Perhaps an observer pattern could be used, where TinyMCE listens to a onBeforeCMSPageLoad
|
|
|
|
* event?
|
|
|
|
*/
|
|
|
|
function tinymce_removeAll() {
|
|
|
|
if((typeof tinymce != 'undefined') && tinymce.EditorManager) {
|
|
|
|
var id;
|
|
|
|
for(id in tinymce.EditorManager.editors) {
|
|
|
|
tinymce.EditorManager.editors[id].remove();
|
|
|
|
}
|
|
|
|
tinymce.EditorManager.editors = {};
|
|
|
|
}
|
|
|
|
|
2010-01-13 00:54:29 +01:00
|
|
|
}
|