Пример #1
0
 consumer_info.promise.then(function() {
     // Re-render footer region if necessary.
     var current_region = user_helpers.region('restofworld');
     if (current_region !== context.user_region) {
         console.log('Region has changed from ' + context.user_region +
                     ' to ' + current_region + ' since we rendered ' +
                     'the footer, updating region in footer.');
         $('#site-footer span.region')
             .removeClass('region-' + context.user_region)
             .addClass('region-' + current_region)
             .text(regions.REGION_CHOICES_SLUG[current_region]);
     }
 });
Пример #2
0
    z.page.on('reload_chrome', function() {
        console.log('Reloading chrome');
        var user_helpers = require('user_helpers');
        var context = {
            render_newsletter: !storage.getItem('newsletter-completed'),
            user_region: user_helpers.region('restofworld'),
            user_email: user.get_setting('email'),
            user_lang: user_helpers.lang(),
            z: z
        };
        $('#site-header').html(
            nunjucks.env.render('header.html', context));
        $('#site-footer').html(
            nunjucks.env.render('footer.html', context));

        if (!window['incompatibility-banner'] &&
                !navigator.mozApps &&
                !navigator.userAgent.match(/googlebot/i)) {
            console.log('Adding incompatibility banner');
            $('#site-nav').after(nunjucks.env.render('incompatible.html'));
        }

        var logged_in = user.logged_in();

        if (!logged_in) {
            z.body.removeClass('show-recommendations');
        }

        siteConfig.promise.then(function () {
            if (capabilities.nativeFxA() || capabilities.yulelogFxA()) {
                // We might want to style things differently for native FxA users,
                // specifically they should need to log out through settings instead
                // of through Marketplace (hide logout buttons for bug 1073177).
                // Unfortunately we need to wait for the switches to load.
                z.body.addClass('native-fxa');
            }

            var banner = document.getElementById('fx-accounts-banner');
            if (banner) {
                banner.dismissBanner();
            }
            if (user.canMigrate()) {
                $('#site-nav').after(
                    nunjucks.env.render('fx-accounts-banner.html',
                                        {logged_in: logged_in}));
            }
        });

        // TODO: Move this to the consumer-info callback when the waffle is
        // removed as we no longer require siteConfig for the waffle switch.
        $.when(siteConfig, consumer_info).then(function() {
            // To show or not to show the recommendations nav.
            if (logged_in && user.get_setting('enable_recommendations') &&
                    // TODO: Remove when waffle removed (bug 1083942).
                    settings.switches.indexOf('recommendations') !== -1) {
                z.body.addClass('show-recommendations');
            }
        });

        consumer_info.promise.then(function() {
            // Re-render footer region if necessary.
            var current_region = user_helpers.region('restofworld');
            if (current_region !== context.user_region) {
                console.log('Region has changed from ' + context.user_region +
                            ' to ' + current_region + ' since we rendered ' +
                            'the footer, updating region in footer.');
                $('#site-footer span.region')
                    .removeClass('region-' + context.user_region)
                    .addClass('region-' + current_region)
                    .text(regions.REGION_CHOICES_SLUG[current_region]);
            }
        });

        z.body.toggleClass('logged-in', logged_in);
        z.page.trigger('reloaded_chrome');
    }).trigger('reload_chrome');