jQuery(window).load(function() { var Gallery = (function() { var fGallery = createFGalleries(); var pGallery = createPGallery(); var isFlex = (jQuery('body').width() <= 480) ? true : false; function switchGallery(val) { isFlex = val; } function createFGalleries() { var fGalleries = []; jQuery(".flexslider").each(function(index){ fGalleries.push("
"+jQuery(this).html()+"
"); }); return fGalleries; } function createPGallery() { var pGalleries = []; jQuery(".flexslider").each(function(index){ var title = jQuery(this).attr("data-title"); var dShadow = (jQuery(this).attr("data-dShadow") == "true") ? "class='dShadow'" : ""; var that = jQuery(this).children(".slides"); var width = (that.attr("data-width") == 0) ? "" : " width='"+that.attr("data-width")+"'"; var height = (that.attr("data-height") == 0) ? "" : " height='"+that.attr("data-height")+"'"; var galleryImgs = []; var imageTitles = []; var imageDesc = []; var alt; that.children("li").each(function(index, el) { var alt = (jQuery(el).children('img').attr('alt') === undefined) ? "" : jQuery(el).children('img').attr('alt'); galleryImgs.push("'" + jQuery(el).children('img').attr('src') + "'"); imageTitles.push("'" + alt + "'"); imageDesc.push("'"+jQuery(el).children('.flex-caption').text()+"'"); }); var gallery = ""; pGalleries.push(gallery); }); return pGalleries; } return { renderPGallery: function() { switchGallery(true); jQuery(".flexslider").each(function(index){ jQuery(this).replaceWith(pGallery[index]); }); jQuery("a[rel^='prettyPhoto']").prettyPhoto({counter_separator_label:' of ',theme:'light_rounded',overlay_gallery:true}); jQuery(window).bind('resize', function() {handleScreenSize(Gallery);}); }, renderFGallery: function() { switchGallery(false); jQuery(".reflex-gallery").each(function(index){ jQuery(this).replaceWith(fGallery[index]); }); jQuery('.flexslider').flexslider(); }, IsFlex: function() { return isFlex; } } })(); handleScreenSize(Gallery); jQuery(window).bind('resize' ,function() {handleScreenSize(Gallery);}); }); function handleScreenSize(g) { var screenWidth = jQuery('body').width(); if (screenWidth > 480) { if(!g.IsFlex()) { g.renderPGallery(); } } else { if(g.IsFlex()) { g.renderFGallery(); } } } /* playback timings (ms): LoadShardBlock: 123.41 (3) esindex: 0.011 captures_list: 146.13 CDXLines.iter: 11.933 (3) PetaboxLoader3.datanode: 180.076 (4) exclusion.robots: 0.415 exclusion.robots.policy: 0.395 RedisCDXSource: 7.351 PetaboxLoader3.resolve: 180.104 load_resource: 299.054 */