Skip to content

Instantly share code, notes, and snippets.

@elchele
Last active August 29, 2015 14:00
Show Gist options
  • Save elchele/11274321 to your computer and use it in GitHub Desktop.
Save elchele/11274321 to your computer and use it in GitHub Desktop.
Hiding the Sugar 7 intelligence pane by default
({
/* **** PRE-7.2 ONLY ****
place in /custom/modules/<Module>/clients/base/fields/sidebartoggle/ for module specific
place in /custom/clients/base/fields/sidebartoggle/ for global context */
extendsFrom: 'sidebartoggle',
/* Override existing _render method and call default toggle() method to mimic click of button to hide
the sidebar/intelligence pane */
_render: function() {
app.view.invokeParent(this, {type: 'field', name: 'sidebartoggle', method: '_render', args: []});
this.toggle();
},
_dispose: function() {
this._super('_dispose');
}
})
({
/* 7.2 and higher */
extendsFrom: 'SidebartoggleField',
_render: function() {
this._super('_render');
var defaultLayout = this.closestComponent('sidebar');
if (defaultLayout && this._state == 'open') {
defaultLayout.trigger('sidebar:toggle', true);
this._state = 'close';
}
else if (defaultLayout && this._state == 'close')
{
defaultLayout.trigger('sidebar:toggle', false);
this._state = 'open';
}
},
_dispose: function() {
this._super('_dispose');
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment