Desktop markdown wiki app. Built with node, Electron Framework and AngularJS.

sidebar-ctrl.js 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /**
  2. * @ngdoc function
  3. * @name domainManagerApp.controller:AboutCtrl
  4. * @description
  5. * # AboutCtrl
  6. * Controller of the domainManagerApp
  7. */
  8. angular.module('codexApp.sidebar', [])
  9. .controller('SidebarCtrl',['$scope', '$rootScope', '$state', 'PrefsService', function ($scope, $rootScope, $state, PrefsService) {
  10. console.log('-> Sidebar loaded')
  11. $scope.showSidebar = true;
  12. $scope.goToAllNotes = function() {
  13. PrefsService.setCurrentView("All Notes");
  14. $scope.activateSidebarBtn(0);
  15. $rootScope.$broadcast('main-window:note-list');
  16. $rootScope.$broadcast('window-view:change');
  17. $state.go("index");
  18. }
  19. $scope.goToAllFiles = function() {
  20. PrefsService.setCurrentView("All Files");
  21. $scope.activateSidebarBtn(1);
  22. $rootScope.$broadcast('main-window:file-list');
  23. $rootScope.$broadcast('window-view:change');
  24. $state.go("index");
  25. }
  26. $scope.goToNotebooks = function() {
  27. PrefsService.setCurrentView("Notebooks");
  28. $scope.activateSidebarBtn(2);
  29. $rootScope.$broadcast('main-window:file-list');
  30. $rootScope.$broadcast('window-view:change');
  31. $state.go("index");
  32. }
  33. $rootScope.$on('main-window:note-view', function(){
  34. $scope.activateSidebarBtn();
  35. });
  36. $rootScope.$on('sidebar:toogle', function() {
  37. if(!$scope.$$phase) {
  38. $scope.$apply(function(){
  39. $scope.toogleSidebar();
  40. });
  41. } else {
  42. $scope.toogleSidebar();
  43. }
  44. });
  45. $scope.toogleSidebar = function() {
  46. if( $scope.showSidebar == true){
  47. $scope.showSidebar = false;
  48. } else {
  49. $scope.showSidebar = true;
  50. }
  51. }
  52. $scope.sidebar = [
  53. {
  54. "view" : "All Notes",
  55. "active" : "active"
  56. },
  57. {
  58. "view" : "All Files",
  59. "active" : ""
  60. },
  61. {
  62. "view" : "Notebooks",
  63. "active" : ""
  64. }
  65. ]
  66. $scope.activateSidebarBtn = function(num) {
  67. if(!$scope.$$phase) {
  68. $scope.$apply(function(){
  69. for (var i = 0; i < $scope.sidebar.length; i++) {
  70. $scope.sidebar[i].active = "";
  71. }
  72. $scope.sidebar[num].active = "active";
  73. });
  74. } else {
  75. for (var i = 0; i < $scope.sidebar.length; i++) {
  76. $scope.sidebar[i].active = "";
  77. }
  78. if (typeof(num)==='undefined') return;
  79. $scope.sidebar[num].active = "active";
  80. }
  81. }
  82. }]);