1( function( $ ) { 2 "use strict"; 3 4 var body = $( 'body' ), 5 _window = $( window ); 6 7 var calculateGrid = function($container) { 8 var windowWidth = _window.width(); 9 var columns = parseInt( $container.data('columns') ); 10 var gutterWidth = $container.data('gutterSpace'); 11 // need to return exact decimal width 12 var containerWidth = Math.floor($container[0].getBoundingClientRect().width); 13 var minColumnWidth = 200; 14 15 if ( isNaN( gutterWidth ) ) { 16 gutterWidth = 20; 17 } 18 else if ( gutterWidth > 50 || gutterWidth < 0 ) { 19 gutterWidth = 20; 20 } 21 22 gutterWidth = parseInt( gutterWidth ); 23 24 var allGutters = gutterWidth * ( columns - 1 ); 25 var contentWidth = containerWidth - allGutters; 26 27 var columnWidth = Math.floor( contentWidth / columns ); 28 29 if ( columnWidth < minColumnWidth ) { 30 columns = Math.floor( contentWidth / minColumnWidth ); 31 32 if ( columns < 1 ) { 33 columns = 1; 34 } 35 36 allGutters = gutterWidth * ( columns - 1 ); 37 contentWidth = containerWidth - allGutters; 38 39 columnWidth = Math.floor( contentWidth / columns ); 40 } 41 42 if ( windowWidth <= 568 ) { 43 columns = 1; 44 45 allGutters = gutterWidth * ( columns - 1 ); 46 contentWidth = containerWidth - allGutters; 47 48 columnWidth = Math.floor( contentWidth / columns ); 49 } 50 51 return {columnWidth: columnWidth, gutterWidth: gutterWidth, columns: columns}; 52 } 53 54 var runMasonry = function( duration, $container, $posts, method) { 55 var o = calculateGrid($container); 56 57 if ( o.columns == 1 ) { 58 if ( $container.hasClass('masonry') ) { 59 $container.masonry('destroy'); 60 } 61 62 $container.removeAttr("style"); 63 $container.children().removeAttr("style"); 64 $container.css('height', 'auto'); 65 66 return; 67 } 68 else if ( 'layout' == method ) { 69 $container.masonry('layout'); 70 71 return; 72 } 73 else { 74 var marginBottom = o.gutterWidth; 75 76 $posts.css({'width':o.columnWidth+'px', 'margin-bottom':o.gutterWidth+'px', 'padding':'0'}); 77 78 $container.masonry( { 79 itemSelector: '.wc-shortcodes-post-box', 80 columnWidth: o.columnWidth, 81 gutter: o.gutterWidth, 82 transitionDuration: duration 83 } ); 84 85 return; 86 } 87 } 88 89 $('.wc-shortcodes-posts').each( function() { 90 var $container = $(this); 91 var $posts = $container.children('.wc-shortcodes-post-box'); 92 93 $posts.css({'visibility':'hidden','position':'relative'}).addClass('wc-shortcodes-loading'); 94 95 $.each( $posts, function( index, value ) { 96 var $post = $(this); 97 var $imgs = $post.find('img'); 98 99 if ( $imgs.length ) { 100 $post.imagesLoaded() 101 .always( function( instance ) { 102 $post.css('visibility', 'visible').removeClass('wc-shortcodes-loading'); 103 runMasonry(0, $container, $posts, 'layout'); 104 }); 105 } 106 else { 107 $post.css('visibility', 'visible').removeClass('wc-shortcodes-loading'); 108 } 109 }); 110 111 runMasonry(0, $container, $posts, 'masonry'); 112 113 $(window).resize(function() { 114 runMasonry(0, $container, $posts, 'masonry'); 115 }); 116 117 // $(window).load(function() { 118 // }); 119 120 if (window.twttr !== undefined) { 121 twttr.ready(function (twttr) { 122 twttr.events.bind('loaded', function (event) { 123 //DO A MASONRY RELAYOUT HERE 124 runMasonry(0, $container, $posts, 'layout'); 125 }); 126 }); 127 } 128 129 $container.find(".wc-shortcodes-post-box .rslides").responsiveSlides({ 130 auto: false, // Boolean: Animate automatically, true or false 131 speed: 500, // Integer: Speed of the transition, in milliseconds 132 timeout: 4000, // Integer: Time between slide transitions, in milliseconds 133 pager: false, // Boolean: Show pager, true or false 134 nav: true, // Boolean: Show navigation, true or false 135 random: false, // Boolean: Randomize the order of the slides, true or false 136 pause: false, // Boolean: Pause on hover, true or false 137 pauseControls: true, // Boolean: Pause when hovering controls, true or false 138 prevText: "", // String: Text for the "previous" button 139 nextText: "", // String: Text for the "next" button 140 maxwidth: "", // Integer: Max-width of the slideshow, in pixels 141 navContainer: "", // Selector: Where controls should be appended to, default is after the 'ul' 142 manualControls: "", // Selector: Declare custom pager navigation 143 namespace: "rslides", // String: Change the default namespace used 144 before: function(){}, // Function: Before callback 145 after: function(){ 146 runMasonry(0, $container, $posts, 'layout'); 147 }// Function: After callback 148 }); 149 }); 150
151 var $filterNav = $('.wc-shortcodes-filtering.wc-shortcodes-filtering-dynamic.wc-shortcodes-filtering-layout-masonry'); 152 var $term = $filterNav.find('.wc-shortcodes-term'); 153 $term.click( function( event ) { 154 event.preventDefault(); 155 156 $term.removeClass('wc-shortcodes-term-active'); 157 $(this).addClass('wc-shortcodes-term-active'); 158 159 var selector = $(this).attr('data-filter'); 160 var target = $filterNav.data('target'); 161 var $target = $(target); 162 $target.animate({opacity: 0}, 300, function() { 163 var $targetPosts = $target.children('.wc-shortcodes-post-box'); 164 if ( '*' == selector ) { 165 $targetPosts.show(); 166 } 167 else { 168 $targetPosts.hide(); 169 $target.find(selector).show(); 170 } 171 172 runMasonry(0, $target, $targetPosts, 'layout'); 173 174 $target.animate({opacity: 1}, 300); 175 }); 176 177 return false; 178 }); 179 180} )( jQuery );
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.