UNPKG

cobuild-angular-stack

Version:

Base stack angular sass jade gulp

221 lines (188 loc) 7.92 kB
(function () { 'use strict'; angular.module('uniko.guest') .controller('GuestMainController', GuestMainController) .controller('CartController', CartController); GuestMainController.$inject = ['$scope', '$rootScope', '$timeout', '$state', 'CoupleAccount', '$http', '$stateParams', '$uibModal', 'toastr', 'Upload', 'Auth', 'uiGmapGoogleMapApi', '$analytics', '$translate', 'account', 'lodash']; function GuestMainController($scope, $rootScope, $timeout, $state, CoupleAccount, $http, $stateParams, $uibModal, toastr, Upload, Auth, GoogleMapApi, $analytics, $translate, account, lodash) { var styleMap = [ { "featureType": "water", "elementType": "geometry", "stylers": [{"color": "#e9e9e9"}, {"lightness": 17}] }, { "featureType": "landscape", "elementType": "geometry", "stylers": [{"color": "#f5f5f5"}, {"lightness": 20}] }, { "featureType": "road.highway", "elementType": "geometry.fill", "stylers": [{"color": "#ffffff"}, {"lightness": 17}] }, { "featureType": "road.highway", "elementType": "geometry.stroke", "stylers": [{"color": "#ffffff"}, {"lightness": 29}, {"weight": 0.2}] }, { "featureType": "road.arterial", "elementType": "geometry", "stylers": [{"color": "#ffffff"}, {"lightness": 18}] }, { "featureType": "road.local", "elementType": "geometry", "stylers": [{"color": "#ffffff"}, {"lightness": 16}] }, { "featureType": "poi", "elementType": "geometry", "stylers": [{"color": "#f5f5f5"}, {"lightness": 21}] }, { "featureType": "poi.park", "elementType": "geometry", "stylers": [{"color": "#dedede"}, {"lightness": 21}] }, { "elementType": "labels.text.stroke", "stylers": [{"visibility": "on"}, {"color": "#ffffff"}, {"lightness": 16}] }, { "elementType": "labels.text.fill", "stylers": [{"saturation": 36}, {"color": "#333333"}, {"lightness": 40}] }, {"elementType": "labels.icon", "stylers": [{"visibility": "off"}]}, { "featureType": "transit", "elementType": "geometry", "stylers": [{"color": "#f2f2f2"}, {"lightness": 19}] }, { "featureType": "administrative", "elementType": "geometry.fill", "stylers": [{"color": "#fefefe"}, {"lightness": 20}] }, { "featureType": "administrative", "elementType": "geometry.stroke", "stylers": [{"color": "#fefefe"}, {"lightness": 17}, {"weight": 1.2}] }]; $scope.account = account; var originalaccount; $scope.weddingDate = null; $scope.rsvp = { confirm: true }; //$scope.emailFormat = /^[\w\+-_]+@\w+\.\w{2,5}$/; $scope.emailFormat = /^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$/; $scope.sendedRSVP = false; $scope.window = { show: false, options: { pixelOffset: {width: 0, height: -40} }, templateurl: 'window.tpl.html', templateparameter: {}, closeClick: function () { $scope.window.show = false; } }; $scope.map = { control: {}, center: { latitude: 19.4284700, longitude: -99.1276600 }, zoom: 7, dragging: false, bounds: {}, markers: [], idkey: 'place_id', events: { idle: function (map) { }, dragend: function (map) { } }, options: { styles: styleMap } }; $scope.sendRsvp = function () { CoupleAccount .prototype$__create__rsvps({id: $scope.account.id}, $scope.rsvp) .$promise .then(function () { getMixpanel().people.increment({ 'RSVP': 1 }); $analytics.eventTrack('RSVP Confirmation', { 'Status': $scope.rsvp.confirm ? 'Accepted' : 'Declined' }); $scope.sendedRSVP = true; setTimeout(function() { console.log("llega"); $('html,body').animate({ scrollTop: $("#success-position").offset().top }, 1000); },1000); }) .catch(console.log.bind(console)); }; $rootScope.cartDisabled = $scope.account.isDisabled; getMixpanel().identify($scope.account.id); $scope.weddingData = $scope.account.weddingData; if ($scope.account.weddingData.date) { $scope.account.weddingData.date = new Date($scope.account.weddingData.date); } if ($scope.account.weddingData.gpsaddress) { $scope.map.markers = [$scope.account.weddingData.gpsaddress]; $scope.map.zoom = 16; $scope.map.center = { latitude: $scope.account.weddingData.gpsaddress.latitude, longitude: $scope.account.weddingData.gpsaddress.longitude }; } $scope.account.weddingData.coverPhoto = $scope.account.weddingData.coverPhoto ? $scope.account.weddingData.coverPhoto : "https://s3-us-west-2.amazonaws.com/uniko-prod/products/undefined/images/1463434858873?timestamp=1463434861201"; $('.bg-cover').css('background-image', 'url("' + $scope.account.weddingData.coverPhoto + '")'); $rootScope.$broadcast('imageProfile', $scope.account.weddingData.profilePhoto); GoogleMapApi.then(function (maps) { maps.visualRefresh = true; $scope.defaultBounds = new google.maps.LatLngBounds( new google.maps.LatLng(40.82148, -73.66450), new google.maps.LatLng(40.66541, -74.31715)); $scope.map.bounds = { northeast: { latitude: $scope.defaultBounds.getNorthEast().lat(), longitude: $scope.defaultBounds.getNorthEast().lng() }, southwest: { latitude: $scope.defaultBounds.getSouthWest().lat(), longitude: -$scope.defaultBounds.getSouthWest().lng() } }; }); } CartController.$inject = ['$rootScope', '$scope', '$localStorage','lodash']; function CartController($rootScope, $scope, $localStorage, lodash) { function loadUrl() { var cart = $localStorage.cart; var paymentInfo = $localStorage.paymentInfo; delete $rootScope.cartUrl; delete $rootScope.cartId; delete $rootScope.totalCart; if (!cart) { return; } lodash.some(cart, function (val, key) { $rootScope.cartUrl = $localStorage.cartUrls[key].url; return $rootScope.cartId = key; }); if (!$rootScope.cartId) { return; } var weddingCart = cart[$rootScope.cartId]; if (!weddingCart) { delete $rootScope.totalCart; return; } $rootScope.totalCart = weddingCart.length; } $scope.$watch(function () { return JSON.stringify($localStorage); }, loadUrl); if ($localStorage.cart) { loadUrl(); } } })();