(function( $ ) { var catGallery4 = function(element, options){ var settings = $.extend({}, $.fn.catGallery4.defaults, options); $(element).find('ul li').css('visibility','hidden'); $(window).on('load',function(){ var maxCellZm = 0; var tabScale = settings.tabScale; 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]]; } //console.log(maxCell+'--'+maxCellZm); if(maxCell != maxCellZm){ var liClear = maxCell*2-4+1; $(element).find('ul li').removeClass('clearLi'); $(element).find('ul li').eq(liClear).addClass('clearLi'); var tol = 0.003; var procIgw = Math.round((100/maxCell) * 1000) / 1000 var procIgw = procIgw-tol; $(element).find('ul li').css('width',procIgw+'%'); var li_first = $(element).find('ul li').get(0); var liWFirst = (procIgw*2-tol); //console.log(liWFirst); $(li_first).css('width',liWFirst+'%'); maxCellZm = maxCell; } }).trigger('resize'); }); return this; }; $.fn.catGallery4 = function(options) { return this.each(function(key, value){ var element = $(this); if (element.data('c4')) return element.data('c4'); var c4 = new catGallery4(this, options); element.data('c4', c4); }); }; $.fn.catGallery4.defaults = { countImage: 3, widthGallery : 990, widthImg: 100 } })( jQuery );