2007-07-19 12:40:05 +02:00
|
|
|
/**
|
|
|
|
* Generic base class for all side panels
|
|
|
|
*/
|
|
|
|
SidePanel = Class.create();
|
|
|
|
SidePanel.prototype = {
|
|
|
|
initialize : function() {
|
|
|
|
this.body = this.getElementsByTagName('div')[0];
|
|
|
|
},
|
|
|
|
destroy: function() {
|
|
|
|
this.body = null;
|
|
|
|
},
|
|
|
|
onshow : function() {
|
|
|
|
this.onresize();
|
|
|
|
this.body.innerHTML = '<p>loading...</p>';
|
|
|
|
this.ajaxGetPanel(this.afterPanelLoaded);
|
|
|
|
},
|
|
|
|
ajaxGetPanel : function(onComplete) {
|
|
|
|
new Ajax.Updater(this.body, this.ajaxURL(), {
|
|
|
|
onComplete : onComplete ? onComplete.bind(this) : null,
|
|
|
|
onFailure : this.ajaxPanelError
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
ajaxPanelError : function (response) {
|
|
|
|
errorMessage("error getting side panel", response);
|
|
|
|
},
|
|
|
|
|
|
|
|
ajaxURL : function() {
|
|
|
|
var srcName = this.id.replace('_holder','');
|
|
|
|
var id = $('Form_EditForm').elements.ID;
|
|
|
|
if(id) id = id.value; else id = "";
|
2009-05-12 06:49:25 +02:00
|
|
|
|
2008-10-08 04:00:39 +02:00
|
|
|
// This assumes that admin/cms/ refers to CMSMain
|
2009-05-12 06:49:25 +02:00
|
|
|
var url = 'admin/cms/' + srcName + '/' + id + '?ajax=1';
|
|
|
|
if($('Form_EditForm_Locale')) url += "&locale=" + $('Form_EditForm_Locale').value;
|
|
|
|
return url;
|
2007-07-19 12:40:05 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
afterPanelLoaded : function() {
|
|
|
|
},
|
|
|
|
onpagechanged : function() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SidePanelRecord = Class.create();
|
|
|
|
SidePanelRecord.prototype = {
|
|
|
|
onclick : function(event) {
|
|
|
|
Event.stop(event);
|
|
|
|
$('Form_EditForm').getPageFromServer(this.getID());
|
|
|
|
},
|
|
|
|
destroy: function() {
|
|
|
|
this.onclick = null;
|
|
|
|
},
|
|
|
|
getID : function() {
|
|
|
|
if(this.href.match(/\/([^\/]+)$/)) return parseInt(RegExp.$1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-21 03:35:22 +01:00
|
|
|
|
2007-07-19 12:40:05 +02:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Version list
|
|
|
|
*/
|
|
|
|
VersionList = Class.extend('SidePanel');
|
|
|
|
VersionList.prototype = {
|
|
|
|
initialize : function() {
|
|
|
|
this.mode = 'view';
|
|
|
|
this.SidePanel.initialize();
|
|
|
|
},
|
|
|
|
destroy: function() {
|
|
|
|
this.SidePanel = null;
|
|
|
|
this.onclose = null;
|
|
|
|
},
|
|
|
|
|
|
|
|
ajaxURL : function() {
|
|
|
|
return this.SidePanel.ajaxURL() + '&unpublished=' + ($('versions_showall').checked ? 1 : 0);
|
|
|
|
},
|
|
|
|
afterPanelLoaded : function() {
|
|
|
|
this.idLoaded = $('Form_EditForm').elements.ID.value;
|
|
|
|
VersionItem.applyTo('#' + this.id + ' tbody tr');
|
|
|
|
},
|
|
|
|
|
|
|
|
select : function(pageID, versionID, sourceEl) {
|
|
|
|
if(this.mode == 'view') {
|
|
|
|
sourceEl.select();
|
2009-05-12 06:49:25 +02:00
|
|
|
var url = 'admin/getversion/' + pageID + '/' + versionID;
|
|
|
|
if($('Form_EditForm_Locale')) url += "?locale=" + $('Form_EditForm_Locale').value;
|
|
|
|
$('Form_EditForm').loadURLFromServer(url);
|
2007-07-19 12:40:05 +02:00
|
|
|
$('viewArchivedSite').style.display = '';
|
|
|
|
$('viewArchivedSite').getVars = '?archiveDate=' + sourceEl.getElementsByTagName('td')[1].className;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
$('viewArchivedSite').style.display = 'none';
|
|
|
|
|
|
|
|
if(this.otherVersionID) {
|
|
|
|
sourceEl.select();
|
|
|
|
this.otherSourceEl.select(true);
|
|
|
|
statusMessage('Loading comparison...');
|
2009-05-12 06:49:25 +02:00
|
|
|
var url = 'admin/compareversions/' + pageID + '/?From=' + this.otherVersionID + '&To=' + versionID;
|
|
|
|
if($('Form_EditForm_Locale')) url += "&locale=" + $('Form_EditForm_Locale').value;
|
|
|
|
$('Form_EditForm').loadURLFromServer(url);
|
2007-07-19 12:40:05 +02:00
|
|
|
} else {
|
|
|
|
sourceEl.select();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.otherVersionID = versionID;
|
|
|
|
this.otherSourceEl = sourceEl;
|
|
|
|
},
|
|
|
|
onpagechanged : function() {
|
|
|
|
if(this.idLoaded != $('Form_EditForm').elements.ID.value) {
|
|
|
|
this.body.innerHTML = '<p>loading...</p>';
|
|
|
|
this.ajaxGetPanel(this.afterPanelLoaded);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
refresh : function() {
|
|
|
|
this.ajaxGetPanel(this.afterPanelLoaded);
|
|
|
|
},
|
|
|
|
onclose : function() {
|
2007-10-29 02:13:21 +01:00
|
|
|
if(this.idLoaded) {
|
|
|
|
$('Form_EditForm').getPageFromServer(this.idLoaded);
|
|
|
|
}
|
|
|
|
$('viewArchivedSite').style.display = 'none';
|
2007-07-19 12:40:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-21 03:35:22 +01:00
|
|
|
VersionItem = Class.create();
|
2007-07-19 12:40:05 +02:00
|
|
|
VersionItem.prototype = {
|
|
|
|
initialize : function() {
|
|
|
|
this.holder = $('versions_holder');
|
|
|
|
},
|
|
|
|
|
|
|
|
destroy: function() {
|
|
|
|
this.holder = null;
|
|
|
|
this.onclick = null;
|
|
|
|
},
|
|
|
|
|
|
|
|
onclick : function() {
|
|
|
|
this.holder.select(this.pageID(), this.versionID(), this);
|
|
|
|
},
|
|
|
|
idPair : function() {
|
|
|
|
if(this.id.match(/page-([^-]+)-version-([^-]+)$/)) {
|
|
|
|
return RegExp.$1 + '/' + RegExp.$2;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
pageID : function() {
|
|
|
|
if(this.id.match(/page-([^-]+)-version-([^-]+)$/)) {
|
|
|
|
return RegExp.$1;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
versionID : function() {
|
|
|
|
if(this.id.match(/page-([^-]+)-version-([^-]+)$/)) {
|
|
|
|
return RegExp.$2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
VersionAction = Class.create();
|
|
|
|
VersionAction.prototype = {
|
|
|
|
initialize: function() {
|
|
|
|
this.holder = $('versions_holder');
|
|
|
|
|
|
|
|
this.showallCheckbox = $('versions_showall');
|
|
|
|
this.showallCheckbox.holder = this;
|
|
|
|
this.showallCheckbox.onclick = this.showall_change;
|
2007-09-15 02:48:48 +02:00
|
|
|
|
|
|
|
this.comparemodeCheckbox = $('versions_comparemode');
|
|
|
|
this.comparemodeCheckbox.holder = this;
|
|
|
|
this.comparemodeCheckbox.onclick = function() { this.holder.comparemode_change(this.checked); }
|
2007-07-19 12:40:05 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
showall_change: function() {
|
|
|
|
this.holder.holder.refresh();
|
|
|
|
},
|
|
|
|
|
|
|
|
destroy: function() {
|
2007-09-15 02:48:48 +02:00
|
|
|
if(this.comparemodeCheckbox) {
|
|
|
|
this.comparemodeCheckbox.holder = null;
|
|
|
|
this.comparemodeCheckbox.onclick = null;
|
2007-07-19 12:40:05 +02:00
|
|
|
}
|
|
|
|
if(this.showallCheckbox) {
|
|
|
|
this.showallCheckbox.holder = null;
|
|
|
|
this.showallCheckbox.onchange = null;
|
|
|
|
}
|
|
|
|
this.holder = null;
|
2007-09-15 02:48:48 +02:00
|
|
|
this.comparemodeCheckbox = null;
|
2007-07-19 12:40:05 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
2007-09-15 02:48:48 +02:00
|
|
|
* Handler function when comparemode checkbox is clicked
|
2007-07-19 12:40:05 +02:00
|
|
|
*/
|
2007-09-15 02:48:48 +02:00
|
|
|
comparemode_change: function(isChecked) {
|
|
|
|
if (true == isChecked) {
|
|
|
|
return this.compare();
|
|
|
|
} else {
|
|
|
|
return this.view();
|
2007-07-19 12:40:05 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
view: function() {
|
|
|
|
this.holder.mode = 'view';
|
|
|
|
},
|
|
|
|
|
|
|
|
compare: function() {
|
|
|
|
this.holder.mode = 'compare';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
VersionItem.applyTo('#versions_holder tbody tr');
|
|
|
|
VersionAction.applyTo('#versions_holder p.pane_actions');
|
|
|
|
VersionList.applyTo('#versions_holder');
|
|
|
|
|