'+
'Show More'+
'
';
}
$('#jux_easy_instagram_feed.jux_shortcodeId_'+$id).append(html);
Jux_lightGallery();
if($layout == 'grid'){ Masonry_Grid(); }
if($layout == 'slider'){ Jux_slickSlider(); }
var limit_offset = limit_post;
// On before slide change
$('#lightgallery').on('beforeChange', function(nextSlide){
if(limit > 0){
var offset = limit_offset ;
var limit_social = limit;
}else{
var offset = 100 ;
var limit_social = 100;
}
var Url_NextSlider = JUX_BASE_URL + '&offset='+offset+'&limit_post='+limit_post+'&limit_social='+limit_social;
$.ajax({
type: "GET",
dataType: 'json',
cache:false,
url: Url_NextSlider,
error: function() {
console.log('Error Ajax - Check url bellow');
console.log(Url_NextSlider);
},
success: function(result) {
var html = '';
var result_lists = result.lists_item;
$.each(result_lists, function(i,item){
html += Jux_Item(i+offset, item);
});
limit_offset = offset + $total_show;
var $id = $('#jux_easy_instagram_feed').attr('data-shortcodeID');
var $container = $('#jux_easy_instagram_feed.jux_shortcodeId_'+$id+' .jux-wrapper');
$container.slick('slickAdd',html);
}
});
});
// js xu li show more
$("#jux_easy_instagram_feed.jux_shortcodeId_"+$id+" .ff-loadmore-wrapper a.jux-loadmore" ).click(function() {
// move element loader to div wrapper load more and show loader and hide button load more
$('#jux_easy_instagram_feed.jux_shortcodeId_'+$id+' .ff-loadmore-wrapper').append($("#jux_easy_instagram_feed.jux_shortcodeId_"+$id+" .ff-loader"));
$('#jux_easy_instagram_feed.jux_shortcodeId_'+$id+' > .ff-loadmore-wrapper > .ff-loader').removeClass('ff-squeezed');
$('#jux_easy_instagram_feed.jux_shortcodeId_'+$id+' > .ff-loadmore-wrapper > .ff-btn.jux-loadmore').css('opacity','0');
var offset = limit_offset ;
if(limit > 0){
var limit_social = limit;
}else{
var limit_social = offset + limit_post;
}
var Url_LoadMore = JUX_BASE_URL + '&offset='+offset+'&limit_post='+limit_post+'&limit_social='+limit_social;
$.ajax({
type: "GET",
dataType: 'json',
cache:false,
url: Url_LoadMore,
error: function() {
console.log('Error Ajax - Check url bellow');
console.log(Url_LoadMore);
},
success: function(result) {
// after load data then hide element loader and show button loadmore
$('#jux_easy_instagram_feed.jux_shortcodeId_'+$id+' > .ff-loadmore-wrapper > .ff-loader').addClass('#jux_easy_instagram_feed ff-squeezed');
$('#jux_easy_instagram_feed.jux_shortcodeId_'+$id+' > .ff-loadmore-wrapper > .ff-btn.jux-loadmore').css('opacity','1');
var html = '';
var result_lists = result.lists_item;
var result_filter = result.number_social;
var column1RelArray = [];
var string_attr ='';
$.each(result_lists, function(i,item){
html += Jux_Item(i+offset, item);
});
limit_offset = offset + limit_post;
var total = Object.keys(result_lists).length;
if(total == 0 ){
$('#jux_easy_instagram_feed.jux_shortcodeId_'+$id+' > .ff-loadmore-wrapper > .ff-btn.jux-loadmore').css('opacity','0');
}
var newItems = $(html).appendTo('#jux_easy_instagram_feed.jux_shortcodeId_'+$id+' .jux-wrapper');
jQuery("#jux_easy_instagram_feed.jux_shortcodeId_"+$id+" .jux-wrapper").isotope('insert', newItems );
$container.imagesLoaded().progress( function() {
$container.isotope('layout');
});
Masonry_Grid();
Fix_Height_Image();
Jux_lightGallery();
} // end success ajax load more
}); // end ajax load more
});
Fix_Height_Image();
}
});
}
Load_Ajax_Data();
jQuery(window).resize(function(){
// Load_Ajax_Data();
Fix_Height_Image();
});
function time_ago(time) {
switch (typeof time) {
case 'number':
break;
case 'string':
time = +new Date(time);
break;
case 'object':
if (time.constructor === Date) time = time.getTime();
break;
default:
time = +new Date();
}
var time_formats = [
[60, 'seconds', 1], // 60
[120, '1 minute ago', '1 minute from now'], // 60*2
[3600, 'minutes', 60], // 60*60, 60
[7200, '1 hour ago', '1 hour from now'], // 60*60*2
[86400, 'hours', 3600], // 60*60*24, 60*60
[172800, 'Yesterday', 'Tomorrow'], // 60*60*24*2
[604800, 'days', 86400], // 60*60*24*7, 60*60*24
[1209600, 'Last week', 'Next week'], // 60*60*24*7*4*2
[2419200, 'weeks', 604800], // 60*60*24*7*4, 60*60*24*7
[4838400, 'Last month', 'Next month'], // 60*60*24*7*4*2
[29030400, 'months', 2419200], // 60*60*24*7*4*12, 60*60*24*7*4
[58060800, 'Last year', 'Next year'], // 60*60*24*7*4*12*2
[2903040000, 'years', 29030400], // 60*60*24*7*4*12*100, 60*60*24*7*4*12
[5806080000, 'Last century', 'Next century'], // 60*60*24*7*4*12*100*2
[58060800000, 'centuries', 2903040000] // 60*60*24*7*4*12*100*20, 60*60*24*7*4*12*100
];
var seconds = (+new Date() - time) / 1000,
token = 'ago',
list_choice = 1;
if (seconds == 0) {
return 'Just now'
}
if (seconds < 0) {
seconds = Math.abs(seconds);
token = 'from now';
list_choice = 2;
}
var i = 0,
format;
while (format = time_formats[i++])
if (seconds < format[0]) {
if (typeof format[2] == 'string')
return format[list_choice];
else
return Math.floor(seconds / format[2]) + ' ' + format[1] + ' ' + token;
}
return time;
}
function Jux_Item(i,item) {
var templates = $('#jux_easy_instagram_feed.jux_shortcodeId_'+$id).attr('data-template');
var sourceType = $('#jux_easy_instagram_feed.jux_shortcodeId_'+$id).attr('data-type');
var hashtag = $('#jux_easy_instagram_feed.jux_shortcodeId_'+$id).attr('data-hashtag');
var id_lightbox = (item.id).toString().replace(/[^a-z0-9\s]/gi, '');
html =''+
'
';
return html;
}
function Jux_lightGallery(){
jQuery(document).ready(function($){
// var $id = $('#jux_easy_instagram_feed').attr('data-shortcodeID');
$('#jux_easy_instagram_feed.jux_shortcodeId_'+$id+' .jux-wrapper div.jux-lightbox').nivoLightbox({
effect:'fadeScale', // The effect to use when showing the lightbox
theme: 'default', // The lightbox theme to use
keyboardNav: true, // Enable/Disable keyboard navigation (left/right/escape)
clickOverlayToClose: true, // If false clicking the "close" button will be the only way to close the lightbox
onInit: function(){}, // Callback when lightbox has loaded
beforeShowLightbox: function(){}, // Callback before the lightbox is shown
afterShowLightbox: function(lightbox){}, // Callback after the lightbox is shown
beforeHideLightbox: function(){}, // Callback before the lightbox is hidden
afterHideLightbox: function(){}, // Callback after the lightbox is hidden
onPrev: function(element){}, // Callback when the lightbox gallery goes to previous item
onNext: function(element){}, // Callback when the lightbox gallery goes to next item
errorMessage: 'The requested content cannot be loaded. Please try again later.', // Error message when content can't be loaded
beforeHideLightbox: function(){
$(".nivo-lightbox-content video").remove();
}
});
// fix problem lightbox when click tag a still show lightbox not show url tag a
$('div.jux-lightbox a').click(function(e) {
e.stopPropagation();
});
});
}
function Masonry_Grid(){
jQuery(document).ready(function($){
// var $id = $('#jux_easy_instagram_feed').attr('data-shortcodeID');
// fix height image
var height = $('#jux_easy_instagram_feed.jux_shortcodeId_'+$id+' .jux-wrapper .jux-item .inner-preview').width();
$('#jux_easy_instagram_feed.jux_shortcodeId_'+$id+' .jux-wrapper .jux-item .inner-preview').css('height',height);
$('#jux_easy_instagram_feed.jux_shortcodeId_'+$id+' .jux-wrapper .jux-item .inner-preview').css('width',height);
// is load isotop
// var $id = $('#jux_easy_instagram_feed').attr('data-shortcodeID');
var $container = $('#jux_easy_instagram_feed.jux_shortcodeId_'+$id+' .jux-wrapper');
if ($container.length > 0) {
$container.imagesLoaded(function() {
$container.isotope({
itemSelector: '.jux-item',
layoutMode: 'masonry'
});
setTimeout(function() {
$container.isotope('layout');
}, 500);
});
}
});
}
function Fix_Height_Image(){
// jQuery(document).ready(function($){
// var $id = $('#jux_easy_instagram_feed').attr('data-shortcodeID');
var width = $('#jux_easy_instagram_feed.jux_shortcodeId_'+$id+' .jux-wrapper .jux-item .jux-feed-post').width();
// var width = $('#jux_easy_instagram_feed.jux_shortcodeId_'+$id+' .jux-wrapper .jux-item .jux-meta').width();
$('#jux_easy_instagram_feed.jux_shortcodeId_'+$id+'.template_tile .jux-item').height(width);
$('.template_tile.jux_shortcodeId_'+$id+' .slick-slide > div').height(width);
$('#jux_easy_instagram_feed.jux_shortcodeId_'+$id+' .jux-item div.inner-preview').height(width);
$('#jux_easy_instagram_feed.jux_shortcodeId_'+$id+' .jux-item div.inner-preview').width(width);
$('#jux_easy_instagram_feed.jux_shortcodeId_'+$id+'.template_tile .jux-item div.inner-overlay').height(width);
$('#jux_easy_instagram_feed.jux_shortcodeId_'+$id+'.template_tile .jux-item div.inner-overlay').width(width);
$('#jux_easy_instagram_feed.jux_shortcodeId_'+$id+'.template_tile .jux-item div.jux-meta').height(width);
$('#jux_easy_instagram_feed.jux_shortcodeId_'+$id+'.template_tile .jux-item div.jux-meta').width(width);
$('#jux_easy_instagram_feed.jux_shortcodeId_'+$id+'.template_tile .jux-item div.jux-content').height(width);
$('#jux_easy_instagram_feed.jux_shortcodeId_'+$id+'.template_tile .jux-item div.jux-content').width(width);
// thay doi kich thuoc anh thanh vuong, thay vi de anh kich thuoc tu nhien
$( "div.jux-item" ).each(function( index ) {
var img = new Image();
img.src = $(this).find("img.jux-image").attr('src');
img.onload = function() {
var img_width = this.width;
var img_height = this.height;
var img_src = img.src;
if(img_width > img_height){
$('#jux_easy_instagram_feed.jux_shortcodeId_'+$id+' .jux-item div.inner-preview').find('img[src="'+img_src+'"]').css({'width':'auto','max-width':'none','height':'100%'}).attr('data-width',img_width).attr('data-height',img_height);
}else{
$('#jux_easy_instagram_feed.jux_shortcodeId_'+$id+' .jux-item div.inner-preview').find('img[src="'+img_src+'"]').css({'height':'auto','max-height':'none','width':'100%'}).attr('data-width',img_width).attr('data-height',img_height);
}
}
});
// });
}
function Jux_slickSlider(){
jQuery(document).ready(function($){
// var $id = $('#jux_easy_instagram_feed').attr('data-shortcodeID');
var responsives = '[{"reponsive_window_width":"","reponsive_columns":"","reponsive_rows":"","reponsive_gutter":""}]';
var res_obj = JSON.parse(responsives);
if(responsives !== '' && res_obj[0].reponsive_window_width !== '' ){
var breakpoint1 = res_obj[0].reponsive_window_width;
var breakpoint2 = res_obj[1].reponsive_window_width;
var slidesToShow1 = res_obj[0].reponsive_columns;
var slidesToShow2 = res_obj[1].reponsive_columns;
var rows1 = res_obj[0].reponsive_rows;
var rows2 = res_obj[1].reponsive_rows;
}else{
var breakpoint1 = 992;
var breakpoint2 = 480;
var slidesToShow1 = 3;
var slidesToShow2 = 1;
var rows1 = 2;
var rows2 = 1;
}
var $container = $('#jux_easy_instagram_feed.jux_shortcodeId_'+$id+' .jux-wrapper');
var $autoplay = $('#jux_easy_instagram_feed.jux_shortcodeId_'+$id).attr('data-autoplay') == 'false' ? false : true;
var $arrows = $('#jux_easy_instagram_feed.jux_shortcodeId_'+$id).attr('data-arrow') == 'false' ? false : true;
var $draggable = $('#jux_easy_instagram_feed.jux_shortcodeId_'+$id).attr('data-drag') == 'false' ? false : true;
var $loop = $('#jux_easy_instagram_feed.jux_shortcodeId_'+$id).attr('data-loop') == 'false' ? false : true;
var $autoplaySpeed = $('#jux_easy_instagram_feed.jux_shortcodeId_'+$id).attr('data-autospeed');
var $speed = $('#jux_easy_instagram_feed.jux_shortcodeId_'+$id).attr('data-speed');
var $columns = $('#jux_easy_instagram_feed.jux_shortcodeId_'+$id).attr('data-columns');
var $rows = $('#jux_easy_instagram_feed.jux_shortcodeId_'+$id).attr('data-rows');
var $padding = $('#jux_easy_instagram_feed.jux_shortcodeId_'+$id).attr('data-gutter');
$container.slick({
vertical:false,
dots: false,
slidesToScroll:Number($columns),
arrows:true,
draggable: $draggable,
centerPadding:'0px', // padding
infinite:true, // loop
slidesToShow:Number($columns), // number column
rows:Number($rows), // number row
autoplay:$autoplay,
autoplaySpeed: $autoplaySpeed,
speed: $speed,
responsive: [
{
breakpoint: Number(breakpoint1),
settings: {
slidesToShow:Number(slidesToShow1),
rows: Number(rows1),
}
},
{
breakpoint: Number(breakpoint2),
settings: {
slidesToShow: Number(slidesToShow2),
rows: Number(rows2),
}
}
]
});
Fix_Height_Image();
});
}
});
});
';
if(templates == 'classic'){
html+='
'+
''+
'
';
}
html+='';
if(sourceType !== 'businessHashtag'){
html+='
'+
''+
''+
'
';
}else{
html+=''+
''+item.user_name+''+
'
'+
''+
'
';
}
if(sourceType !== 'businessHashtag'){
html+=''+
''+hashtag+''+
'
'+
''+item.created_time+'
';
}
html+=''+
'
'+
' '+
' '+
'