authService.login = function(data){
var deferred = $q.defer();
$http.post('/auth/login', data).then(function(response){
setTimeout(function() {
if(response.data){
deferred.resolve(response);
}else {
deferred.reject('err');
}
},1000);
});
return deferred.promise;
};
angular.module('authController', ['ngCookies'])
.controller('authController', ['$scope', '$http', '$rootScope', '$location', '$cookies', function($scope, $http, $rootScope, $location, $cookies){
$scope.user = {username: '', password: ''};
$scope.error_message = '';
$scope.login = function(){
$http.post('/auth/login', $scope.user).success(function(data){
if(data.state === 'success'){
$rootScope.authenticated = true;
$rootScope.current_user = data.user.username;
$cookies.putObject('user', data.user);
$location.path('/');
}
else{
$scope.error_message = data.message;
}
});
};
}]);
})();
.run(function($rootScope, $cookies) {
$rootScope.authenticated = false;
$rootScope.current_user = '';
var cookies = $cookies.getObject('user');
if(cookies){
$rootScope.authenticated = true;
$rootScope.current_user = cookies.username;
}
$rootScope.signout = function(){
$http.get('auth/signout');
$rootScope.authenticated = false;
$rootScope.current_user = '';
};
});
function OnResize() {
parent.$('.fancybox-inner').css('height', 'auto');
parent.$('.fancybox-outer').css('height', 'auto');
parent.$('.fancybox-wrap').css('height', 'auto');
parent.$('.fancybox-skin').css('height', 'auto');
//parent.$('.fancybox-iframe').css('height', 'auto');
var DivH = $('#order').height() + parseInt($('#order').css('padding-top'))*2;
wrTop = (parent.$('.fancybox-overlay').height()-DivH)/2;
if(wrTop < 0){
wrTop = 0;
DivH = parent.$('.fancybox-overlay').height();
}
parent.$('.fancybox-iframe').css('height', DivH);
parent.$('.fancybox-inner').css({'height': DivH});
parent.$('.fancybox-wrap').css({'top': wrTop});
}