MINOR Removed hardcoding of history ajax links

This commit is contained in:
Ingo Schommer 2011-09-19 21:34:46 +02:00
parent b924fdbde6
commit ab9d62b53c
2 changed files with 10 additions and 4 deletions

View File

@ -221,6 +221,12 @@ class CMSPageHistoryController extends CMSMain {
$hiddenID->setValue($id);
$form->unsetValidator();
$form->addExtraClass('cms-versions-form'); // placeholder, necessary for $.metadata() to work
$form->addExtraClass(Convert::raw2json(array(
'link-tmpl-compare' => Controller::join_links($this->Link('compare'), '%s', '%s', '%s'),
'link-tmpl-show' => Controller::join_links($this->Link('show'), '%s', '%s'),
)));
return $form;
}

View File

@ -54,23 +54,23 @@
if(!id) return false;
var button, url, selected, to, from, compare, data;
var button, url, selected, to, from, compare, data, metadata;
metadata = this.metadata({type: 'class'});
compare = (this.find(":input[name=CompareMode]").is(":checked"));
selected = this.find("table input[type=checkbox]").filter(":checked");
if(compare) {
if(selected.length != 2) return false;
to = selected.eq(0).val();
from = selected.eq(1).val();
button = this.find(':submit[name=action_doCompare]');
url = 'admin/page/history/compare/'+ [id,from,to].join('/') +"/";
url = ss.i18n.sprintf(metadata['link-tmpl-compare'], id,from,to);
}
else {
to = selected.eq(0).val();
button = this.find(':submit[name=action_doShowVersion]');
url = 'admin/page/history/show/'+ [id,to].join('/') + "/";
url = ss.i18n.sprintf(metadata['link-tmpl-show'], id,to);
}
window.History.pushState({selector: '.cms-edit-form'}, '', url);