view/shared/assets/js/wb/ads/2.2.7/ads.js
/**
     * Displays an ad in all defined slots and if refreshable, updates slot with a new ad.
     * This code will wait until all slot have been "resolved", meaning they have their
     * targeting and a gpt slot object has been created and attached to the slot.
     *
     * @return {*}
     */
Displays an ad in all defined slots and if refreshable, updates slot with a new ad.
This code will wait until all slot have been "resolved", meaning they have their
targeting and a gpt slot object has been created and attached to the slot.


Displays an ad in all defined slots and if refreshable updates slot with a new ad . This code will wait until all slot have been " resolved " meaning they have their targeting and a gpt slot object has been created and attached to the slot .
function showAds() {
        flushCmd();
        var deferreds = $.map(slots, function(slot, index) {
            return slot.deferred;
        });
        $.when.apply($, deferreds).then(function() {
            trigger('pre.display.ads');
            $.each(slots, function(index, slot) {
                var adDiv = $('#' + slot.div_id);
                var adSlotData = adDiv.data(settings.data_store);
                var refreshable = adDiv.data('refresh') || false;
                var unfilled = adDiv.data('unfilled') || false;
                var filled = adDiv.data('filled') || false;
                var registered = adDiv.data('registered');
                if (dfp_settings.enable_single_request) {
                    if (refreshable) {
                        pushCmd(function() { googletag.pubads().refresh([adSlotData]); });
                        debug("showAds :: refreshing ad " + adDiv.attr('id'));
                    } else if (unfilled) {
                        pushCmd(function() { googletag.pubads().refresh([adSlotData]); });
                        debug("showAds :: filling unfilled ad " + adDiv.attr('id'));
                        adDiv.data('unfilled', false);
                    }
                } else {
                    if (refreshable) {
                        if (!registered) {
                            pushCmd(function() {
                                googletag.display(adDiv.attr('id')); 
                                debug("showAds :: displaying ad " + adDiv.attr('id') + " - will REFRESH on next showAds()");
                                adDiv.data('registered', true);
                            });
                        } else {
                            pushCmd(function() { googletag.pubads().refresh([adSlotData]); }); 
                            debug("showAds :: refreshing ad " + adDiv.attr('id'));
                        }
                    } else if (!filled) {
                        pushCmd(function() { googletag.display(adDiv.attr('id')); });
                        debug("showAds :: displaying ad " + adDiv.attr('id') + " for the first and only time!");
                        adDiv.data('filled', true);
                    } else {
                        debug("showAds :: nonrefreshing ad " + adDiv.attr('id') + " already displayed..skipping.");
                    }
                }
            });
            flushCmd();
            trigger('post.display.ads');
        });
        return _this;
    }
function showAds ( ) { flushCmd ( ) ; var deferreds = $ . map ( slots , function ( slot , index ) { return slot . deferred ; } ) ; $ . when . apply ( $ , deferreds ) . then ( function ( ) { trigger ( 'pre.display.ads' ) ; $ . each ( slots , function ( index , slot ) { var adDiv = $ ( '#' + slot . div_id ) ; var adSlotData = adDiv . data ( settings . data_store ) ; var refreshable = adDiv . data ( 'refresh' ) || false ; var unfilled = adDiv . data ( 'unfilled' ) || false ; var filled = adDiv . data ( 'filled' ) || false ; var registered = adDiv . data ( 'registered' ) ; if ( dfp_settings . enable_single_request ) { if ( refreshable ) { pushCmd ( function ( ) { googletag . pubads ( ) . refresh ( [ adSlotData ] ) ; } ) ; debug ( "showAds :: refreshing ad " + adDiv . attr ( 'id' ) ) ; } else if ( unfilled ) { pushCmd ( function ( ) { googletag . pubads ( ) . refresh ( [ adSlotData ] ) ; } ) ; debug ( "showAds :: filling unfilled ad " + adDiv . attr ( 'id' ) ) ; adDiv . data ( 'unfilled' , false ) ; } } else { if ( refreshable ) { if ( ! registered ) { pushCmd ( function ( ) { googletag . display ( adDiv . attr ( 'id' ) ) ; debug ( "showAds :: displaying ad " + adDiv . attr ( 'id' ) + " - will REFRESH on next showAds()" ) ; adDiv . data ( 'registered' , true ) ; } ) ; } else { pushCmd ( function ( ) { googletag . pubads ( ) . refresh ( [ adSlotData ] ) ; } ) ; debug ( "showAds :: refreshing ad " + adDiv . attr ( 'id' ) ) ; } } else if ( ! filled ) { pushCmd ( function ( ) { googletag . display ( adDiv . attr ( 'id' ) ) ; } ) ; debug ( "showAds :: displaying ad " + adDiv . attr ( 'id' ) + " for the first and only time!" ) ; adDiv . data ( 'filled' , true ) ; } else { debug ( "showAds :: nonrefreshing ad " + adDiv . attr ( 'id' ) + " already displayed..skipping." ) ; } } } ) ; flushCmd ( ) ; trigger ( 'post.display.ads' ) ; } ) ; return _this ; }
Displays an ad in all defined slots and if refreshable, updates slot with a new ad.
Displays an ad in all defined slots and if refreshable updates slot with a new ad .
// display the refreshable slot // issue refresh call if already registered