Use ngAnimate to animate sidebar hiding/showing

This commit is contained in:
Tor Hveem 2014-02-21 09:32:52 +01:00
commit 46b503e1b4
3 changed files with 33 additions and 7 deletions

View file

@ -1,4 +1,4 @@
var weechat = angular.module('weechat', ['ngRoute', 'localStorage', 'weechatModels', 'plugins', 'ngSanitize', 'ngWebsockets', 'pasvaz.bindonce', 'ngTouch']);
var weechat = angular.module('weechat', ['ngRoute', 'localStorage', 'weechatModels', 'plugins', 'ngSanitize', 'ngWebsockets', 'pasvaz.bindonce', 'ngTouch', 'ngAnimate']);
weechat.filter('toArray', function () {
'use strict';
@ -581,6 +581,8 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
}
});
$scope.showSidebar = true;
$scope.buffers = models.model.buffers;
$scope.activeBuffer = models.getActiveBuffer;
@ -626,8 +628,16 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
// Open and close panels while on mobile devices through swiping
$scope.swipeSidebar = function() {
if (document.body.clientWidth < mobile_cutoff) {
$('#sidebar').collapse('toggle');
$scope.showSidebar = !$scope.showSidebar;
// remove or add margin if big screen
if (document.body.clientWidth > mobile_cutoff) {
if($scope.showSidebar) {
$('#bufferlines').css('margin-left','145px');
$('.navbar-fixed-bottom').css('margin-left','145px');
}else{
$('#bufferlines').css('margin-left','0');
$('.navbar-fixed-bottom').css('margin-left','0');
}
}
};
@ -662,7 +672,7 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
// If we are on mobile we need to collapse the menu on sidebar clicks
// We use 968 px as the cutoff, which should match the value in glowingbear.css
if (document.body.clientWidth < mobile_cutoff) {
$('#sidebar').collapse('toggle');
$scope.showSidebar = false;
}
return models.setActiveBuffer(bufferId, key);
};