Skip to content

Commit 12cd9e8

Browse files
committed
Added modal window option
1 parent c427033 commit 12cd9e8

File tree

6 files changed

+93
-7
lines changed

6 files changed

+93
-7
lines changed

css/map.css

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,53 @@
135135
height: 530px;
136136
}
137137

138+
/* Modal window */
139+
140+
#overlay
141+
{
142+
position: fixed;
143+
left: 0px;
144+
top: 0px;
145+
width:100%;
146+
height:100%;
147+
z-index: 10000;
148+
background: url(../images/overlay-bg.png) repeat;
149+
}
150+
151+
#modal-window
152+
{
153+
position: absolute;
154+
left: 50%;
155+
margin-left: -460px; /* width divided by 2 */
156+
margin-top: 60px;
157+
width: 920px;
158+
height: 590px;
159+
z-index: 10010;
160+
background: #fff;
161+
border-radius: 10px;
162+
box-shadow: 0 0 10px #656565;
163+
}
164+
165+
#modal-content
166+
{
167+
float: left;
168+
padding: 0 30px; /* there's already a margin on the top of the map-container div */
169+
}
170+
171+
#close-icon
172+
{
173+
position: absolute;
174+
top: -6px;
175+
right: -6px;
176+
width: 18px;
177+
height: 18px;
178+
cursor: pointer;
179+
background: #2c2c2c url(../images/close-icon.png) 3px 3px no-repeat;
180+
border: 1px solid #000;
181+
border-radius: 3px;
182+
box-shadow: 0 0 3px #656565;
183+
}
184+
138185

139186
/* The following is for the geocode page and not the store locator */
140187

images/close-icon.png

1.04 KB
Loading

images/overlay-bg.png

932 Bytes
Loading

js/jquery.storelocator.js

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* storeLocator v1.0.1 - jQuery store locator plugin
2+
* storeLocator v1.1.1 - jQuery store locator plugin
33
* (c) Copyright 2012, Bjorn Holine (http://www.bjornblog.com)
44
* Released under the MIT license
55
* Distance calculation function by Chris Pietschmann: http://pietschsoft.com/post/2008/02/01/Calculate-Distance-Between-Geocodes-in-C-and-JavaScript.aspx
@@ -21,13 +21,22 @@ $.fn.storeLocator = function(options) {
2121
'listColor1' : 'ffffff',
2222
'listColor2' : 'eeeeee',
2323
'bounceMarker' : true,
24-
'slideMap' : true
24+
'slideMap' : false,
25+
'modalWindow' : true
2526
}, options);
2627

2728
return this.each(function() {
2829

2930
var $this = $(this);
3031

32+
//Add modal window divs if set
33+
if(settings.modalWindow == true)
34+
{
35+
$this.wrap('<div id="overlay"><div id="modal-window"><div id="modal-content">');
36+
$('#modal-window').prepend('<div id="close-icon"><\/div>');
37+
$('#overlay').hide();
38+
}
39+
3140
if(settings.slideMap == true)
3241
{
3342
//Let's hide the map container to begin
@@ -184,6 +193,29 @@ $.fn.storeLocator = function(options) {
184193
//Slide in the map container
185194
$this.slideDown();
186195
}
196+
if(settings.modalWindow == true)
197+
{
198+
//Pop up the modal window
199+
$('#overlay').fadeIn();
200+
//Close modal when close icon is clicked
201+
$(document).on('click', '#close-icon', function(){
202+
$('#overlay').hide();
203+
});
204+
//Close modal when background overlay is clicked
205+
$(document).on('click', '#overlay', function(){
206+
$('#overlay').hide();
207+
});
208+
//Prevent clicks within the modal window from closing the entire thing
209+
$(document).on('click', '#modal-window', function(e){
210+
e.stopPropagation();
211+
});
212+
//Close modal when escape key is pressed
213+
$(document).keyup(function(e){
214+
if (e.keyCode == 27) {
215+
$('#overlay').hide();
216+
}
217+
});
218+
}
187219
var map = new google.maps.Map(document.getElementById(settings.mapDiv),myOptions);
188220
var markers = new Array();
189221
//Create one infowindow to fill later

js/jquery.storelocator.min.js

Lines changed: 8 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

readme.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ A note on the distance calculation: this plugin currently uses a distance functi
88

99
## Changelog
1010

11+
### Version 1.1.1
12+
13+
Added a modal window option. Set slideMap to false and modalWindow to true to use it. Also started using the new [jQuery .on() event api](http://blog.jquery.com/2011/11/03/jquery-1-7-released/) - make sure you're using jQuery v1.7+ or this won't work.
14+
1115
### Version 1.0.1
1216

1317
Left a couple of console.logs in my code, which was causing IE to hang.

0 commit comments

Comments
 (0)