make sure maps dont load twice

This commit is contained in:
sanj 2011-01-03 12:46:39 +05:30
parent 2b53746209
commit 996435aab4

View File

@ -22,10 +22,14 @@ $(function() {
var t = $(this); var t = $(this);
var href = t.attr("href"); var href = t.attr("href");
if (href.indexOf("http://maps.google.com") != -1) { if (href.indexOf("http://maps.google.com") != -1) {
if (t.data("mapLoaded")) {
return false;
}
var embedUrl = href + "&output=embed"; var embedUrl = href + "&output=embed";
var iframe = $('<iframe />').attr("src", embedUrl).attr("width", "425").attr("height", "350"); var iframe = $('<iframe />').attr("src", embedUrl).attr("width", "425").attr("height", "350");
var parentP = t.parents('p'); var parentP = t.parents('p');
parentP.append("<br />").append(iframe); parentP.append("<br />").append(iframe);
t.data("mapLoaded", true);
t.toggle(function() { t.toggle(function() {
iframe.slideUp(); iframe.slideUp();
}, function() { }, function() {