(function( $ ) { var catGallery2 = function(element, options){ var settings = $.extend({}, $.fn.catGallery2.defaults, options); $(element).find('ul li').css('visibility','hidden'); var tabScaleG = tabScale[settings.countImage]; $(window).on('load',function(){ var tabScale =tabScaleG; var tabScaleCount = []; var tabSc = {}; var zmiana = settings.countImage; var maxCellZm = 0; $(element).find('ul li').css('visibility','visible'); for(var i=0;i0){ tabScaleCount.push(tabScale[i]); tabSc[tabScale[i]] = zmiana; } zmiana--; } var maxCell = 0; var countImg = settings.countImage; $(window).on('resize', function(){ var screen_width = screen.width; var maxCell = 1; function isBigEnough(element, index, array) { return element <= screen_width; } filtered = tabScaleCount.filter(isBigEnough); if(typeof filtered[0] != 'undefined'){ maxCell = tabSc[filtered[0]]; } if(maxCell != maxCellZm){ var procIgw = Math.round((100/maxCell) * 10000) / 10000 //var procIgw = Math.floor(100/maxCell); $(element).find('ul li').css('width',procIgw+'%'); maxCellZm = maxCell; } }).trigger('resize'); }); return this; }; $.fn.catGallery2 = function(options) { return this.each(function(key, value){ var element = $(this); if (element.data('c2')) return element.data('c2'); var c2 = new catGallery2(this, options); element.data('c2', c2); }); }; $.fn.catGallery2.defaults = { countImage: 3, widthGallery : 990, widthImg: 100 } })( jQuery );