This repository has been archived by the owner on Jan 21, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1708 from vogdb/issue-1708
Epom Adprovider
- Loading branch information
Showing
3 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
class CM_AdproviderAdapter_Epom extends CM_AdproviderAdapter_Abstract { | ||
|
||
public function getHtml($zoneData, array $variables) { | ||
$zoneId = CM_Util::htmlspecialchars($zoneData['zoneId']); | ||
$variables = $this->_variableKeysToUnderscore($variables); | ||
$variables['key'] = '2ea5b261f06ca771033a5fa9e22493f1'; | ||
|
||
$html = '<div id="epom-' . $zoneId . '" class="epom-ad" data-zone-id="' . $zoneId . '" data-variables="' . | ||
CM_Util::htmlspecialchars(json_encode($variables, JSON_FORCE_OBJECT)) . '"></div>'; | ||
return $html; | ||
} | ||
|
||
private function _variableKeysToUnderscore($variables) { | ||
foreach ($variables as $key => $value) { | ||
unset ($variables[$key]); | ||
$underscoreKey = str_replace('-', '_', $key); | ||
$variables[$underscoreKey] = $value; | ||
} | ||
return $variables; | ||
} | ||
} |
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