2014-12-07 07:44:50 -08:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
angular.module('copayApp.services').factory('go', function($window, $location) {
|
|
|
|
var root = {};
|
|
|
|
|
|
|
|
var hideSidebars = function() {
|
2014-12-07 09:12:58 -08:00
|
|
|
if (typeof document === 'undefined')
|
|
|
|
return;
|
|
|
|
|
2014-12-07 07:44:50 -08:00
|
|
|
// hack to hide sidebars and use ng-click (no href=)
|
|
|
|
var win = angular.element($window);
|
2014-12-07 09:12:58 -08:00
|
|
|
var elem = angular.element(document.querySelector('#off-canvas-wrap'))
|
2014-12-07 07:44:50 -08:00
|
|
|
elem.removeClass('move-right');
|
|
|
|
elem.removeClass('move-left');
|
|
|
|
};
|
|
|
|
|
2014-12-08 07:45:12 -08:00
|
|
|
var toggleSidebar = function(invert) {
|
2014-12-08 00:34:59 -08:00
|
|
|
if (typeof document === 'undefined')
|
|
|
|
return;
|
|
|
|
|
2014-12-08 07:45:12 -08:00
|
|
|
var elem = angular.element(document.querySelector('#off-canvas-wrap'));
|
|
|
|
var leftbarActive = angular.element(document.getElementsByClassName('move-right')).length;
|
|
|
|
var rightbarActive = angular.element(document.getElementsByClassName('move-left')).length;
|
|
|
|
|
2014-12-08 00:34:59 -08:00
|
|
|
if (invert) {
|
2014-12-08 07:45:12 -08:00
|
|
|
if (rightbarActive) {
|
|
|
|
hideSidebars();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
elem.addClass('move-right');
|
|
|
|
}
|
2014-12-08 00:34:59 -08:00
|
|
|
}
|
2014-12-08 07:45:12 -08:00
|
|
|
else {
|
|
|
|
if (leftbarActive) {
|
|
|
|
hideSidebars();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
elem.addClass('move-left');
|
|
|
|
}
|
2014-12-08 00:34:59 -08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-12-07 07:44:50 -08:00
|
|
|
root.go = function(path) {
|
|
|
|
var parts = path.split('#');
|
|
|
|
$location.path(parts[0]);
|
|
|
|
if (parts[1])
|
|
|
|
$location.hash(parts[1]);
|
|
|
|
hideSidebars();
|
|
|
|
};
|
|
|
|
|
2014-12-08 00:34:59 -08:00
|
|
|
root.swipe = function(invert) {
|
2014-12-08 07:45:12 -08:00
|
|
|
toggleSidebar(invert);
|
2014-12-08 00:34:59 -08:00
|
|
|
};
|
|
|
|
|
2014-12-07 07:44:50 -08:00
|
|
|
return root;
|
|
|
|
});
|