Commit f8227ce5 authored by mxh's avatar mxh
Browse files

#3174864 Added support for theme breakpoints.

parent 0f0efae0
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -11,9 +11,13 @@ use Drupal\ad_entity\Render\Markup;
 * Implements hook_ad_entity_module_info().
 */
function ad_entity_adtech_v2_ad_entity_module_info() {
  // The ATF integration does not support direct configuration of
  // personalized ads, thus it's also not consent aware in perspective of the
  // ad_entity module. The ATF SDK handles the whole process on its own,
  // using the given CMP solution provided for each project.
  return [
    'personalization' => TRUE,
    'consent_aware' => TRUE,
    'personalization' => FALSE,
    'consent_aware' => FALSE,
  ];
}

+1 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ function template_preprocess_adtech_v2_default(array &$variables) {
  $settings        = $ad_entity->getThirdPartySettings('ad_entity_adtech_v2');
  $config          = \Drupal::config('ad_entity.settings');
  $global_settings = $config->get('adtech_v2_factory');
  $variables['use_theme_breakpoints'] = !empty($global_settings['use_theme_breakpoints']);

  // Generate attributes.
  $id = Html::getUniqueId($ad_entity->id());
+3 −0
Original line number Diff line number Diff line
@@ -2,6 +2,9 @@ ad_entity.settings.adtech_v2_factory:
  type: mapping
  label: 'AdTech Factory v2 settings'
  mapping:
    use_theme_breakpoints:
      type: boolean
      label: 'Initialize ad slots in respect of theme breakpoints.'
    async_tag:
      type: string
      label: 'Async Tag (provided by ATF personnel)'
+1 −1
Original line number Diff line number Diff line
@@ -62,7 +62,7 @@
        }
        eb.i = 0;
        eb.el = eb.slot_el.parentNode;
        while (eb.i < 5 && eb.el && !eb.container) {
        while (eb.i < 3 && eb.el && !eb.container) {
          for (eb.containerId in adEntity.adContainers) {
            if (adEntity.adContainers.hasOwnProperty(eb.containerId)) {
              eb.container = adEntity.adContainers[eb.containerId];
+18 −14
Original line number Diff line number Diff line
@@ -11,29 +11,33 @@
  ad_entity.viewHandlers.adtech_v2_default = {
    initialize: function (containers, context, settings) {
      var container;
      var container_id;
      var ad_el;
      var ad_tag;
      var buffer = {};

      // The contained ad tags will be loaded by ATF SDK automatically.
      // There is no way to manually pass ad tags to the SDK, thus here
      // the contained ad tags will just be collected for later event binding.
      for (container_id in containers) {
        if (containers.hasOwnProperty(container_id)) {
          container = containers[container_id];
          ad_el = container.el.querySelector('.adtech-v2-factory-ad');
          if (ad_el === null) {
      for (buffer.containerId in containers) {
        if (containers.hasOwnProperty(buffer.containerId)) {
          container = containers[buffer.containerId];
          buffer.applicant = container.el.querySelector('.slot-applicant');
          if (buffer.applicant) {
            buffer.slotHtml = JSON.parse(buffer.applicant.getAttribute('data-slot'));
            if (buffer.slotHtml) {
              ad_entity.helpers.trigger(window, 'atf:BeforeSlotLoad', false, true, { container: container, slotHtml: buffer.slotHtml });
              // Once the slot element is in the DOM, it will be automatically
              // recognized and loaded by the ATF PPTM/SDK.
              container.el.innerHTML = buffer.slotHtml;
            }
          }
          buffer.ad_el = container.el.querySelector('.adtech-v2-factory-ad');
          if (buffer.ad_el === null) {
            continue;
          }

          this.numberOfAds++;
          ad_tag = {
            el: ad_el,
          container.ad_tag = {
            el: buffer.ad_el,
            data: function (key, value) {
              return ad_entity.helpers.metadata(this.el, this, key, value);
            }
          };
          container.ad_tag = ad_tag;
        }
      }
    },
Loading