Add Google Maps Iframe embed service

This commit is contained in:
Hugo Heneault 2018-09-14 11:55:41 +02:00
parent 096065c0bb
commit 1b5f0cad47
2 changed files with 35 additions and 0 deletions

View File

@ -1447,5 +1447,11 @@ var tarteaucitron = {
}
}
return source;
},
"getElemWidth": function(elem) {
return elem.getAttribute('width') || elem.clientWidth;
},
"getElemHeight": function(elem) {
return elem.getAttribute('height') || elem.clientHeight;
}
};

View File

@ -1191,6 +1191,35 @@ tarteaucitron.services.googlemapssearch = {
}
};
// googlemaps embed iframe
tarteaucitron.services.googlemapsembed = {
"key": "googlemapsembed",
"type": "api",
"name": "Google Maps Embed",
"uri": "http://www.google.com/ads/preferences/",
"needConsent": true,
"cookies": ['apisid', 'hsid', 'nid', 'sapisid', 'sid', 'sidcc', 'ssid', '1p_jar'],
"js": function () {
"use strict";
tarteaucitron.fallback(['googlemapsembed'], function (x) {
var width = tarteaucitron.getElemWidth(x),
height = tarteaucitron.getElemHeight(x),
url = x.getAttribute("data-url");
return '<iframe src="' + url + '" width="' + width + '" height="' + height + '" frameborder="0" scrolling="no" allowtransparency allowfullscreen></iframe>';
});
},
"fallback": function () {
"use strict";
var id = 'googlemapsembed';
tarteaucitron.fallback(['googlemapsembed'], function (elem) {
elem.style.width = tarteaucitron.getElemWidth(elem) + 'px';
elem.style.height = tarteaucitron.getElemHeight(elem) + 'px';
return tarteaucitron.engage(id);
});
}
};
// google tag manager
tarteaucitron.services.googletagmanager = {
"key": "googletagmanager",