@azerion/phaser-ads
Advanced tools
Comparing version 2.4.0 to 2.4.1
@@ -157,7 +157,28 @@ declare module 'phaser-ads' { | ||
} | ||
enum GameDistributionAlignment { | ||
TopLeft = 0, | ||
TopCenter = 1, | ||
TopRight = 2, | ||
CenterLeft = 3, | ||
Center = 4, | ||
CenterRight = 5, | ||
BottomLeft = 6, | ||
BottomCenter = 7, | ||
BottomRight = 8 | ||
} | ||
class GameDistributionBanner { | ||
element: HTMLElement; | ||
private resizeListener; | ||
private parent; | ||
private alignment; | ||
private width; | ||
private height; | ||
private offsetX; | ||
private offsetY; | ||
constructor(); | ||
loadBanner(): void; | ||
destroy(): void; | ||
alignIn(element: HTMLElement, position: GameDistributionAlignment): void; | ||
setOffset(x?: number, y?: number): void; | ||
private resize; | ||
setSize(size: GameDistributionBannerSize): void; | ||
@@ -164,0 +185,0 @@ position(x: number, y: number): void; |
/*! | ||
* phaser-ads - version 2.4.0 | ||
* phaser-ads - version 2.4.1 | ||
* A Phaser plugin for providing nice ads integration in your phaser.io game | ||
@@ -650,4 +650,18 @@ * | ||
})(GameDistributionBannerSize = AdProvider.GameDistributionBannerSize || (AdProvider.GameDistributionBannerSize = {})); | ||
var GameDistributionAlignment; | ||
(function (GameDistributionAlignment) { | ||
GameDistributionAlignment[GameDistributionAlignment["TopLeft"] = 0] = "TopLeft"; | ||
GameDistributionAlignment[GameDistributionAlignment["TopCenter"] = 1] = "TopCenter"; | ||
GameDistributionAlignment[GameDistributionAlignment["TopRight"] = 2] = "TopRight"; | ||
GameDistributionAlignment[GameDistributionAlignment["CenterLeft"] = 3] = "CenterLeft"; | ||
GameDistributionAlignment[GameDistributionAlignment["Center"] = 4] = "Center"; | ||
GameDistributionAlignment[GameDistributionAlignment["CenterRight"] = 5] = "CenterRight"; | ||
GameDistributionAlignment[GameDistributionAlignment["BottomLeft"] = 6] = "BottomLeft"; | ||
GameDistributionAlignment[GameDistributionAlignment["BottomCenter"] = 7] = "BottomCenter"; | ||
GameDistributionAlignment[GameDistributionAlignment["BottomRight"] = 8] = "BottomRight"; | ||
})(GameDistributionAlignment = AdProvider.GameDistributionAlignment || (AdProvider.GameDistributionAlignment = {})); | ||
var GameDistributionBanner = /** @class */ (function () { | ||
function GameDistributionBanner() { | ||
this.offsetX = 0; | ||
this.offsetY = 0; | ||
this.element = document.createElement('div'); | ||
@@ -668,3 +682,56 @@ this.element.style.position = 'absolute'; | ||
document.body.removeChild(this.element); | ||
this.element = null; | ||
this.parent = null; | ||
this.alignment = null; | ||
if (this.resizeListener) { | ||
window.removeEventListener('resize', this.resizeListener); | ||
} | ||
}; | ||
GameDistributionBanner.prototype.alignIn = function (element, position) { | ||
var _this = this; | ||
this.parent = element; | ||
this.alignment = position; | ||
this.resizeListener = function () { return _this.resize(); }; | ||
window.addEventListener('resize', this.resizeListener); | ||
this.resize(); | ||
}; | ||
GameDistributionBanner.prototype.setOffset = function (x, y) { | ||
if (x === void 0) { x = 0; } | ||
if (y === void 0) { y = 0; } | ||
this.offsetX = x; | ||
this.offsetY = y; | ||
this.resize(); | ||
}; | ||
GameDistributionBanner.prototype.resize = function () { | ||
var parentBoundingRect = this.parent.getBoundingClientRect(); | ||
switch (this.alignment) { | ||
case GameDistributionAlignment.TopLeft: | ||
this.position(parentBoundingRect.left, parentBoundingRect.top); | ||
break; | ||
case GameDistributionAlignment.TopCenter: | ||
this.position(parentBoundingRect.left + parentBoundingRect.width / 2 - this.width / 2, parentBoundingRect.top); | ||
break; | ||
case GameDistributionAlignment.TopRight: | ||
this.position(parentBoundingRect.left + parentBoundingRect.width - this.width, parentBoundingRect.top); | ||
break; | ||
case GameDistributionAlignment.CenterLeft: | ||
this.position(parentBoundingRect.left, parentBoundingRect.top + parentBoundingRect.height / 2 - this.height / 2); | ||
break; | ||
case GameDistributionAlignment.Center: | ||
this.position(parentBoundingRect.left + parentBoundingRect.width / 2 - this.width / 2, parentBoundingRect.top + parentBoundingRect.height / 2 - this.height / 2); | ||
break; | ||
case GameDistributionAlignment.CenterRight: | ||
this.position(parentBoundingRect.left + parentBoundingRect.width - this.width, parentBoundingRect.top + parentBoundingRect.height / 2 - this.height / 2); | ||
break; | ||
case GameDistributionAlignment.BottomLeft: | ||
this.position(parentBoundingRect.left, parentBoundingRect.top + parentBoundingRect.height - this.height); | ||
break; | ||
case GameDistributionAlignment.BottomCenter: | ||
this.position(parentBoundingRect.left + parentBoundingRect.width / 2 - this.width / 2, parentBoundingRect.top + parentBoundingRect.height - this.height); | ||
break; | ||
case GameDistributionAlignment.BottomRight: | ||
this.position(parentBoundingRect.left + parentBoundingRect.width - this.width, parentBoundingRect.top + parentBoundingRect.height - this.height); | ||
break; | ||
} | ||
}; | ||
GameDistributionBanner.prototype.setSize = function (size) { | ||
@@ -699,2 +766,4 @@ var width, height; | ||
} | ||
this.width = width; | ||
this.height = height; | ||
this.element.style.width = width + "px"; | ||
@@ -704,4 +773,4 @@ this.element.style.height = height + "px"; | ||
GameDistributionBanner.prototype.position = function (x, y) { | ||
this.element.style.left = x + "px"; | ||
this.element.style.top = y + "px"; | ||
this.element.style.left = x + this.offsetX + "px"; | ||
this.element.style.top = y + this.offsetY + "px"; | ||
}; | ||
@@ -708,0 +777,0 @@ return GameDistributionBanner; |
/*! | ||
* phaser-ads - version 2.4.0 | ||
* phaser-ads - version 2.4.1 | ||
* A Phaser plugin for providing nice ads integration in your phaser.io game | ||
@@ -10,2 +10,2 @@ * | ||
var __extends=this&&this.__extends||function(){var a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(a,b){a.__proto__=b}||function(a,b){for(var c in b)b.hasOwnProperty(c)&&(a[c]=b[c])};return function(b,c){function d(){this.constructor=b}a(b,c),b.prototype=null===c?Object.create(c):(d.prototype=c.prototype,new d)}}(),PhaserAds;!function(a){var b;!function(a){a[a.start=0]="start",a[a.firstQuartile=1]="firstQuartile",a[a.midPoint=2]="midPoint",a[a.thirdQuartile=3]="thirdQuartile",a[a.complete=4]="complete"}(b=a.AdEvent||(a.AdEvent={}));var c;!function(a){a[a.interstitial=0]="interstitial",a[a.rewarded=1]="rewarded",a[a.banner=2]="banner",a[a.video=3]="video"}(c=a.AdType||(a.AdType={}));var d=function(a){function b(b,c){var d=a.call(this,b,c)||this;return d.onContentPaused=new Phaser.Signal,d.onContentResumed=new Phaser.Signal,d.onAdProgression=new Phaser.Signal,d.onAdsDisabled=new Phaser.Signal,d.onAdClicked=new Phaser.Signal,d.onAdRewardGranted=new Phaser.Signal,d.onAdLoaded=new Phaser.Signal,d.onBannerShown=new Phaser.Signal,d.onBannerHidden=new Phaser.Signal,d.bannerActive=!1,d.provider=null,d.wasMuted=!1,Object.defineProperty(b,"ads",{value:d}),d}return __extends(b,a),b.prototype.setAdProvider=function(a){this.provider=a,this.provider.setManager(this)},b.prototype.showAd=function(){for(var a=[],b=0;b<arguments.length;b++)a[b]=arguments[b];if(null===this.provider)throw new Error("Can not request an ad without an provider, please attach an ad provider!");a[0]!==c.banner&&(this.wasMuted=this.game.sound.mute,this.game.sound.mute=!0),this.provider.showAd.apply(this.provider,a)},b.prototype.loadBanner=function(){for(var a=[],b=0;b<arguments.length;b++)a[b]=arguments[b];return this.provider.loadBanner.apply(this.provider,a)},b.prototype.isRewardedAvailable=function(){return this.provider.hasRewarded},b.prototype.preloadAd=function(){for(var a=[],b=0;b<arguments.length;b++)a[b]=arguments[b];if(null===this.provider)throw new Error("Can not preload an ad without an provider, please attach an ad provider!");this.provider.preloadAd.apply(this.provider,a)},b.prototype.destroyAd=function(){for(var a=[],b=0;b<arguments.length;b++)a[b]=arguments[b];if(null===this.provider)throw new Error("Can not destroy an ad without an provider, please attach an ad provider!");this.provider.destroyAd.apply(this.provider,a)},b.prototype.hideAd=function(){for(var a=[],b=0;b<arguments.length;b++)a[b]=arguments[b];if(null===this.provider)throw new Error("Can not hide an ad without an provider, please attach an ad provider!");this.unMuteAfterAd(),this.provider.hideAd.apply(this.provider,a)},b.prototype.adsEnabled=function(){return this.provider.adsEnabled},b.prototype.unMuteAfterAd=function(){this.wasMuted||(this.game.sound.mute=!1)},b}(Phaser.Plugin);a.AdManager=d}(PhaserAds||(PhaserAds={}));var PhaserAds;!function(a){var b;!function(b){var c;!function(a){a[a.AdMob=0]="AdMob",a[a.MoPub=1]="MoPub",a[a.Chartboost=2]="Chartboost",a[a.Heyzap=3]="Heyzap"}(c=b.CocoonProvider||(b.CocoonProvider={}));var d=function(){function b(a,b,d){if(this.adsEnabled=!1,this.banner=null,this.bannerShowable=!1,this.interstitial=null,this.interstitialShowable=!1,this.rewarded=null,this.hasRewarded=!1,(a.device.cordova||a.device.crosswalk)&&Cocoon&&Cocoon.Ad){switch(this.adsEnabled=!0,b){default:case c.AdMob:this.cocoonProvider=Cocoon.Ad.AdMob;break;case c.Chartboost:this.cocoonProvider=Cocoon.Ad.Chartboost;break;case c.Heyzap:this.cocoonProvider=Cocoon.Ad.Heyzap;break;case c.MoPub:this.cocoonProvider=Cocoon.Ad.MoPub}this.cocoonProvider.configure(d)}}return b.prototype.setManager=function(a){this.adManager=a},b.prototype.showAd=function(b){if(!this.adsEnabled)return this.adManager.unMuteAfterAd(),void(b!==a.AdType.banner&&this.adManager.onContentResumed.dispatch());if(b===a.AdType.banner){if(!this.bannerShowable||null===this.banner)return void this.adManager.unMuteAfterAd();this.adManager.onBannerShown.dispatch(this.banner.width,this.banner.height),this.adManager.bannerActive=!0,this.banner.show()}if(b===a.AdType.interstitial){if(!this.interstitialShowable||null===this.interstitial)return this.adManager.unMuteAfterAd(),void this.adManager.onContentResumed.dispatch(a.AdType.interstitial);this.interstitial.show()}if(b===a.AdType.rewarded){if(!this.hasRewarded||null===this.rewarded)return this.adManager.unMuteAfterAd(),void this.adManager.onContentResumed.dispatch(a.AdType.rewarded);this.rewarded.show()}},b.prototype.preloadAd=function(b,c,d){var e=this;this.adsEnabled&&(this.destroyAd(b),b===a.AdType.banner&&(this.banner=this.cocoonProvider.createBanner(c),d&&this.banner.setLayout(d),this.banner.on("load",function(){e.bannerShowable=!0}),this.banner.on("fail",function(){e.bannerShowable=!1,e.banner=null}),this.banner.on("click",function(){e.adManager.onAdClicked.dispatch(a.AdType.banner)}),this.banner.on("show",function(){}),this.banner.on("dismiss",function(){}),this.banner.load()),b===a.AdType.interstitial&&(this.interstitial=this.cocoonProvider.createInterstitial(c),this.interstitial.on("load",function(){e.interstitialShowable=!0}),this.interstitial.on("fail",function(){e.interstitialShowable=!1,e.interstitial=null}),this.interstitial.on("click",function(){e.adManager.onAdClicked.dispatch(a.AdType.interstitial)}),this.interstitial.on("show",function(){e.adManager.onContentPaused.dispatch(a.AdType.interstitial)}),this.interstitial.on("dismiss",function(){e.adManager.unMuteAfterAd(),e.adManager.onContentResumed.dispatch(a.AdType.interstitial),e.interstitialShowable=!1,e.interstitial=null}),this.interstitial.load()),b===a.AdType.rewarded&&(this.rewarded=this.cocoonProvider.createRewardedVideo(c),this.rewarded.on("load",function(){e.hasRewarded=!0}),this.rewarded.on("fail",function(){e.hasRewarded=!1,e.rewarded=null}),this.rewarded.on("click",function(){e.adManager.onAdClicked.dispatch(a.AdType.rewarded)}),this.rewarded.on("show",function(){e.adManager.onContentPaused.dispatch(a.AdType.rewarded)}),this.rewarded.on("dismiss",function(){e.adManager.unMuteAfterAd(),e.adManager.onContentResumed.dispatch(a.AdType.rewarded),e.hasRewarded=!1,e.rewarded=null}),this.rewarded.on("reward",function(){e.adManager.unMuteAfterAd(),e.adManager.onAdRewardGranted.dispatch(a.AdType.rewarded),e.hasRewarded=!1,e.rewarded=null}),this.rewarded.load()))},b.prototype.destroyAd=function(b){if(this.adsEnabled){if(b===a.AdType.banner&&null!==this.banner){try{this.cocoonProvider.releaseBanner(this.banner)}catch(a){}this.banner=null,this.bannerShowable=!1}b===a.AdType.interstitial&&null!==this.interstitial&&(this.cocoonProvider.releaseInterstitial(this.interstitial),this.interstitial=null,this.interstitialShowable=!1)}},b.prototype.hideAd=function(b){this.adsEnabled&&(b===a.AdType.interstitial&&null!==this.interstitial&&this.interstitial.hide(),b===a.AdType.banner&&null!==this.banner&&(this.adManager.bannerActive&&(this.adManager.bannerActive=!1,this.adManager.onBannerHidden.dispatch(this.banner.width,this.banner.height)),this.banner.hide()),b===a.AdType.rewarded&&null!==this.rewarded&&this.rewarded.hide())},b}();b.CocoonAds=d}(b=a.AdProvider||(a.AdProvider={}))}(PhaserAds||(PhaserAds={}));var PhaserAds;!function(a){var b;!function(a){var b=function(){function a(a,b,c,d){void 0===d&&(d=!1),this.adsEnabled=!1,this.hasRewarded=!1,void 0===cordova.plugins||void 0!==cordova.plugins&&void 0===cordova.plugins.gdApi||(d&&cordova.plugins.gdApi.enableTestAds(),this.setAdListeners(),cordova.plugins.gdApi.init([b,c],function(a){},function(a){}))}return a.prototype.setAdListeners=function(){var a=this;cordova.plugins.gdApi.setAdListener(function(b){switch(b.event){case"BANNER_STARTED":a.adManager.onContentPaused.dispatch();break;case"API_IS_READY":a.adsEnabled=!0;break;case"API_ALREADY_INITIALIZED":break;case"BANNER_CLOSED":case"API_NOT_READY":case"BANNER_FAILED":a.adManager.onContentResumed.dispatch()}},function(b){a.adsEnabled=!1})},a.prototype.setManager=function(a){this.adManager=a},a.prototype.showAd=function(a){var b=this;this.adsEnabled?cordova.plugins.gdApi.showBanner(function(a){},function(a){b.adManager.onContentResumed.dispatch()}):this.adManager.onContentResumed.dispatch()},a.prototype.preloadAd=function(){},a.prototype.destroyAd=function(){},a.prototype.hideAd=function(){},a}();a.CordovaGameDistribution=b}(b=a.AdProvider||(a.AdProvider={}))}(PhaserAds||(PhaserAds={}));var PhaserAds;!function(a){var b;!function(a){var b;!function(a){a[a.Interstitial=0]="Interstitial",a[a.Video=1]="Video",a[a.Rewarded=2]="Rewarded",a[a.Banner=3]="Banner"}(b=a.HeyzapAdTypes||(a.HeyzapAdTypes={}));var c=function(){function a(a,b){var c=this;this.adsEnabled=!1,this.hasRewarded=!1,(a.device.cordova||a.device.crosswalk)&&(this.adsEnabled=!0,HeyzapAds.start(b).then(function(){},function(a){c.adsEnabled=!1}))}return a.prototype.setManager=function(a){this.adManager=a},a.prototype.showAd=function(a,c){var d=this;switch(this.adsEnabled||(this.adManager.unMuteAfterAd(),this.adManager.onContentResumed.dispatch()),a){case b.Interstitial:HeyzapAds.InterstitialAd.addEventListener(HeyzapAds.InterstitialAd.Events.HIDE,function(){d.adManager.unMuteAfterAd(),d.adManager.onContentResumed.dispatch(HeyzapAds.InterstitialAd.Events.HIDE)}),HeyzapAds.InterstitialAd.addEventListener(HeyzapAds.InterstitialAd.Events.SHOW_FAILED,function(){d.adManager.unMuteAfterAd(),d.adManager.onContentResumed.dispatch(HeyzapAds.InterstitialAd.Events.SHOW_FAILED)}),HeyzapAds.InterstitialAd.addEventListener(HeyzapAds.InterstitialAd.Events.CLICKED,function(){d.adManager.onAdClicked.dispatch(HeyzapAds.InterstitialAd.Events.CLICKED)}),HeyzapAds.InterstitialAd.show().then(function(){d.adManager.onContentPaused.dispatch()},function(a){d.adManager.unMuteAfterAd(),d.adManager.onContentResumed.dispatch()});break;case b.Video:HeyzapAds.VideoAd.addEventListener(HeyzapAds.VideoAd.Events.HIDE,function(){d.adManager.unMuteAfterAd(),d.adManager.onContentResumed.dispatch(HeyzapAds.VideoAd.Events.HIDE)}),HeyzapAds.VideoAd.addEventListener(HeyzapAds.VideoAd.Events.SHOW_FAILED,function(){d.adManager.unMuteAfterAd(),d.adManager.onContentResumed.dispatch(HeyzapAds.VideoAd.Events.SHOW_FAILED)}),HeyzapAds.VideoAd.addEventListener(HeyzapAds.VideoAd.Events.CLICKED,function(){d.adManager.onAdClicked.dispatch(HeyzapAds.VideoAd.Events.CLICKED)}),HeyzapAds.VideoAd.show().then(function(){d.adManager.onContentPaused.dispatch()},function(a){d.adManager.unMuteAfterAd(),d.adManager.onContentResumed.dispatch()});break;case b.Rewarded:HeyzapAds.IncentivizedAd.addEventListener(HeyzapAds.IncentivizedAd.Events.HIDE,function(){d.adManager.unMuteAfterAd(),d.adManager.onContentResumed.dispatch(HeyzapAds.IncentivizedAd.Events.HIDE)}),HeyzapAds.IncentivizedAd.addEventListener(HeyzapAds.IncentivizedAd.Events.SHOW_FAILED,function(){d.adManager.unMuteAfterAd(),d.adManager.onContentResumed.dispatch(HeyzapAds.IncentivizedAd.Events.SHOW_FAILED)}),HeyzapAds.IncentivizedAd.addEventListener(HeyzapAds.IncentivizedAd.Events.CLICKED,function(){d.adManager.onAdClicked.dispatch(HeyzapAds.IncentivizedAd.Events.CLICKED)}),HeyzapAds.IncentivizedAd.show().then(function(){d.adManager.onContentPaused.dispatch()},function(a){d.adManager.unMuteAfterAd(),d.adManager.onContentResumed.dispatch()});break;case b.Banner:HeyzapAds.BannerAd.show(c).then(function(){},function(a){})}},a.prototype.preloadAd=function(a){this.adsEnabled&&a===b.Rewarded&&HeyzapAds.IncentivizedAd.fetch().then(function(){},function(a){})},a.prototype.destroyAd=function(a){this.adsEnabled&&a===b.Banner&&HeyzapAds.BannerAd.destroy().then(function(){},function(a){})},a.prototype.hideAd=function(a){this.adsEnabled&&a===b.Banner&&HeyzapAds.BannerAd.hide().then(function(){},function(a){})},a}();a.CordovaHeyzap=c}(b=a.AdProvider||(a.AdProvider={}))}(PhaserAds||(PhaserAds={}));var PhaserAds;!function(a){var b;!function(b){var c;!function(a){a.interstitial="interstitial",a.rewarded="rewarded",a.display="display"}(c=b.GameDistributionAdType||(b.GameDistributionAdType={}));var d;!function(a){a[a.LargeRectangle=0]="LargeRectangle",a[a.MediumRectangle=1]="MediumRectangle",a[a.Billboard=2]="Billboard",a[a.Leaderboard=3]="Leaderboard",a[a.Skyscraper=4]="Skyscraper",a[a.WideSkyscraper=5]="WideSkyscraper"}(d=b.GameDistributionBannerSize||(b.GameDistributionBannerSize={}));var e=function(){function a(){this.element=document.createElement("div"),this.element.style.position="absolute",this.element.style.top="0px",this.element.style.left="0px",this.element.id="banner-"+Date.now()+(1e7*Math.random()|0),document.body.appendChild(this.element)}return a.prototype.loadBanner=function(){return gdsdk.showAd(c.display,{containerId:this.element.id})},a.prototype.destroy=function(){document.body.removeChild(this.element)},a.prototype.setSize=function(a){var b,c;switch(a){default:case d.LargeRectangle:b=336,c=280;break;case d.MediumRectangle:b=300,c=250;break;case d.Billboard:b=970,c=250;break;case d.Leaderboard:b=728,c=90;break;case d.Skyscraper:b=120,c=600;break;case d.WideSkyscraper:b=160,c=600}this.element.style.width=b+"px",this.element.style.height=c+"px"},a.prototype.position=function(a,b){this.element.style.left=a+"px",this.element.style.top=b+"px"},a}();b.GameDistributionBanner=e;var f=function(){function b(a,b,c){void 0===c&&(c="");var d=this;this.adsEnabled=!0,this.hasRewarded=!1,this.areAdsEnabled(),GD_OPTIONS={gameId:b,advertisementSettings:{autoplay:!1},onEvent:function(a){switch(a.name){case"SDK_GAME_PAUSE":d.adManager.onContentPaused.dispatch()}}},function(a,b,c){var d,e=a.getElementsByTagName(b)[0];a.getElementById(c)||(d=a.createElement(b),d.id=c,d.src="//html5.api.gamedistribution.com/main.min.js",e.parentNode.insertBefore(d,e))}(document,"script","gamedistribution-jssdk")}return b.prototype.setManager=function(a){this.adManager=a},b.prototype.showAd=function(b,d){var e=this;return this.adsEnabled?"undefined"==typeof gdsdk||gdsdk&&"undefined"==typeof gdsdk.showAd?(this.adsEnabled=!1,this.adManager.unMuteAfterAd(),void this.adManager.onContentResumed.dispatch()):b===a.AdType.rewarded&&this.hasRewarded===!1?(this.adManager.unMuteAfterAd(),void this.adManager.onContentResumed.dispatch()):void gdsdk.showAd(b===a.AdType.rewarded?c.rewarded:c.interstitial).then(function(){b===a.AdType.rewarded&&e.hasRewarded===!0&&(e.adManager.onAdRewardGranted.dispatch(),e.hasRewarded=!1),e.adManager.unMuteAfterAd(),e.adManager.onContentResumed.dispatch()}).catch(function(){b===a.AdType.rewarded&&e.hasRewarded===!0&&(e.hasRewarded=!1),e.adManager.unMuteAfterAd(),e.adManager.onContentResumed.dispatch()}):(this.adManager.unMuteAfterAd(),void this.adManager.onContentResumed.dispatch())},b.prototype.loadBanner=function(a){var b=new e;return b.setSize(a),b.loadBanner(),b},b.prototype.preloadAd=function(a){var b=this;this.hasRewarded||gdsdk.preloadAd(c.rewarded).then(function(){b.hasRewarded=!0,b.adManager.onAdLoaded.dispatch(a)})},b.prototype.destroyAd=function(){},b.prototype.hideAd=function(){},b.prototype.areAdsEnabled=function(){var a=this,b=document.createElement("div");b.innerHTML=" ",b.className="adsbox",b.style.position="absolute",b.style.fontSize="10px",document.body.appendChild(b);var c=function(){var a=!0;return 0===b.offsetHeight&&(a=!1),b.parentNode.removeChild(b),a};window.setTimeout(function(){a.adsEnabled=c()},100)},b}();b.GameDistributionAds=f}(b=a.AdProvider||(a.AdProvider={}))}(PhaserAds||(PhaserAds={}));var PhaserAds;!function(a){var b;!function(b){var c=function(){function b(a,b){this.adsManager=null,this.googleEnabled=!1,this.adsEnabled=!0,this.adTagUrl="",this.adRequested=!1,this.hasRewarded=!1,this.adManager=null,this.resizeListener=null,this.areAdsEnabled(),"undefined"!=typeof google&&(this.googleEnabled=!0,this.gameContent="string"==typeof a.parent?document.getElementById(a.parent):a.parent,this.gameContent.style.position="absolute",this.gameContent.style.width="100%",this.adContent=this.gameContent.parentNode.appendChild(document.createElement("div")),this.adContent.id="phaser-ad-container",this.adContent.style.position="absolute",this.adContent.style.zIndex="9999",this.adContent.style.display="none",this.adContent.style.top="0",this.adContent.style.left="0",this.adContent.style.width="100%",this.adContent.style.height="100%",this.adContent.style.overflow="hidden",this.adTagUrl=b,this.game=a,this.adDisplay=new google.ima.AdDisplayContainer(this.adContent),google.ima.settings.setVpaidMode(google.ima.ImaSdkSettings.VpaidMode.ENABLED),google.ima.settings.setLocale("nl"),this.adLoader=new google.ima.AdsLoader(this.adDisplay),this.adLoader.addEventListener(google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,this.onAdManagerLoader,!1,this),this.adLoader.addEventListener(google.ima.AdErrorEvent.Type.AD_ERROR,this.onAdError,!1,this))}return b.prototype.setManager=function(a){this.adManager=a},b.prototype.showAd=function(a){if(!this.adRequested){if(this.adsEnabled||this.adManager.onAdsDisabled.dispatch(!0),!this.googleEnabled)return void this.onContentResumeRequested();this.adDisplay.initialize();var b=new google.ima.AdsRequest;b.adTagUrl=this.adTagUrl+this.parseCustomParams(a);var c=window.innerWidth,d=window.innerHeight;this.game.scale.isFullScreen&&document.body.clientHeight<window.innerHeight&&(d=document.body.clientHeight,c=document.body.clientWidth),b.linearAdSlotWidth=c,b.linearAdSlotHeight=d,b.nonLinearAdSlotWidth=c,b.nonLinearAdSlotHeight=d,b.forceNonLinearFullSlot=!0;try{this.adRequested=!0,this.adLoader.requestAds(b)}catch(a){this.onContentResumeRequested()}}},b.prototype.preloadAd=function(){},b.prototype.destroyAd=function(){},b.prototype.hideAd=function(){},b.prototype.onAdManagerLoader=function(a){var b=this,c=new google.ima.AdsRenderingSettings;c.restoreCustomPlaybackStateOnAdBreakComplete=!0;var d=a.getAdsManager(this.gameContent,c);this.adsManager=d,d.addEventListener(google.ima.AdEvent.Type.CONTENT_PAUSE_REQUESTED,this.onContentPauseRequested,!1,this),d.addEventListener(google.ima.AdEvent.Type.CONTENT_RESUME_REQUESTED,this.onContentResumeRequested,!1,this),d.addEventListener(google.ima.AdErrorEvent.Type.AD_ERROR,this.onAdError,!1,this),[google.ima.AdEvent.Type.ALL_ADS_COMPLETED,google.ima.AdEvent.Type.CLICK,google.ima.AdEvent.Type.COMPLETE,google.ima.AdEvent.Type.FIRST_QUARTILE,google.ima.AdEvent.Type.LOADED,google.ima.AdEvent.Type.MIDPOINT,google.ima.AdEvent.Type.PAUSED,google.ima.AdEvent.Type.STARTED,google.ima.AdEvent.Type.THIRD_QUARTILE].forEach(function(a){d.addEventListener(a,b.onAdEvent,!1,b)});try{this.adContent.style.display="block";var e=window.innerWidth,f=window.innerHeight;this.adsManager.init(e,f,google.ima.ViewMode.NORMAL),this.adsManager.start(),this.resizeListener=function(){null!==b.adsManager&&b.adsManager.resize(window.innerWidth,window.innerHeight,google.ima.ViewMode.NORMAL)},window.addEventListener("resize",this.resizeListener)}catch(a){this.onAdError(a)}},b.prototype.onAdEvent=function(b){switch(b.type){case google.ima.AdEvent.Type.CLICK:this.adManager.onAdClicked.dispatch();break;case google.ima.AdEvent.Type.LOADED:this.adRequested=!1;var c=b.getAd();c.isLinear()||this.onContentResumeRequested();break;case google.ima.AdEvent.Type.STARTED:this.adManager.onAdProgression.dispatch(a.AdEvent.start);break;case google.ima.AdEvent.Type.FIRST_QUARTILE:this.adManager.onAdProgression.dispatch(a.AdEvent.firstQuartile);break;case google.ima.AdEvent.Type.MIDPOINT:this.adManager.onAdProgression.dispatch(a.AdEvent.midPoint);break;case google.ima.AdEvent.Type.THIRD_QUARTILE:this.adManager.onAdProgression.dispatch(a.AdEvent.thirdQuartile);break;case google.ima.AdEvent.Type.COMPLETE:this.adManager.onAdProgression.dispatch(a.AdEvent.complete);break;case google.ima.AdEvent.Type.ALL_ADS_COMPLETED:this.onContentResumeRequested()}},b.prototype.onAdError=function(a){null!==this.adsManager&&(this.adsManager.destroy(),this.adsManager=null,null!==this.resizeListener&&(window.removeEventListener("resize",this.resizeListener),this.resizeListener=null)),this.adRequested&&(this.adRequested=!1),this.onContentResumeRequested()},b.prototype.onContentPauseRequested=function(){this.adManager.onContentPaused.dispatch()},b.prototype.onContentResumeRequested=function(){return"undefined"==typeof google?(this.adManager.unMuteAfterAd(),void this.adManager.onContentResumed.dispatch()):(this.adContent.style.display="none",this.adManager.unMuteAfterAd(),void this.adManager.onContentResumed.dispatch())},b.prototype.parseCustomParams=function(a){if(void 0!==a){var b="";for(var c in a)if(a.hasOwnProperty(c)){b.length>0&&(b+="&");var d=Array.isArray(a[c])?a[c].join(","):a[c];b+=c+"="+d}return"&cust_params="+encodeURIComponent(b)}return""},b.prototype.areAdsEnabled=function(){var a=this,b=document.createElement("div");b.innerHTML=" ",b.className="adsbox",b.style.position="absolute",b.style.fontSize="10px",document.body.appendChild(b);var c=function(){var a=!0;return 0===b.offsetHeight&&(a=!1),b.parentNode.removeChild(b),a};window.setTimeout(function(){a.adsEnabled=c()},100)},b}();b.Ima3=c}(b=a.AdProvider||(a.AdProvider={}))}(PhaserAds||(PhaserAds={})); | ||
var __extends=this&&this.__extends||function(){var a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(a,b){a.__proto__=b}||function(a,b){for(var c in b)b.hasOwnProperty(c)&&(a[c]=b[c])};return function(b,c){function d(){this.constructor=b}a(b,c),b.prototype=null===c?Object.create(c):(d.prototype=c.prototype,new d)}}(),PhaserAds;!function(a){var b;!function(a){a[a.start=0]="start",a[a.firstQuartile=1]="firstQuartile",a[a.midPoint=2]="midPoint",a[a.thirdQuartile=3]="thirdQuartile",a[a.complete=4]="complete"}(b=a.AdEvent||(a.AdEvent={}));var c;!function(a){a[a.interstitial=0]="interstitial",a[a.rewarded=1]="rewarded",a[a.banner=2]="banner",a[a.video=3]="video"}(c=a.AdType||(a.AdType={}));var d=function(a){function b(b,c){var d=a.call(this,b,c)||this;return d.onContentPaused=new Phaser.Signal,d.onContentResumed=new Phaser.Signal,d.onAdProgression=new Phaser.Signal,d.onAdsDisabled=new Phaser.Signal,d.onAdClicked=new Phaser.Signal,d.onAdRewardGranted=new Phaser.Signal,d.onAdLoaded=new Phaser.Signal,d.onBannerShown=new Phaser.Signal,d.onBannerHidden=new Phaser.Signal,d.bannerActive=!1,d.provider=null,d.wasMuted=!1,Object.defineProperty(b,"ads",{value:d}),d}return __extends(b,a),b.prototype.setAdProvider=function(a){this.provider=a,this.provider.setManager(this)},b.prototype.showAd=function(){for(var a=[],b=0;b<arguments.length;b++)a[b]=arguments[b];if(null===this.provider)throw new Error("Can not request an ad without an provider, please attach an ad provider!");a[0]!==c.banner&&(this.wasMuted=this.game.sound.mute,this.game.sound.mute=!0),this.provider.showAd.apply(this.provider,a)},b.prototype.loadBanner=function(){for(var a=[],b=0;b<arguments.length;b++)a[b]=arguments[b];return this.provider.loadBanner.apply(this.provider,a)},b.prototype.isRewardedAvailable=function(){return this.provider.hasRewarded},b.prototype.preloadAd=function(){for(var a=[],b=0;b<arguments.length;b++)a[b]=arguments[b];if(null===this.provider)throw new Error("Can not preload an ad without an provider, please attach an ad provider!");this.provider.preloadAd.apply(this.provider,a)},b.prototype.destroyAd=function(){for(var a=[],b=0;b<arguments.length;b++)a[b]=arguments[b];if(null===this.provider)throw new Error("Can not destroy an ad without an provider, please attach an ad provider!");this.provider.destroyAd.apply(this.provider,a)},b.prototype.hideAd=function(){for(var a=[],b=0;b<arguments.length;b++)a[b]=arguments[b];if(null===this.provider)throw new Error("Can not hide an ad without an provider, please attach an ad provider!");this.unMuteAfterAd(),this.provider.hideAd.apply(this.provider,a)},b.prototype.adsEnabled=function(){return this.provider.adsEnabled},b.prototype.unMuteAfterAd=function(){this.wasMuted||(this.game.sound.mute=!1)},b}(Phaser.Plugin);a.AdManager=d}(PhaserAds||(PhaserAds={}));var PhaserAds;!function(a){var b;!function(b){var c;!function(a){a[a.AdMob=0]="AdMob",a[a.MoPub=1]="MoPub",a[a.Chartboost=2]="Chartboost",a[a.Heyzap=3]="Heyzap"}(c=b.CocoonProvider||(b.CocoonProvider={}));var d=function(){function b(a,b,d){if(this.adsEnabled=!1,this.banner=null,this.bannerShowable=!1,this.interstitial=null,this.interstitialShowable=!1,this.rewarded=null,this.hasRewarded=!1,(a.device.cordova||a.device.crosswalk)&&Cocoon&&Cocoon.Ad){switch(this.adsEnabled=!0,b){default:case c.AdMob:this.cocoonProvider=Cocoon.Ad.AdMob;break;case c.Chartboost:this.cocoonProvider=Cocoon.Ad.Chartboost;break;case c.Heyzap:this.cocoonProvider=Cocoon.Ad.Heyzap;break;case c.MoPub:this.cocoonProvider=Cocoon.Ad.MoPub}this.cocoonProvider.configure(d)}}return b.prototype.setManager=function(a){this.adManager=a},b.prototype.showAd=function(b){if(!this.adsEnabled)return this.adManager.unMuteAfterAd(),void(b!==a.AdType.banner&&this.adManager.onContentResumed.dispatch());if(b===a.AdType.banner){if(!this.bannerShowable||null===this.banner)return void this.adManager.unMuteAfterAd();this.adManager.onBannerShown.dispatch(this.banner.width,this.banner.height),this.adManager.bannerActive=!0,this.banner.show()}if(b===a.AdType.interstitial){if(!this.interstitialShowable||null===this.interstitial)return this.adManager.unMuteAfterAd(),void this.adManager.onContentResumed.dispatch(a.AdType.interstitial);this.interstitial.show()}if(b===a.AdType.rewarded){if(!this.hasRewarded||null===this.rewarded)return this.adManager.unMuteAfterAd(),void this.adManager.onContentResumed.dispatch(a.AdType.rewarded);this.rewarded.show()}},b.prototype.preloadAd=function(b,c,d){var e=this;this.adsEnabled&&(this.destroyAd(b),b===a.AdType.banner&&(this.banner=this.cocoonProvider.createBanner(c),d&&this.banner.setLayout(d),this.banner.on("load",function(){e.bannerShowable=!0}),this.banner.on("fail",function(){e.bannerShowable=!1,e.banner=null}),this.banner.on("click",function(){e.adManager.onAdClicked.dispatch(a.AdType.banner)}),this.banner.on("show",function(){}),this.banner.on("dismiss",function(){}),this.banner.load()),b===a.AdType.interstitial&&(this.interstitial=this.cocoonProvider.createInterstitial(c),this.interstitial.on("load",function(){e.interstitialShowable=!0}),this.interstitial.on("fail",function(){e.interstitialShowable=!1,e.interstitial=null}),this.interstitial.on("click",function(){e.adManager.onAdClicked.dispatch(a.AdType.interstitial)}),this.interstitial.on("show",function(){e.adManager.onContentPaused.dispatch(a.AdType.interstitial)}),this.interstitial.on("dismiss",function(){e.adManager.unMuteAfterAd(),e.adManager.onContentResumed.dispatch(a.AdType.interstitial),e.interstitialShowable=!1,e.interstitial=null}),this.interstitial.load()),b===a.AdType.rewarded&&(this.rewarded=this.cocoonProvider.createRewardedVideo(c),this.rewarded.on("load",function(){e.hasRewarded=!0}),this.rewarded.on("fail",function(){e.hasRewarded=!1,e.rewarded=null}),this.rewarded.on("click",function(){e.adManager.onAdClicked.dispatch(a.AdType.rewarded)}),this.rewarded.on("show",function(){e.adManager.onContentPaused.dispatch(a.AdType.rewarded)}),this.rewarded.on("dismiss",function(){e.adManager.unMuteAfterAd(),e.adManager.onContentResumed.dispatch(a.AdType.rewarded),e.hasRewarded=!1,e.rewarded=null}),this.rewarded.on("reward",function(){e.adManager.unMuteAfterAd(),e.adManager.onAdRewardGranted.dispatch(a.AdType.rewarded),e.hasRewarded=!1,e.rewarded=null}),this.rewarded.load()))},b.prototype.destroyAd=function(b){if(this.adsEnabled){if(b===a.AdType.banner&&null!==this.banner){try{this.cocoonProvider.releaseBanner(this.banner)}catch(a){}this.banner=null,this.bannerShowable=!1}b===a.AdType.interstitial&&null!==this.interstitial&&(this.cocoonProvider.releaseInterstitial(this.interstitial),this.interstitial=null,this.interstitialShowable=!1)}},b.prototype.hideAd=function(b){this.adsEnabled&&(b===a.AdType.interstitial&&null!==this.interstitial&&this.interstitial.hide(),b===a.AdType.banner&&null!==this.banner&&(this.adManager.bannerActive&&(this.adManager.bannerActive=!1,this.adManager.onBannerHidden.dispatch(this.banner.width,this.banner.height)),this.banner.hide()),b===a.AdType.rewarded&&null!==this.rewarded&&this.rewarded.hide())},b}();b.CocoonAds=d}(b=a.AdProvider||(a.AdProvider={}))}(PhaserAds||(PhaserAds={}));var PhaserAds;!function(a){var b;!function(a){var b=function(){function a(a,b,c,d){void 0===d&&(d=!1),this.adsEnabled=!1,this.hasRewarded=!1,void 0===cordova.plugins||void 0!==cordova.plugins&&void 0===cordova.plugins.gdApi||(d&&cordova.plugins.gdApi.enableTestAds(),this.setAdListeners(),cordova.plugins.gdApi.init([b,c],function(a){},function(a){}))}return a.prototype.setAdListeners=function(){var a=this;cordova.plugins.gdApi.setAdListener(function(b){switch(b.event){case"BANNER_STARTED":a.adManager.onContentPaused.dispatch();break;case"API_IS_READY":a.adsEnabled=!0;break;case"API_ALREADY_INITIALIZED":break;case"BANNER_CLOSED":case"API_NOT_READY":case"BANNER_FAILED":a.adManager.onContentResumed.dispatch()}},function(b){a.adsEnabled=!1})},a.prototype.setManager=function(a){this.adManager=a},a.prototype.showAd=function(a){var b=this;this.adsEnabled?cordova.plugins.gdApi.showBanner(function(a){},function(a){b.adManager.onContentResumed.dispatch()}):this.adManager.onContentResumed.dispatch()},a.prototype.preloadAd=function(){},a.prototype.destroyAd=function(){},a.prototype.hideAd=function(){},a}();a.CordovaGameDistribution=b}(b=a.AdProvider||(a.AdProvider={}))}(PhaserAds||(PhaserAds={}));var PhaserAds;!function(a){var b;!function(a){var b;!function(a){a[a.Interstitial=0]="Interstitial",a[a.Video=1]="Video",a[a.Rewarded=2]="Rewarded",a[a.Banner=3]="Banner"}(b=a.HeyzapAdTypes||(a.HeyzapAdTypes={}));var c=function(){function a(a,b){var c=this;this.adsEnabled=!1,this.hasRewarded=!1,(a.device.cordova||a.device.crosswalk)&&(this.adsEnabled=!0,HeyzapAds.start(b).then(function(){},function(a){c.adsEnabled=!1}))}return a.prototype.setManager=function(a){this.adManager=a},a.prototype.showAd=function(a,c){var d=this;switch(this.adsEnabled||(this.adManager.unMuteAfterAd(),this.adManager.onContentResumed.dispatch()),a){case b.Interstitial:HeyzapAds.InterstitialAd.addEventListener(HeyzapAds.InterstitialAd.Events.HIDE,function(){d.adManager.unMuteAfterAd(),d.adManager.onContentResumed.dispatch(HeyzapAds.InterstitialAd.Events.HIDE)}),HeyzapAds.InterstitialAd.addEventListener(HeyzapAds.InterstitialAd.Events.SHOW_FAILED,function(){d.adManager.unMuteAfterAd(),d.adManager.onContentResumed.dispatch(HeyzapAds.InterstitialAd.Events.SHOW_FAILED)}),HeyzapAds.InterstitialAd.addEventListener(HeyzapAds.InterstitialAd.Events.CLICKED,function(){d.adManager.onAdClicked.dispatch(HeyzapAds.InterstitialAd.Events.CLICKED)}),HeyzapAds.InterstitialAd.show().then(function(){d.adManager.onContentPaused.dispatch()},function(a){d.adManager.unMuteAfterAd(),d.adManager.onContentResumed.dispatch()});break;case b.Video:HeyzapAds.VideoAd.addEventListener(HeyzapAds.VideoAd.Events.HIDE,function(){d.adManager.unMuteAfterAd(),d.adManager.onContentResumed.dispatch(HeyzapAds.VideoAd.Events.HIDE)}),HeyzapAds.VideoAd.addEventListener(HeyzapAds.VideoAd.Events.SHOW_FAILED,function(){d.adManager.unMuteAfterAd(),d.adManager.onContentResumed.dispatch(HeyzapAds.VideoAd.Events.SHOW_FAILED)}),HeyzapAds.VideoAd.addEventListener(HeyzapAds.VideoAd.Events.CLICKED,function(){d.adManager.onAdClicked.dispatch(HeyzapAds.VideoAd.Events.CLICKED)}),HeyzapAds.VideoAd.show().then(function(){d.adManager.onContentPaused.dispatch()},function(a){d.adManager.unMuteAfterAd(),d.adManager.onContentResumed.dispatch()});break;case b.Rewarded:HeyzapAds.IncentivizedAd.addEventListener(HeyzapAds.IncentivizedAd.Events.HIDE,function(){d.adManager.unMuteAfterAd(),d.adManager.onContentResumed.dispatch(HeyzapAds.IncentivizedAd.Events.HIDE)}),HeyzapAds.IncentivizedAd.addEventListener(HeyzapAds.IncentivizedAd.Events.SHOW_FAILED,function(){d.adManager.unMuteAfterAd(),d.adManager.onContentResumed.dispatch(HeyzapAds.IncentivizedAd.Events.SHOW_FAILED)}),HeyzapAds.IncentivizedAd.addEventListener(HeyzapAds.IncentivizedAd.Events.CLICKED,function(){d.adManager.onAdClicked.dispatch(HeyzapAds.IncentivizedAd.Events.CLICKED)}),HeyzapAds.IncentivizedAd.show().then(function(){d.adManager.onContentPaused.dispatch()},function(a){d.adManager.unMuteAfterAd(),d.adManager.onContentResumed.dispatch()});break;case b.Banner:HeyzapAds.BannerAd.show(c).then(function(){},function(a){})}},a.prototype.preloadAd=function(a){this.adsEnabled&&a===b.Rewarded&&HeyzapAds.IncentivizedAd.fetch().then(function(){},function(a){})},a.prototype.destroyAd=function(a){this.adsEnabled&&a===b.Banner&&HeyzapAds.BannerAd.destroy().then(function(){},function(a){})},a.prototype.hideAd=function(a){this.adsEnabled&&a===b.Banner&&HeyzapAds.BannerAd.hide().then(function(){},function(a){})},a}();a.CordovaHeyzap=c}(b=a.AdProvider||(a.AdProvider={}))}(PhaserAds||(PhaserAds={}));var PhaserAds;!function(a){var b;!function(b){var c;!function(a){a.interstitial="interstitial",a.rewarded="rewarded",a.display="display"}(c=b.GameDistributionAdType||(b.GameDistributionAdType={}));var d;!function(a){a[a.LargeRectangle=0]="LargeRectangle",a[a.MediumRectangle=1]="MediumRectangle",a[a.Billboard=2]="Billboard",a[a.Leaderboard=3]="Leaderboard",a[a.Skyscraper=4]="Skyscraper",a[a.WideSkyscraper=5]="WideSkyscraper"}(d=b.GameDistributionBannerSize||(b.GameDistributionBannerSize={}));var e;!function(a){a[a.TopLeft=0]="TopLeft",a[a.TopCenter=1]="TopCenter",a[a.TopRight=2]="TopRight",a[a.CenterLeft=3]="CenterLeft",a[a.Center=4]="Center",a[a.CenterRight=5]="CenterRight",a[a.BottomLeft=6]="BottomLeft",a[a.BottomCenter=7]="BottomCenter",a[a.BottomRight=8]="BottomRight"}(e=b.GameDistributionAlignment||(b.GameDistributionAlignment={}));var f=function(){function a(){this.offsetX=0,this.offsetY=0,this.element=document.createElement("div"),this.element.style.position="absolute",this.element.style.top="0px",this.element.style.left="0px",this.element.id="banner-"+Date.now()+(1e7*Math.random()|0),document.body.appendChild(this.element)}return a.prototype.loadBanner=function(){return gdsdk.showAd(c.display,{containerId:this.element.id})},a.prototype.destroy=function(){document.body.removeChild(this.element),this.element=null,this.parent=null,this.alignment=null,this.resizeListener&&window.removeEventListener("resize",this.resizeListener)},a.prototype.alignIn=function(a,b){var c=this;this.parent=a,this.alignment=b,this.resizeListener=function(){return c.resize()},window.addEventListener("resize",this.resizeListener),this.resize()},a.prototype.setOffset=function(a,b){void 0===a&&(a=0),void 0===b&&(b=0),this.offsetX=a,this.offsetY=b,this.resize()},a.prototype.resize=function(){var a=this.parent.getBoundingClientRect();switch(this.alignment){case e.TopLeft:this.position(a.left,a.top);break;case e.TopCenter:this.position(a.left+a.width/2-this.width/2,a.top);break;case e.TopRight:this.position(a.left+a.width-this.width,a.top);break;case e.CenterLeft:this.position(a.left,a.top+a.height/2-this.height/2);break;case e.Center:this.position(a.left+a.width/2-this.width/2,a.top+a.height/2-this.height/2);break;case e.CenterRight:this.position(a.left+a.width-this.width,a.top+a.height/2-this.height/2);break;case e.BottomLeft:this.position(a.left,a.top+a.height-this.height);break;case e.BottomCenter:this.position(a.left+a.width/2-this.width/2,a.top+a.height-this.height);break;case e.BottomRight:this.position(a.left+a.width-this.width,a.top+a.height-this.height)}},a.prototype.setSize=function(a){var b,c;switch(a){default:case d.LargeRectangle:b=336,c=280;break;case d.MediumRectangle:b=300,c=250;break;case d.Billboard:b=970,c=250;break;case d.Leaderboard:b=728,c=90;break;case d.Skyscraper:b=120,c=600;break;case d.WideSkyscraper:b=160,c=600}this.width=b,this.height=c,this.element.style.width=b+"px",this.element.style.height=c+"px"},a.prototype.position=function(a,b){this.element.style.left=a+this.offsetX+"px",this.element.style.top=b+this.offsetY+"px"},a}();b.GameDistributionBanner=f;var g=function(){function b(a,b,c){void 0===c&&(c="");var d=this;this.adsEnabled=!0,this.hasRewarded=!1,this.areAdsEnabled(),GD_OPTIONS={gameId:b,advertisementSettings:{autoplay:!1},onEvent:function(a){switch(a.name){case"SDK_GAME_PAUSE":d.adManager.onContentPaused.dispatch()}}},function(a,b,c){var d,e=a.getElementsByTagName(b)[0];a.getElementById(c)||(d=a.createElement(b),d.id=c,d.src="//html5.api.gamedistribution.com/main.min.js",e.parentNode.insertBefore(d,e))}(document,"script","gamedistribution-jssdk")}return b.prototype.setManager=function(a){this.adManager=a},b.prototype.showAd=function(b,d){var e=this;return this.adsEnabled?"undefined"==typeof gdsdk||gdsdk&&"undefined"==typeof gdsdk.showAd?(this.adsEnabled=!1,this.adManager.unMuteAfterAd(),void this.adManager.onContentResumed.dispatch()):b===a.AdType.rewarded&&this.hasRewarded===!1?(this.adManager.unMuteAfterAd(),void this.adManager.onContentResumed.dispatch()):void gdsdk.showAd(b===a.AdType.rewarded?c.rewarded:c.interstitial).then(function(){b===a.AdType.rewarded&&e.hasRewarded===!0&&(e.adManager.onAdRewardGranted.dispatch(),e.hasRewarded=!1),e.adManager.unMuteAfterAd(),e.adManager.onContentResumed.dispatch()}).catch(function(){b===a.AdType.rewarded&&e.hasRewarded===!0&&(e.hasRewarded=!1),e.adManager.unMuteAfterAd(),e.adManager.onContentResumed.dispatch()}):(this.adManager.unMuteAfterAd(),void this.adManager.onContentResumed.dispatch())},b.prototype.loadBanner=function(a){var b=new f;return b.setSize(a),b.loadBanner(),b},b.prototype.preloadAd=function(a){var b=this;this.hasRewarded||gdsdk.preloadAd(c.rewarded).then(function(){b.hasRewarded=!0,b.adManager.onAdLoaded.dispatch(a)})},b.prototype.destroyAd=function(){},b.prototype.hideAd=function(){},b.prototype.areAdsEnabled=function(){var a=this,b=document.createElement("div");b.innerHTML=" ",b.className="adsbox",b.style.position="absolute",b.style.fontSize="10px",document.body.appendChild(b);var c=function(){var a=!0;return 0===b.offsetHeight&&(a=!1),b.parentNode.removeChild(b),a};window.setTimeout(function(){a.adsEnabled=c()},100)},b}();b.GameDistributionAds=g}(b=a.AdProvider||(a.AdProvider={}))}(PhaserAds||(PhaserAds={}));var PhaserAds;!function(a){var b;!function(b){var c=function(){function b(a,b){this.adsManager=null,this.googleEnabled=!1,this.adsEnabled=!0,this.adTagUrl="",this.adRequested=!1,this.hasRewarded=!1,this.adManager=null,this.resizeListener=null,this.areAdsEnabled(),"undefined"!=typeof google&&(this.googleEnabled=!0,this.gameContent="string"==typeof a.parent?document.getElementById(a.parent):a.parent,this.gameContent.style.position="absolute",this.gameContent.style.width="100%",this.adContent=this.gameContent.parentNode.appendChild(document.createElement("div")),this.adContent.id="phaser-ad-container",this.adContent.style.position="absolute",this.adContent.style.zIndex="9999",this.adContent.style.display="none",this.adContent.style.top="0",this.adContent.style.left="0",this.adContent.style.width="100%",this.adContent.style.height="100%",this.adContent.style.overflow="hidden",this.adTagUrl=b,this.game=a,this.adDisplay=new google.ima.AdDisplayContainer(this.adContent),google.ima.settings.setVpaidMode(google.ima.ImaSdkSettings.VpaidMode.ENABLED),google.ima.settings.setLocale("nl"),this.adLoader=new google.ima.AdsLoader(this.adDisplay),this.adLoader.addEventListener(google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,this.onAdManagerLoader,!1,this),this.adLoader.addEventListener(google.ima.AdErrorEvent.Type.AD_ERROR,this.onAdError,!1,this))}return b.prototype.setManager=function(a){this.adManager=a},b.prototype.showAd=function(a){if(!this.adRequested){if(this.adsEnabled||this.adManager.onAdsDisabled.dispatch(!0),!this.googleEnabled)return void this.onContentResumeRequested();this.adDisplay.initialize();var b=new google.ima.AdsRequest;b.adTagUrl=this.adTagUrl+this.parseCustomParams(a);var c=window.innerWidth,d=window.innerHeight;this.game.scale.isFullScreen&&document.body.clientHeight<window.innerHeight&&(d=document.body.clientHeight,c=document.body.clientWidth),b.linearAdSlotWidth=c,b.linearAdSlotHeight=d,b.nonLinearAdSlotWidth=c,b.nonLinearAdSlotHeight=d,b.forceNonLinearFullSlot=!0;try{this.adRequested=!0,this.adLoader.requestAds(b)}catch(a){this.onContentResumeRequested()}}},b.prototype.preloadAd=function(){},b.prototype.destroyAd=function(){},b.prototype.hideAd=function(){},b.prototype.onAdManagerLoader=function(a){var b=this,c=new google.ima.AdsRenderingSettings;c.restoreCustomPlaybackStateOnAdBreakComplete=!0;var d=a.getAdsManager(this.gameContent,c);this.adsManager=d,d.addEventListener(google.ima.AdEvent.Type.CONTENT_PAUSE_REQUESTED,this.onContentPauseRequested,!1,this),d.addEventListener(google.ima.AdEvent.Type.CONTENT_RESUME_REQUESTED,this.onContentResumeRequested,!1,this),d.addEventListener(google.ima.AdErrorEvent.Type.AD_ERROR,this.onAdError,!1,this),[google.ima.AdEvent.Type.ALL_ADS_COMPLETED,google.ima.AdEvent.Type.CLICK,google.ima.AdEvent.Type.COMPLETE,google.ima.AdEvent.Type.FIRST_QUARTILE,google.ima.AdEvent.Type.LOADED,google.ima.AdEvent.Type.MIDPOINT,google.ima.AdEvent.Type.PAUSED,google.ima.AdEvent.Type.STARTED,google.ima.AdEvent.Type.THIRD_QUARTILE].forEach(function(a){d.addEventListener(a,b.onAdEvent,!1,b)});try{this.adContent.style.display="block";var e=window.innerWidth,f=window.innerHeight;this.adsManager.init(e,f,google.ima.ViewMode.NORMAL),this.adsManager.start(),this.resizeListener=function(){null!==b.adsManager&&b.adsManager.resize(window.innerWidth,window.innerHeight,google.ima.ViewMode.NORMAL)},window.addEventListener("resize",this.resizeListener)}catch(a){this.onAdError(a)}},b.prototype.onAdEvent=function(b){switch(b.type){case google.ima.AdEvent.Type.CLICK:this.adManager.onAdClicked.dispatch();break;case google.ima.AdEvent.Type.LOADED:this.adRequested=!1;var c=b.getAd();c.isLinear()||this.onContentResumeRequested();break;case google.ima.AdEvent.Type.STARTED:this.adManager.onAdProgression.dispatch(a.AdEvent.start);break;case google.ima.AdEvent.Type.FIRST_QUARTILE:this.adManager.onAdProgression.dispatch(a.AdEvent.firstQuartile);break;case google.ima.AdEvent.Type.MIDPOINT:this.adManager.onAdProgression.dispatch(a.AdEvent.midPoint);break;case google.ima.AdEvent.Type.THIRD_QUARTILE:this.adManager.onAdProgression.dispatch(a.AdEvent.thirdQuartile);break;case google.ima.AdEvent.Type.COMPLETE:this.adManager.onAdProgression.dispatch(a.AdEvent.complete);break;case google.ima.AdEvent.Type.ALL_ADS_COMPLETED:this.onContentResumeRequested()}},b.prototype.onAdError=function(a){null!==this.adsManager&&(this.adsManager.destroy(),this.adsManager=null,null!==this.resizeListener&&(window.removeEventListener("resize",this.resizeListener),this.resizeListener=null)),this.adRequested&&(this.adRequested=!1),this.onContentResumeRequested()},b.prototype.onContentPauseRequested=function(){this.adManager.onContentPaused.dispatch()},b.prototype.onContentResumeRequested=function(){return"undefined"==typeof google?(this.adManager.unMuteAfterAd(),void this.adManager.onContentResumed.dispatch()):(this.adContent.style.display="none",this.adManager.unMuteAfterAd(),void this.adManager.onContentResumed.dispatch())},b.prototype.parseCustomParams=function(a){if(void 0!==a){var b="";for(var c in a)if(a.hasOwnProperty(c)){b.length>0&&(b+="&");var d=Array.isArray(a[c])?a[c].join(","):a[c];b+=c+"="+d}return"&cust_params="+encodeURIComponent(b)}return""},b.prototype.areAdsEnabled=function(){var a=this,b=document.createElement("div");b.innerHTML=" ",b.className="adsbox",b.style.position="absolute",b.style.fontSize="10px",document.body.appendChild(b);var c=function(){var a=!0;return 0===b.offsetHeight&&(a=!1),b.parentNode.removeChild(b),a};window.setTimeout(function(){a.adsEnabled=c()},100)},b}();b.Ima3=c}(b=a.AdProvider||(a.AdProvider={}))}(PhaserAds||(PhaserAds={})); |
@@ -6,2 +6,7 @@ # Changelog | ||
## [2.4.1] 2019-11-15 | ||
### Added | ||
- GD banner alignment enum | ||
- Possibility to align GD Banner in a given HTMLElement | ||
## [2.4.0] 2019-11-15 | ||
@@ -8,0 +13,0 @@ ### Added |
{ | ||
"name": "@azerion/phaser-ads", | ||
"author": "Azerion", | ||
"version": "2.4.0", | ||
"version": "2.4.1", | ||
"description": "A Phaser plugin for providing nice ads integration in your phaser.io game", | ||
@@ -6,0 +6,0 @@ "contributors": [ |
Sorry, the diff of this file is not supported yet
153856
1776