{"version":3,"names":[],"mappings":"","sources":["app-controller.js"],"sourcesContent":["(function() {\r\n 'use strict';\r\n\r\n /**\r\n * @ngdoc object\r\n * @name sliceApp.controller:AppCtrl\r\n *\r\n * @description\r\n *\r\n */\r\n angular\r\n .module('sliceApp')\r\n .controller('AppCtrl', AppCtrl);\r\n\r\n function AppCtrl($scope, $rootScope, $timeout, $mdDialog, $state, $location, App, MyOrder) {\r\n\r\n $scope.franchiseGraphics = {};\r\n $rootScope.pageTitle = \"\";\r\n $scope.currentLocation = \"\";\r\n $scope.mainViewClasses = \"\";\r\n $scope.menu = undefined;\r\n $scope.franchise = undefined;\r\n $scope.branches = [];\r\n $scope.rout = $state.current;\r\n $scope.itemsInOrderCount = 0;\r\n $scope.pizzaToppings = [];\r\n\r\n $scope.getFranchiseGraphics = function() {\r\n showLoader();\r\n App.getFranchiseGraphics().then(function(response) {\r\n $scope.franchiseGraphics = response.data;\r\n $rootScope.$broadcast(\"graphicsReady\");\r\n hideLoader();\r\n });\r\n }\r\n\r\n $scope.getMenu = function() {\r\n showLoader();\r\n App.getMenu().then(function(response) {\r\n $scope.menu = {\r\n categories: response.data.categories,\r\n pizzas: response.data.pizzas\r\n };\r\n $scope.pizzaToppings = response.data.pizzaToppings;\r\n $rootScope.$broadcast(\"menuReady\");\r\n hideLoader();\r\n var user = $scope.getItemFromLocalStorage(\"userDetails\");\r\n if (user == undefined) {\r\n $location.path(\"login\");\r\n } else {\r\n $location.path(\"menu\");\r\n }\r\n });\r\n }\r\n\r\n $scope.getFranchise = function() {\r\n App.getFranchise().then(function(response) {\r\n $scope.franchise = response.data.franchise;\r\n $scope.branches = response.data.branches;\r\n });\r\n }\r\n\r\n $scope.getCombos = function() {\r\n App.getCombos().then(function(response) {\r\n $scope.combos = response.data;\r\n });\r\n }\r\n\r\n $scope.back = function() {\r\n window.history.back();\r\n }\r\n\r\n $scope.goTo = function(location) {\r\n $location.path(location);\r\n }\r\n\r\n $scope.hideDialog = function() {\r\n $mdDialog.hide();\r\n }\r\n\r\n $scope.slideUp = function() {\r\n $(\"html, body\").animate({\r\n scrollTop: 0\r\n }, \"fast\");\r\n }\r\n\r\n\r\n\r\n $scope.setItemInLocalStorage = function(key, value) {\r\n localStorage.setItem(key, JSON.stringify(value));\r\n }\r\n\r\n $scope.getItemFromLocalStorage = function(key) {\r\n var value = localStorage.getItem(key);\r\n if (value == undefined) return value;\r\n else {\r\n return JSON.parse(value);\r\n }\r\n }\r\n\r\n $scope.verifyToken = function() {\r\n var token = $scope.getItemFromLocalStorage(\"loginToken\");\r\n if (token == undefined) $scope.goTo(\"login\");\r\n else {\r\n App.verifyToken(token).then(function(response) {\r\n if (!response.data) {\r\n localStorage.clear();\r\n $scope.goTo(\"login\");\r\n }\r\n })\r\n }\r\n }\r\n\r\n $scope.getTotalOrderPrice = function() {\r\n return MyOrder.getTotalOrderPrice();\r\n }\r\n\r\n // Events\r\n $rootScope.$on(\"itemAddedToOrder\", function(e, itemsCount) {\r\n $scope.itemsInOrderCount = itemsCount;\r\n });\r\n //On route change\r\n $rootScope.$on('$stateChangeSuccess', function(event, toState, toParams, fromState, fromParams) {\r\n $scope.currentLocation = toState.name;\r\n\r\n $state.current = $scope.rout;\r\n\r\n if (toState.data != undefined && toState.data.mainViewClasses != undefined) {\r\n $scope.mainViewClasses = toState.data.mainViewClasses;\r\n } else {\r\n $scope.mainViewClasses = \"\";\r\n }\r\n $scope.slideUp();\r\n\r\n });\r\n\r\n\r\n $scope.getMenu();\r\n $scope.getFranchiseGraphics();\r\n $scope.getFranchise();\r\n $scope.getCombos();\r\n\r\n }\r\n}());\r\n"],"file":"app-controller.js"}