-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathResponsiveAdsense.js
More file actions
32 lines (28 loc) · 940 Bytes
/
ResponsiveAdsense.js
File metadata and controls
32 lines (28 loc) · 940 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
var ResponsiveAdsense = new (function(){
var THIS = this;
THIS._banners = [];
THIS._t = ['WebkitTransform','MozTransform','OTransform ','msTransform','transform'];
THIS.resizeHandler = function(){
var bc = THIS._banners;
for(var x=0;x<bc.length;x++)
{
var banner = bc[x].getElementsByTagName("ins")[0];
if(!banner) throw new Error('The ResponsiveAdsense container should contain the element <ins class="adsbygoogle" ...>');
for(var y=0; y<THIS._t.length; y++)
{
try{
banner.style[THIS._t[y]] = 'scaleX(' + (bc[x].clientWidth / banner.offsetWidth) + ') scaleY(' + (bc[x].clientHeight / banner.offsetHeight) + ')';
banner.style[THIS._t[y]+'Origin'] = 'top left';
} catch(e){};
}
}
};
return this;
})();
ResponsiveAdsense.addBanner = function(el){
this._banners.push(el);
};
ResponsiveAdsense.addBanners = function(arrEls){
for(var x=0;x<arrEls.length;x++)
this.addBanner(arrEls[x]);
};