Personal portfolio website for Regina Carvalho. Built with Famous.js library.

contact.js 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /**
  2. * @ngdoc function
  3. * @name domainManagerApp.controller:AboutCtrl
  4. * @description
  5. * # AboutCtrl
  6. * Controller of the domainManagerApp
  7. */
  8. angular.module('goApp.contact', ['ngFx', 'ngAnimate', 'goApp.data', 'mandrill'])
  9. .controller('ContactController',['$scope', '$rootScope', '$famous', '$timeline', '$location', '$route', '$timeout', 'Data', 'Mandrill', '$mixpanel', function ($scope, $rootScope, $famous, $timeline, $location, $route, $timeout, Data, Mandrill, $mixpanel) {
  10. 'use strict';
  11. $scope.showError = false;
  12. $scope.showSuccess = false;
  13. $scope.showSubmit = true;
  14. console.log('> Loading Contact Page');
  15. $mixpanel.track('Page View', { "Page": "Contact" });
  16. // Get Page Data
  17. var link = $location.url();
  18. $scope.pageData = Data.getPageData(link);
  19. $rootScope.$on('data:loaded', function(data) {
  20. if(!$scope.$$phase) {
  21. $scope.$apply(function(){
  22. $scope.pageData = Data.getPageData(link);
  23. $scope.showSlider();
  24. });
  25. }
  26. });
  27. $scope.sendMessage = function(msgData){
  28. console.log("> Sending message from " + msgData.name);
  29. Mandrill.sendMail(msgData);
  30. $mixpanel.track('Messsage Sent', { "Name": msgData.name, "email": msgData.email });
  31. if(!$scope.$$phase) {
  32. $scope.$apply(function(){
  33. $scope.showSubmit = false;
  34. });
  35. } else {
  36. $scope.showSubmit = false;
  37. }
  38. };
  39. // FadeIn
  40. $timeout(function(){
  41. $scope.showView = true;
  42. },100);
  43. // FadeOut
  44. $scope.fadeOut = function() {
  45. $scope.showView = false;
  46. $timeout(function(){
  47. $scope.showView = false;
  48. $location.path("/");
  49. },800);
  50. };
  51. $rootScope.$on('email_sent:error', function(data) {
  52. if(!$scope.$$phase) {
  53. $scope.$apply(function(){
  54. $scope.showError = true;
  55. $scope.showSubmit = false;
  56. $timeout(function(){
  57. if(!$scope.$$phase) {
  58. $scope.$apply(function(){
  59. $scope.showError = false;
  60. $scope.showSubmit = true;
  61. });
  62. }
  63. },5000);
  64. });
  65. }
  66. });
  67. $rootScope.$on('email_sent:success', function(data) {
  68. if(!$scope.$$phase) {
  69. $scope.$apply(function(){
  70. $scope.showSuccess = true;
  71. $scope.msgData.name = "";
  72. $scope.msgData.email = "";
  73. $scope.msgData.message = "";
  74. $timeout(function(){
  75. if(!$scope.$$phase) {
  76. $scope.$apply(function(){
  77. $scope.showSuccess = false;
  78. $scope.showSubmit = true;
  79. });
  80. } else {
  81. $scope.showSuccess = false;
  82. $scope.showSubmit = true;
  83. }
  84. },5000);
  85. });
  86. } else {
  87. $scope.showSuccess = true;
  88. $scope.msgData.name = "";
  89. $scope.msgData.email = "";
  90. $scope.msgData.message = "";
  91. $timeout(function(){
  92. if(!$scope.$$phase) {
  93. $scope.$apply(function(){
  94. $scope.showSuccess = false;
  95. $scope.showSubmit = true;
  96. });
  97. } else {
  98. $scope.showSuccess = false;
  99. $scope.showSubmit = true;
  100. }
  101. },5000);
  102. }
  103. });
  104. }]);