ENHANCEMENT Hide "edit page" menu entry in CMS when no page is opened for editing (for usability reasons)

This commit is contained in:
Ingo Schommer 2011-12-14 18:01:03 +01:00
parent f3494839b0
commit 1c20213dbd

View File

@ -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');