/
githubmirror
/
amphtml
Обзор
Документация
Войти
/
githubmirror
/
amphtml
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
examples/amp-ad-exit.amp.html
149 строк
4 KB
Caroline Liu
Apply bulk transform to html tags (#34836)
15 июн 2021, 21:07
Не верифицирован
15 июн 2021, 21:07
3ace35c
Код
Авторство
О чём код?
<!doctype html> <html amp4ads lang="en"> <head> <title>amp-ad-exit example</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width,minimum-scale=1"> <style amp4ads-boilerplate>body{visibility:hidden}</style> <script async src="https://cdn.ampproject.org/amp4ads-v0.js"></script> <style amp-custom> .ad { border: 1px solid black; width: 280px; height: 230px; background: #fff; } h1, .product { cursor: pointer; } h1 { font-size: 150%; margin: 0; color: #4285f4; text-decoration: underline; } .product { width: 100px; height: 100px; margin: 10px; padding: 10px; background: #0f9d58; float: left; } amp-carousel .content { width: 80%; height: 80%; margin: 10% 10%; text-align: center; } .content pre { display: inline; } #exit-selector option { display: none; } #exit-selector option[selected] { display: initial; } #cta { width: 100px; } </style> <script async custom-element="amp-ad-exit" src="https://cdn.ampproject.org/v0/amp-ad-exit-0.1.js"></script> <script async custom-element="amp-carousel" src="https://cdn.ampproject.org/v0/amp-carousel-0.1.js"></script> <script async custom-element="amp-selector" src="https://cdn.ampproject.org/v0/amp-selector-0.1.js"></script> </head> <body> <amp-ad-exit id="exit-api" layout="nodisplay"> <script type="application/json"> { "targets": { "target1": { "finalUrl": "http://localhost:8000/?product1&x=CLICK_X&y=CLICK_Y&e=_elem&shouldNotBeReplaced=AMP_VERSION", "vars": { "_elem": {"defaultValue": "headline"} } }, "target2": { "finalUrl": "http://localhost:8000/?product2&x=CLICK_X&y=CLICK_Y&e=_elem&shouldNotBeReplaced=AMP_VERSION", "vars": { "_elem": {"defaultValue": "headline"} } }, "target2_filtered": { "finalUrl": "http://localhost:8000/?product2&r=RANDOM", "trackingUrls": [ "http://localhost:8000/?tracking-url&clicked=_elem" ], "vars": { "_elem": {"defaultValue": "headline"} }, "filters": ["longDelay", "borderProtection"] } }, "filters": { "longDelay": { "type": "clickDelay", "delay": 10000 }, "borderProtection": { "type": "clickLocation", "bottom": 10, "left": 10, "right": 10, "relativeTo": "#product2" } }, "transport": { "beacon": true, "image": true } } </script> </amp-ad-exit> <div class="ad"> <h1 on="tap:exit-api.exit(target='target1')" role="button" tabindex="1">amp-ad-exit example</h1> <div class="product" id="product1" on="tap:exit-api.exit(target='target1', _elem='Product 1')" role="button" tabindex="1"> <p>product 1</p> </div> <div class="product" id="product2" on="tap:exit-api.exit(target='target2_filtered', _elem='Product 2')" role="button" tabindex="1"> <p>product 2</p> </div> <p><a href="https://www.google.com/" on="tap:exit-api.exit(target='target1', _elem='anchor')"><A> tags don't work well (try middle-clicking)</a> </div> <div class="ad" on="tap:exit-api.exit(target='target1')" role="button" tabindex="1"> <amp-carousel height="230" layout="fixed-height" type="slides"> <div class="content">amp-carousel example</div> <div class="content">The exit event is on the parent <div></div> <div class="content"> But the buttons don't trigger an exit because of a default InactiveElement filter that matches their <pre>amp-carousel-button</pre> class. </div> </amp-carousel> </div> <div class="ad"> <amp-carousel height="150" layout="fixed-height" type="slides" on="slideChange:exit-selector.toggle(index=event.index, value=true)"> <div class="content" role="link" tabindex="1" on="tap:exit-api.exit(target='target1', _elem='slide1')">product 1</div> <div class="content" role="link" tabindex="1" on="tap:exit-api.exit(target='target2', _elem='slide2')">product 2</div> </amp-carousel> <button id="cta" tabindex="1" on="tap:exit-api.exit(variable='current', default='target1', _elem='cta')"> Buy <span> <amp-selector id="exit-selector" on="select:exit-api.setVariable(name='current', target=event.targetOption)"> <option option="target1" selected>product 1</option> <option option="target2">product 2</option> </amp-selector> </span> </button> </div> </body> </html>