2011-04-24 01:05:01 +02:00
|
|
|
(function($) {
|
|
|
|
$.entwine('ss', function($){
|
|
|
|
$('.cms-page-add-form-dialog').entwine({
|
|
|
|
onmatch: function() {
|
|
|
|
this.dialog({
|
|
|
|
autoOpen: false,
|
|
|
|
bgiframe: true,
|
|
|
|
modal: true,
|
|
|
|
height: 400,
|
|
|
|
width: 600,
|
|
|
|
ghost: true
|
|
|
|
});
|
|
|
|
this._super();
|
2012-05-14 01:43:55 +02:00
|
|
|
},
|
|
|
|
onunmatch: function() {
|
|
|
|
this._super();
|
2011-04-24 01:05:01 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
$('.cms-page-add-form-dialog input[name=PageType]').entwine({
|
|
|
|
onmatch: function() {
|
|
|
|
if(this.is(':checked')) this.trigger('click');
|
|
|
|
this._super();
|
|
|
|
},
|
2012-05-14 01:43:55 +02:00
|
|
|
onunmatch: function() {
|
|
|
|
this._super();
|
|
|
|
},
|
2011-04-24 01:05:01 +02:00
|
|
|
onclick: function() {
|
2011-05-08 13:36:55 +02:00
|
|
|
var el = this.parents('li:first');
|
|
|
|
el.setSelected(true);
|
|
|
|
el.siblings().setSelected(false);
|
|
|
|
}
|
|
|
|
});
|
2012-05-07 14:30:08 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Reset the parent node selection if the type is
|
|
|
|
* set back to "toplevel page", to avoid submitting inconsistent state.
|
|
|
|
*/
|
|
|
|
$(".cms-add-form .parent-mode :input").entwine({
|
|
|
|
onclick: function(e) {
|
|
|
|
if(this.val() == 'top') {
|
|
|
|
var parentField = this.closest('form').find('#ParentID .TreeDropdownField');
|
|
|
|
parentField.setValue('');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2011-05-08 13:36:55 +02:00
|
|
|
|
|
|
|
$(".cms-add-form").entwine({
|
|
|
|
onmatch: function() {
|
|
|
|
var self = this;
|
|
|
|
this.find('#ParentID .TreeDropdownField').bind('change', function() {
|
|
|
|
self.updateTypeList();
|
|
|
|
});
|
2012-01-05 17:01:48 +01:00
|
|
|
this.updateTypeList();
|
2012-05-11 07:37:31 +02:00
|
|
|
this._super();
|
2011-05-08 13:36:55 +02:00
|
|
|
},
|
2012-05-14 01:43:55 +02:00
|
|
|
onunmatch: function() {
|
|
|
|
this._super();
|
|
|
|
},
|
2011-05-08 13:36:55 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Limit page type selection based on parent class.
|
|
|
|
* Similar implementation to LeftAndMain.Tree.js.
|
|
|
|
*/
|
|
|
|
updateTypeList: function() {
|
|
|
|
var hints = this.find('.hints').data('hints'),
|
|
|
|
metadata = this.find('#ParentID .TreeDropdownField').data('metadata'),
|
|
|
|
id = this.find('#ParentID .TreeDropdownField').getValue(),
|
2012-01-05 17:01:48 +01:00
|
|
|
newClassName = metadata ? metadata.ClassName : null,
|
2012-01-09 13:20:11 +01:00
|
|
|
hintKey = newClassName ? newClassName : 'Root',
|
2012-01-22 11:58:24 +01:00
|
|
|
hint = (typeof hints[hintKey] != 'undefined') ? hints[hintKey] : null;
|
2012-01-09 13:20:11 +01:00
|
|
|
|
|
|
|
var disallowedChildren = (hint && typeof hint.disallowedChildren != 'undefined') ? hint.disallowedChildren : [],
|
|
|
|
defaultChildClass = (hint && typeof hint.defaultChild != 'undefined') ? hint.defaultChild : null;
|
2011-05-08 13:36:55 +02:00
|
|
|
|
|
|
|
// Limit selection
|
|
|
|
this.find('#PageType li').each(function() {
|
|
|
|
var className = $(this).find('input').val(), isAllowed = ($.inArray(className, disallowedChildren) == -1);
|
|
|
|
$(this).setEnabled(isAllowed);
|
|
|
|
});
|
|
|
|
|
|
|
|
// Set default child selection, or fall back to first available option
|
|
|
|
if(defaultChildClass) {
|
|
|
|
var selectedEl = this.find('#PageType li input[value=' + defaultChildClass + ']').parents('li:first');
|
|
|
|
} else {
|
|
|
|
var selectedEl = this.find('#PageType li:not(.disabled):first');
|
|
|
|
}
|
|
|
|
selectedEl.setSelected(true);
|
|
|
|
selectedEl.siblings().setSelected(false);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
$(".cms-add-form #PageType li").entwine({
|
2012-01-05 17:01:48 +01:00
|
|
|
onclick: function() {
|
|
|
|
this.setSelected(true);
|
|
|
|
},
|
2011-05-08 13:36:55 +02:00
|
|
|
setSelected: function(bool) {
|
2012-01-06 16:54:16 +01:00
|
|
|
var input = this.find('input');
|
2011-05-08 13:36:55 +02:00
|
|
|
this.toggleClass('selected', bool);
|
2012-01-06 16:54:16 +01:00
|
|
|
if(bool && !input.is(':disabled')) {
|
2012-01-05 17:01:48 +01:00
|
|
|
this.siblings().setSelected(false);
|
2012-01-06 16:54:16 +01:00
|
|
|
input.attr('checked', 'checked');
|
2012-01-05 17:01:48 +01:00
|
|
|
}
|
2011-05-08 13:36:55 +02:00
|
|
|
},
|
|
|
|
setEnabled: function(bool) {
|
2012-01-05 17:01:48 +01:00
|
|
|
$(this).toggleClass('disabled', !bool);
|
|
|
|
if(!bool) $(this).find('input').attr('disabled', 'disabled').removeAttr('checked');
|
|
|
|
else $(this).find('input').removeAttr('disabled');
|
2011-04-24 01:05:01 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
$(".cms-page-add-button").entwine({
|
|
|
|
onclick: function(e) {
|
|
|
|
$('.cms-page-add-form-dialog').dialog('open');
|
|
|
|
e.preventDefault();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
2012-05-11 07:37:31 +02:00
|
|
|
}(jQuery));
|