Skip to content

Instantly share code, notes, and snippets.

@ghorvat
Created August 31, 2015 10:25
Show Gist options
  • Save ghorvat/280702a4877da2123af9 to your computer and use it in GitHub Desktop.
Save ghorvat/280702a4877da2123af9 to your computer and use it in GitHub Desktop.
function myFunction() {
var expTiles = jQuery('.category [class*="col-"]').not('.hidden');
var tmpCount = 0;
var nextIsFirst = false;
var maxInRow;
maxInRow=12;
expTiles.each(function () {
var $this = jQuery(this);
var myColumns;
var elem;
if (nextIsFirst) {
$(this).addClass("first");
nextIsFirst = false;
tmpCount = 0;
}
var numbers = [];
var string = this.className;
var regex = (/col-(xs|sm|md|lg)-(\d+)/g);
while (match = regex.exec(string)) {
numbers.push(match[2]);
}
for(i=0; i<numbers.length; i++){
elem = numbers;
myColumns = numbers[i];
console.log(numbers);
var myColumns2 = parseInt(myColumns);
}
tmpCount +=myColumns2;
//console.log(tmpCount);
if (tmpCount >= maxInRow) {
nextIsFirst = true;
}
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment