1/** 2 * Layers Pro JS 3 * 4 * This file contains all theme JS functions. 5 */ 6jQuery(function($){ 7 8 9 /** 10 * Search 11 */ 12 $(document).on( 'click', '.search-close', function(){ 13 14 $('.search-interface-overlay') 15 .removeClass('search-interface-play-in') 16 .addClass('search-interface-play-out'); 17 18 return false; 19 20 }); 21 $(document).on( 'click', '.header-search > a, .menui-item-layers-search > a', function(){ 22 23 var $search_field = $('#layers-modal-search-field'); 24 25 $('.search-interface-overlay') 26 .removeClass('search-interface-play-out') 27 .addClass('search-interface-play-in'); 28 29 setTimeout(function() { 30 $search_field 31 .focus() 32 .layers_pro_set_cursor_postion( $search_field.val().length ); 33 }, 600 ); 34 35 return false; 36 }); 37 38 /** 39 * Allow animation if x-animation is found 40 */ 41 // For all the animations on page animate as soon as the 42 // scrolling reaches 25% above the widget 43 /** 44 * X - Scroll Animations. 45 */ 46 var bodyEl = $('body'); 47 var footerEl = $('#footer'); 48 49 if ( bodyEl.hasClass('layers-animate') ) { 50 var sectionsToAnimate = [ 51 "#wrapper-content > .widget", 52 ".title-container .title", 53 "#post-list .post", 54 ".sidebar", 55 "#wrapper-content :not(\".swiper-container\") .grid > article:not('.layers-masonry-column')" 56 ]; 57 58 // Special header animation 59 60 // Header site to fade in with downward direction 61 $(".header-site").addClass("do-animate delay-200 animated-1s layers-default-fade-in-down"); 62 63 // Header block container to fade in upward direction 64 $(".header-block.container").addClass("do-animate delay-200 animated-1s layers-default-fade-in-up"); 65 66 $(sectionsToAnimate.join(",")).not(".do-animate").addClass("do-animate translucent animated-1s layers-default-fade-in-up"); 67 footerEl.addClass("animated-1s"); 68 69 $('.do-animate').waypoint({ 70 offset : '75%', 71 handler : layersAnimationHandler('layers-default', false) 72 }); 73 footerEl.waypoint({ 74 offset : '90%', 75 handler : layersAnimationHandler('layers-default', false) 76 }); 77 78 // As we are using delay-200 for header and footer lets remove 79 // the class of opacity from body for more smooth animations 80 setTimeout(function(){ 81 bodyEl.removeClass('opacity-0'); 82 }, 200); 83 } 84 85 // For all the animations on page animate as soon as the 86 // scrolling reaches 25% above the widget 87 $('.do-animate').waypoint({ 88 handler: layersAnimationHandler('x', false), 89 offset: '75%' 90 }); 91 92}); 93 94/** 95 * Helper function that initialsizes our Carousel. It expects that there 96 * is a row of our standard Layers post list HTML that it will convert 97 * 98 * @param string widget_id Widgets id selector eg #widget_66 99 * @param object settings Settings object 100 * @return Swiper Swiper object 101 */ 102function layers_pro_init_post_carousel( widget_id, settings ) { 103 104 // Debigging disable. 105 // return; 106 107 // Get the all important row that will will contain our carousel. 108 var carousel_row = jQuery( widget_id ).find( '.post-carousel-row' ); 109 var carousel_row_grid = carousel_row.find('.grid'); 110 111 /** 112 * Prepare a cloned Mimic row that we will grab our sizing from - which allows for responsive resizing. 113 */ 114 115 // Create a holder to hold the cloned elements that we will subsequently mimic in our carousel. 116 var mimic_row = jQuery( '<div class="layers-pro-post-carousel-mimic-row"><div class="grid">' ); 117 var mimic_row_grid = mimic_row.find( '.grid' ); 118 119 jQuery( widget_id ).prepend( mimic_row ); 120 121 // Hide this mimic row until it's needed - it will be shown, DOM measurments taken from it, then hidden again before it's rendered. 122 // mimic_row.hide(); 123 124 // Copy the classes from the row so the CSS (especially responsive) make it behave in the same way. 125 mimic_row.addClass( carousel_row.attr('class') ); 126 127 // Clone one of the article elements that we will mimic (clone many during debugging stage). 128 mimic_row_grid.prepend( jQuery( widget_id ).find( '.grid' ).children(':lt(6)').clone() ); 129 130 // Empty the articles so they don't tax the browsers performance. 131 mimic_row_grid.children().html('').prepend('<div style="background:black"> </div>'); 132 133 /** 134 * Prepare the actual Carousel elemnts. 135 */ 136 137 // Wrap the elemnts in the necessary holders required for Swiper. 138 carousel_row_grid.children().not('.swiper-pagination, .arrows').wrapAll('<div class="swiper-wrapper">'); 139 carousel_row_grid.children().wrapAll('<div class="swiper-container">'); 140 141 // Get the final element that will become our carousel. 142 carousel_element = carousel_row_grid.find('.swiper-container'); 143 144 // Setup the slides/columns. 145 carousel_element.find('.column, .column-flush') 146 // Remove framewrok classes from the column that will disrupt the carousel display. 147 .removeClass('column column-flush span-1 span-2 span-3 span-4 span-5 span-6 span-7 span-8 span-9 span-10 span-11 span-12') 148 // Add the swiper-slide class that Swiper needs. 149 .addClass('swiper-slide'); 150 151 152 /** 153 * Start getting and settings properties. 154 */ 155 156 // Use the mimic row to get measurements from from our CSS. 157 var space_between = layers_pro_post_carousel_calculate_space_between( carousel_row, mimic_row ); 158 var per_row = layers_pro_post_carousel_calculate_per_row( carousel_row, mimic_row ); 159 160 // Set the padding of the wrapper to start. 161 carousel_row.css( { 'padding-left' : layers_pro_post_carousel_calculate_holder_spacing( carousel_row, mimic_row ), 'padding-right' : layers_pro_post_carousel_calculate_holder_spacing( carousel_row, mimic_row ) } ); 162 163 // Merge defaults with the settings passed. 164 settings = jQuery.extend( { 165 mode :'horizontal', 166 calculateHeight : true, 167 wrapperClass : 'swiper-wrapper', 168 slideClass : 'swiper-slide', 169 spaceBetween : space_between, 170 slidesPerView : per_row, 171 loop : true, 172 paginationClickable : true, 173 }, settings ); 174 175 carousel_row.addClass('post-carousel-row-swiper'); 176 177 // Init the Carousel. 178 var post_swiper = carousel_element.swiper( settings ); 179 180 /* 181 post_swiper.enableKeyboardControl(); 182 183 jQuery( widget_id ).find('.arrows a').on( 'click' , function(e){ 184 e.preventDefault(); 185 186 // "Hi Mom" 187 $that = jQuery(this); 188 189 if( $that.hasClass( 'swiper-pagination-switch' ) ){ // Anchors 190 post_swiper.swipeTo( $that.index() ); 191 } else if( $that.hasClass( 'l-left-arrow' ) ){ // Previous 192 post_swiper.swipePrev(); 193 } else if( $that.hasClass( 'l-right-arrow' ) ){ // Next 194 // post_swiper.swipeNext(); 195 } 196 197 return false;
198 }); 199 */ 200 201 // Setup resize event so the carousel is constantly mimicing our mimic row - and auto heighting it's columns. 202 jQuery(window).resize(function(){ 203 layers_pro_post_carousel_resize( post_swiper, carousel_row, mimic_row ); 204 }); 205 layers_pro_post_carousel_resize( post_swiper, carousel_row, mimic_row ); 206 207 // Return the slider incase it is needed further. 208 return post_swiper; 209} 210 211function layers_pro_post_carousel_resize( post_swiper, carousel_row, mimic_row ) { 212 213 // Get. 214 var space_between = layers_pro_post_carousel_calculate_space_between( carousel_row, mimic_row ); 215 var per_row = layers_pro_post_carousel_calculate_per_row( carousel_row, mimic_row ); 216 var holder_padding = layers_pro_post_carousel_calculate_holder_spacing( carousel_row, mimic_row ); 217 218 // Set. 219 carousel_row.css( { 'padding-left' : holder_padding, 'padding-right' : holder_padding } ); 220 post_swiper.params.spaceBetween = space_between; 221 post_swiper.params.slidesPerView = per_row; 222 post_swiper.update(); 223 224 // Also auto height match the rows. 225 layers_pro_post_carousel_match_heights( post_swiper ); 226} 227 228/** 229 * Helper function that looks at our mimic row and culculates 230 * how many columns it is displaying per row - so the Carousel 231 * can mimic our CSS frameworks column behaviour. 232 */ 233function layers_pro_post_carousel_calculate_per_row( carousel_row, mimic_row ){ 234 235 // Cache elements. 236 var column_element = mimic_row.find('.column, .column-flush').eq(0); 237 238 // Flash show the element so it holds size in the DOM 239 mimic_row.show(); 240 241 // Calculate columns per_row. 242 var per_row = parseInt( Math.round( mimic_row.width() / column_element.width() ) ); 243 244 // Hide the element soon as the calculations are done. 245 mimic_row.hide(); 246 247 return per_row; 248} 249 250/** 251 * Helper function, similar to above, looks at our mimic 252 * row and calculates the space-between at any given time. 253 */ 254function layers_pro_post_carousel_calculate_space_between( carousel_row, mimic_row ){ 255 256 // Cache elements. 257 var column_element = mimic_row.find('.column, .column-flush').eq(0); 258 259 // Flash show the element so it holds size in the DOM 260 mimic_row.show(); 261 262 // Calculate the margin-right. 263 var space_between = parseInt( column_element.css('margin-left') ) + parseInt( column_element.css('margin-right') ); 264 265 // Hide the element soon as the calculations are done. 266 mimic_row.hide(); 267 268 return space_between; 269} 270 271/** 272 * Helper function, similar to above, looks at our mimic 273 * row and calculates the holder-spacing at any given time. 274 */ 275function layers_pro_post_carousel_calculate_holder_spacing( carousel_row, mimic_row ){ 276 277 // Cache elements. 278 var column_element = mimic_row.find('.column, .column-flush').eq(0); 279 280 // Flash show the element so it holds size in the DOM 281 mimic_row.show(); 282 283 // Get Values. 284 var holder_padding = 0; 285 holder_padding += parseInt( column_element.css('margin-left') ); // Get columns left-margin. 286 holder_padding += ( parseInt( mimic_row.css('padding-left') ) ) / 2; // Get holder padding. 287 288 // Hide the element soon as the calculations are done. 289 mimic_row.hide(); 290 291 return holder_padding; 292} 293 294/** 295 * Helper function that calculates the highest column 296 * and makes sure all other rows match it's height. 297 */ 298function layers_pro_post_carousel_match_heights( post_swiper, match_height ){ 299 300 // Reset the container and thumbnail-body height, if it has been set on the previous resize iteration. 301 // Transition must be set to 0s so the postions can be measured immediately and not after animations 302 post_swiper.container.css({ height: '' }); 303 post_swiper.container.find('.thumbnail-body').css( 'height', '' ); 304 post_swiper.container.find('.thumbnail-body .button').css( { 'margin-top': '', transition: '0s,0s' } ); 305 306 // Don't do any height matching if there is only one slide showing - this happens on Mobile. 307 if ( post_swiper.params.slidesPerView <= 1 ) return; 308 309 // Find the highest slide, and set the Swiper container to that height. 310 var height = 0; 311 post_swiper.slides.each(function( key, slide ){ 312 var slide_height = jQuery(slide).outerHeight(); 313 if( height < slide_height ) height = slide_height; 314 }); 315 post_swiper.container.css({ height: height+'px' }); 316 317 // Then go through each slide and stretch the thumbnail-body to fill in the empty space. 318 post_swiper.slides.each( function( key, slide ) { 319 320 // Skip auto-heighting of 'Display: Overlay' blocks. 321 if ( jQuery(slide).hasClass('with-overlay') ) return true; 322 323 var thumb_height = 0; 324 var padding_top = 0; 325 var padding_bottom = 0; 326 var slide_height = jQuery(slide).height(); 327 328 if ( jQuery(slide).find( '.thumbnail-media' ).length ) { 329 thumb_height = jQuery(slide).find( '.thumbnail-media' ).outerHeight(); 330 } 331 332 if ( jQuery(slide).find( '.thumbnail-body' ).length ) { 333 padding_top = jQuery(slide).find( '.thumbnail-body' ).css( 'padding-top' ); 334 padding_bottom = jQuery(slide).find( '.thumbnail-body' ).css( 'padding-top' ); 335 336 var $body_height = parseInt(slide_height) - parseInt(thumb_height) - parseInt(padding_top) - parseInt(padding_bottom) 337 338 jQuery(slide).find( '.thumbnail-body' ).height( $body_height ); 339 340 } 341 }); 342 343} 344 345// Set cursor position 346jQuery.fn.layers_pro_set_cursor_postion = function(pos) { 347 this.each(function(index, elem) { 348 if (elem.setSelectionRange) { 349 elem.setSelectionRange(pos, pos); 350 } 351 else if (elem.createTextRange) { 352 var range = elem.createTextRange(); 353 range.collapse(true); 354 range.moveEnd('character', pos); 355 range.moveStart('character', pos); 356 range.select(); 357 } 358 }); 359 return this; 360}; 361 362function layersCheckMobile(){ 363 var isMobile = false; //initiate as false 364 365 if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|ipad|iris|kindle|Android|Silk|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(navigator.userAgent) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|
365sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(navigator.userAgent.substr(0,4))) { 366 isMobile = true; 367 } 368 369 return isMobile; 370} 371 372/** 373 * Animation handler for most of the animation regarding 374 * do-animate 375 */ 376(function($ , $window) { 377 $window.layersAnimationHandler = function (replacementClass, addDefaultAnimation) { 378 // Using closure for more dynamic functions 379 return function () { 380 // Get the element 381 var element = $(this.element); 382 // Split all the class names as array 383 var classList = element.attr("class").split(/\s+/); 384 385 var hasAnimation = false; 386 // The standard procedure is we x-ify the animation class name and remove the x 387 // as soon as the offset limit is reached 388 $.each(classList, function (i, cls) { 389 if (cls.match("^" + replacementClass + "-")) { 390 element.removeClass(cls); 391 element.addClass(cls.replace(replacementClass + '-', '')); 392 hasAnimation = true; 393 } 394 }); 395 396 if (!hasAnimation && addDefaultAnimation) { 397 element.addClass('fade-in-up'); 398 } 399 // Animation only occurs once, so as soon as animation is 400 // done remove the waypoint monitor and do-animate class 401 // from element to prevent multiple event binding 402 element.removeClass('do-animate'); 403 this.destroy(); 404 } 405 }; 406})(jQuery, window);
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.