BUGFIX Fixed ParentType selector javascript in SiteTree->getCMSFields()

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@92676 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2009-11-21 02:39:18 +00:00
parent 21160c6ccb
commit 1bac2dc4aa
2 changed files with 20 additions and 25 deletions

View File

@ -67,6 +67,10 @@
border: none;
padding: 0;
}
.right form .parentTypeSelector {
margin-left: 0;
}
.right form .dropdown,
.right form .countrydropdown {

View File

@ -139,34 +139,25 @@ var ss_MainLayout;
/**
* @class ParentID field combination - mostly toggling between
* the two radiobuttons and setting the hidden "ParentID" field
* @name ss.EditForm.ParentType
* @name ss.EditForm.parentTypeSelector
*/
$('#Form_EditForm_ParentType').concrete('ss', function($){
return/** @lends ss.EditForm.ParentType */{
$('#Form_EditForm .parentTypeSelector').concrete('ss', function($){
return/** @lends ss.EditForm.parentTypeSelector */{
onmatch : function() {
var parentTypeRootEl = $('#Form_EditForm_ParentType_root');
var parentTypeSubpageEl = $('#Form_EditForm_ParentType_subpage');
if(parentTypeRootEl) {
parentTypeRootEl.onclick = this._rootClick.bind(this);
}
if(parentTypeSubpageEl) {
parentTypeSubpageEl.onclick = this.showHide;
}
this.showHide();
var self = this;
this.find(':input[name=ParentType]').bind('click', function(e) {self._toggleSelection(e);});
this._toggleSelection();
},
_rootClick : function() {
$('#Form_EditForm_ParentID').val(0);
this.showHide();
},
showHide : function() {
var parentTypeRootEl = $('#Form_EditForm_ParentType_root');
if(parentTypeRootEl && parentTypeRootEl.checked) {
$('#ParentID').hide();
} else {
$('#ParentID').show();
}
_toggleSelection: function(e) {
var selected = this.find(':input[name=ParentType]:checked').val();
// reset parent id if 'root' radiobutton is selected
if(selected == 'root') this.find(':input[name=ParentID]').val(0);
console.debug(selected);
// toggle tree dropdown based on selection
this.find('#ParentID').toggle(selected != 'root');
}
};
});