Skip to content

Commit

Permalink
Update store locator JS
Browse files Browse the repository at this point in the history
closes dynamic#129
closes dynamic#120
  • Loading branch information
jsirish committed Feb 11, 2017
1 parent 7142d76 commit 8bc832c
Show file tree
Hide file tree
Showing 57 changed files with 5,015 additions and 28 deletions.
2 changes: 1 addition & 1 deletion code/extensions/DistanceDataExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function augmentSQL(SQLQuery &$query)

$query
->addSelect(array(
'( 3959 * acos( cos( radians(' . $Lat . ') ) * cos( radians( `Lat` ) ) * cos( radians( `Lng` ) - radians(' . $Lng . ') ) + sin( radians(' . $Lat . ') ) * sin( radians( `Lat` ) ) ) ) AS distance',
'( 3959 * acos( cos( radians(' . $Lat . ') ) * cos( radians( `Lat` ) ) * cos( radians( `Lng` ) - radians(' . $Lng . ') ) + sin( radians(' . $Lat . ') ) * sin( radians( `Lat` ) ) ) ) AS distanceCalc',
));
}
}
Expand Down
34 changes: 25 additions & 9 deletions code/pages/Locator.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,10 @@ public function init()
Requirements::css('locator/css/map.css');
Requirements::javascript('framework/thirdparty/jquery/jquery.js');
Requirements::javascript('https://maps.google.com/maps/api/js?key=' . $key);
Requirements::javascript('locator/thirdparty/handlebars/handlebars-v1.3.0.js');
Requirements::javascript('locator/thirdparty/jquery-store-locator/js/jquery.storelocator.js');
//Requirements::javascript('locator/thirdparty/handlebars/handlebars-v1.3.0.js');
//Requirements::javascript('locator/thirdparty/jquery-store-locator/js/jquery.storelocator.js');
Requirements::javascript('locator/thirdparty/jquery-store-locator-plugin/assets/js/libs/handlebars.min.js');
Requirements::javascript('locator/thirdparty/jquery-store-locator-plugin/assets/js/plugins/storeLocator/jquery.storelocator.js');

$featuredInList = ($locations->filter('Featured', true)->count() > 0);
$defaultCoords = $this->getAddressSearchCoords() ? $this->getAddressSearchCoords() : '';
Expand Down Expand Up @@ -259,24 +261,38 @@ public function init()
$url .= '?' . http_build_query($vars);
}
$link = $this->Link() . 'xml.xml' . $url;
$link = Controller::join_links($this->AbsoluteLink(), 'xml.xml', $url);

// init map
Requirements::customScript("
$(function(){
$('#map-container').storeLocator({
" . $load . "
//" . $load . "
dataLocation: '" . $link . "',
listTemplatePath: '" . $listTemplatePath . "',
infowindowTemplatePath: '" . $infowindowTemplatePath . "',
originMarker: true,
" . $modal . ',
' . $featured . ",
slideMap: false,
zoomLevel: 0,
//" . $modal . ',
//' . $featured . ",
//slideMap: false,
noForm: true,
distanceAlert: -1,
//distanceAlert: -1,
" . $kilometer . ',
' . $defaultCoords . '
//' . $defaultCoords . ',
mapID: "map",
locationList: "loc-list",
formContainer: "form-container",
formID: "LocatorForm_LocationSearch",
addressID: "LocatorForm_LocationSearch_Address",
searchID: "LocatorForm_LocationSearch_action_doFilterLocations",
\'mapSettings\' : {
zoom : 12,
mapTypeId: google.maps.MapTypeId.ROADMAP,
disableDoubleClickZoom: true,
scrollwheel: false,
navigationControl: false,
draggable: false
}
});
});
');
Expand Down
28 changes: 14 additions & 14 deletions css/map.css
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,15 @@
/* ===
Results List
=== */
#loc-list
.loc-list
{
float: left;
height: 530px;
width: 25%;
overflow: auto;
}

#loc-list ul
.loc-list ul
{
display: block;
clear: left;
Expand All @@ -86,7 +86,7 @@
width: 100%;
}

#loc-list .list-label
.loc-list .list-label
{
float: left;
margin: 10px 0 0 6px;
Expand All @@ -98,26 +98,26 @@
font-weight: bold;
}

#loc-list .list-details
.loc-list .list-details
{
float: left;
margin-left: 6px;
width: 165px;
}

#loc-list .list-content
.loc-list .list-content
{
padding: 10px;
}

#loc-list .loc-dist
.loc-list .loc-dist
{
font-weight: bold;
font-style: italic;
color: #8e8e8e;
}

#loc-list li
.loc-list li
{
display: block;
clear: left;
Expand All @@ -128,10 +128,10 @@
border: 1px solid #fff; /* Adding this to prevent moving li elements when adding the list-focus class*/
}

#loc-list li:first-child {margin-top: 0px;}
.loc-list li:first-child {margin-top: 0px;}


#loc-list .list-focus
.loc-list .list-focus
{
border: 1px solid rgba(82,168,236,0.9);
-moz-box-shadow: 0 0 8px rgba(82,168,236,0.7);
Expand Down Expand Up @@ -215,7 +215,7 @@

@media only screen and (max-width: 960px) {

#loc-list {
.loc-list {

}

Expand All @@ -231,15 +231,15 @@

@media only screen and (min-width: 641px) and (max-width: 959px) {

#loc-list .list-label{
.loc-list .list-label{
margin-left: 0px;
}

#loc-list .list-content {
.loc-list .list-content {
padding: 10px 0px;
}

#loc-list .list-details {
.loc-list .list-details {
width: 140px;
}

Expand All @@ -248,7 +248,7 @@

@media only screen and (max-width: 640px) {

#loc-list {
.loc-list {
width: 100%;
height: auto;
}
Expand Down
9 changes: 5 additions & 4 deletions templates/Layout/Locator.ss
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
<div class="content-container unit size3of4 lastUnit">
<h1>$Title</h1>
<% if $Content %><div class="typography">$Content</div><% end_if %>
<div class="form-container">
$LocationSearch
</div>
<% if $Locations %>
<p>$Locations.Count locations</p>
<div id="form-container">
$LocationSearch
</div>


<div id="map-container">
<div id="map"></div>
<div id="loc-list">
<div class="loc-list">
<ul id="list">
<li><img src="locator/images/ajax-loader.gif" class="loading"></li>
</ul>
Expand Down
Loading

0 comments on commit 8bc832c

Please sign in to comment.