Created
October 9, 2015 14:30
-
-
Save veeracs/6de92de4347658915cf2 to your computer and use it in GitHub Desktop.
CM DFP unit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.module('directives', []) | |
.directive('cmunit', ['$compile', 'AdBrandMappingService', | |
function($compile, AdBrandMappingService) { | |
return { | |
restrict: 'E', | |
replace: true, | |
template: '<div class="cm-ads-unit" id="cmunit{{size}}_frame"></div>', | |
link: function(scope, elm, attrs, ctrl) { | |
var site = AdBrandMappingService.getDfpReference(scope.appName); | |
scope.size = (scope.adBlocked) ? '_failsafe' : attrs.size; | |
if (scope.adBlocked) { | |
// elm.html('<link rel="stylesheet" type="text/css" href="https://stag-cnid.condenastdigital.com/client/css/suboffer_new.css?ver=10.8.0"><div class="dfp-suboffer {{appName}}"><p class="txt-thanks">THANK YOU FOR CREATING A LOGIN</p><a class="btn btn-default btn-conde btn-offer" href="#/' + scope.brand + '/subscribe"><h4>SUBSCRIBE</h4><p>6 ISSUES for $5 - SUBSCRIBE</p></a><a ng-click="finish()" href="" class="brand-lnk">Back to ' + scope.brandName + '</a></div>'); | |
scope.failsafe = true; | |
scope.size = '_failsafe'; | |
} else { | |
scope.size = attrs.size; | |
console.info('%cCN site init....', 'color:orange'); | |
CN.site.init({ | |
title: 'cnid', | |
zone: 'sitedetails', | |
name: site, | |
env: scope.cnidEnv | |
}); | |
console.info('%cCN dart init....', 'color:orange'); | |
CN.dart.init({ | |
configFile: '/client/libs/ads/config.js', | |
site: site, | |
zone: 'sitedetails', | |
kws: ['cnid', 'sitedetails', 'cmunit', 'subscribe', scope.appName], | |
gptCallback: function(event) { | |
console.log('gptCallback fires...'); | |
console.log('Dart call initialized with:'); | |
console.log('site: ' + site); | |
console.log('scope.appName: ' + scope.appName); | |
if (scope.cnidEnv !== 'PROD') { | |
$('body').triggerHandler($.Event('adRender', event)); | |
CN.debug.info('%cCid: ' + event.creativeId + ' is rendered to slot of size: ' + event.size[0] + 'x' + event.size[1], 'color:orange'); | |
} | |
} | |
}); | |
CN.dart.call('cmunit', { | |
sz: attrs.size, | |
collapse: true | |
}); | |
// console.log(CN.dart.getAdLog()); | |
} | |
} | |
}; | |
} | |
]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment