buildOutlink_() {
    this.setDragCap_(DRAG_CAP_PX);
    this.setOpenThreshold_(OPEN_THRESHOLD_PX);

    this.headerEl.classList.add(
      'i-amphtml-story-draggable-drawer-header-attachment-remote'
    );
    this.element.classList.add('i-amphtml-story-page-attachment-remote');
    // Use an anchor element to make this a real link in vertical rendering.
    const link = htmlFor(this.element)`
      <a class="i-amphtml-story-page-attachment-remote-content" target="_blank">
        <span class="i-amphtml-story-page-attachment-remote-title"><span ref="openStringEl"></span><span ref="urlStringEl"></span></span>
        <svg class="i-amphtml-story-page-attachment-remote-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48"><path d="M38 38H10V10h14V6H10c-2.21 0-4 1.79-4 4v28c0 2.21 1.79 4 4 4h28c2.21 0 4-1.79 4-4V24h-4v14zM28 6v4h7.17L15.51 29.66l2.83 2.83L38 12.83V20h4V6H28z"></path></svg>
      </a>`;

    // For backwards compatibility if element is amp-story-page-outlink.
    const hrefAttr =
      this.element.tagName === 'AMP-STORY-PAGE-OUTLINK'
        ? this.element.querySelector('a').getAttribute('href')
        : this.element.getAttribute('href');

    // URL will be validated and resolved based on the canonical URL if relative
    // when navigating.
    link.setAttribute('href', hrefAttr);
    const {openStringEl, urlStringEl} = htmlRefs(link);

    // Navigation is handled programmatically. Disable clicks on the placeholder
    // anchor to prevent from users triggering double navigations, which has
    // side effects in native contexts opening webviews/CCTs.
    link.addEventListener('click', (event) => event.preventDefault());

    // Set image.
    const openImgAttr = this.element.getAttribute('cta-image');
    if (openImgAttr && openImgAttr !== 'none') {
      const ctaImgEl = this.win.document.createElement('div');
      ctaImgEl.classList.add('i-amphtml-story-page-attachment-remote-img');
      setImportantStyles(ctaImgEl, {
        'background-image': 'url(' + openImgAttr + ')',
      });
      link.prepend(ctaImgEl);
    } else if (!openImgAttr) {
      // Attach link icon SVG by default.
      const linkImage = buildOutlinkLinkIconElement(link);
      link.prepend(linkImage);
    }

    // Set url prevew text.
    const localizationService = getLocalizationService(devAssert(this.element));
    if (localizationService) {
      const localizedOpenString = localizationService.getLocalizedString(
        LocalizedStringId.AMP_STORY_OPEN_OUTLINK_TEXT
      );
      openStringEl.textContent = localizedOpenString;
    }
    urlStringEl.textContent = hrefAttr;

    this.contentEl.appendChild(link);
  }
/**
   * Builds outlink CTA drawer UI.
   * @private
   */
Builds outlink CTA drawer UI.
@private
Builds outlink CTA drawer UI . @private
buildOutlink_() {
    this.setDragCap_(DRAG_CAP_PX);
    this.setOpenThreshold_(OPEN_THRESHOLD_PX);
    this.headerEl.classList.add(
      'i-amphtml-story-draggable-drawer-header-attachment-remote'
    );
    this.element.classList.add('i-amphtml-story-page-attachment-remote');
    const link = htmlFor(this.element)`
      <a class="i-amphtml-story-page-attachment-remote-content" target="_blank">
        <span class="i-amphtml-story-page-attachment-remote-title"><span ref="openStringEl"></span><span ref="urlStringEl"></span></span>
        <svg class="i-amphtml-story-page-attachment-remote-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48"><path d="M38 38H10V10h14V6H10c-2.21 0-4 1.79-4 4v28c0 2.21 1.79 4 4 4h28c2.21 0 4-1.79 4-4V24h-4v14zM28 6v4h7.17L15.51 29.66l2.83 2.83L38 12.83V20h4V6H28z"></path></svg>
      </a>`;
    const hrefAttr =
      this.element.tagName === 'AMP-STORY-PAGE-OUTLINK'
        ? this.element.querySelector('a').getAttribute('href')
        : this.element.getAttribute('href');
    link.setAttribute('href', hrefAttr);
    const {openStringEl, urlStringEl} = htmlRefs(link);
    link.addEventListener('click', (event) => event.preventDefault());
    const openImgAttr = this.element.getAttribute('cta-image');
    if (openImgAttr && openImgAttr !== 'none') {
      const ctaImgEl = this.win.document.createElement('div');
      ctaImgEl.classList.add('i-amphtml-story-page-attachment-remote-img');
      setImportantStyles(ctaImgEl, {
        'background-image': 'url(' + openImgAttr + ')',
      });
      link.prepend(ctaImgEl);
    } else if (!openImgAttr) {
      const linkImage = buildOutlinkLinkIconElement(link);
      link.prepend(linkImage);
    }
    const localizationService = getLocalizationService(devAssert(this.element));
    if (localizationService) {
      const localizedOpenString = localizationService.getLocalizedString(
        LocalizedStringId.AMP_STORY_OPEN_OUTLINK_TEXT
      );
      openStringEl.textContent = localizedOpenString;
    }
    urlStringEl.textContent = hrefAttr;
    this.contentEl.appendChild(link);
  }
buildOutlink_ ( ) { this . setDragCap_ ( DRAG_CAP_PX ) ; this . setOpenThreshold_ ( OPEN_THRESHOLD_PX ) ; this . headerEl . classList . add ( 'i-amphtml-story-draggable-drawer-header-attachment-remote' ) ; this . element . classList . add ( 'i-amphtml-story-page-attachment-remote' ) ; const link = htmlFor ( this . element ) ` ` ; const hrefAttr = this . element . tagName === 'AMP-STORY-PAGE-OUTLINK' ? this . element . querySelector ( 'a' ) . getAttribute ( 'href' ) : this . element . getAttribute ( 'href' ) ; link . setAttribute ( 'href' , hrefAttr ) ; const { openStringEl , urlStringEl } = htmlRefs ( link ) ; link . addEventListener ( 'click' , ( event ) => event . preventDefault ( ) ) ; const openImgAttr = this . element . getAttribute ( 'cta-image' ) ; if ( openImgAttr && openImgAttr !== 'none' ) { const ctaImgEl = this . win . document . createElement ( 'div' ) ; ctaImgEl . classList . add ( 'i-amphtml-story-page-attachment-remote-img' ) ; setImportantStyles ( ctaImgEl , { 'background-image' : 'url(' + openImgAttr + ')' , } ) ; link . prepend ( ctaImgEl ) ; } else if ( ! openImgAttr ) { const linkImage = buildOutlinkLinkIconElement ( link ) ; link . prepend ( linkImage ) ; } const localizationService = getLocalizationService ( devAssert ( this . element ) ) ; if ( localizationService ) { const localizedOpenString = localizationService . getLocalizedString ( LocalizedStringId . AMP_STORY_OPEN_OUTLINK_TEXT ) ; openStringEl . textContent = localizedOpenString ; } urlStringEl . textContent = hrefAttr ; this . contentEl . appendChild ( link ) ; }
Builds outlink CTA drawer UI.
Builds outlink CTA drawer UI .
// Use an anchor element to make this a real link in vertical rendering. // For backwards compatibility if element is amp-story-page-outlink. // URL will be validated and resolved based on the canonical URL if relative // when navigating. // Navigation is handled programmatically. Disable clicks on the placeholder // anchor to prevent from users triggering double navigations, which has // side effects in native contexts opening webviews/CCTs. // Set image. // Attach link icon SVG by default. // Set url prevew text.