|
@@ -41,23 +41,61 @@ var app = angular.module("robware", ['ngAnimate'], function($httpProvider) {
|
|
|
return query.length ? query.substr(0, query.length - 1) : query;
|
|
|
};
|
|
|
// Override $http service's default transformRequest
|
|
|
- $httpProvider.defaults.transformRequest = [function(data) {
|
|
|
- return angular.isObject(data) && String(data) !== '[object File]' ? param(data) : data;
|
|
|
- }];
|
|
|
+ $httpProvider.defaults.transformRequest = [
|
|
|
+ function(data) {
|
|
|
+ return angular.isObject(data) && String(data) !== '[object File]' ? param(data) : data;
|
|
|
+ }
|
|
|
+ ];
|
|
|
+
|
|
|
+ $httpProvider.interceptors.push([
|
|
|
+ '$rootScope',
|
|
|
+ '$q',
|
|
|
+ function($rootScope, $q) {
|
|
|
+ return {
|
|
|
+ request: function(config) {
|
|
|
+ if (!config.dontShowSpinner)
|
|
|
+ $rootScope.showSpinner();
|
|
|
+ return config;
|
|
|
+ },
|
|
|
+ requestError: function(rejection) {
|
|
|
+ $rootScope.hideSpinner();
|
|
|
+ return $q.reject(rejection);
|
|
|
+ },
|
|
|
+ response: function(response) {
|
|
|
+ $rootScope.hideSpinner();
|
|
|
+ return response;
|
|
|
+ },
|
|
|
+ responseError: function(rejection) {
|
|
|
+ $rootScope.hideSpinner();
|
|
|
+ return $q.reject(rejection);
|
|
|
+ }
|
|
|
+ };
|
|
|
+ }
|
|
|
+ ]);
|
|
|
});
|
|
|
|
|
|
-app.controller("main", function($scope) {
|
|
|
- var largeWindowBoundary = 1023;
|
|
|
+app.controller("main", ['$scope', '$rootScope', function($scope, $rootScope) {
|
|
|
+ var largeWindowBoundary = 1023;
|
|
|
|
|
|
- $scope.menuVisible = false;//window.innerWidth > largeWindowBoundary;
|
|
|
+ $scope.menuVisible = false;//window.innerWidth > largeWindowBoundary;
|
|
|
|
|
|
- $scope.shouldShowMenu = function() {
|
|
|
- return $scope.menuVisible || window.innerWidth > largeWindowBoundary;
|
|
|
- };
|
|
|
+ $scope.shouldShowMenu = function() {
|
|
|
+ return $scope.menuVisible || window.innerWidth > largeWindowBoundary;
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.spinnerVisible = false;
|
|
|
+
|
|
|
+ $rootScope.showSpinner = function() {
|
|
|
+ $scope.spinnerVisible = true;
|
|
|
+ };
|
|
|
+
|
|
|
+ $rootScope.hideSpinner = function() {
|
|
|
+ $scope.spinnerVisible = false;
|
|
|
+ };
|
|
|
|
|
|
- $(window).on("resize.doResize", function() {
|
|
|
- $scope.$apply(function() {
|
|
|
- //$scope.menuVisible = false;
|
|
|
+ $(window).on("resize.doResize", function() {
|
|
|
+ $scope.$apply(function() {
|
|
|
+ //$scope.menuVisible = false;
|
|
|
+ });
|
|
|
});
|
|
|
- });
|
|
|
-});
|
|
|
+ }]);
|