1/** 2 * @author Chris Baldelomar 3 * @website http://wordpresscanvas.com/ 4 */ 5 6 7( function( $ ) { 8 "use strict"; 9 10 var body = $( 'body' ), 11 _window = $( window ); 12 13 var calculateGrid = function($container) { 14 var windowWidth = _window.width(); 15 var columns = parseInt( $container.data('columns') ); 16 var gutterWidth = $container.data('gutterWidth'); 17 // need to return exact decimal width 18 var containerWidth = Math.floor($container[0].getBoundingClientRect().width); 19 20 if ( isNaN( gutterWidth ) ) { 21 gutterWidth = 5; 22 } 23 else if ( gutterWidth > 30 || gutterWidth < 0 ) { 24 gutterWidth = 5; 25 } 26 27 if ( windowWidth <= 568 ) { 28 columns = 1 29 } 30 31 gutterWidth = parseInt( gutterWidth ); 32 33 var allGutters = gutterWidth * ( columns - 1 ); 34 var contentWidth = containerWidth - allGutters; 35 36 var columnWidth = Math.floor( contentWidth / columns ); 37 38 return {columnWidth: columnWidth, gutterWidth: gutterWidth, columns: columns}; 39 } 40 41 var runMasonry = function( duration, $container, $posts, method ) { 42 var o = calculateGrid($container); 43 44 if ( o.columns == 1 ) { 45 if ( $container.hasClass('masonry') ) { 46 $container.masonry('destroy'); 47 } 48 49 $container.removeAttr("style"); 50 $container.children().removeAttr("style"); 51 $container.css('height', 'auto'); 52 53 return; 54 } 55 else if ( 'layout' == method ) { 56 $container.masonry('layout'); 57 58 return; 59 } 60 else { 61 $posts.css({'width':o.columnWidth+'px', 'margin-bottom':o.gutterWidth+'px', 'padding':'0'}); 62 $container = $container.masonry( { 63 itemSelector: '.gallery-item', 64 columnWidth: o.columnWidth, 65 gutter: o.gutterWidth, 66 transitionDuration: duration 67 } ); 68 69 return; 70 } 71 } 72 73 var initGallery = function() { 74 $('.gallery-masonry').each( function() { 75 var $container = $(this); 76 var $posts = $container.children('.gallery-item'); 77 var attachmentId; 78 79 $posts.css('visibility', 'hidden'); 80 81 // keeps the media elements from calculating for the full width of the post 82 $(document).ready(function(){ 83 // we are going to append masonry items as the images load 84 runMasonry(0, $container, $posts, 'masonry'); 85 86 $container.imagesLoaded() 87 .always( function( instance ) { 88 $posts.css('visibility', 'visible'); 89 }) 90 .progress( function( instance, image ) { 91 attachmentId = image.img.dataset.attachmentId; 92 $container.children('.gallery-item-attachment-' + attachmentId ).css('visibility', 'visible') 93 runMasonry(0, $container, $posts, 'layout'); 94 }); 95 }); 96 97 $(window).resize(function() { 98 runMasonry(0, $container, $posts, 'masonry'); 99 }); 100 101 }); 102 103 /* BEGIN: BoldGrid */ 104 if( jQuery().coverflow ) { 105 $('.gallery-coverflow').each( function() { 106 var $this = $(this); 107 $this.hide(); 108 imagesLoaded( $this, function() { 109 $this.show(); 110 111 if ( $.fn.reflect && $this.data('reflections') === true ) { 112 $this.find('img').reflect(); 113 } 114 115 var $coverflow = $this.coverflow({ 116 index: $this.data('index'), 117 density: 2, 118 innerAngle: 0, 119 duration: $this.data('speed'), 120 'confirm' : function (e) { 121 if ( e.currentTarget ) { 122 $(e.currentTarget).find('a').trigger('click'); 123 } 124 } 125 }); 126 127 $this.find('a').on("click", function (e) { 128 if ( e.originalEvent ) { 129 e.preventDefault(); 130 e.stopPropagation(); 131 } 132 }); 133 }); 134 }); 135 } 136 /* END: BoldGrid */ 137 138 if( jQuery().magnificPopup) { 139 $('.gallery-link-file').each( function() { 140 var $this = $(this); 141 142 if ( $this.hasClass( 'magnificpopup-is-active' ) ) { 143 return; 144 } 145 146 $this.magnificPopup({ 147 delegate: '.gallery-icon a', 148 gallery: { 149 enabled: true 150 }, 151 type:'image', 152 image: { 153 titleSrc: function(item) { 154 var caption = $(item.el).parent().next('.gallery-caption').html(); 155 if ( 'string' == typeof caption && caption.length > 0 ) 156 return caption; 157 158 return ''; 159 } 160 } 161 }); 162 163 $this.addClass( 'magnificpopup-is-active' ); 164 }); 165 } 166 167 if( jQuery().wcflexslider) { 168 $('.wcflexslider-container').each( function() { 169 var $this = $(this); 170 if ( $this.is(':hidden') ) { 171 return; 172 } 173 174 if ( $this.hasClass( 'wcflexslider-is-active' ) ) { 175 return; 176 } 177 178 var $flex = $(this).children('.gallery.wcflexslider'); 179 var columns = parseInt( $flex.data('columns') ); 180 var columnsTablet = columns - 1; 181 var columnsPhone = columns - 2; 182 var gutterWidth = $flex.data('gutterWidth'); 183 var hideControls = $flex.data('hideControls'); 184 var showNav = hideControls ? false : true; 185 var containerWidth = $this.width(); 186
187 /* BEGIN: BoldGrid */ 188 if ( $.fn.reflect && $this.find('.gallery').data('reflections') === true ) { 189 $flex.find('img').reflect(); 190 } 191 /* END: BoldGrid */ 192 193 $this.addClass('wcflexslider-is-active'); 194 195 gutterWidth = parseInt( gutterWidth ); 196 197 imagesLoaded( $flex, function() { 198 if ( $flex.hasClass('wcslider') ) { 199 $flex.wcflexslider({ 200 prevText: "", 201 nextText: "", 202 smoothHeight: true, 203 slideshow: false, 204 directionNav: showNav, 205 animation:"fade" 206 }); 207 } 208 else if ( $flex.hasClass('wcslider2') ) { 209 $flex.wcflexslider({ 210 prevText: "", 211 nextText: "", 212 smoothHeight: true, 213 slideshow: false, 214 directionNav: showNav, 215 animation:"slide" 216 }); 217 } 218 else if ( $flex.hasClass('wcsliderauto') ) { 219 $flex.wcflexslider({ 220 prevText: "", 221 nextText: "", 222 smoothHeight: true, 223 slideshow: true, 224 directionNav: showNav, 225 animation:"slide" 226 }); 227 } 228 /* BEGIN: BoldGrid */ 229 else if ( $flex.hasClass('wcsliderfadeauto') ) { 230 $flex.wcflexslider({ 231 prevText: "", 232 nextText: "", 233 smoothHeight: true, 234 slideshow: true, 235 directionNav: showNav, 236 animation:"fade" 237 }); 238 } 239 /* END: BoldGrid */ 240 else if ( $flex.hasClass('wccarousel') ) { 241 $flex.wcflexslider({ 242 prevText: "", 243 nextText: "", 244 smoothHeight: false, 245 slideshow: false, 246 directionNav: showNav, 247 animation: "slide", 248 animationLoop: false, 249 itemWidth: 270, 250 itemMargin: gutterWidth 251 }); 252 } 253 else if ( $flex.hasClass('wcslider3bottomlinks') || $flex.hasClass('wcslider4bottomlinks') ) { 254 $flex.wcflexslider({ 255 prevText: "", 256 nextText: "", 257 smoothHeight: true, 258 slideshow: true, 259 directionNav: showNav, 260 animation:"slide", 261 init: function() { 262 $this.find('.wc-image-links .gallery-item').each( function() { 263 var $link = $(this); 264 var $a = $link.find('.gallery-icon a'); 265 if ( 0 < $a.length ) { 266 var href = $a.attr('href'); 267 if ( 'string' == typeof( href ) ) { 268 var $caption = $link.find('.gallery-caption'); 269 if ( 0 < $caption.length ) { 270 $caption.wrap('<a href="'+href+'"></a>'); 271 } 272 } 273 } 274 }); 275 } 276 }); 277 } 278 }); 279 }); 280 } 281 if( jQuery().owlCarousel) { 282 $('.wcowlcarousel').each( function() { 283 var $this = $(this); 284 if ( $this.is(':hidden') ) { 285 return; 286 } 287 288 if ( $this.hasClass( 'wcowlcarousel-is-active' ) ) { 289 return; 290 } 291 292 var $owl = $this.children('.owl-carousel'); 293 var columns = parseInt( $owl.data('columns') ); 294 var columnsTablet = columns - 1; 295 var columnsPhone = columns - 2; 296 var gutterWidth = $owl.data('gutterWidth'); 297 var hideControls = $owl.data('hideControls'); 298 var showNav = hideControls ? false : true; 299 var containerWidth = $this.width(); 300 301 $this.addClass('wcowlcarousel-is-active'); 302 303 gutterWidth = parseInt( gutterWidth ); 304 if ( 1 > columnsTablet ) { 305 columnsTablet = 1; 306 } 307 if ( 1 > columnsPhone ) { 308 columnsPhone = 1; 309 } 310 311 if ( $this.hasClass('wcowlautowidth') ) { 312 $owl.owlCarousel({ 313 margin: gutterWidth, 314 loop: true, 315 dots: false, 316 autoWidth: true, 317 responsive: { 318 0:{ 319 nav: false, 320 }, 321 569:{ 322 nav: showNav, 323 } 324 } 325 }); 326 } 327 else if ( $this.hasClass('wcowlcolumns') ) { 328 $owl.owlCarousel({ 329 margin: gutterWidth, 330 loop: true, 331 dots: false, 332 items: columns, 333 responsive: { 334 0:{ 335 nav: false 336 }, 337 569:{ 338 nav: showNav 339 } 340 } 341 }); 342 } 343 else if ( $this.hasClass('wcowlslider') ) { 344 $owl.owlCarousel({ 345 margin: 0, 346 loop: true, 347 dots: false, 348 items: 1, 349 autoHeight:true, 350 responsive: { 351 0:{ 352 nav: false 353 }, 354 569:{ 355 nav: showNav 356 } 357 } 358 }); 359 } 360 }); 361 } 362 }; 363 364 $(document).ready( initGallery ); 365 366 // Triggers re-layout on infinite scroll 367 $( document.body ).on( 'post-load', function () { 368 initGallery(); 369 }); 370 371 // Triggers re-layout on accordion, tabs, toggle 372 $( document.body ).on( 'wcs-toggled', function () { 373 initGallery(); 374 }); 375 376} )( 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.