Browse Source

Additional fixes for #649 with multiple sidebars

pull/1615/head
jlukic 10 years ago
parent
commit
9de6cc1c9c
1 changed files with 25 additions and 18 deletions
  1. 43
      src/definitions/modules/sidebar.js

43
src/definitions/modules/sidebar.js

@ -15,20 +15,20 @@
$.fn.sidebar = function(parameters) { $.fn.sidebar = function(parameters) {
var var
$allModules = $(this),
$window = $(window),
$document = $(document),
$html = $('html'),
$head = $('head'),
$allModules = $(this),
$window = $(window),
$document = $(document),
$html = $('html'),
$head = $('head'),
moduleSelector = $allModules.selector || '',
moduleSelector = $allModules.selector || '',
time = new Date().getTime(),
performance = [],
time = new Date().getTime(),
performance = [],
query = arguments[0],
methodInvoked = (typeof query == 'string'),
queryArguments = [].slice.call(arguments, 1),
query = arguments[0],
methodInvoked = (typeof query == 'string'),
queryArguments = [].slice.call(arguments, 1),
requestAnimationFrame = window.requestAnimationFrame requestAnimationFrame = window.requestAnimationFrame
|| window.mozRequestAnimationFrame || window.mozRequestAnimationFrame
@ -351,7 +351,7 @@ $.fn.sidebar = function(parameters) {
settings.transition = 'overlay'; settings.transition = 'overlay';
} }
module.refresh(); module.refresh();
if(module.othersVisible() && module.get.transition() !== 'overlay') {
if(module.othersActive() && module.get.transition() !== 'overlay') {
settings.transition = 'overlay'; settings.transition = 'overlay';
if(settings.exclusive) { if(settings.exclusive) {
module.hideOthers(); module.hideOthers();
@ -391,17 +391,24 @@ $.fn.sidebar = function(parameters) {
} }
}, },
othersAnimating: function() {
return ($sidebars.not($module).filter('.' + className.animating).length > 0);
},
othersVisible: function() { othersVisible: function() {
return ($sidebars.not($module).filter('.' + className.visible).length > 0); return ($sidebars.not($module).filter('.' + className.visible).length > 0);
}, },
othersActive: function() {
return(module.othersVisible() || module.othersAnimating());
},
hideOthers: function(callback) { hideOthers: function(callback) {
var var
$otherSidebars = $sidebars.not($module).filter('.' + className.visible), $otherSidebars = $sidebars.not($module).filter('.' + className.visible),
callback = callback || function(){},
sidebarCount = $otherSidebars.length, sidebarCount = $otherSidebars.length,
callbackCount = 0 callbackCount = 0
; ;
callback = callback || function(){};
$otherSidebars $otherSidebars
.sidebar('hide', function() { .sidebar('hide', function() {
callbackCount++; callbackCount++;
@ -427,7 +434,7 @@ $.fn.sidebar = function(parameters) {
transition = module.get.transition(), transition = module.get.transition(),
$transition = (transition == 'safe') $transition = (transition == 'safe')
? $context ? $context
: (transition == 'overlay' || module.othersVisible())
: transition == 'overlay' || module.othersActive()
? $module ? $module
: $pusher, : $pusher,
animate, animate,
@ -442,10 +449,10 @@ $.fn.sidebar = function(parameters) {
} }
module.set.transition(); module.set.transition();
module.repaint(); module.repaint();
module.set.animating();
animate = function() { animate = function() {
module.bind.clickaway(); module.bind.clickaway();
module.add.bodyCSS(); module.add.bodyCSS();
module.set.animating();
module.set.visible(); module.set.visible();
if(!module.othersVisible()) { if(!module.othersVisible()) {
if(settings.dimPage) { if(settings.dimPage) {
@ -471,7 +478,7 @@ $.fn.sidebar = function(parameters) {
transition = module.get.transition(), transition = module.get.transition(),
$transition = (transition == 'safe') $transition = (transition == 'safe')
? $context ? $context
: (transition == 'overlay' || module.othersVisible())
: (transition == 'overlay' || module.othersActive())
? $module ? $module
: $pusher, : $pusher,
animate, animate,
@ -487,9 +494,9 @@ $.fn.sidebar = function(parameters) {
module.unbind.clickaway(); module.unbind.clickaway();
module.unbind.scrollLock(); module.unbind.scrollLock();
module.repaint(); module.repaint();
module.set.animating();
animate = function() { animate = function() {
module.set.animating();
module.remove.visible(); module.remove.visible();
if(settings.dimPage && !module.othersVisible()) { if(settings.dimPage && !module.othersVisible()) {
$pusher.removeClass(className.dimmed); $pusher.removeClass(className.dimmed);
@ -556,7 +563,7 @@ $.fn.sidebar = function(parameters) {
module.unbind.clickaway(); module.unbind.clickaway();
module.set.animating(); module.set.animating();
module.remove.visible(); module.remove.visible();
if(settings.dimPage && !module.othersVisible()) {
if(settings.dimPage && !module.othersActive()) {
$pusher.removeClass(className.dimmed); $pusher.removeClass(className.dimmed);
} }
$context $context

Loading…
Cancel
Save