mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUGFIX Fixed CMS panel expansion after changing links in the CMS (needed to retain the layout settings of the old panel to keep the preview expanded)
This commit is contained in:
parent
2777637d82
commit
d3477cc13c
@ -152,13 +152,29 @@
|
|||||||
|
|
||||||
// Update panels
|
// Update panels
|
||||||
var newContentEl = $(data);
|
var newContentEl = $(data);
|
||||||
|
|
||||||
if(newContentEl.find('.cms-container').length) {
|
if(newContentEl.find('.cms-container').length) {
|
||||||
throw 'Content loaded via ajax is not allowed to contain tags matching the ".cms-container" selector to avoid infinite loops';
|
throw 'Content loaded via ajax is not allowed to contain tags matching the ".cms-container" selector to avoid infinite loops';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set loading state and store element state
|
||||||
newContentEl.addClass('loading');
|
newContentEl.addClass('loading');
|
||||||
|
var origStyle = contentEl.attr('style'),
|
||||||
|
layoutClasses = ['east', 'west', 'center', 'north', 'south'],
|
||||||
|
origLayoutClasses = $.grep(
|
||||||
|
contentEl.attr('class').split(' '),
|
||||||
|
function(val) {
|
||||||
|
return ($.inArray(val, layoutClasses) >= 0);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
newContentEl
|
||||||
|
.removeClass(layoutClasses.join(' '))
|
||||||
|
.addClass(origLayoutClasses.join(' '))
|
||||||
|
.attr('style', origStyle);
|
||||||
|
|
||||||
|
// Replace panel completely (we need to override the "layout" attribute, so can't replace the child instead)
|
||||||
contentEl.replaceWith(newContentEl);
|
contentEl.replaceWith(newContentEl);
|
||||||
|
|
||||||
|
// Unset loading and restore element state (to avoid breaking existing panel visibility, e.g. with preview expanded)
|
||||||
self.redraw();
|
self.redraw();
|
||||||
newContentEl.removeClass('loading');
|
newContentEl.removeClass('loading');
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user