')
.addClass(containerId + ' down arrow')
.attr('data-direction', 'down')
.button({
text: false,
icons: {
primary: "ui-icon-carat-1-s"
}
});
headerContainer.append(divUp).append(divDown);
}
else {
var divLeft = $('
')
.addClass(containerId + ' left arrow')
.attr('data-direction', 'left')
.button({
disabled: true,
text: false,
icons: {
primary: "ui-icon-carat-1-w"
}
});
var divRight = $('
')
.addClass(containerId + ' right arrow')
.attr('data-direction', 'right')
.button({
text: false,
icons: {
primary: "ui-icon-carat-1-e"
}
});
headerContainer.append(divLeft).append(divRight);
}
}
// Define inner container width and height based on "direction" parameter
if (params.direction == 'horizontal') {
// Get total width for all the elements
var totalWidth = entryCount * container.find('.feedget-element').outerWidth(true);
elementsContainer.width(totalWidth);
var elementOverflow = container.find('.feedget-element').outerHeight(true) - container.find('.feedget-element').height();
if (params.showHeader) {
var innerContainerHeight = container.innerHeight() - headerContainer.outerHeight(true);
} else {
var innerContainerHeight = container.innerHeight();
}
if (totalWidth < container.width()) {
totalWidth = container.width();
}
var overflowTop = parseInt(elementsContainer.css('padding-top'));
var overflowBottom = parseInt(elementsContainer.css('padding-top'));
bodyContainer.height(parseInt(
innerContainerHeight -
(2 * parseFloat(bodyContainer.css('borderTopWidth')))));
if (elementsContainer.width() > container.width()) {
elementsContainer.height(bodyContainer[0].clientHeight - overflowTop - overflowBottom);
container.find('.feedget-element').height(bodyContainer[0].clientHeight - overflowTop - overflowBottom - elementOverflow);
}
else {
// Too few elements too fill the width of the container, disable navigation buttons
if (params.buttons) {
$('#' + containerId + ' .arrow').button({ disabled: true });
}
elementsContainer.height(innerContainerHeight - overflowTop - overflowBottom);
container.find('.feedget-element').height(innerContainerHeight - overflowTop - overflowBottom - elementOverflow);
}
}
else {
var innerContainerWidth = container.width();
if (!(elementsContainer.height() > container.height())) {
// Too few elements too fill the width of the container, disable navigation buttons
if (params.buttons) {
$('#' + containerId + ' .arrow').css('opacity', '0.2');
$(document).off('click', '#' + containerId + ' .arrow');
}
}
if (params.showHeader) {
bodyContainer.height(parseInt(
container.height() - headerContainer.outerHeight(true) -
(2 * parseFloat(bodyContainer.css('borderTopWidth')))));
} else {
bodyContainer.height(parseInt(
container.height() -
(2 * parseFloat(bodyContainer.css('borderTopWidth')))));
}
}
// Load twitter buttons
if (params.twitter) {
$.getScript('https://platform.twitter.com/widgets.js', function() {
twttr.widgets.load();
});
}
// Buttons click event
$(document).on('click', '#' + containerId + ' .arrow', function(e) {
buttonClick($(this).data('direction'), container, scrollLocked);
});
// Scroll event. We have to update the current element id based on the elements that are visible on the body container
$('#' + containerId + ' .feedget-body-container').scroll(function(e) {
if (!scrollLocked) {
var bc = $(this);
var elContainer = bc.find('.feedget-elements-container');
// Determine which elements are visible on the body container
var els = $('#' + containerId + ' .feedget-element').filter(function (index) {
if (params.direction == 'vertical') {
return $(this).offset().top >= bc.offset().top &&
$(this).offset().top <= bc.offset().top + bc.height();
}
else {
return $(this).offset().left >= bc.offset().left &&
$(this).offset().left <= bc.offset().left + bc.width();
}
});
// Get the first element that is visible in the body container
if (els.length) {
var firstEl = $(els).first();
var currId = firstEl.data('element-id');
$('#' + containerId + ' .feedget-elements-container').attr('data-current-element-id', currId);
}
// Detect if scroll edges were reached
detectScrollEdges(container);
}
});
});
}, "jsonp");
//
// Event Binding
//
/*
$(document).on('mouseenter', '.feedget-element', function(e) {
$(this).siblings().each(function() {
$(this).stop();
$(this).animate({
opacity: 0.2
}, 200, function() {
// Animation complete.
});
});
});
$(document).on('mouseleave', '.feedget-element', function(e) {
$(this).siblings().each(function() {
$(this).stop();
$(this).animate({
opacity: 1
}, 200, function() {
// Animation complete.
});
});
});
*/
return this;
};
})( jQuery );