(function($) {
//create the array of days
var day_names = new Array("SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT");
//The number of days in any given month.
var days_in_month = 0;
//the day of the month the first day lands on. In reference to the index of day_names array.
var starting_day = 0;
//Keep track if div.slides already has been loaded or not.
var loaded = false;
$.fn.button_carousel = function(number_of_days, startingday) {
console.debug("initializing button carousel");
days_in_month = number_of_days;
starting_day = startingday;
//Create initial carousel interface
var container = $('div#carousel');
// i'm registering click handler here
// before the element created
// it should work, as we use event delegation
// and placing it inside the plugins definition itselft
$('div#carousel').on('click', 'a#next', function(event) {
event.preventDefault();
console.debug("next click");
});
container.append('<div id="nav_previous"><a href="#" id="prev"></a></div><div id="slides"><ul></ul></div><div id="nav_next"><a href="#" id="next"></a></div>');
//populate unordered list with input type button elements.
populate_carousel(number_of_days, startingday);
return this;
};
// this should not work unless use document
// instead of 'div#carousel'
// or just place it inside the plugins fn
// to make it work properly
$('div#carousel').on('click', 'a#prev', function(event) {
event.preventDefault();
console.debug("prev click");
});
function populate_carousel(number_of_days, startingday) {
days_in_month = number_of_days;
starting_day = startingday;
var index = starting_day;
//alert("populating");
if (loaded === false) {
//first time loading input elements
var container = $('div#slides...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.