Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

ENHANCEMENT Hide "edit page" menu entry in CMS when no page is opened…

… for editing (for usability reasons)
  • Loading branch information...
commit 1c20213dbd691b4c4a1d326555e88561b1884799 1 parent f349483
@chillu chillu authored
Showing with 16 additions and 1 deletion.
  1. +16 −1 admin/javascript/LeftAndMain.Menu.js
View
17 admin/javascript/LeftAndMain.Menu.js
@@ -26,13 +26,13 @@
$('.cms-menu-list').entwine({
onmatch: function() {
var self = this;
-
$('.cms-container').bind('afterstatechange', function(e, data) {
var controller = data.xhr.getResponseHeader('X-Controller');
if(controller) {
var item = self.find('li#Menu-' + controller);
if(!item.hasClass('current')) item.select();
}
+ self.updateItems();
});
// Sync collapsed state with parent panel
@@ -43,7 +43,15 @@
// Select default element (which might reveal children in hidden parents)
this.find('li.current').select();
+ this.updateItems();
+
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().find('li').removeClass('current');
if(parent) parent.addClass('current').siblings().removeClass('current');
+ this.getMenu().updateItems();
this.trigger('select');
}
});
+ $('.cms-menu-list *').entwine({
+ getMenu: function() {
+ return this.parents('.cms-menu-list:first');
+ }
+ });
+
$('.cms-menu-list li *').entwine({
getMenuItem: function() {
return this.parents('li:first');
Please sign in to comment.
Something went wrong with that request. Please try again.