Permalink
Browse files

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
  • Loading branch information...
1 parent 21160c6 commit 1bac2dc4aaf3510ad6d4a95adb42fdd1801060d8 @chillu chillu committed Nov 21, 2009
Showing with 20 additions and 25 deletions.
  1. +4 −0 css/cms_right.css
  2. +16 −25 javascript/CMSMain.js
View
@@ -67,6 +67,10 @@
border: none;
padding: 0;
}
+
+ .right form .parentTypeSelector {
+ margin-left: 0;
+ }
.right form .dropdown,
.right form .countrydropdown {
View
@@ -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();
- },
-
- _rootClick : function() {
- $('#Form_EditForm_ParentID').val(0);
- this.showHide();
+ var self = this;
+
+ this.find(':input[name=ParentType]').bind('click', function(e) {self._toggleSelection(e);});
+
+ this._toggleSelection();
},
-
- 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');
}
};
});

0 comments on commit 1bac2dc

Please sign in to comment.