Skip to content

Instantly share code, notes, and snippets.

@digitaldesigndj
Created May 6, 2014 21:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save digitaldesigndj/ac8b65c024f15fca23a4 to your computer and use it in GitHub Desktop.
Save digitaldesigndj/ac8b65c024f15fca23a4 to your computer and use it in GitHub Desktop.
Vype Ad Cycles

Fixed Header Advertisment code

wp-content/themes/vype/javascripts/scripts.js

var top_divs = $("#adspace div").not(".clearfix").hide(),
    top_i = 0;
// var top_num_ads = $('#adspace > div').attr("num_ads");
var top_num_ads = $('#adspace > div').not(".clearfix").length;
var top_cycle_delay = 12000;

function top_cycle() {
    top_divs.eq(top_i).fadeIn(400).delay(top_cycle_delay).fadeOut(400, top_cycle);
    top_i = ++top_i % top_divs.length; // increment i,
    //   and reset to 0 when it equals divs.length
};
if (top_num_ads > 1) {
    top_cycle();
} else {
    top_divs.show();
}

And the sidebar ad cycle code derived from the fixed header code:

var sidebar_divs = $(".adsanity-group div").not(".clearfix").hide(),
    sidebar_i = 0;
var sidebar_num_ads = $('.adsanity-group > div').not(".clearfix").length;
var sidebar_cycle_delay = 12000;
function sidebar_cycle() {
    sidebar_divs.eq(sidebar_i).fadeIn(400).delay(sidebar_cycle_delay).fadeOut(400, sidebar_cycle);
    sidebar_i = ++sidebar_i % sidebar_divs.length; // increment i,
    //   and reset to 0 when it equals divs.length
};
if (sidebar_num_ads > 1) {
    sidebar_cycle();
} else {
    sidebar_divs.show();
}

-Taylor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment