Skip to content

Commit

Permalink
MINOR Hiding collapsed panel views by CSS to avoid FOUC, and initiali…
Browse files Browse the repository at this point in the history
…sing component without triggering events to avoid redrawing the whole CMS layout twice due to it listening for panel changes
  • Loading branch information
chillu committed Feb 16, 2012
1 parent 07f4cd4 commit d41f37f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion admin/css/screen.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 12 additions & 7 deletions admin/javascript/LeftAndMain.Panel.js
Expand Up @@ -56,7 +56,7 @@
if(typeof cookieCollapsed != 'undefined' && cookieCollapsed != null) collapsed = (cookieCollapsed == 'true');
}
if(typeof collapsed == 'undefined') collapsed = jQuery(this).hasClass('collapsed');
this.togglePanel(!collapsed);
this.togglePanel(!collapsed, true);

this._super();
},
Expand All @@ -70,11 +70,14 @@
},

/**
* @param Boolean TRUE to expand, FALSE to collapse.
* @param {Boolean} TRUE to expand, FALSE to collapse.
* @param {Boolean} TRUE means that events won't be fired, which is useful for the component initialization phase.
*/
togglePanel: function(bool) {
this.trigger('beforetoggle.sspanel', bool);
this.trigger(bool ? 'beforeexpand' : 'beforecollapse');
togglePanel: function(bool, silent) {
if(!silent) {
this.trigger('beforetoggle.sspanel', bool);
this.trigger(bool ? 'beforeexpand' : 'beforecollapse');
}

this.toggleClass('collapsed', !bool);
var newWidth = bool ? this.getWidthExpanded() : this.getWidthCollapsed();
Expand All @@ -93,8 +96,10 @@
// Save collapsed state in cookie
if($.cookie && this.attr('id')) $.cookie('cms-panel-collapsed-' + this.attr('id'), !bool, {path: '/', expires: 31});

this.trigger('toggle', bool);
this.trigger(bool ? 'expand' : 'collapse');
if(!silent) {
this.trigger('toggle', bool);
this.trigger(bool ? 'expand' : 'collapse');
}
},

expandPanel: function(force) {
Expand Down
1 change: 1 addition & 0 deletions admin/scss/_style.scss
Expand Up @@ -918,6 +918,7 @@ form.member-profile-form {

.cms-panel-content-collapsed {
width: 40px;
display: none; // Avoids FOUC

h2, h3 {
border-bottom: 0;
Expand Down

0 comments on commit d41f37f

Please sign in to comment.