Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added refresh interval for amp-ad blocks in the apester-media #35961

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions extensions/amp-apester-media/0.1/amp-apester-media.css
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,17 @@
zoom: 1;
-webkit-overflow-scrolling: touch !important;
}

.i-amphtml-amp-apester-companion {
display: block;
margin: 10px auto;
}

.i-amphtml-amp-apester-bottom-ad {
display: block !important;
position: absolute !important;
bottom: 0 !important;
left: 50% !important;
transform: translateX(-50%) !important;
margin: 0 !important;
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,21 @@ export function handleCompanionBottomAd(media, apesterElement) {
function constructCompanionBottomAd(slot, bannerSizes, apesterElement) {
const width = bannerSizes[0][0];
const height = bannerSizes[0][1];
const refreshInterval = 30;
const ampAd = createElementWithAttributes(
/** @type {!Document} */ (apesterElement.ownerDocument),
'amp-ad',
dict({
'width': `${width}`,
'height': `${height}`,
'type': 'doubleclick',
'style':
'position: absolute !important; bottom: 0;left: 50%;margin-left: -150px;margin-bottom: 0;',
'layout': 'fixed',
'data-slot': `${slot}`,
'data-multi-size-validation': 'false',
'data-enable-refresh': `${refreshInterval}`,
})
);
ampAd.classList.add('i-amphtml-amp-apester-companion');
ampAd.classList.add('i-amphtml-amp-apester-bottom-ad');
apesterElement.appendChild(ampAd);
Services.mutatorForDoc(apesterElement).requestChangeSize(ampAd, height);
return ampAd;
Expand Down
18 changes: 16 additions & 2 deletions extensions/amp-apester-media/0.1/monetization/companion/display.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,32 @@ export function handleCompanionDisplay(media, apesterElement) {
settings['bannerAdProvider'] === ALLOWED_AD_PROVIDER
) {
const slot = settings['slot'];
const refreshInterval =
settings['options']['autoRefreshTime'] === 60000 ? 60 : 30;
const defaultBannerSizes = [[300, 250]];
const bannerSizes = settings['bannerSizes'] || defaultBannerSizes;
constructCompanionDisplayAd(slot, bannerSizes, apesterElement);
constructCompanionDisplayAd(
slot,
bannerSizes,
apesterElement,
refreshInterval
);
}
}

/**
* @param {string} slot
* @param {Array} bannerSizes
* @param {!AmpElement} apesterElement
* @param {number} refreshInterval
* @return {!Element}
*/
function constructCompanionDisplayAd(slot, bannerSizes, apesterElement) {
function constructCompanionDisplayAd(
slot,
bannerSizes,
apesterElement,
refreshInterval
) {
const maxWidth = Math.max.apply(
null,
bannerSizes.map((s) => s[0])
Expand All @@ -64,6 +77,7 @@ function constructCompanionDisplayAd(slot, bannerSizes, apesterElement) {
'data-slot': `${slot}`,
'data-multi-size-validation': 'false',
'data-multi-size': multiSizeData,
'data-enable-refresh': `${refreshInterval}`,
})
);
ampAd.classList.add('i-amphtml-amp-apester-companion');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ function getCompanionPosition(video) {
*/
function addCompanionSrElement(videoTag, position, macros, apesterElement) {
const size = getCompanionVideoAdSize(apesterElement);
const refreshInterval = 30;
const ampBladeAd = createElementWithAttributes(
/** @type {!Document} */ (apesterElement.ownerDocument),
'amp-ad',
Expand All @@ -87,6 +88,7 @@ function addCompanionSrElement(videoTag, position, macros, apesterElement) {
'data-blade_macros': JSON.stringify(macros),
'data-blade_player_id': videoTag,
'data-blade_api_key': '5857d2ee263dc90002000001',
'data-enable-refresh': `${refreshInterval}`,
})
);

Expand Down