(function(){ 'use strict'; angular.module('sbAdminApp') .controller('con',['$scope',con]) .controller('MainController', ['navService','$rootScope','$mdSidenav', '$mdBottomSheet', '$log', '$q', '$state', '$mdToast', '$scope', '$mdMedia', '$mdDialog','LoginService', 'toaster', MainController]); function MainController(navService,$rootScope, $mdSidenav, $mdBottomSheet, $log, $q, $state, $mdToast, $scope, $mdMedia, $mdDialog, LoginService, toaster) { var vm = this; //vm.menuItems = [ ]; vm.selectItem = selectItem; vm.toggleItemsList = toggleItemsList; vm.showActions = showActions; vm.title = $state.current.data.title; vm.showSimpleToast = showSimpleToast; vm.toggleRightSidebar = toggleRightSidebar; vm.autoFocusContent = false; vm.isOpen = isOpen; vm.toggleOpen = toggleOpen; vm.menu = navService; $scope.companyName = localStorage.getItem("companyName"); /*navService.loadAllItems().then(function(menuItems) { vm.menuItems = [].concat(menuItems); });*/ function toggleRightSidebar() { $mdSidenav('right').toggle(); } function toggleItemsList() { var pending = $mdBottomSheet.hide() || $q.when(true); pending.then(function(){ $mdSidenav('left').toggle(); }); } function isOpen(section) { return navService.isSectionSelected(section); } function toggleOpen(section) { navService.toggleSelectSection(section); } function selectItem (item) { /*$scope.searchDID = false; if(item.name == 'DID'){ $scope.searchDID = true; }*/ vm.title = item.name; vm.toggleItemsList(); vm.showSimpleToast(vm.title); } function showActions($event) { $mdBottomSheet.show({ parent: angular.element(document.getElementById('content')), templateUrl: 'app/views/partials/bottomSheet.html', controller: [ '$mdBottomSheet', SheetController], controllerAs: "vm", bindToController : true, targetEvent: $event }).then(function(clickedItem) { clickedItem && $log.debug( clickedItem.name + ' clicked!'); }); function SheetController( $mdBottomSheet ) { var vm = this; vm.actions = [ { name: 'Share', icon: 'share', url: 'https://twitter.com/intent/tweet?text=Angular%20Material%20Dashboard%20https://github.com/flatlogic/angular-material-dashboard%20via%20@flatlogicinc' }, { name: 'Star', icon: 'star', url: 'https://github.com/flatlogic/angular-material-dashboard/stargazers' } ]; vm.performAction = function(action) { $mdBottomSheet.hide(action); }; } } function showSimpleToast(title) { $mdToast.show( $mdToast.simple() .content(title) .hideDelay(2000) .position('bottom right') ); } $scope.logout = function() { LoginService.logOut().save().$promise.then(function(result){ window.location.reload(); LoginService.deleteUser(); $state.go("login"); }, function(error){ if(error){ toaster.error("server error"); } }); } } function con($scope){ $scope.class = "sidebar-full"; $scope.changeClass = function(){ if ($scope.class === "sidebar-full"){ $scope.class = "sidebar-mini"; } else{ $scope.class = "sidebar-full"; } }; } })();