diff --git a/admin/javascript/LeftAndMain.AddForm.js b/admin/javascript/LeftAndMain.AddForm.js
index f65526d3c..896f0e47b 100644
--- a/admin/javascript/LeftAndMain.AddForm.js
+++ b/admin/javascript/LeftAndMain.AddForm.js
@@ -107,49 +107,46 @@
/**
* Function: refresh
+ * This is called after each change event of PageType dropdown
*
* Parameters:
* (DOMElement) selectedNode
*/
refresh: function(selectedNode) {
- // Note: Uses siteTreeHints global
+
var tree = this.getTree(),
selectedNode = selectedNode || $(tree).jstree('get_selected')
origOptions = this.getOrigOptions(),
- dropdown = this.find('select[name=PageType]');
+ dropdown = this.find('select[name=PageType]'),
+ disallowed = [],
+ className = (selectedNode) ? selectedNode.getClassname() : null,
+ siteTreeHints = $.parseJSON($('#sitetree_ul').attr('data-hints')),
+ disableDropDown = true,
+ selectedOption = dropdown.val();
// Clear all existing '));
- }
- } else {
- // No tree node selected, reset to original elements
- $.each(origOptions, function(i, optProps) {
- if(optProps) dropdown.append($(''));
- });
+ //Use tree hints to find allowed children for this node
+ if (className && typeof siteTreeHints !== 'undefined') {
+ disallowed = siteTreeHints[className].disallowedChildren;
}
- // TODO Re-select the currently selected element
+ $.each(origOptions, function(i, optProps) {
+ if ($.inArray(i, disallowed) === -1 && optProps) {
+ dropdown.append($(''));
+ disableDropDown = false;
+ }
+ });
// Disable dropdown if no elements are selectable
- if(allowed) dropdown.removeAttr('disabled');
+ if (!disableDropDown) dropdown.removeAttr('disabled');
else dropdown.attr('disabled', 'disabled');
-
+
+ //Re-select the currently selected element
+ if (selectedOption) dropdown.val(selectedOption);
+
// Set default child (optional)
if(selectedNode.hints && selectedNode.hints.defaultChild) {
dropdown.val(selectedNode.hints.defaultChild);
diff --git a/admin/javascript/LeftAndMain.Tree.js b/admin/javascript/LeftAndMain.Tree.js
index e5cf99189..dae05e6af 100755
--- a/admin/javascript/LeftAndMain.Tree.js
+++ b/admin/javascript/LeftAndMain.Tree.js
@@ -3,20 +3,24 @@
*/
(function($) {
-
+
$.entwine('ss', function($){
$('.cms-tree').entwine({
+
+ Hints: null,
+
onmatch: function() {
this._super();
+ this.setHints($.parseJSON(this.attr('data-hints')));
+
/**
* @todo Icon and page type hover support
* @todo Sorting of sub nodes (originally placed in context menu)
* @todo Refresh after language