Commit 833096115b46db31279dbc30e49bf5eaca7800fc
1 parent
ceda190f
-Map in process
Showing
6 changed files
with
68 additions
and
137 deletions
Show diff stats
frontend/assets/MapAsset.php
| @@ -15,8 +15,7 @@ | @@ -15,8 +15,7 @@ | ||
| 15 | public $baseUrl = '@web'; | 15 | public $baseUrl = '@web'; |
| 16 | public $css = []; | 16 | public $css = []; |
| 17 | public $js = [ | 17 | public $js = [ |
| 18 | - 'https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false', | ||
| 19 | - 'js/gmaps.js', | 18 | + '//maps.googleapis.com/maps/api/js?key=AIzaSyCoR1Jb-mIFUjPwKiuSlmtYBEwnJOBnAgg&callback=initMap', |
| 20 | 'js/gmaps.init.js', | 19 | 'js/gmaps.init.js', |
| 21 | ]; | 20 | ]; |
| 22 | public $depends = [ | 21 | public $depends = [ |
frontend/controllers/SiteController.php
| @@ -116,27 +116,6 @@ class SiteController extends Controller | @@ -116,27 +116,6 @@ class SiteController extends Controller | ||
| 116 | } | 116 | } |
| 117 | 117 | ||
| 118 | /** | 118 | /** |
| 119 | - * Signs user up. | ||
| 120 | - * | ||
| 121 | - * @return mixed | ||
| 122 | - */ | ||
| 123 | - public function actionSignup() | ||
| 124 | - { | ||
| 125 | - $model = new SignupForm(); | ||
| 126 | - if ($model->load(Yii::$app->request->post())) { | ||
| 127 | - if ($user = $model->signup()) { | ||
| 128 | - if (Yii::$app->getUser()->login($user)) { | ||
| 129 | - return $this->goHome(); | ||
| 130 | - } | ||
| 131 | - } | ||
| 132 | - } | ||
| 133 | - | ||
| 134 | - return $this->render('signup', [ | ||
| 135 | - 'model' => $model, | ||
| 136 | - ]); | ||
| 137 | - } | ||
| 138 | - | ||
| 139 | - /** | ||
| 140 | * Requests password reset. | 119 | * Requests password reset. |
| 141 | * | 120 | * |
| 142 | * @return mixed | 121 | * @return mixed |
| @@ -217,6 +196,12 @@ class SiteController extends Controller | @@ -217,6 +196,12 @@ class SiteController extends Controller | ||
| 217 | return [ | 196 | return [ |
| 218 | 'success' => true, | 197 | 'success' => true, |
| 219 | 'message' => 'Success message', | 198 | 'message' => 'Success message', |
| 199 | + 'alert' => '<div class="alert alert-success"> | ||
| 200 | + <h3>Success</h3> | ||
| 201 | + <p> | ||
| 202 | + Success text | ||
| 203 | + </p> | ||
| 204 | + </div>', | ||
| 220 | ]; | 205 | ]; |
| 221 | } else { | 206 | } else { |
| 222 | return [ | 207 | return [ |
frontend/views/site/contact.php
| @@ -6,15 +6,24 @@ | @@ -6,15 +6,24 @@ | ||
| 6 | */ | 6 | */ |
| 7 | 7 | ||
| 8 | use artbox\core\models\Feedback; | 8 | use artbox\core\models\Feedback; |
| 9 | + use common\models\Settings; | ||
| 9 | use frontend\assets\MapAsset; | 10 | use frontend\assets\MapAsset; |
| 10 | use yii\helpers\Html; | 11 | use yii\helpers\Html; |
| 11 | use yii\bootstrap\ActiveForm; | 12 | use yii\bootstrap\ActiveForm; |
| 12 | use yii\web\View; | 13 | use yii\web\View; |
| 13 | 14 | ||
| 14 | MapAsset::register($this); | 15 | MapAsset::register($this); |
| 16 | + $settings = Settings::getInstance(); | ||
| 15 | 17 | ||
| 16 | $this->title = 'Contact'; | 18 | $this->title = 'Contact'; |
| 17 | $this->params[ 'breadcrumbs' ][] = $this->title; | 19 | $this->params[ 'breadcrumbs' ][] = $this->title; |
| 20 | + | ||
| 21 | + $js = <<< JS | ||
| 22 | +window.lat = {$settings->lat}; | ||
| 23 | +window.lon = {$settings->lon}; | ||
| 24 | +JS; | ||
| 25 | + | ||
| 26 | + $this->registerJs($js, View::POS_END); | ||
| 18 | ?> | 27 | ?> |
| 19 | 28 | ||
| 20 | <div id="content"> | 29 | <div id="content"> |
| @@ -144,8 +153,6 @@ | @@ -144,8 +153,6 @@ | ||
| 144 | </div> | 153 | </div> |
| 145 | <!-- /.row --> | 154 | <!-- /.row --> |
| 146 | <?php ActiveForm::end(); ?> | 155 | <?php ActiveForm::end(); ?> |
| 147 | - | ||
| 148 | - | ||
| 149 | </div> | 156 | </div> |
| 150 | </div> | 157 | </div> |
| 151 | <!-- /.row --> | 158 | <!-- /.row --> |
frontend/web/css/custom.css
| @@ -88,7 +88,7 @@ | @@ -88,7 +88,7 @@ | ||
| 88 | #back-to-top { | 88 | #back-to-top { |
| 89 | position: fixed; | 89 | position: fixed; |
| 90 | top: 100px; | 90 | top: 100px; |
| 91 | - left: 0px; | 91 | + left: 0; |
| 92 | z-index: 9999; | 92 | z-index: 9999; |
| 93 | width: 40px; | 93 | width: 40px; |
| 94 | height: 40px; | 94 | height: 40px; |
| @@ -100,7 +100,7 @@ | @@ -100,7 +100,7 @@ | ||
| 100 | text-decoration: none; | 100 | text-decoration: none; |
| 101 | transition: opacity 0.2s ease-out; | 101 | transition: opacity 0.2s ease-out; |
| 102 | opacity: 0; | 102 | opacity: 0; |
| 103 | - padding: 4px; | 103 | + padding: 4px 1px 4px 0; |
| 104 | } | 104 | } |
| 105 | 105 | ||
| 106 | #back-to-top:hover { | 106 | #back-to-top:hover { |
frontend/web/js/gmaps.init.js
| 1 | $( | 1 | $( |
| 2 | function() { | 2 | function() { |
| 3 | 3 | ||
| 4 | - map(); | ||
| 5 | - | ||
| 6 | - } | ||
| 7 | -); | ||
| 8 | - | ||
| 9 | -/* map */ | ||
| 10 | - | ||
| 11 | -function map() { | ||
| 12 | - | ||
| 13 | - var styles = [ | ||
| 14 | - { | ||
| 15 | - "featureType": "landscape", | ||
| 16 | - "stylers": [ | ||
| 17 | - {"saturation": -100}, | ||
| 18 | - {"lightness": 65}, | ||
| 19 | - {"visibility": "on"} | ||
| 20 | - ] | ||
| 21 | - }, | ||
| 22 | - { | ||
| 23 | - "featureType": "poi", | ||
| 24 | - "stylers": [ | ||
| 25 | - {"saturation": -100}, | ||
| 26 | - {"lightness": 51}, | ||
| 27 | - {"visibility": "simplified"} | ||
| 28 | - ] | ||
| 29 | - }, | ||
| 30 | - { | ||
| 31 | - "featureType": "road.highway", | ||
| 32 | - "stylers": [ | ||
| 33 | - {"saturation": -100}, | ||
| 34 | - {"visibility": "simplified"} | ||
| 35 | - ] | ||
| 36 | - }, | ||
| 37 | - { | ||
| 38 | - "featureType": "road.arterial", | ||
| 39 | - "stylers": [ | ||
| 40 | - {"saturation": -100}, | ||
| 41 | - {"lightness": 30}, | ||
| 42 | - {"visibility": "on"} | ||
| 43 | - ] | ||
| 44 | - }, | ||
| 45 | - { | ||
| 46 | - "featureType": "road.local", | ||
| 47 | - "stylers": [ | ||
| 48 | - {"saturation": -100}, | ||
| 49 | - {"lightness": 40}, | ||
| 50 | - {"visibility": "on"} | ||
| 51 | - ] | ||
| 52 | - }, | ||
| 53 | - { | ||
| 54 | - "featureType": "transit", | ||
| 55 | - "stylers": [ | ||
| 56 | - {"saturation": -100}, | ||
| 57 | - {"visibility": "simplified"} | ||
| 58 | - ] | ||
| 59 | - }, | ||
| 60 | - { | ||
| 61 | - "featureType": "administrative.province", | ||
| 62 | - "stylers": [ {"visibility": "off"} ] | ||
| 63 | - }, | ||
| 64 | - { | ||
| 65 | - "featureType": "water", | ||
| 66 | - "elementType": "labels", | ||
| 67 | - "stylers": [ | ||
| 68 | - {"visibility": "on"}, | ||
| 69 | - {"lightness": -25}, | ||
| 70 | - {"saturation": -100} | ||
| 71 | - ] | ||
| 72 | - }, | ||
| 73 | - { | ||
| 74 | - "featureType": "water", | ||
| 75 | - "elementType": "geometry", | ||
| 76 | - "stylers": [ | ||
| 77 | - {"hue": "#ffff00"}, | ||
| 78 | - {"lightness": -25}, | ||
| 79 | - {"saturation": -97} | ||
| 80 | - ] | ||
| 81 | - } | ||
| 82 | - ]; | ||
| 83 | - map = new GMaps( | ||
| 84 | - { | ||
| 85 | - el: '#map', | ||
| 86 | - lat: -12.043333, | ||
| 87 | - lng: -77.028333, | ||
| 88 | - zoomControl: true, | ||
| 89 | - zoomControlOpt: { | ||
| 90 | - style: 'SMALL', | ||
| 91 | - position: 'TOP_LEFT' | ||
| 92 | - }, | ||
| 93 | - panControl: false, | ||
| 94 | - streetViewControl: false, | ||
| 95 | - mapTypeControl: false, | ||
| 96 | - overviewMapControl: false, | 4 | + function initMap() { |
| 5 | + var map = new google.maps.Map( | ||
| 6 | + document.getElementById('map'), { | ||
| 7 | + center: { | ||
| 8 | + lat: parseFloat(window.lat), | ||
| 9 | + lng: parseFloat(window.lon) | ||
| 10 | + }, | ||
| 97 | scrollwheel: false, | 11 | scrollwheel: false, |
| 98 | - draggable: false, | ||
| 99 | - styles: styles | 12 | + zoom: 16 |
| 13 | + } | ||
| 14 | + ); | ||
| 100 | } | 15 | } |
| 101 | - ); | ||
| 102 | - | ||
| 103 | - var image = 'img/marker.png'; | ||
| 104 | 16 | ||
| 105 | - map.addMarker( | ||
| 106 | - { | ||
| 107 | - lat: -12.043333, | ||
| 108 | - lng: -77.028333, | ||
| 109 | - icon: image/* , | ||
| 110 | - title: '', | ||
| 111 | - infoWindow: { | ||
| 112 | - content: '<p>HTML Content</p>' | ||
| 113 | - }*/ | ||
| 114 | - } | ||
| 115 | - ); | ||
| 116 | -} | ||
| 117 | \ No newline at end of file | 17 | \ No newline at end of file |
| 18 | + window.initMap = initMap(); | ||
| 19 | + } | ||
| 20 | +); |
frontend/web/js/script.js
| 1 | $( | 1 | $( |
| 2 | function() { | 2 | function() { |
| 3 | 3 | ||
| 4 | + /** | ||
| 5 | + * Modal form submit code | ||
| 6 | + */ | ||
| 4 | $(document) | 7 | $(document) |
| 5 | .on( | 8 | .on( |
| 6 | 'beforeSubmit', '#feedback-form', function(e) { | 9 | 'beforeSubmit', '#feedback-form', function(e) { |
| @@ -33,6 +36,40 @@ $( | @@ -33,6 +36,40 @@ $( | ||
| 33 | } | 36 | } |
| 34 | ); | 37 | ); |
| 35 | 38 | ||
| 39 | + /** | ||
| 40 | + * Contact form submitting | ||
| 41 | + */ | ||
| 42 | + $(document) | ||
| 43 | + .on( | ||
| 44 | + 'beforeSubmit', '#contact-form', function(e) { | ||
| 45 | + var f = this; | ||
| 46 | + var form = $(this); | ||
| 47 | + var formData = form.serialize(); | ||
| 48 | + $.ajax( | ||
| 49 | + { | ||
| 50 | + url: form.attr("action"), | ||
| 51 | + type: form.attr("method"), | ||
| 52 | + data: formData, | ||
| 53 | + success: function(data) { | ||
| 54 | + f.reset(); | ||
| 55 | + form.replaceWith(data.alert) | ||
| 56 | + }, | ||
| 57 | + error: function() { | ||
| 58 | + | ||
| 59 | + } | ||
| 60 | + } | ||
| 61 | + ); | ||
| 62 | + } | ||
| 63 | + ) | ||
| 64 | + .on( | ||
| 65 | + 'submit', '#contact-form', function(e) { | ||
| 66 | + e.preventDefault(); | ||
| 67 | + } | ||
| 68 | + ); | ||
| 69 | + | ||
| 70 | + /** | ||
| 71 | + * Button UP code | ||
| 72 | + */ | ||
| 36 | if ($('#back-to-top').length) { | 73 | if ($('#back-to-top').length) { |
| 37 | var scrollTrigger = 100, // px | 74 | var scrollTrigger = 100, // px |
| 38 | backToTop = function() { | 75 | backToTop = function() { |