christeach
8/3/2017 - 9:13 AM

Sitebar Extension - Responsive Sitebar Extension für den Creative Manager

Sitebar Extension - Responsive Sitebar Extension für den Creative Manager

(function(){
	o.html5sitebar = {
		adexpanded : false,
		minWidth : parseInt("160"),
		minHeight : parseInt("600"),
		noVScale:false,
		posFix:false,
		getWindowDim: function(){
			var wd = o.w.innerWidth|| o.w.document.documentElement.clientWidth || o.w.document.body.clientWidth,
			ht = o.w.innerHeight|| o.w.document.documentElement.clientHeight || o.w.document.body.clientHeight;
			return {
				width: wd,
				height: ht
				};
		},
		scrollBarSize:function () {
			var outer = document.createElement("div"), widthNoScroll = 0, widthWithScroll = 0, inner = "";

			outer.style.visibility = "hidden";
			outer.style.width = "100px";
			outer.style.msOverflowStyle = "scrollbar";

			o.w.document.body.appendChild(outer);
			outer.style.overflow = "scroll";

			inner = o.w.document.createElement("div");
			inner.style.width = "100%";
			outer.appendChild(inner);

			widthNoScroll = outer.offsetWidth;
			widthWithScroll = inner.offsetWidth;

			outer.parentNode.removeChild(outer);

			return widthNoScroll - widthWithScroll;
		},
		resizeAd:function(){
			var p = o.html5sitebar,
			addiv = o.$(o.divID), innerdiv = o.$(o.inDivID), frame = o.$(o.frameID),
			sideWidth = p.getWindowDim().width - p.scrollBarSize() - o.$().x(), sideHeight = p.getWindowDim().height - o.$().y(),
			newWidth = sideWidth,
			newHeight = sideHeight;
			
			if(newWidth<p.minWidth){
				newWidth = p.minWidth;
			}
			if(newHeight<p.minHeight || p.noVScale){
				newHeight = p.minHeight;
			}
			addiv.style.width = frame.style.width = Math.round(newWidth) + "px";
			addiv.style.height = frame.style.height = Math.round(newHeight) + "px";
		},
		scrollTop:function (){
			return o.w.document.body.scrollTop || o.w.document.documentElement.scrollTop;
		},
		init:function(){
			o.addEventListener("start", function(){
				var p =  o.html5sitebar,
				domain = o.w.location.hostname;
				//if(typeof o.qs("ftx","")!=="undefined" && typeof o.qs("fty","")!=="undefined" && o.qs("ftx","")!=="" && o.qs("fty","")!==""){
					o.attachtobody = false;
					o.customPos = true;
				//}
					var f = function(){
					try {
						o.dispatchEvent("scroll");
					}catch(e){}
				};
				if(o.w.addEventListener) {
						o.w.addEventListener("scroll",f,false);
					}else{
						o.w.attachEvent("onscroll",f);
					}
					o.addEventListener("scroll", function() {
				});
			});
			o.addEventListener("adonpage", function(){
				var p =  o.html5sitebar,
				addiv = o.$(o.divID), innerdiv = o.$(o.inDivID), frame = o.$(o.frameID), posdiv = o.$(o.phID);
				if (o.bver("Safari") && !o.bver("chrome")) {
					addiv.style.position = 'absolute';
				}else{
					addiv.style.position = 'fixed';
				}
				posdiv.style.height = 1 + 'px';
				p.resizeAd();
				if(p.posFix){
						var rp = setInterval(function(){
								if(o.$().x() === 0){
									o.dispatchEvent('resize');
							}else{
								clearInterval(rp);
							}
						}, 150);
				}

				//safeFrame Fix
				if(o.safeFrame) {
					document.querySelector('iframe').style.width = '100%';
					document.querySelector('iframe').style.height = '100%';
				}

				if(typeof o.qs("ftz","")==="undefined" || o.qs("ftz","")===""){
					o.$().style.zIndex = 2;
				}
					
			});
			o.addEventListener("resize", function(){
				var p =  o.html5sitebar;
				p.resizeAd();
			});
			o.addEventListener("scroll", function(){
				var p =  o.html5sitebar;
				//p.resizeAd();
			});
			o.addEventListener("adready", function(){
				var p =  o.html5sitebar;
				p.resizeAd();
			});
            o.addEventListener("contract", function(){
				var p =  o.html5sitebar;
				p.resizeAd();
			});
            setTimeout("o.dispatchEvent('resize')",200);
		}()
	};
	o.customPosFunc = function(){
        var p =  o.html5sitebar;
        o.$().style.top = 0 +"px";
	};
})();


//Parses scrollValues to html5 via external interface updated version v4
(function () {
    o.scrollY = {
        getScrollY: function () {
            var scrOfY = o.w.pageYOffset || o.w.document.body.scrollTop;
            return scrOfY;
        },
        submitScroll: function () {
            var p = o.scrollY,
                scrollObject = {
                    yPos: p.getScrollY(),
                    yMax: p.getDocHeight()
                };
            try {
                o.dispatchToCreative('onScroll', scrollObject);
            } catch (e) {}
        },
        getDocHeight: function () {
            var p = o.scrollY;
            p.yMax = Math.max(
                Math.max(o.w.document.body.scrollHeight, o.w.document.documentElement.scrollHeight),
                Math.max(o.w.document.body.offsetHeight, o.w.document.documentElement.offsetHeight),
                Math.max(o.w.document.body.clientHeight, o.w.document.documentElement.clientHeight)
            );
            return p.yMax;
        },
        init: function () {
            o.addEventListener("adonpage", function () {
                var p = o.scrollY;
                if (typeof o.w.addEventListener !== "undefined") {
                    o.w.addEventListener("scroll", p.submitScroll, true);
                } else {
                    o.w.attachEvent("onscroll", p.submitScroll);
                }
            });
            o.addEventListener("adready", function () {
                var p = o.scrollY;
                p.submitScroll();
            });
            o.addEventListener("start", function () {
                var p = o.scrollY;
                o.flashVar('yMax', p.getDocHeight());
            });
        }()
    };
})();
(function(){
	o.html5sitebar = {
		adexpanded : false,
		minWidth : parseInt("160"),
		minHeight : parseInt("600"),
		noVScale:false,
		posFix:false,
		getWindowDim: function(){
			var wd = o.w.innerWidth|| o.w.document.documentElement.clientWidth || o.w.document.body.clientWidth,
			ht = o.w.innerHeight|| o.w.document.documentElement.clientHeight || o.w.document.body.clientHeight;
			return {
				width: wd,
				height: ht
				};
		},
		scrollBarSize:function () {
			var outer = document.createElement("div"), widthNoScroll = 0, widthWithScroll = 0, inner = "";

			outer.style.visibility = "hidden";
			outer.style.width = "100px";
			outer.style.msOverflowStyle = "scrollbar";

			o.w.document.body.appendChild(outer);
			outer.style.overflow = "scroll";

			inner = o.w.document.createElement("div");
			inner.style.width = "100%";
			outer.appendChild(inner);

			widthNoScroll = outer.offsetWidth;
			widthWithScroll = inner.offsetWidth;

			outer.parentNode.removeChild(outer);

			return widthNoScroll - widthWithScroll;
		},
		resizeAd:function(){
			var p = o.html5sitebar,
			addiv = o.$(o.divID), innerdiv = o.$(o.inDivID), frame = o.$(o.frameID),
			sideWidth = p.getWindowDim().width - p.scrollBarSize() - o.$().x(), sideHeight = p.getWindowDim().height - o.$().y(),
			newWidth = sideWidth,
			newHeight = sideHeight;
			
			if(newWidth<p.minWidth){
				newWidth = p.minWidth;
			}
			if(newHeight<p.minHeight || p.noVScale){
				newHeight = p.minHeight;
			}
			addiv.style.width = frame.style.width = Math.round(newWidth) + "px";
			addiv.style.height = frame.style.height = Math.round(newHeight) + "px";
		},
		scrollTop:function (){
			return o.w.document.body.scrollTop || o.w.document.documentElement.scrollTop;
		},
		init:function(){
			o.addEventListener("start", function(){
				var p =  o.html5sitebar,
				domain = o.w.location.hostname;
				//if(typeof o.qs("ftx","")!=="undefined" && typeof o.qs("fty","")!=="undefined" && o.qs("ftx","")!=="" && o.qs("fty","")!==""){
					o.attachtobody = false;
					o.customPos = true;
				//}
					var f = function(){
					try {
						o.dispatchEvent("scroll");
					}catch(e){}
				};
				if(o.w.addEventListener) {
						o.w.addEventListener("scroll",f,false);
					}else{
						o.w.attachEvent("onscroll",f);
					}
					o.addEventListener("scroll", function() {
				});
			});
			o.addEventListener("adonpage", function(){
				var p =  o.html5sitebar,
				addiv = o.$(o.divID), innerdiv = o.$(o.inDivID), frame = o.$(o.frameID), posdiv = o.$(o.phID);
				if (o.bver("Safari") && !o.bver("chrome")) {
					addiv.style.position = 'absolute';
				}else{
					addiv.style.position = 'fixed';
				}
				posdiv.style.height = 1 + 'px';
				p.resizeAd();
				if(p.posFix){
						var rp = setInterval(function(){
								if(o.$().x() === 0){
									o.dispatchEvent('resize');
							}else{
								clearInterval(rp);
							}
						}, 150);
				}

				//safeFrame Fix
				if(o.safeFrame) {
					document.querySelector('iframe').style.width = '100%';
					document.querySelector('iframe').style.height = '100%';
				}

				if(typeof o.qs("ftz","")==="undefined" || o.qs("ftz","")===""){
					o.$().style.zIndex = 2;
				}
					
			});
			o.addEventListener("resize", function(){
				var p =  o.html5sitebar;
				p.resizeAd();
			});
			o.addEventListener("scroll", function(){
				var p =  o.html5sitebar;
				//p.resizeAd();
			});
			o.addEventListener("adready", function(){
				var p =  o.html5sitebar;
				p.resizeAd();
			});
            o.addEventListener("contract", function(){
				var p =  o.html5sitebar;
				p.resizeAd();
			});
            setTimeout("o.dispatchEvent('resize')",200);
		}()
	};
	o.customPosFunc = function(){
        var p =  o.html5sitebar;
        o.$().style.top = 0 +"px";
	};
})();


//Parses scrollValues to html5 via external interface updated version v4
(function () {
    o.scrollY = {
        getScrollY: function () {
            var scrOfY = o.w.pageYOffset || o.w.document.body.scrollTop;
            return scrOfY;
        },
        submitScroll: function () {
            var p = o.scrollY,
                scrollObject = {
                    yPos: p.getScrollY(),
                    yMax: p.getDocHeight()
                };
            try {
                o.dispatchToCreative('onScroll', scrollObject);
            } catch (e) {}
        },
        getDocHeight: function () {
            var p = o.scrollY;
            p.yMax = Math.max(
                Math.max(o.w.document.body.scrollHeight, o.w.document.documentElement.scrollHeight),
                Math.max(o.w.document.body.offsetHeight, o.w.document.documentElement.offsetHeight),
                Math.max(o.w.document.body.clientHeight, o.w.document.documentElement.clientHeight)
            );
            return p.yMax;
        },
        init: function () {
            o.addEventListener("adonpage", function () {
                var p = o.scrollY;
                if (typeof o.w.addEventListener !== "undefined") {
                    o.w.addEventListener("scroll", p.submitScroll, true);
                } else {
                    o.w.attachEvent("onscroll", p.submitScroll);
                }
            });
            o.addEventListener("adready", function () {
                var p = o.scrollY;
                p.submitScroll();
            });
            o.addEventListener("start", function () {
                var p = o.scrollY;
                o.flashVar('yMax', p.getDocHeight());
            });
        }()
    };
})();