diff --git a/index.html b/index.html index a859e6a04..bb651ad55 100644 --- a/index.html +++ b/index.html @@ -20,7 +20,10 @@ - +
Loading... diff --git a/js/controllers/index.js b/js/controllers/index.js new file mode 100644 index 000000000..8a0d4b4ef --- /dev/null +++ b/js/controllers/index.js @@ -0,0 +1,12 @@ +'use strict'; + +angular.module('copayApp.controllers').controller('IndexController', function($scope, go) { + $scope.init = function() { + + }; + + $scope.swipe = function(invert) { + go.swipe(invert); + }; + +}); diff --git a/js/services/go.js b/js/services/go.js index f0a71785d..88492b189 100644 --- a/js/services/go.js +++ b/js/services/go.js @@ -14,6 +14,21 @@ angular.module('copayApp.services').factory('go', function($window, $location) { elem.removeClass('move-left'); }; + var showSidebar = function(invert) { + if (typeof document === 'undefined') + return; + + // hack to hide sidebars and use ng-click (no href=) + var win = angular.element($window); + var elem = angular.element(document.querySelector('#off-canvas-wrap')) + if (invert) { + elem.addClass('move-right'); + } + else { + elem.addClass('move-left'); + } + }; + root.go = function(path) { var parts = path.split('#'); $location.path(parts[0]); @@ -22,5 +37,36 @@ angular.module('copayApp.services').factory('go', function($window, $location) { hideSidebars(); }; + var pages = [ + '/homeWallet', + '/receive', + '/send', + '/history' + ]; + + var sidebarActive = false; + + root.swipe = function(invert) { + var currentPage = $location.path(); + var pageIndex; + if (!sidebarActive) { + pageIndex = invert ? pages.indexOf(currentPage) - 1 : pages.indexOf(currentPage) + 1; + } + else { + pageIndex = pages.indexOf(currentPage); + } + var page = pages[pageIndex]; + + if (pageIndex === -1 || pageIndex === 4) { + sidebarActive = true; + showSidebar(invert); + } + else if (pageIndex >= 0 && pageIndex <= 3) { + var goTo = pages[pageIndex]; + sidebarActive = false; + root.go(goTo); + } + }; + return root; });