コード例 #1
0
ファイル: full-height.js プロジェクト: stinsonga/frontend
    fastdom.read(() => {
        const elements = Array.from(
            document.getElementsByClassName('js-is-fixed-height')
        );

        return { elements, isMobile: getBreakpoint() === 'mobile' };
    });
コード例 #2
0
ファイル: rich-links.js プロジェクト: easyrider/frontend
const getSpacefinderRules = (): SpacefinderRules => ({
    bodySelector: '.js-article__body',
    slotSelector: ' > p',
    minAbove: 200,
    minBelow: 250,
    clearContentMeta: 50,
    selectors: {
        ' > h2': {
            minAbove: getBreakpoint() === 'mobile' ? 20 : 0,
            minBelow: 200,
        },
        ' > *:not(p):not(h2):not(blockquote)': {
            minAbove: 35,
            minBelow: 300,
        },
        ' .ad-slot': {
            minAbove: 150,
            minBelow: 200,
        },
        ' .element-rich-link': {
            minAbove: 500,
            minBelow: 500,
        },
    },
});
コード例 #3
0
ファイル: page.js プロジェクト: guardian/frontend
const isCompetition = (yes: yesable): boolean => {
    const notMobile = getBreakpoint() !== 'mobile';
    const competition = notMobile
        ? ($('.js-football-competition').attr('data-link-name') || '').replace(
              'keyword: football/',
              ''
          )
        : '';

    return isit(competition, yes);
};
コード例 #4
0
const getRules = (): SpacefinderRules => {
    switch (getBreakpoint()) {
        case 'mobile':
        case 'mobileMedium':
        case 'mobileLandscape':
        case 'phablet':
            return mobileRules;
        case 'tablet':
        case 'desktop':
            return desktopRules;
        default:
            return defaultRules;
    }
};
コード例 #5
0
const findBreakpoint = (): string => {
    switch (getBreakpoint(true)) {
        case 'mobile':
        case 'mobileMedium':
        case 'mobileLandscape':
            return 'mobile';
        case 'phablet':
        case 'tablet':
            return 'tablet';
        case 'desktop':
        case 'leftCol':
        case 'wide':
            return 'desktop';
        default:
            return 'mobile';
    }
};
コード例 #6
0
ファイル: smartAppBanner.js プロジェクト: easyrider/frontend
    loadCssPromise.then(() => {
        const msg = new Message(messageCode, { position: 'top' });
        const fullTemplate = tmp + (getBreakpoint() === 'mobile' ? '' : tablet);

        msg.show(template(fullTemplate, DATA[messageCode.toUpperCase()]));

        addCookie(COOKIE_IMPRESSION_KEY, String(impressions + 1));

        fastdom.read(() => {
            const $banner = $('.site-message--ios, .site-message--android');
            const bannerHeight = $banner.dim().height;
            if (window.scrollY !== 0) {
                window.scrollTo(window.scrollX, window.scrollY + bannerHeight);
            }
        });

        return true;
    });
コード例 #7
0
const insertAds = (slots: HTMLElement[]): void => {
    const isMobile = getBreakpoint() === 'mobile';

    for (let i = 0; i < slots.length && SLOTCOUNTER < MAX_ADS; i += 1) {
        const slotName = getSlotName(isMobile, SLOTCOUNTER);

        const adSlots = createSlots('inline', {
            name: slotName,
            classes: 'liveblog-inline',
        });

        adSlots.forEach(adSlot => {
            if (slots[i] && slots[i].parentNode) {
                slots[i].parentNode.insertBefore(adSlot, slots[i].nextSibling);
            }
        });

        // Only add the first adSlot (the DFP one) in DFP/GTP
        if (slots[i] && slots[i].parentNode) {
            addSlot(adSlots[0], false);
            SLOTCOUNTER += 1;
        }
    }
};
コード例 #8
0
    constructor(config: any = defaultConfig) {
        // this is used for SpeedCurve tests
        const noadsUrl: boolean = /[#&]noads(&.*)?$/.test(window.location.hash);
        const forceAdFree: boolean = /[#&]noadsaf(&.*)?$/.test(
            window.location.hash
        );
        const forceAds: boolean = /[?&]forceads(&.*)?$/.test(
            window.location.search
        );
        const externalAdvertising = !noadsUrl && !userPrefs.isOff('adverts');
        const sensitiveContent =
            config.get('page.shouldHideAdverts') ||
            config.get('page.section') === 'childrens-books-site';
        const isMinuteArticle = config.get('page.isMinuteArticle');
        const isArticle = config.get('page.contentType') === 'Article';
        const isInteractive = config.get('page.contentType') === 'Interactive';
        const isLiveBlog = config.get('page.isLiveBlog');
        const isHosted = config.get('page.isHosted');
        const isIdentityPage =
            config.get('page.contentType') === 'Identity' ||
            config.get('page.section') === 'identity'; // needed for pages under profile.* subdomain
        const switches = config.get('switches');
        const isWidePage = getBreakpoint() === 'wide';
        const supportsSticky =
            document.documentElement &&
            document.documentElement.classList.contains('has-sticky');
        const newRecipeDesign =
            config.get('page.showNewRecipeDesign') &&
            config.get('tests.abNewRecipeDesign');
        const isSecureContact = config
            .get('page.pageId', '')
            .includes(
                'help/ng-interactive/2017/mar/17/contact-the-guardian-securely'
            );

        // Feature switches
        this.adFree = !!forceAdFree || isAdFreeUser();

        this.dfpAdvertising =
            forceAds ||
            (switches.commercial &&
                externalAdvertising &&
                !sensitiveContent &&
                !isIdentityPage &&
                !this.adFree);

        this.stickyTopBannerAd =
            !this.adFree &&
            !config.get('page.disableStickyTopBanner') &&
            !supportsSticky;

        this.articleBodyAdverts =
            this.dfpAdvertising &&
            !this.adFree &&
            !isMinuteArticle &&
            isArticle &&
            !isLiveBlog &&
            !isHosted &&
            !newRecipeDesign;

        this.carrotTrafficDriver =
            !this.adFree &&
            this.articleBodyAdverts &&
            config.get('switches.carrotTrafficDriver', false) &&
            !config.get('page.isPaidContent');

        this.videoPreRolls = this.dfpAdvertising && !this.adFree;

        this.highMerch =
            this.dfpAdvertising &&
            !this.adFree &&
            !isMinuteArticle &&
            !isHosted &&
            !isInteractive &&
            !config.get('page.isFront') &&
            !newRecipeDesign;

        this.thirdPartyTags =
            !this.adFree &&
            externalAdvertising &&
            !isIdentityPage &&
            !isSecureContact;

        this.outbrain =
            this.dfpAdvertising &&
            !this.adFree &&
            switches.outbrain &&
            !noadsUrl &&
            !sensitiveContent &&
            isArticle &&
            !config.get('page.isPreview') &&
            config.get('page.showRelatedContent') &&
            !(isUserLoggedIn() && config.get('page.commentable'));

        this.commentAdverts =
            this.dfpAdvertising &&
            !this.adFree &&
            !isMinuteArticle &&
            config.get('switches.enableDiscussionSwitch') &&
            config.get('page.commentable') &&
            (!isLiveBlog || isWidePage);

        this.liveblogAdverts =
            isLiveBlog && this.dfpAdvertising && !this.adFree;

        this.paidforBand = config.get('page.isPaidContent') && !supportsSticky;
    }