Browse Source

Fix controls bar calculation

Controls bar calculation needs to take the sidebar visibility into
account.

Recalculation is now triggered when sidebar is toggled, using a new
app-content event "appresized".
tags/v8.2beta1
Vincent Petry 8 years ago
parent
commit
7303b68577
2 changed files with 12 additions and 6 deletions
  1. 3
    3
      core/js/apps.js
  2. 9
    3
      core/js/js.js

+ 3
- 3
core/js/apps.js View File

*/ */
exports.Apps.showAppSidebar = function($el) { exports.Apps.showAppSidebar = function($el) {
var $appSidebar = $el || $('#app-sidebar'); var $appSidebar = $el || $('#app-sidebar');
$appSidebar.removeClass('disappear')
$('#app-content').addClass('with-app-sidebar');
$appSidebar.removeClass('disappear');
$('#app-content').addClass('with-app-sidebar').trigger(new $.Event('appresized'));


}; };


exports.Apps.hideAppSidebar = function($el) { exports.Apps.hideAppSidebar = function($el) {
var $appSidebar = $el || $('#app-sidebar'); var $appSidebar = $el || $('#app-sidebar');
$appSidebar.addClass('disappear'); $appSidebar.addClass('disappear');
$('#app-content').removeClass('with-app-sidebar');
$('#app-content').removeClass('with-app-sidebar').trigger(new $.Event('appresized'));
}; };


/** /**

+ 9
- 3
core/js/js.js View File

// if there is a scrollbar … // if there is a scrollbar …
if($('#app-content').get(0).scrollHeight > $('#app-content').height()) { if($('#app-content').get(0).scrollHeight > $('#app-content').height()) {
if($(window).width() > 768) { if($(window).width() > 768) {
controlsWidth = $('#content').width() - $('#app-navigation').width() - $('#app-sidebar').width() - getScrollBarWidth();
controlsWidth = $('#content').width() - $('#app-navigation').width() - getScrollBarWidth();
if (!$('#app-sidebar').hasClass('hidden') && !$('#app-sidebar').hasClass('disappear')) {
controlsWidth -= $('#app-sidebar').width();
}
} else { } else {
controlsWidth = $('#content').width() - getScrollBarWidth(); controlsWidth = $('#content').width() - getScrollBarWidth();
} }
} else { // if there is none } else { // if there is none
if($(window).width() > 768) { if($(window).width() > 768) {
controlsWidth = $('#content').width() - $('#app-navigation').width() - $('#app-sidebar').width();
controlsWidth = $('#content').width() - $('#app-navigation').width();
if (!$('#app-sidebar').hasClass('hidden') && !$('#app-sidebar').hasClass('disappear')) {
controlsWidth -= $('#app-sidebar').width();
}
} else { } else {
controlsWidth = $('#content').width(); controlsWidth = $('#content').width();
} }


$(window).resize(_.debounce(adjustControlsWidth, 250)); $(window).resize(_.debounce(adjustControlsWidth, 250));


$('body').delegate('#app-content', 'apprendered', adjustControlsWidth);
$('body').delegate('#app-content', 'apprendered appresized', adjustControlsWidth);


} }



Loading…
Cancel
Save