Skip to content

Instantly share code, notes, and snippets.

@rigelstpierre
Created March 5, 2014 19:13
Show Gist options
  • Save rigelstpierre/9374372 to your computer and use it in GitHub Desktop.
Save rigelstpierre/9374372 to your computer and use it in GitHub Desktop.
FF.calendarPosts = function() {
FF.el.calendar_post_list_item.click(function (e) {
e.preventDefault();
// set vars on this
var $this = $(this),
item_title = $this.data('title'),
item_permalink = $this.data('permalink'),
item_date = $this.data('date'),
item_featured_img_url = $this.data('featured-img-url'),
item_author_img_url = $this.data('author-img-url'),
item_author = $this.data('author'),
item_author_bio = $this.data('author-bio');
$('#calendar_post_list li').removeClass('active');
$this.addClass('active');
if($this.hasClass('publish')) {
// set vars on post el to append later
var p = FF.el.calendar_post,
post_title = p.find('#data-title'),
post_permalink = p.find('#data-permalink'),
post_date = p.find('#data-date'),
post_featured_img_url = p.find('#data-featured-img-url'),
post_author_img_url = p.find('#data-author-img-url'),
post_author = p.find('#data-author'),
post_author_bio = p.find('#data-author-bio');
post_title.html(item_title);
post_date.html(item_date);
post_featured_img_url.attr('src', item_featured_img_url);
post_author_img_url.attr('src', item_author_img_url);
post_author.html(item_author);
post_author_bio.html(item_author_bio);
post_permalink.attr('href', item_permalink);
$('#calendar_post_list #calendar_post').remove();
$('#calendar_post_list #future_post').remove();
var calendar_post = $('#calendar_post').html();
var calendar_post_container = $('<article id="calendar_post" class="container"</article>');
if ($(window).width() <= 767) {
$this.after(calendar_post_container);
calendar_post_container.append(calendar_post);
}
else {
$this.parent().after(calendar_post_container);
calendar_post_container.append(calendar_post);
}
addthis.update('share', 'url', item_permalink);
addthis.toolbox(".addthis_toolbox");
}
else {
var p = FF.el.future_post,
post_author_img_url = p.find('#data-author-img-url'),
post_author = p.find('#data-author'),
post_author_bio = p.find('#data-author-bio');
post_author_img_url.attr('src', item_author_img_url);
post_author.html(item_author);
post_author_bio.html(item_author_bio);
$('#calendar_post_list #calendar_post').remove();
$('#calendar_post_list #future_post').remove();
var future_post = $('#future_post').html();
var future_post_container = $('<article id="future_post" class="container"</article>');
if ($(window).width() <= 767) {
$this.after(future_post_container);
future_post_container.append(future_post);
}
else {
$this.parent().after(future_post_container);
future_post_container.append(future_post);
};
};
});
$('#calendar_post_list li.publish:last').addClass('active');
$('.active').click();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment