mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
ENHANCEMENT Hide "edit page" menu entry in CMS when no page is opened for editing (for usability reasons)
This commit is contained in:
parent
f3494839b0
commit
1c20213dbd
@ -26,13 +26,13 @@
|
|||||||
$('.cms-menu-list').entwine({
|
$('.cms-menu-list').entwine({
|
||||||
onmatch: function() {
|
onmatch: function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
$('.cms-container').bind('afterstatechange', function(e, data) {
|
$('.cms-container').bind('afterstatechange', function(e, data) {
|
||||||
var controller = data.xhr.getResponseHeader('X-Controller');
|
var controller = data.xhr.getResponseHeader('X-Controller');
|
||||||
if(controller) {
|
if(controller) {
|
||||||
var item = self.find('li#Menu-' + controller);
|
var item = self.find('li#Menu-' + controller);
|
||||||
if(!item.hasClass('current')) item.select();
|
if(!item.hasClass('current')) item.select();
|
||||||
}
|
}
|
||||||
|
self.updateItems();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Sync collapsed state with parent panel
|
// Sync collapsed state with parent panel
|
||||||
@ -43,7 +43,15 @@
|
|||||||
// Select default element (which might reveal children in hidden parents)
|
// Select default element (which might reveal children in hidden parents)
|
||||||
this.find('li.current').select();
|
this.find('li.current').select();
|
||||||
|
|
||||||
|
this.updateItems();
|
||||||
|
|
||||||
this._super();
|
this._super();
|
||||||
|
},
|
||||||
|
|
||||||
|
updateItems: function() {
|
||||||
|
// Hide "edit page" commands unless the section is activated
|
||||||
|
var editPageItem = this.find('#Menu-CMSMain');
|
||||||
|
editPageItem[editPageItem.is('.current') ? 'show' : 'hide']();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -73,11 +81,18 @@
|
|||||||
this.siblings().removeClass('current').close();
|
this.siblings().removeClass('current').close();
|
||||||
this.siblings().find('li').removeClass('current');
|
this.siblings().find('li').removeClass('current');
|
||||||
if(parent) parent.addClass('current').siblings().removeClass('current');
|
if(parent) parent.addClass('current').siblings().removeClass('current');
|
||||||
|
this.getMenu().updateItems();
|
||||||
|
|
||||||
this.trigger('select');
|
this.trigger('select');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('.cms-menu-list *').entwine({
|
||||||
|
getMenu: function() {
|
||||||
|
return this.parents('.cms-menu-list:first');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
$('.cms-menu-list li *').entwine({
|
$('.cms-menu-list li *').entwine({
|
||||||
getMenuItem: function() {
|
getMenuItem: function() {
|
||||||
return this.parents('li:first');
|
return this.parents('li:first');
|
||||||
|
Loading…
Reference in New Issue
Block a user