extensions/amp-story/1.0/amp-story.js
/**
   * Renders the layout for the story
   * @return {!Promise} A promise that is resolved when the story layout is
   *       loaded
   * @private
   */
Renders the layout for the story
@return {!Promise} A promise that is resolved when the story layout is
loaded
@private
Renders the layout for the story @return { !Promise } A promise that is resolved when the story layout is loaded @private
layoutStory_() {
    const firstPageEl = user().assertElement(
        this.element.querySelector('amp-story-page'),
        'Story must have at least one page.');
    const initialPageId = this.getHistoryStatePageId_() || firstPageEl.id;
    if (!this.paginationButtons_) {
      this.buildPaginationButtons_();
    }
    this.initializeBookend_();
    this.initializeSidebar_();
    const storyLayoutPromise = this.initializePages_()
        .then(() => {
          this.buildSystemLayer_();
          this.handleConsentExtension_();
          this.initializeStoryAccess_();
          this.pages_.forEach((page, index) => {
            page.setState(PageState.NOT_ACTIVE);
            this.upgradeCtaAnchorTagsForTracking_(page, index);
          });
        })
        .then(() => this.switchTo_(initialPageId))
        .then(() => this.updateViewportSizeStyles_())
        .then(() => {
          const uiState = this.storeService_.get(StateProperty.UI_STATE);
          if (uiState === UIType.MOBILE) {
            this.shareMenu_.build();
          }
          const infoDialog = Services.viewerForDoc(this.element).isEmbedded() ?
            new InfoDialog(this.win, this.element) : null;
          if (infoDialog) {
            infoDialog.build();
          }
        });
    storyLayoutPromise.then(() => this.whenPagesLoaded_(PAGE_LOAD_TIMEOUT_MS))
        .then(() => this.markStoryAsLoaded_());
    return storyLayoutPromise;
  }
layoutStory_ ( ) { const firstPageEl = user ( ) . assertElement ( this . element . querySelector ( 'amp-story-page' ) , 'Story must have at least one page.' ) ; const initialPageId = this . getHistoryStatePageId_ ( ) || firstPageEl . id ; if ( ! this . paginationButtons_ ) { this . buildPaginationButtons_ ( ) ; } this . initializeBookend_ ( ) ; this . initializeSidebar_ ( ) ; const storyLayoutPromise = this . initializePages_ ( ) . then ( ( ) => { this . buildSystemLayer_ ( ) ; this . handleConsentExtension_ ( ) ; this . initializeStoryAccess_ ( ) ; this . pages_ . forEach ( ( page , index ) => { page . setState ( PageState . NOT_ACTIVE ) ; this . upgradeCtaAnchorTagsForTracking_ ( page , index ) ; } ) ; } ) . then ( ( ) => this . switchTo_ ( initialPageId ) ) . then ( ( ) => this . updateViewportSizeStyles_ ( ) ) . then ( ( ) => { const uiState = this . storeService_ . get ( StateProperty . UI_STATE ) ; if ( uiState === UIType . MOBILE ) { this . shareMenu_ . build ( ) ; } const infoDialog = Services . viewerForDoc ( this . element ) . isEmbedded ( ) ? new InfoDialog ( this . win , this . element ) : null ; if ( infoDialog ) { infoDialog . build ( ) ; } } ) ; storyLayoutPromise . then ( ( ) => this . whenPagesLoaded_ ( PAGE_LOAD_TIMEOUT_MS ) ) . then ( ( ) => this . markStoryAsLoaded_ ( ) ) ; return storyLayoutPromise ; }
Renders the layout for the story
 @return {!Promise} A promise that is resolved when the story layout is
       loaded
 @private
Renders the layout for the story @return { !Promise } A promise that is resolved when the story layout is loaded @private
// Preloads and prerenders the share menu if mobile, where the share // button is visible. // Do not block the layout callback on the completion of these promises, as // that prevents descendents from being laid out (and therefore loaded).