123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- * @ngdoc function
- * @name domainManagerApp.controller:AboutCtrl
- * @description
- * # AboutCtrl
- * Controller of the domainManagerApp
- */
- angular.module('goApp.contact', ['ngFx', 'ngAnimate', 'goApp.data', 'mandrill'])
- .controller('ContactController',['$scope', '$rootScope', '$famous', '$timeline', '$location', '$route', '$timeout', 'Data', 'Mandrill', '$mixpanel', function ($scope, $rootScope, $famous, $timeline, $location, $route, $timeout, Data, Mandrill, $mixpanel) {
- 'use strict';
- $scope.showError = false;
- $scope.showSuccess = false;
- $scope.showSubmit = true;
- console.log('> Loading Contact Page');
- $mixpanel.track('Page View', { "Page": "Contact" });
-
- var link = $location.url();
- $scope.pageData = Data.getPageData(link);
- $rootScope.$on('data:loaded', function(data) {
- if(!$scope.$$phase) {
- $scope.$apply(function(){
- $scope.pageData = Data.getPageData(link);
- $scope.showSlider();
- });
- }
- });
- $scope.sendMessage = function(msgData){
- console.log("> Sending message from " + msgData.name);
- Mandrill.sendMail(msgData);
- $mixpanel.track('Messsage Sent', { "Name": msgData.name, "email": msgData.email });
- if(!$scope.$$phase) {
- $scope.$apply(function(){
- $scope.showSubmit = false;
- });
- } else {
- $scope.showSubmit = false;
- }
- };
-
- $timeout(function(){
- $scope.showView = true;
- },100);
-
- $scope.fadeOut = function() {
- $scope.showView = false;
- $timeout(function(){
- $scope.showView = false;
- $location.path("/");
- },800);
- };
- $rootScope.$on('email_sent:error', function(data) {
- if(!$scope.$$phase) {
- $scope.$apply(function(){
- $scope.showError = true;
- $scope.showSubmit = false;
- $timeout(function(){
- if(!$scope.$$phase) {
- $scope.$apply(function(){
- $scope.showError = false;
- $scope.showSubmit = true;
- });
- }
- },5000);
- });
- }
- });
- $rootScope.$on('email_sent:success', function(data) {
- if(!$scope.$$phase) {
- $scope.$apply(function(){
- $scope.showSuccess = true;
- $scope.msgData.name = "";
- $scope.msgData.email = "";
- $scope.msgData.message = "";
- $timeout(function(){
- if(!$scope.$$phase) {
- $scope.$apply(function(){
- $scope.showSuccess = false;
- $scope.showSubmit = true;
- });
- } else {
- $scope.showSuccess = false;
- $scope.showSubmit = true;
- }
- },5000);
- });
- } else {
- $scope.showSuccess = true;
- $scope.msgData.name = "";
- $scope.msgData.email = "";
- $scope.msgData.message = "";
- $timeout(function(){
- if(!$scope.$$phase) {
- $scope.$apply(function(){
- $scope.showSuccess = false;
- $scope.showSubmit = true;
- });
- } else {
- $scope.showSuccess = false;
- $scope.showSubmit = true;
- }
- },5000);
- }
- });
- }]);
|