12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- * @ngdoc function
- * @name domainManagerApp.controller:AboutCtrl
- * @description
- * # AboutCtrl
- * Controller of the domainManagerApp
- */
- angular.module('codexApp.sidebar', [])
- .controller('SidebarCtrl',['$scope', '$rootScope', '$state', 'PrefsService', "FileService", function ($scope, $rootScope, $state, PrefsService, FileService) {
- console.log('-> Sidebar loaded')
- $scope.showSidebar = true;
- $scope.goToAllNotes = function() {
- PrefsService.setCurrentView("All Notes");
- $scope.activateSidebarBtn(0);
- $rootScope.$broadcast('main-window:note-list');
- $rootScope.$broadcast('window-view:change');
- $state.go("index");
- }
- $scope.goToAllFiles = function() {
- PrefsService.setCurrentView("All Files");
- $scope.activateSidebarBtn(1);
- $rootScope.$broadcast('main-window:file-list');
- $rootScope.$broadcast('window-view:change');
- $state.go("index");
- }
- $scope.goToNotebooks = function() {
- FileService.setCurrentNote(FileService.getNote(FileService.getNotesDir()));
- PrefsService.setCurrentView("Notebooks");
- $scope.activateSidebarBtn(2);
- $rootScope.$broadcast('main-window:file-list');
- $rootScope.$broadcast('window-view:change');
- $state.go("index");
- }
- $rootScope.$on('main-window:note-view', function(){
- $scope.activateSidebarBtn();
- });
- $rootScope.$on('sidebar:toogle', function() {
- if(!$scope.$$phase) {
- $scope.$apply(function(){
- $scope.toogleSidebar();
- });
- } else {
- $scope.toogleSidebar();
- }
- });
- $scope.toogleSidebar = function() {
- if( $scope.showSidebar == true){
- $scope.showSidebar = false;
- } else {
- $scope.showSidebar = true;
- }
- }
- $scope.sidebar = [
- {
- "view" : "All Notes",
- "active" : "active"
- },
- {
- "view" : "All Files",
- "active" : ""
- },
- {
- "view" : "Notebooks",
- "active" : ""
- }
- ]
- $scope.activateSidebarBtn = function(num) {
- if(!$scope.$$phase) {
- $scope.$apply(function(){
- for (var i = 0; i < $scope.sidebar.length; i++) {
- $scope.sidebar[i].active = "";
- }
- $scope.sidebar[num].active = "active";
- });
- } else {
- for (var i = 0; i < $scope.sidebar.length; i++) {
- $scope.sidebar[i].active = "";
- }
- if (typeof(num)==='undefined') return;
- $scope.sidebar[num].active = "active";
- }
- }
- }]);
|