Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

BUGFIX Changed TreeNodeAPI->setNodeIcon() javascript to not require t…

…he old classname to replace. All PHP classnames stored in CSS class strings now have the prefix 'class-' which makes them easy to detect without context

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@92668 467b73ca-7a2a-4603-9d3b-597d59a354a9
  • Loading branch information...
commit fef02e8b1ead2a0d8ff542e2911a6b23bcd2f71d 1 parent a9c257b
@chillu chillu authored
Showing with 7 additions and 3 deletions.
  1. +7 −3 javascript/LeftAndMain_left.js
View
10 javascript/LeftAndMain_left.js
@@ -133,9 +133,9 @@ TreeAPI.prototype = {
});
},
- setNodeIcon: function(idx, oldClassName, newClassName) {
+ setNodeIcon: function(idx, newClassName) {
this.performOnTreeNode(idx, function(treeNode) {
- treeNode.className = treeNode.className.replace(oldClassName,newClassName);
+ treeNode.className = treeNode.className.replace(/(class-)[^\s]*/,'$1' + newClassName);
treeNode.aSpan.className = 'a ' + treeNode.className.replace('closed','spanClosed');
var aTag = treeNode.getElementsByTagName('a')[0];
aTag.title = 'Page type: ' + newClassName;
@@ -149,7 +149,11 @@ TreeAPI.prototype = {
setNodeParentID: function (idx, parentID) {
var treeNode = this.getTreeNodeByIdx(idx);
var parentNode = this.getTreeNodeByIdx(parentID);
- parentNode.appendTreeNode(treeNode);
+ var currentParentNode = jQuery(treeNode).parents('li')[0];
+ // Only change parent node if its different than the current,
+ // otherwise we affect the sort order unnecessarily due to
+ // appendTreeNode() not looking at existing sorts
+ if(!currentParentNode || parentNode != currentParentNode) parentNode.appendTreeNode(treeNode);
},
setCurrentByIdx : function(idx) {

0 comments on commit fef02e8

Please sign in to comment.
Something went wrong with that request. Please try again.