diff --git a/client-vendor/after-body/jquery.epom/jquery.epom.js b/client-vendor/after-body/jquery.epom/jquery.epom.js new file mode 100755 index 000000000..07c397a30 --- /dev/null +++ b/client-vendor/after-body/jquery.epom/jquery.epom.js @@ -0,0 +1,53 @@ +/* + * Author: CM + */ +(function($, global) { + + /** + * @param {String} category + * @param {String} action + * @param {String} label + */ + function trackEvent(category, action, label) { + if (global.ga) { + global.ga('send', { + 'hitType': 'event', + 'eventCategory': category, + 'eventAction': action, + 'eventLabel': label, + }); + } + } + + $.fn.epom = function() { + return this.each(function() { + var zoneId = $(this).data('zone-id'); + var variables = $(this).data('variables'); + var src = (location.protocol == 'https:' ? 'https:' : 'http:') + '//n181adserv.com\/ads-api'; + var $element = $(this); + + var loadCallback = function(result) { + if (result.success) { + $element.html(result.code); + var hasContent = !$element.is(':empty'); + $element.trigger('epom-loaded', {hasContent: hasContent}); + + if (hasContent) { + $element.addClass('advertisement-hasContent'); + trackEvent('Banner', 'Impression', 'zone-' + zoneId); + var $link = $element.find('a[href]'); + if ($element.is(':visible') && $link.length > 0) { + trackEvent('Banner', 'Impression-Clickable', 'zone-' + zoneId); + $link.on('click', function() { + trackEvent('Banner', 'Click', 'zone-' + zoneId); + }); + } + } + } + }; + + variables['format'] = 'jsonp'; + $.getJSON(src + '?callback=?', variables, loadCallback); + }); + }; +})(jQuery, window); diff --git a/library/CM/AdproviderAdapter/Epom.php b/library/CM/AdproviderAdapter/Epom.php new file mode 100644 index 000000000..fbb41fd47 --- /dev/null +++ b/library/CM/AdproviderAdapter/Epom.php @@ -0,0 +1,23 @@ +_variableKeysToUnderscore($variables); + $variables['key'] = '2ea5b261f06ca771033a5fa9e22493f1'; + + $html = '
'; + return $html; + } + + private function _variableKeysToUnderscore($variables) { + foreach ($variables as $key => $value) { + unset ($variables[$key]); + $underscoreKey = str_replace('-', '_', $key); + $variables[$underscoreKey] = $value; + } + return $variables; + } +} diff --git a/library/CM/App.js b/library/CM/App.js index ed13d45b6..e8d90b410 100644 --- a/library/CM/App.js +++ b/library/CM/App.js @@ -308,6 +308,7 @@ var CM_App = CM_Class_Abstract.extend({ $dom.find('.toggleNext').toggleNext(); $dom.find('.tabs').tabs(); $dom.find('.openx-ad:visible').openx(); + $dom.find('.epom-ad').epom(); $dom.find('.fancySelect').fancySelect(); }, /**