<script type="text/javascript">
var loadedImageCount, imageCount;
$(function(){
// GRID
var $container = $('.grid');
$container.imagesLoaded( function(){
$container.isotope({
itemSelector : '.element-item',
layoutMode: 'fitRows',
horizontal: {
verticalAlignment: 0.5
}
});
});
// filter functions
var filterFns = {
// show if number is greater than 50
numberGreaterThan50: function() {
var number = $(this).find('.number').text();
return parseInt( number, 10 ) > 50;
},
// show if name ends with -ium
ium: function() {
var name = $(this).find('.name').text();
return name.match( /ium$/ );
}
};
// bind filter button click
$('.filters-button-group').on( 'click', 'button', function() {
var filterValue = $( this ).attr('data-filter');
// use filterFn if matches value
filterValue = filterFns[ filterValue ] || filterValue;
$container.isotope({ filter: filterValue });
});
// change is-checked class on buttons
$('.button-group').each( function( i, buttonGroup ) {
var $buttonGroup = $( buttonGroup );
$buttonGroup.on( 'click', 'button', function() {
$buttonGroup.find('.is-checked').removeClass('is-checked');
$( this ).addClass('is-checked');
});
});
var loadedImageCount, imageCount;
$('#add').click( function() {
// add new images
var items = getItems();
$container.prepend( $(items) );
// use ImagesLoaded
$container.imagesLoaded()
.progress( onProgress )
.always( onAlways );
});
});
// ----- ----- //
// return doc fragment with
function getItems() {
var items = '';
for ( var i = 0; i < 6; i++ ) {
items += getImageItem();
}
alert(items);
return items;
}
// return an <li> with a <img> in it
function getImageItem() {
var item = "";
jQuery.ajax
({
url: "pegaPortifolio.php/?id=1", //?id="+idUltimo,
dataType: "json", //Tipo de Retorno
success:
function(data) {
var pt1 = "";
var i = 1;
var ultimo_id = 0;
var size = 0,
var size = 0, key;
key;
for (key in data) {
if (data.hasOwnProperty(key)) size++; //cod para contar o tamanho do array multidimensional
} //size , variavel com o tamamho do array
for (i = 0; i < size; i++) { //monta o html para exibir os dados
pt1 +='<div+= '<div class="element-item '+data[i]' + data[i].menu+'"menu + '" data-category="transition"><div style="padding:2.5px;"><div style="border: 1px solid #AAAAAA;"><a href="#portfolioModal54" class="portfolio-link" data-toggle="modal"><img src="'+data[i]src="' + data[i].imageM+'"imageM + '" alt="project 2"><div class="fundo-port"><h1>"'+data[i]port"><h1>"' + data[i].tipo+'"<tipo + '"</h1><h2>"'+data[i]h1><h2>"' + data[i].nome+'"<nome + '"</h2></div></a></div></div></div>';
}
}
});
//alert(pt1);
item = pt1; //NÂO PEGA A VARIAVEL
alert(pt1);
return item;
}
// triggered after each item is loaded
function onProgress( imgLoad, image ) {
// change class if the image is loaded or broken
var $item = $( image.img ).parent();
$item.removeClass('is-loading');
if ( !image.isLoaded ) {
$item.addClass('is-broken');
}
// update progress element
loadedImageCount++;
}
// hide status when done
function onAlways() {
}
</script>