1/*! 2 * RT-Theme 19 WordPress Theme Scripts 3 * Copyright (C) 2014 RT-Themes 4 * http://rtthemes.com 5 * 6 * various scripts file 7 */ 8 9 10(function($){ 11"use strict"; 12 13 14 /* ******************************************************************************* 15 16 GLOBAL VARS 17 18 ***********************************************************************************/ 19 var is_rtl = $("body").hasClass("rtl"); 20 var window_width = $(window).width(); 21 var is_layout1 = $("body").hasClass("layout1"); 22 var is_layout2 = $("body").hasClass("layout2"); 23 var is_layout3 = $("body").hasClass("layout3"); 24 var is_layout4 = $("body").hasClass("layout4"); 25 26 /* ******************************************************************************* 27 28 LOADERS 29 30 ***********************************************************************************/ 31 32 $('html').imagesLoaded( { background: ".has-bg-image, body, .slide-background, .left-side-background, #right_side" }, function() { //all images loaded 33 $(window).trigger("rt_images_loaded"); 34 }); 35 36 $(window).on('rt_images_loaded', function() { //window and all images loaded 37 if( document.readyState === "complete" ){ 38 $(window).trigger("rt_loaded"); 39 }else{ 40 $(window).on('load', function() { 41 $(window).trigger("rt_loaded"); 42 }); 43 } 44 }); 45 46 Pace.on('hide', function(){ //everything loaded including ajax 47 $(window).trigger("rt_pace_done"); 48 }); 49 50 51 /* ******************************************************************************* 52 53 WINDOW WIDTH RESIZE ONLY 54 55 ***********************************************************************************/ 56 $(window).resize(function(){ 57 if($(this).width() != window_width){ 58 window_width = $(this).width(); 59 $(window).trigger("window_width_resize"); 60 } 61 }); 62 63 /* ******************************************************************************* 64 65 CHECK IF THE HIDDEN MOBILE MENU ACTIVE 66 67 ***********************************************************************************/ 68 if( ! $.fn.is_mobile_menu ){ 69 70 $.fn.is_mobile_menu = function() 71 { 72 return $(window).width() < 980; 73 }; 74 } 75 /* ******************************************************************************* 76 77 RT Overlapped first row 78 79 ********************************************************************************** */ 80 81 if ( ! $.fn.rt_overlapped_row ) { 82 $.fn.rt_overlapped_row = function() { 83 84 if( $(this).length == 0 ){ 85 return; 86 } 87 88 if( $(this).hasClass("overlap") ){ 89 $('.sub_page_header > .content_row_wrapper').addClass("underlap"); 90 }else{ 91 $('.sub_page_header > .content_row_wrapper').removeClass("underlap"); 92 } 93 94 }; 95 } 96 97 $('#main_content .content_row:nth-child(2):not(.no-composer)').rt_overlapped_row(); 98 99 /* ******************************************************************************* 100 101 RESPONSIVE HEADINGS 102 103 ********************************************************************************** */ 104 $.fn.rt_font_resize = function() { 105 106 $(this).each(function(){ 107 var $this = $(this), 108 max_font_size = $this.data("maxfont-size"), 109 min_font_size = $this.data("minfont-size"); 110 111 var resize_font_size = function(){ 112 113 var compress = 1; 114 compress = window_width < 1290 ? 0.9 : compress; 115 compress = window_width < 1100 ? 0.8 : compress; 116 compress = window_width < 980 ? 0.7 : compress; 117 compress = window_width < 768 ? 0.6 : compress; 118 compress = window_width < 560 ? 0.5 : compress; 119 compress = window_width < 480 ? 0.4 : compress; 120 compress = window_width < 300 ? 0.35 : compress; 121 122 if(compress == 1){ 123 $this.css('font-size', max_font_size +'px'); 124 return false; 125 } 126 127 $this.css('font-size', Math.max( min_font_size, parseFloat( compress * max_font_size ) ) +'px'); 128 }; 129 130 resize_font_size(); 131 $(window).on('resize.rt_font_resize orientationchange.rt_font_resize', resize_font_size); 132 }); 133 134 }; 135 136 $('[data-maxfont-size]').rt_font_resize(); 137 138 139 140 /* ******************************************************************************* 141 142 CUSTOM BUTTON HOVERS 143 144 ********************************************************************************** */ 145 $.fn.rt_button_hovers = function() { 146 147 var styles = ""; 148 149 $(this).each(function(){ 150 var $this = $(this), 151 unique_class_name = "button-" + Math.floor((Math.random() * 10000) + 1); 152 $this.addClass(unique_class_name); 153 styles += "."+unique_class_name+":hover{"+$this.data("hover-style")+"}"; 154 $this.removeAttr("data-hover-style"); 155 156 }); 157 158 $("<style>"+styles+"</style>").appendTo($("head")); 159 160 }; 161 162 $('[data-hover-style]').rt_button_hovers(); 163 164 165 166 /* ******************************************************************************* 167 168 ON PAGE LOAD 169 170 ***********************************************************************************/ 171 $(window).on("rt_images_loaded",function(){ 172 173 $("body").removeClass("rt-loading"); 174 $("#loader-wrapper").css({"opacity":0}); 175 $(window).trigger("rt-loaded"); 176 177 if ( ! Modernizr.touch && ! window.location.hash) { 178 $(window).scrollTop(0); 179 } 180 }); 181 182 $(window).on("rt_pace_done",function(){ 183 $('.pace').remove(); 184 if( $("body").hasClass("rt-loading") ){ 185 $("body").removeClass("rt-loading"); 186 $("#loader-wrapper").css({"opacity":0}); 187 $(window).trigger("rt-loaded"); 188 } 189 }); 190 191 /* ******************************************************************************* 192 193 ON LEAVE 194 195 ***********************************************************************************/ 196 197 if( ! $.fn.rt_on_leave ){ 198 199 $.fn.rt_on_leave = function() 200 { 201 202 $('a[href^="'+rtframework_params["home_url"]+'"]').on("click", function(e){ 203 204 if( $.fn.is_mobile_menu() ){ 205 return; 206 } 207 208 if ( window.parent.location !== window.location ) {//check if customizer active 209 return; 210 } 211 212 var cur_url = window.location.host + window.location.pathname + window.location.search; 213 var target_url = this.host + this.pathname + this.search; 214 var target_extension = this.pathname.split('.'); 215 var search = this.search; 216 217 if( cur_url == target_url || search.indexOf("replytocom") == 1 ){ 218 return; 219 } 220 221 if( typeof target_extension[1] != "undefined" && typeof target_extension[1] != "php" && typeof target_extension[1] != "html" ){ 222 return; 223 } 224 225 if ( e.ctrlKey || e.shiftKey || e.metaKey || (e.button && e.button == 1) ){ 226 return; 227 } 228 229 230 $("body").removeClass("pace-done"); 231 $("#loader-wrapper").css({"opacity":1}
231); 232 $("body").addClass("rt-loading rt-leaving"); 233 234 if(is_layout1){ 235 $.fn.rt_side_margin(); 236 } 237 238 var href = this.href; 239 window.setTimeout(function() { 240 window.location = href; 241 }, 350); 242 243 return false; 244 245 }); 246 247 }; 248 } 249 250 $(window).on("rt_pace_done",function(){ 251 if( $("#loader-wrapper").length > 0 && rtframework_params["page_leaving"] ){ 252 $.fn.rt_on_leave(); 253 } 254 }); 255 256 /* ******************************************************************************* 257 258 RT ONE PAGE 259 260 ***********************************************************************************/ 261 262 if( ! $.fn.rt_one_page ){ 263 264 $.fn.rt_one_page = function() 265 { 266 267 268 var wp_admin_bar_height = $("#wpadminbar").outerHeight() - 1; 269 270 if( window.location.hash ){ 271 272 var target = $(window.location.hash); 273 274 if( target.length > 0 && $('#navigation a[href*="'+window.location.hash+'"]').length > 0 && ! target.hasClass("vc_tta-panel vc_active") ){ 275 rt_scroll_to( target.offset().top - wp_admin_bar_height, window.location.hash ); 276 } 277 } 278 279 $(this).on("click",function(e){ 280 281 var cur_url = window.location.host + window.location.pathname + window.location.search; 282 var this_url = this.host + this.pathname + this.search; 283 284 if( cur_url == this_url ){ 285 286 e.preventDefault(); 287 288 if( this.hash == "#top" ){ 289 rt_scroll_to( 0, ""); 290 return ; 291 } 292 293 var target = $(this.hash); 294 295 if( target.length == 0 ){ 296 window.location = this.href; 297 return ; 298 } 299 300 if( $("body").hasClass("mobile-menu-active") ){ 301 $(".mobile-menu-button").trigger("click"); 302 } 303 304 var sticky_menu_item = $(".sticky #navigation > li > a"); 305 var sticky_height = 0; 306 307 if( sticky_menu_item.length > 0 ){ 308 sticky_height = sticky_menu_item.height() + 30; 309 } 310 311 var reduce = parseInt(wp_admin_bar_height + sticky_height) || 0; 312 rt_scroll_to( target.offset().top - reduce, this.hash); 313 } 314 }); 315 316 317 $(this).each(function(){ 318 319 var menu_item = $(this), 320 hash = this.hash, 321 section = $(hash); 322 323 menu_item.parent("li").removeClass("current-menu-item current_page_item"); 324 325 section.waypoint(function(direction) { 326 if (direction === 'down') { 327 rt_remove_active_menu_class(); 328 menu_item.parent("li").addClass("current-menu-item current_page_item"); 329 } 330 }, { offset: '50%' }); 331 332 section.waypoint(function(direction) { 333 if (direction === 'up') { 334 rt_remove_active_menu_class(); 335 menu_item.parent("li").addClass("current-menu-item current_page_item"); 336 } 337 }, { 338 offset: function() { 339 return 0; 340 } 341 }); 342 343 section.waypoint(function(direction) { 344 if (direction === 'up') { 345 menu_item.parent("li").removeClass("current-menu-item current_page_item"); 346 } 347 }, { 348 offset: function() { 349 return $.waypoints('viewportHeight'); 350 } 351 }); 352 353 section.waypoint(function(direction) { 354 if (direction === 'down') { 355 menu_item.parent("li").removeClass("current-menu-item current_page_item"); 356 } 357 }, { 358 offset: function() { 359 return -$(this).height(); 360 } 361 }); 362 363 }); 364 365 366 function rt_remove_active_menu_class(){ 367 $("#navigation > li.current-menu-item, #navigation > li.current_page_item").removeClass("current-menu-item current_page_item"); 368 } 369 370 }; 371 } 372 373 374 if ( $.fn.rt_one_page ) { 375 $(window).on("rt_pace_done",function(){ 376 377 $($('#navigation a[href*="#"]:not([href="#"])')).rt_one_page(); 378 }); 379 } 380 381 382 383 /* ******************************************************************************* 384 385 SCROLLTO LINKS 386 387 ***********************************************************************************/ 388 $(".scroll").on("click",function(){ 389 390 if( this.hash == "#top" ){ 391 rt_scroll_to( 0, ""); 392 return ; 393 } 394 395 var wp_admin_bar_height = $("#wpadminbar").outerHeight(); 396 var sticky_menu_item = $(".sticky #navigation > li > a"); 397 var sticky_height = 0; 398 399 if( sticky_menu_item.length > 0 ){ 400 sticky_height = sticky_menu_item.height() + 30; 401 } 402 403 var reduce = wp_admin_bar_height + sticky_height; 404 405 if( $(this.hash).length < 1 ){ 406 return ; 407 } 408 409 rt_scroll_to( $(this.hash).offset().top - reduce, this.hash); 410 }); 411 412 413 /* ******************************************************************************* 414 415 GO TO TOP LINK 416 417 ***********************************************************************************/ 418 419 if( ! $.fn.rt_go_to_top ){ 420 421 $.fn.rt_go_to_top = function() 422 { 423 424 var $this = $(this); 425 $(window).scroll(function(event) { 426 427 var top_distance = 100; 428 var y = $(window).scrollTop(); 429 430 if( y > top_distance ){ 431 $this.addClass("visible"); 432 }else{ 433 $this.removeClass("visible"); 434 } 435 436 }); 437 438 $(this).on("click",function(e){ 439 rt_scroll_to( 0, ""); 440 }); 441 442 }; 443 } 444 445 if ( $.fn.rt_go_to_top ) { 446 $('.go-to-top').rt_go_to_top(); 447 } 448 449 /* ******************************************************************************* 450 451 RT COUNTER 452 453 ***********************************************************************************/ 454 455 if( ! $.fn.rt_counter ){ 456 457 $.fn.rt_counter = function() 458 { 459 460 $(this).each(function(){ 461 var number_holder = $(this).find("> .number"), 462 number = number_holder.text(); 463 464 $(this).waypoint( { 465 triggerOnce: true, 466 offset: "100%", 467 handler: function() { 468 469 $({ 470 Counter: 0 471 }).animate({ 472 Counter: number_holder.text() 473 }, {
474 duration: 1200, 475 step: function () { 476 number_holder.text(Math.ceil(this.Counter)); 477 }, 478 complete: function () { 479 number_holder.text(number); 480 } 481 }); 482 483 } 484 }); 485 }); 486 }; 487 } 488 489 if ( $.fn.rt_counter ) { 490 $(window).on("rt_pace_done",function(){ 491 $('.rt_counter').rt_counter(); 492 }); 493 } 494 495 /* ******************************************************************************* 496 497 RT SCROLL TO 498 499 ***********************************************************************************/ 500 501 function rt_scroll_to( to, hash, timeout ){ 502 503 timeout = timeout || 900; 504 505 $('html, body').stop().animate({ 506 'scrollTop': to 507 }, timeout, 'swing', function() { 508 window.location.hash = hash; 509 $('html,body').scrollTop(to); 510 }); 511 512 } 513 514 515 /* ******************************************************************************* 516 517 FIX FEATURES COLUMN POSITION OF COMPARE TABLES 518 519 ********************************************************************************** */ 520 521 if( ! $.fn.rt_tables ){ 522 523 $.fn.rt_tables = function() 524 { 525 526 var features, 527 table = $(this); 528 529 530 //brings the features column position same with other columns 531 function fix_compare_features( table ){ 532 533 $(table).each(function(i){ 534 535 var start_position_element = $(this).find(".start_position"), 536 features_list = $(this).find(".table_wrap.features ul"), 537 new_offset = start_position_element.offset().top - $(this).offset().top; 538 539 features_list.css("top",new_offset); 540 }); 541 542 } 543 544 545 //copy features to each column for mobile 546 function copy_features( table ){ 547 548 $(table).each(function(){ 549 550 features=[]; 551 //createa features array from the first row 552 $(this).find(".table_wrap.features li").each(function(){ 553 features.push( $(this).html() ); 554 }); 555 556 }); 557 558 $(table).find(".table_wrap").each(function(i){ 559 560 if( $(this).hasClass("features") == "" ){ 561 var i = 0; 562 $(this).find("li").each(function(){ 563 if( features[i] ){ 564 $(this).prepend('<div class="visible-xs-block hidden-sm hidden-md hidden-lg">'+features[i]+'</div>'); 565 } 566 i++; 567 }); 568 } 569 }); 570 } 571 572 //bind to window resize 573 $(window).on("resize",table, function( ){ 574 fix_compare_features( table ); 575 }); 576 577 //start functions 578 fix_compare_features( table ); 579 copy_features( table ); 580 581 }; 582 } 583 584 if ( $.fn.rt_tables ) { 585 $('.pricing_table.compare').rt_tables(); 586 } 587 588 /* ******************************************************************************* 589 590 TOGGLE - ACCORDION 591 592 ********************************************************************************** */ 593 $(".rt-toggle .toggle-content").hide(); 594 $(".rt-toggle .open .toggle-content").show(); 595 596 $(".rt-toggle ol li .toggle-head").on("click",function(){ 597 598 clearTimeout("accordion_timeout"); 599 600 var element = $(this).parent("li"), 601 content = element.find(".toggle-content"); 602 603 if( element.hasClass("open")){ 604 element.removeClass("open"); 605 content.stop().slideUp(300); 606 607 }else{ 608 609 $(this).parents("ol").find("li.open").removeClass("open").find(".toggle-content").stop().slideUp(300); 610 611 element.addClass("open"); 612 content.stop().slideDown(300,function(){ 613 fix_accordion_pos(); 614 }); 615 616 //fixed heights 617 content.find('.fixed_heights').rt_fixed_rows("load"); 618 619 //fixed footers 620 $('[data-footer="fixed_footer"]').rt_fixed_footers(); 621 622 } 623 624 function fix_accordion_pos(){ 625 if( $(window).scrollTop() > element.offset().top ){ 626 var accordion_timeout = setTimeout(function() { 627 var add = $("#wpadminbar").outerHeight() + $(".top-header.stuck").outerHeight(); 628 rt_scroll_to( element.offset().top - add, "", 300); 629 }, 30 ); 630 } 631 } 632 633 }); 634 635 636 /* ******************************************************************************* 637 638 TABS 639 640 ********************************************************************************** */ 641 642 if( ! $.fn.rt_tabs ){ 643 644 $.fn.rt_tabs = function() 645 { 646 647 $(this).each(function () { 648 649 var tabs = $(this), 650 tab_nav = $(this).find("> .tab_nav"), 651 desktop_nav_element = $(this).find("> .tab_nav > li"), 652 mobile_nav_element = $(this).find("> .tab_contents > .tab_content_wrapper > .tab_title"), 653 tab_wrappers = $(this).find("> .tab_contents > .tab_content_wrapper"), 654 tab_style = $(this).attr("data-tab-style"); 655 656 //nav height fix 657 height_fix(1); 658 659 //switcher tabs 660 $(".tab-switcher").on("click",function( e ) { 661 e.preventDefault(); 662 663 close_all(); 664 open_tab( $(this).attr("data-tab-number") ); 665 666 return; 667 }) 668 669 //mobile nav clicks 670 mobile_nav_element.on("click",function() { 671 close_all(); 672 open_tab( $(this).attr("data-tab-number") ); 673 }) 674 675 //desktop nav clicks 676 desktop_nav_element.on("click",function() { 677 close_all(); 678 open_tab( $(this).attr("data-tab-number") ); 679 }) 680 681 //close all tab_style 682 function close_all(){ 683 tab_wrappers.each(function() { 684 $(this).removeClass("active"); 685 }); 686 687 desktop_nav_element.each(function() { 688 $(this).removeClass("active"); 689 }); 690 691 } 692 693 //open a tab 694 function open_tab( tab_number ){ 695 696 var nav_item = tabs.find('[data-tab-number="'+tab_number+'"]'), 697 tab_content_wrapper = tabs.find('[data-tab-content="'+tab_number+'"]'); 698 699 nav_item.addClass("active"); 700 tab_content_wrapper.addClass("active"); 701 height_fix( tab_number ); 702 703 //fixed heights 704 tab_content_wrapper.find('.fixed_heights').rt_fixed_rows("load"); 705 706 707 //fix custom select forms 708 $.fn.rt_customized_selects( tab_content_wrapper ); 709 tab_content_wrapper.find('span.customselect').remove(); 710 tab_content_wrapper.find('select.hasCustomSelect').removeAttr("style"); 711 $.fn.rt_customized_selects( tab_content_wrapper ); 712 713 714 if( $(window).width() < 767 ){ 715 rt_scroll_to( tab_content_wrapper.offset().top, "" ); 716 } 717 } 718 719 //height fix - vertical style 720 function height_fix( tab_number ) { 721 if( tab_style == "tab-style-2" ){ 722 var current_tab_height = tabs.find('[data-tab-content="'+tab_number+'"]').outerHeight(); 723 tab_nav.css({"min-height":current_tab_height+"px"}); 724 } 725 } 726 727 }); 728 729 }; 730 } 731 732 if ( $.fn.rt_tabs ) { 733 $('.rt_tabs').rt_tabs(); 734 } 735 736 /* ******************************************************************************* 737 738 START CAROUSELS 739 740 ********************************************************************************** */ 741 742 $.fn.rt_start_carousels = function( callbacks ) { 743 744 $(this).find(".rt-carousel").each(function(){ 745 746 var autoHeight_, 747 margin = $(this).data("margin") !== "" ? $(this).data("margin") : 15, 748 carousel_holder = $(this), 749 items = parseInt($(this).attr("data-item-width")),//number of items of each slides 750 tablet_items = typeof $(this).data("tablet-item-width") != "undefined" && $(this).data("tablet-item-width") != "" ? parseInt($(this).attr("data-tablet-item-width")) : ( items == 1 ) ? 1 : 2 ,//number of items of each slides 751 mobile_items = typeof $(this).data("mobile-item-width") != "undefined" && $(this).data("mobile-item-width") != "" ? parseInt($(this).attr("data-mobile-item-width")) : 1,//number of items of each slides 752 nav = $(this).attr("data-nav") == "true" ? true : false, 753 dots = $(this).attr("data-dots") == "true" ? true : false, 754 timeout = typeof $(this).attr("data-timeout") != "undefined" ? $(this).data("timeout")
754: 5000, 755 autoplay = $(this).data("autoplay") != "undefined" ? $(this).data("autoplay") : false, 756 loop = $(this).data("loop") != "undefined" ? $(this).data("loop") : false, 757 autowidth = $(this).data("autowidth") != "undefined" ? $(this).data("autowidth") : false, 758 carousel_id = $(this).attr("id"); 759 760 //margin 761 if( items == 1 ){ 762 margin = 0; 763 }else{ 764 margin = margin; 765 } 766 767 //start carousel 768 var carousel = carousel_holder.find(".owl-carousel"); 769 770 if( $(this).find('.item').size() == 1 ){ 771 nav = dots = false; 772 } 773 774 var startover; 775 carousel.on('changed.owl.carousel', function(e) { 776 777 if( ! autoplay ){ 778 return; 779 } 780 781 clearTimeout(startover); 782 783 if (!e.namespace || e.type != 'initialized' && e.property.name != 'position') return; 784 785 var items = $(this).find('.active').size(); 786 787 if( e.item.index == e.item.count - items ){ 788 789 var startover = setTimeout(function() { 790 carousel.trigger('to.owl.carousel', [0, 400, true]); 791 }, timeout ); 792 793 } 794 795 }); 796 797 carousel.owlCarousel({ 798 rtl: is_rtl ? true : false, 799 autoplayTimeout : timeout, 800 autoplay:autoplay, 801 loop:loop, 802 autoplayHoverPause:true, 803 margin:margin, 804 responsiveClass:true, 805 autoWidth:autowidth, 806 autoHeightClass: 'owl-height', 807 navText: ["<span class=\"icon-left-open\"></span>","<span class=\"icon-right-open\"></span>"], 808 navSpeed:700, 809 dotsSpeed:500, 810 responsive:{ 811 0:{ 812 items:mobile_items, 813 nav:nav, 814 dots:dots, 815 autoHeight:1, 816 dotsContainer: "#"+carousel_id+"-dots" 817 }, 818 768:{ 819 items: tablet_items, 820 nav:nav, 821 dots:dots, 822 autoHeight:1, 823 dotsContainer: "#"+carousel_id+"-dots" 824 }, 825 1025:{ 826 items:items, 827 nav:nav, 828 dots:dots, 829 autoHeight:1, 830 dotsContainer: "#"+carousel_id+"-dots", 831 } 832 }, 833 onInitialized: callbacks ? callbacks._onInitialized : isotope_layout, 834 onChanged: callbacks ? callbacks._onChanged : "", 835 onRefreshed: callbacks ? callbacks._onRefreshed : "", 836 onTranslated: isotope_layout, 837 838 }); 839 840 //cosmetic fix for content carousels 841 make_same_height(carousel,items, mobile_items, tablet_items, carousel_holder); 842 $(window).on('resize', function() { 843 setTimeout(function() { 844 reset_carousel_heights(carousel,items, mobile_items, tablet_items, carousel_holder); 845 make_same_height(carousel,items, mobile_items, tablet_items, carousel_holder); 846 }, 500); 847 }); 848 }); 849 850 //reset isotopes after carousel 851 function isotope_layout(){ 852 853 var isotope_gallery = $(".masonry"); 854 855 if( isotope_gallery.length > 0 ){ 856 setTimeout(function() { 857 isotope_gallery.isotope('layout'); 858 }, 100); 859 } 860 } 861 862 //get highest item of the carousel 863 function get_highest_item( carousel ){ 864 var heights = []; 865 carousel.find(".owl-item").each(function(){ 866 heights.push($(this).outerHeight()); 867 }); 868 869 return Math.max.apply(null, heights); 870 } 871 872 //reset carousel item heights 873 function reset_carousel_heights( carousel, items, mobile_items, tablet_items, carousel_holder ){ 874 875 var is_image_carousel = carousel_holder.hasClass("rt-image-carousel"); 876 877 if( mobile_items == 1 && window_width < 768 ){ 878 return false; 879 } 880 881 if( tablet_items == 1 && window_width >= 768 && window_width <= 1025){ 882 return false; 883 } 884 885 if( items == 1 && window_width > 1025 ){ 886 return false; 887 } 888 889 carousel.find(".owl-item > div").each(function(){ 890 $(this).css({"min-height": ""}); 891 }); 892 } 893 894 //make all carousel items in same height 895 function make_same_height( carousel, items, mobile_items, tablet_items, carousel_holder ){ 896 897 var is_image_carousel = carousel_holder.hasClass("rt-image-carousel"); 898 899 if( mobile_items == 1 && window_width < 768 ){ 900 return false; 901 } 902 903 if( tablet_items == 1 && window_width >= 768 && window_width <= 1025){ 904 return false; 905 } 906 907 if( items == 1 && window_width > 1025 ){ 908 return false; 909 } 910 911 var height = get_highest_item( carousel ); 912 913 carousel.find(".owl-item > div").each(function(){ 914 $(this).css({"min-height": height +"px"}); 915 }); 916 917 carousel.trigger('refresh.owl.carousel'); 918 } 919 920 }; 921 922 $(window).on('rt_loaded', function() { 923 $("body").rt_start_carousels(); 924 }); 925 926 /* ******************************************************************************* 927 928 PORTFOLIO ITEMS 929 930 ********************************************************************************** */ 931 932 $.fn.rt_portfolio_items = function() { 933 $(this).each(function(){ 934 var text = $(this).find(".text"), 935 holder_height = $(this).height(), 936 text_height = text.height(), 937 margin = ( text_height < holder_height ) ? ( holder_height - text_height ) / 2 : 0; 938 939 text.css({ 940 "margin-top": margin + "px", 941 "max-height": holder_height + "px" 942 }); 943 }); 944 }; 945 946 $(window).on('rt_loaded resize', function() { 947 $(".type-portfolio.loop > .overlay").rt_portfolio_items(); 948 }); 949 950 951 952 /* ******************************************************************************* 953 954 SEARCH WIDGET 955 956 ********************************************************************************** */ 957 $(".wp-search-form span").on('click', function() { 958 $(this).parents("form:eq(0)").submit(); 959 }); 960 961 /* ******************************************************************************* 962 963 SOCIAL SHARE 964 965 ********************************************************************************** */ 966 967 $(".social_share_holder a").on("click",function( event ) { 968 969 //if email button clicked do nothing 970 if( $(this).hasClass("icon-mail") ){ 971 return ; 972 } 973 974 //for other buttons open a popup window 975 newwindow=window.open($(this).attr("data-url"),'name','height=400,width=400'); 976 977 if (newwindow == null || typeof(newwindow)=='undefined') { 978 alert( rtframework_params["popup_blocker_message"] ); 979 }else{ 980 newwindow.focus(); 981 } 982 983 event.preventDefault(); 984 }); 985 986 /* ******************************************************************************* 987 988 Tooltips 989 990 ********************************************************************************** */ 991 $('[data-toggle="tooltip"]').tooltip(); 992 993 994 /* ******************************************************************************* 995 996 IMG effects 997 998 ********************************************************************************** */ 999 if( ! $.fn.rt_img_effect ){ 1000 1001 $.fn.rt_img_effect = function() 1002 { 1003 $(this).find('.imgeffect').each(function() { 1004 $('<div/>').append($(this).find("img")).appendTo($(this)); 1005 }); 1006 }; 1007 } 1008 1009 $("#container").rt_img_effect(); 1010 1011 1012 /* ******************************************************************************* 1013 1014 TABLET NAVIGATION FIX FOR DEACTIVE STATE 1015 1016 ********************************************************************************** */ 1017 $("#container").on("click",function() { 1018 $( '.header-elements .menu .hover').removeClass("hover"); 1019 return true; 1020 }); 1021 1022 1023 /* ******************************************************************************* 1024 1025 LOAD MORE 1026 1027 ********************************************************************************** */ 1028 1029 $(".load_more").on("click",function(e){ 1030 1031 e.preventDefault(); 1032 1033 var button = $(this), 1034 listid = button.attr("data-listid"), 1035 page_count = parseInt(button.attr("data-page_count")) , 1036 current_page = parseInt(button.attr("data-current_page")) ; 1037 1038 //prevent multiple clicks before loading elements 1039 button.attr("disabled", "disabled"); 1040 1041 //check if there is more posts to display 1042 if( page_count == 1 ){ 1043 return ; 1044 } 1045 1046 //load more button classes 1047 button.children("span").removeClass("icon-angle-double-down").addClass("icon-spin1 animate-spin"); 1048 1049 //start ajax 1050 $.ajax({ 1051 type: 'POST', 1052 url: rtframework_params.ajax_url, 1053 data : { 1054 'action': 'rt_ajax_loader', 1055 'atts': $(this).attr("data-atts"), 1056 'wpml_lang': rtframework_params.wpml_lang, 1057 'page': current_page + 1 1058 }, 1059 success: function(response, textStatus, XMLHttpRequest){ 1060 1061 var response = $(response), elems, wrapper, masonry; 1062 1063 wrapper = $("#"+listid); 1064 1065 if( wrapper.hasClass("masonry") ){ 1066 masonry = true; 1067 } 1068 1069 if( masonry ){
1070 elems = response.find(".isotope-item"); 1071 }else{ 1072 elems = response.find("> div, > article"); 1073 } 1074 1075 1076 // wait the images 1077 imagesLoaded( response ).on('done', function( instance ) { 1078 1079 //append the elements and rebuild the masonry layout 1080 if( masonry ){ 1081 wrapper.isotope().append( elems ).isotope( 'appended', elems ); 1082 }else{ 1083 wrapper.append( elems ); 1084 } 1085 1086 //img effects for new loaded elements 1087 elems.rt_img_effect(); 1088 1089 //media player 1090 elems.rt_mediaelementplayer(); 1091 1092 //append isotope elements 1093 if( masonry ){ 1094 wrapper.isotope('layout'); 1095 } 1096 1097 //lightboxes 1098 elems.rt_lightbox(); 1099 1100 //start carousels 1101 elems.rt_start_carousels( { '_onRefreshed' : function _onRefreshed(){ 1102 if( masonry ){ 1103 wrapper.isotope('layout'); 1104 } 1105 }}); 1106 1107 //portoflio items 1108 elems.find(".type-portfolio.loop > .overlay").rt_portfolio_items(); 1109 1110 //the load more button 1111 button.children("span").removeClass("icon-spin1 animate-spin").addClass("icon-angle-double-down"); 1112 1113 //decrease the page count 1114 button.attr("data-page_count",page_count-1); 1115 1116 //increase the current page count 1117 button.attr("data-current_page", current_page+1 ); 1118 1119 //remove the button if there is no page left 1120 if( page_count -1 <= 1 ){ 1121 button.attr("disabled", "disabled").hide(); 1122 }else{ 1123 button.removeAttr("disabled"); 1124 } 1125 1126 //fix left side 1127 if( $.fn.rt_left_height ){ 1128 $.fn.rt_left_height(); 1129 } 1130 $(window).trigger("scroll"); 1131 }); 1132 1133 }, 1134 error: function( MLHttpRequest, textStatus, errorThrown ){ 1135 console.log(errorThrown); 1136 } 1137 }); 1138 1139 }); 1140 1141 /* ******************************************************************************* 1142 1143 CUSTOM DESIGNED SELECT FORMS 1144 1145 ********************************************************************************** */ 1146 if( ! $.fn.rt_customized_selects ){ 1147 $.fn.rt_customized_selects = function( wrapper ) { 1148 if ( $.isFunction($.fn.customSelect) ) { 1149 1150 var selectors = '.orderby, .variations select:not([multiple]), .widget .menu.dropdown-menu, .gfield:not(.notcustomselect) .ginput_container select:not([multiple]), .wpcf7-form select:not([multiple]):not(.notcustomselect)'; 1151 if( wrapper ){ 1152 wrapper.find(selectors).customSelect( { customClass: "customselect" } ); 1153 }else{ 1154 $(selectors).customSelect( { customClass: "customselect" } ); 1155 } 1156 1157 } 1158 }; 1159 }; 1160 1161 $(window).load(function(){ 1162 $.fn.rt_customized_selects(); 1163 1164 //bind to gravity ajax load 1165 $(document).on('gform_post_render', function(){ 1166 $.fn.rt_customized_selects(); 1167 }); 1168 1169 }); 1170 1171 1172 /* ******************************************************************************* 1173 1174 WC REVIEWS 1175 1176 ********************************************************************************** */ 1177 1178 $(".woocommerce-review-link").on("click",function( event ){ 1179 var review_tab = $("#reviews-title"); 1180 review_tab.trigger("click"); 1181 }); 1182 1183 1184 /* ******************************************************************************* 1185 1186 FORM VALIDATION 1187 1188 ********************************************************************************** */ 1189 1190 $.fn.rt_contact_form = function() { 1191 1192 $(this).each(function(){ 1193 1194 var the_form = $(this); 1195 1196 the_form.find(".submit").on("click",function( event ){ 1197 1198 //vars 1199 var loading = the_form.find(".loading"), 1200 error = false; 1201 1202 //check required fields 1203 the_form.find(".required").each(function(){ 1204 1205 var type = $(this).prop("type") || $(this).prop("tagName").toLowerCase(); 1206 var val = $(this).val(); 1207 1208 if( ! val ){ 1209 $(this).addClass("error"); 1210 error = true; 1211 }else if( type == "checkbox" && ! $(this).prop("checked") ){ 1212 $(this).addClass("error"); 1213 error = true; 1214 }else{ 1215 $(this).removeClass("error"); 1216 } 1217 }); 1218 1219 //there is an error 1220 if(error){ 1221 return ; 1222 } 1223 1224 //show loading icon 1225 loading.show(); 1226 1227 //searialize the form 1228 var serialize_form = $(the_form).serialize(); 1229 1230 //ajax form data 1231 var data = serialize_form +'&action=rt_ajax_contact_form'; 1232 1233 //post 1234 $.post(rtframework_params.ajax_url, data, function(response) { 1235 var response = $(response); 1236 response.prependTo(the_form); 1237 loading.hide(); 1238 }); 1239 1240 //close warnings
1241 the_form.find(".info_box").remove(); 1242 1243 }); 1244 }); 1245 }; 1246 1247 $('.validate_form').rt_contact_form(); 1248 1249 1250 /* ******************************************************************************* 1251 1252 INFO BOX CLOSE 1253 1254 ********************************************************************************** */ 1255 $(document.body).on("click",".info_box .icon-cancel",function() { 1256 $(this).parent(".info_box").fadeOut(); 1257 }); 1258 1259 /* ******************************************************************************* 1260 1261 LIGHTBOX PLUGIN 1262 1263 ***********************************************************************************/ 1264 1265 $.fn.rt_lightbox = function() { 1266 if ($.fn.lightGallery){ 1267 1268 var carousel_atts= { 1269 selector: 'a.lightbox_', 1270 hash: false, 1271 downloadUrl: false, 1272 loop: false, 1273 thumbnail: false, 1274 index: 0, 1275 getCaptionFromTitleOrAlt: false 1276 1277 }; 1278 1279 $(this).find(".rt-image-carousel,.photo_gallery,.post-carousel").lightGallery(carousel_atts); 1280 1281 1282 var carousel_atts= { 1283 selector: 'this', 1284 hash: false, 1285 downloadUrl: false, 1286 loop: false, 1287 thumbnail: false, 1288 index: 0, 1289 getCaptionFromTitleOrAlt: false 1290 1291 }; 1292 1293 $(this).find(".lightbox_").lightGallery(carousel_atts); 1294 1295 } 1296 1297 }; 1298 1299 $(document).rt_lightbox("init"); 1300 1301 1302 /* ******************************************************************************* 1303 1304 RT GOOGLE MAPS 1305 1306 ********************************************************************************** */ 1307 $.fn.rtInitMaps = function(){ 1308 1309 var maps = $('.rt-google-maps'); 1310 if( maps.length == 0 ) return; 1311 1312 maps.each(function(){ 1313 1314 var map_id = $(this).attr("id"); 1315 var locations = $(this).attr("data-locations") ? JSON.parse('['+atob($(this).attr("data-locations"))+']') : ''; 1316 var zoom = $(this).attr("data-zoom") || 10; 1317 1318 //holder height 1319 var height = $('[data-scope="#'+map_id+'"]').attr("data-height"); 1320 1321 if ( height > 0 ){ 1322 $(this).css({'height':height+"px"}); 1323 } 1324 1325 var map = new google.maps.Map( document.getElementById(map_id), { 1326 zoom: parseInt(zoom), 1327 panControl: true, 1328 zoomControl: true, 1329 scaleControl: true, 1330 streetViewControl: false, 1331 overviewMapControl: false, 1332 scrollwheel : false, 1333 navigationControl: true, 1334 center: new google.maps.LatLng(0, 0), 1335 mapTypeId: google.maps.MapTypeId.ROADMAP, 1336 mapId: map_id 1337 }); 1338 1339 //B&W Map 1340 var bwmap = $('[data-scope="#'+map_id+'"]').attr("data-bw"); 1341 1342 if ( typeof bwmap !== "undefined" && bwmap != "" ){ 1343 // Create an array of styles. 1344 var styles = [ 1345 { 1346 stylers: [ 1347 { hue: "#fff" }, 1348 { saturation: -100 }, 1349 { lightness: 0 }, 1350 { gamma: 1 } 1351 ] 1352 } 1353 ]; 1354 // Create a new StyledMapType object, passing it the array of styles, 1355 // as well as the name to be displayed on the map type control. 1356 var styledMap = new google.maps.StyledMapType(styles, {name: "Styled Map"}); 1357 1358 //Associate the styled map with the MapTypeId and set it to display. 1359 map.mapTypes.set('map_style', styledMap); 1360 map.setMapTypeId('map_style'); 1361 } 1362 1363 $.fn.setMarkers(map, locations); 1364 1365 $.fn.fixTabs(map,map_id,zoom); 1366 $.fn.fixAccordions(map,map_id,zoom); 1367 }); 1368 }; 1369 1370 $.fn.setMarkers = function (map, locations) { 1371 if(locations.length>1){ 1372 var bounds = new google.maps.LatLngBounds(); 1373 }else{ 1374 var center = new google.maps.LatLng(locations[0][1], locations[0][2]); 1375 map.panTo(center); 1376 } 1377 1378 for (var i = 0; i < locations.length; i++) { 1379 if (locations[i] instanceof Array) { 1380 var location = locations[i]; 1381 var newLatLng = new google.maps.LatLng(location[1], location[2]); 1382 var marker = new google.maps.marker.AdvancedMarkerElement({ 1383 position: newLatLng, 1384 map: map, 1385 title: location[0] 1386 }); 1387 1388 $.fn.add_new_event(map,marker,location[4]); 1389 if(locations.length>1) bounds.extend(newLatLng); 1390 } 1391 } 1392 1393 if(locations.length>1) map.fitBounds(bounds); 1394 }; 1395 1396 $.fn.add_new_event = function (map,marker,content) { 1397 1398 if(content){ 1399 var infowindow = new google.maps.InfoWindow({ 1400 content: content, 1401 maxWidth: 300 1402 }); 1403 google.maps.event.addListener(marker, 'click', function() {; 1404 infowindow.open(map,marker); 1405 }); 1406 } 1407 }; 1408 1409 $.fn.fixTabs = function (map,map_id,zoom) { 1410 var tabs = $("#"+map_id).parents(".rt_tabs:eq(0)"), 1411 desktop_nav_element = tabs.find("> .tab_nav > li"), 1412 mobile_nav_element = tabs.find("> .tab_contents > .tab_content_wrapper > .tab_title"); 1413 1414 desktop_nav_element.on("click", { map: map } , function() { 1415 var c = map.getCenter(); 1416 google.maps.event.trigger(map, 'resize'); 1417 map.setZoom(zoom); 1418 map.setCenter(c); 1419 }); 1420 1421 mobile_nav_element.on("click", { map: map } , function() { 1422 var c = map.getCenter(); 1423 google.maps.event.trigger(map, 'resize'); 1424 map.setZoom(zoom); 1425 map.setCenter(c); 1426 }); 1427 1428 }; 1429 1430 $.fn.fixAccordions = function (map,map_id,zoom) { 1431 var panes = $("#"+map_id).parents(".rt-toggle:eq(0) > ol > li"); 1432 1433 panes.on("click", { map: map } , function() { 1434 var c = map.getCenter(); 1435 google.maps.event.trigger(map, 'resize'); 1436 map.setZoom(zoom); 1437 map.setCenter(c); 1438 }); 1439 1440 }; 1441 1442 /* ******************************************************************************* 1443 1444 SLIDER PARALLAX EFFECT 1445 1446 ********************************************************************************** */ 1447 1448 $.fn.rt_slider_position = function() 1449 { 1450 var slider = $('#main_content > .content_row:first-child .main-carousel[data-parallax="true"]'); 1451 1452 if( slider.length == 0 || Modernizr.touch ){ 1453 return ; 1454 } 1455 1456 var parallax_effect = ! Modernizr.touch ? true : false, 1457 wp_admin_bar_height = $("#wpadminbar").outerHeight(), 1458 offsetTop = slider.offset().top, 1459 sliderHeight = slider.outerHeight(), 1460 gap = offsetTop - wp_admin_bar_height, 1461 carousel = slider.find(".owl-stage-outer"), 1462 $window = $(window); 1463 1464 1465 //parallax effect 1466 $(window).on("scroll", function( event ){ 1467 1468 var scrollTop = $window.scrollTop() - gap ; 1469 1470 1471 if( sliderHeight < scrollTop ){ 1472 return ; 1473 } 1474 1475 var y = Math.max( 0, scrollTop ), 1476 cy = 0.4*y; 1477 1478 1479 carousel.css({ 1480 "-webkit-transform": "translateY("+cy+"px)", 1481 "-moz-transform": "translateY("+cy+"px)", 1482 "-ms-transform": "translateY("+cy+"px)", 1483 "-o-transform": "translateY("+cy+"px)", 1484 "transform": "translateY("+cy+"px)" 1485 }); 1486 1487 1488 }); 1489 } 1490 1491 $(window).on('rt_loaded resize', function() { 1492 $.fn.rt_slider_position(); 1493 }); 1494 1495 /* ******************************************************************************* 1496 1497 MEDIA PLAYER 1498 1499 ********************************************************************************** */ 1500 1501 $.fn.rt_mediaelementplayer = function() { 1502 var media_holders = $(this).find(".rt-hosted-media video, .rt-hosted-media audio"); 1503 media_holders.mediaelementplayer(); 1504 }; 1505 1506 $(document).rt_mediaelementplayer(); 1507 1508 1509 /* ******************************************************************************* 1510 1511 PARALLAX BACKGROUNDS 1512 1513 ********************************************************************************** */ 1514 1515 if( ! $.fn.rt_parallax_backgrounds ){ 1516 1517 $.fn.rt_parallax_backgrounds = function(options) 1518 { 1519 if( Modernizr.touch ){ 1520 return ; 1521 } 1522 1523 $(this).each(function(){ 1524 1525 var row = $(this).parents("div:eq(0)"), 1526 row_height = row.outerHeight() , 1527 row_width = row.outerWidth() , 1528 row_inheight = row.height(), 1529 parallax_speed = $(this).data("rt-parallax-speed") != undefined ? $(this).data("rt-parallax-speed") : 6, 1530 row_paddings = row_height - row_inheight, 1531 speed = ( row_height / $(window).height() ) + 1, 1532 holder_height = row_height * speed/(1+(6-parallax_speed)/10), 1533 holder_width = row_width * speed/(1+(6-parallax_speed)/10), 1534 effect = $(this).attr("data-rt-parallax-effect"), // vertical, horizontal 1535 direction = $(this).attr("data-rt-parallax-direction"); // -1 down/right , 1 up/left 1536 1537 if( effect == "horizontal" ){ 1538 $(this).css({ "height":row_height+4+"px", "width":holder_width+"px" }); 1539 }else{ 1540 $(this).css({ "height":holder_height+"px", "width":row_width+4+"px" }); 1541 } 1542 1543 1544 if( effect == "horizontal" ){ 1545 $(this).rt_horizontal_parallax_effect({ row: row, row_width: row_width, holder_width: holder_width, direction: direction }); 1546 }else{ 1547 $(this).rt_vertical_parallax_effect({ row: row, row_height: row_height, holder_height: holder_height, direction: direction }); 1548 } 1549 1550 }); 1551 } 1552 1553 $.fn.rt_horizontal_parallax_effect = function( options ) 1554 { 1555 var $this = $(this), 1556 $window = $(window), 1557 invisible_part = options["holder_width"] - options["row_width"], 1558 posTop = options["row"].offset().top, 1559 start_position = options["direction"] == -1 ? -1 * invisible_part : 0; 1560 1561 //start position of the parallax layer 1562 $this.rt_parallax_apply_css(start_position, 0 ); 1563 1564 //scroll function 1565 $(window).scroll(function(event) { 1566 1567 if( ( posTop - $window.height() ) > $window.scrollTop() ){ 1568 return ; 1569 } 1570 1571 var move_rate = ( $window.scrollTop() * invisible_part ) / ( posTop + options["row_width"] ); 1572 var xPos = options["direction"] == 1 ? -1 * move_rate : -1 * invisible_part + move_rate ; 1573 1574 if( xPos < -1 * invisible_part ) xPos = -1 * invisible_part; //max left position 1575 if( xPos > 0 ) xPos = 0; //max right position 1576 1577 $this.rt_parallax_apply_css(xPos, 0); 1578 1579 }); 1580 } 1581 1582 1583 $.fn.rt_vertical_parallax_effect = function( options ) 1584 { 1585 var $this = $(this), 1586 $window = $(window), 1587 invisible_part = options["holder_height"] - options["row_height"], 1588 posTop = options["row"].offset().top, 1589 start_position = options["direction"] == -1 ? -1 * invisible_part : 0; 1590 1591 //start position of the parallax layer 1592 $this.rt_parallax_apply_css(0, start_position ); 1593 1594 //scroll function 1595 $(window).scroll(function(event) { 1596 1597 if( (posTop - $window.height() ) > $window.scrollTop() ){ 1598 return ; 1599 } 1600 1601 var move_rate = ( $window.scrollTop() * invisible_part ) / ( posTop + options["row_height"] ); 1602 var yPos = options["direction"] == 1 ? -1 * move_rate : -1 * invisible_part + move_rate ; 1603 1604 if( yPos < -1 * invisible_part ) yPos = -1 * invisible_part; //max bottom position 1605 if( yPos > 0 ) yPos = 0; //max top position 1606 1607 $this.rt_parallax_apply_css(0, yPos); 1608 1609 //sub page headers 1610 if( $this.parent(".content_row").hasClass("sub_page_header") ){ 1611 if( is_layout1 || is_layout2){ 1612 $this.next(".content_row_wrapper").find(".page-title").rt_parallax_apply_css( 0, $window.scrollTop() / 6 ); 1613 } 1614 } 1615 1616 }); 1617 } 1618 1619 1620 $.fn.rt_parallax_apply_css = function( x, y ) 1621 { 1622 1623 var is_rtl = $("body").hasClass("rtl"); 1624 1625 //if it is rtl language make it reverse 1626 x = is_rtl ? -1 * x : x; 1627 1628 $(this).css({ 1629 "-webkit-transform": "translate("+x+"px, "+y+"px)", 1630 "-moz-transform": "translate("+x+"px, "+y+"px)", 1631 "-ms-transform": "translate("+x+"px, "+y+"px)", 1632 "-o-transform": "translate("+x+"px, "+y+"px)", 1633 "transform": "translate("+x+"px, "+y+"px)" 1634 }); 1635 1636 } 1637 } 1638 1639 1640 if ( $.fn.rt_parallax_backgrounds ) { 1641 //start first to get rid of white images 1642 $(window).on('rt_loaded resize', function() { 1643 $('.rt-parallax-background').rt_parallax_backgrounds(); 1644 }); 1645 } 1646 1647 1648 /* ******************************************************************************* 1649 1650 RT Fixed Rows 1651 1652 ********************************************************************************** */ 1653 1654 $.fn.rt_fixed_rows = function( action ) { 1655 1656 function fix_heights(row) { 1657 row.each(function(){ 1658 1659 var this_row_height = $(this).height(); 1660 1661 if( Modernizr.csstransforms3d ){ 1662 $(this).find(" > .wpb_column, > .col").css({'min-height': this_row_height }); 1663 }else{//ie9 or before 1664 if(!$(this).hasClass("align-contents")){ 1665 $(this).find(" > .wpb_column, > .col").css({'height': this_row_height }); 1666 } 1667 } 1668 1669 }); 1670 } 1671 1672 function reset_heights(row) { 1673 row.each(function(){ 1674 1675 var this_row_height = $(this).height(); 1676 if( Modernizr.csstransforms3d ){
1677 $(this).find(" .wpb_column, .col").css({'min-height': "auto" }); 1678 }else{//ie9 or before 1679 $(this).find(" .wpb_column, .col").css({'height': "auto" }); 1680 } 1681 1682 }); 1683 1684 row.rt_fixed_rows("load"); 1685 } 1686 1687 if( action == "reset"){ 1688 $(this).each(function(){ 1689 if( $(this).children(".content_row_wrapper").length > 0 ){ 1690 reset_heights( $(this).children(".content_row_wrapper") ); 1691 } 1692 1693 if( $(this).find(".content_row").length > 0 ){ 1694 reset_heights( $(this).find(".content_row") ); 1695 } 1696 1697 if( $(this).find(".row").length > 0 ){ 1698 reset_heights( $(this).find(".row") ); 1699 } 1700 1701 reset_heights( $(this) ); 1702 }); 1703 } 1704 1705 if( $(window).width() < 767 ){ 1706 return false; 1707 } 1708 1709 if( action == "load"){ 1710 $(this).each(function(){ 1711 if( $(this).children(".content_row_wrapper").length > 0 ){ 1712 fix_heights( $(this).children(".content_row_wrapper") ); 1713 } 1714 1715 if( $(this).find(".content_row").length > 0 ){ 1716 fix_heights( $(this).find(".content_row") ); 1717 } 1718 1719 if( $(this).find(".row").length > 0 ){ 1720 fix_heights( $(this).find(".row") ); 1721 } 1722 1723 fix_heights( $(this) ); 1724 }); 1725 } 1726 1727 }; 1728 1729 //run the script 1730 $(window).on('rt_pace_done', function() { 1731 $('.fixed_heights').rt_fixed_rows("load"); 1732 }); 1733 1734 $(window).on('resize', function() { 1735 setTimeout(function() { 1736 $('.fixed_heights').rt_fixed_rows("reset"); 1737 }, 700); 1738 }); 1739 1740 1741 1742 /* ******************************************************************************* 1743 1744 MASONRY LAYOUTS 1745 1746 ********************************************************************************** */ 1747 1748 $.fn.rt_run_masonry_isotope = function(options) { 1749 1750 $(this).each(function(){ 1751 var $container = $(this); 1752 1753 1754 var $filter_navigation = $('[data-list-id="'+$(this).attr("id")+'"]'), 1755 isotope = function () { 1756 $container.isotope({ 1757 resizable: true, 1758 itemSelector: '.isotope-item', 1759 layoutMode:'packery', 1760 percentPosition: true, 1761 }); 1762 }; 1763 isotope(); 1764 1765 //draw the lines 1766 var w = $container.width(), 1767 columnNum = $container.attr("data-column-width"); 1768 1769 $container.rt_vertical_lines({ 1770 "w": w, 1771 "columnNum" : columnNum 1772 }); 1773 1774 //filter nativation 1775 $filter_navigation.rt_filter_nav( $container ); 1776 }); 1777 1778 }; 1779 1780 $.fn.rt_run_grid_isotope = function(options) { 1781 var $container = $(this), 1782 $filter_navigation = $(".filter-holder"), 1783 isotope = function () { 1784 $container.isotope({ 1785 resizable: false, 1786 itemSelector: '.col', 1787 layoutMode:'packery' 1788 }); 1789 }; 1790 isotope(); 1791 1792 //filter nativation 1793 $filter_navigation.rt_filter_nav( $container ); 1794 1795 }; 1796 1797 //a function for drawing vertical lines to masonry layouts 1798 $.fn.rt_vertical_lines = function(options) { 1799 1800 var options = $.extend({ 1801 w: 980, 1802 columnNum: 3, 1803 }, options); 1804 1805 1806 if( $(this).find(".col:not(.col-sm-"+ 12/options["columnNum"] +")").length > 0 ){ 1807 $(this).addClass("remove_borders"); 1808 return; 1809 } 1810 1811 //clear newlines first for winresize 1812 $(this).find(".vertical_line").remove(); 1813 1814 //create new 1815 var new_line = $('<div class="vertical_line"></div>'); 1816 1817 for (var i = 1; i < options["columnNum"]; i++) { 1818 new_line.clone().css({"left": ( options["w"] / options["columnNum"] ) * i + "px"}).prependTo( $(this) ); 1819 }; 1820 1821 }; 1822 1823 //a function for filter navigation classes on click 1824 $.fn.rt_filter_nav = function( $container ) { 1825 1826 var $optionLinks = $(this).find('a'); 1827 1828 $optionLinks.on("click",function(){ 1829 var $this = $(this), 1830 selector = $(this).attr('data-filter'); 1831 1832 //filter items 1833 $container.isotope({ filter: selector }); 1834 1835 // add active class to the navigation item 1836 if ( $this.hasClass('active') ) { 1837 // don't proceed if the current item already selected 1838 return false; 1839 } 1840 1841 var $optionSet = $this.parents('.filter_navigation'); 1842 $optionSet.find('.active').removeClass('active'); 1843 $this.addClass('active'); 1844 1845 return false; 1846 }); 1847 1848 }; 1849 1850 1851 //start isotopes 1852 $(window).on('rt_images_loaded resize', function() { 1853 $('.masonry').rt_run_masonry_isotope(); 1854 $('.border_grid.filterable').rt_run_grid_isotope(); 1855 }); 1856 1857 1858 /* ******************************************************************************* 1859 1860 FIX IE FIXED BACKGROUND BUG 1861 1862 ********************************************************************************** */ 1863 if(navigator.userAgent.match(/Trident\/7\./)) { // if IE 1864 1865 $('body').on("mousewheel", function () { 1866 // remove default behavior 1867 event.preventDefault(); 1868 1869 //scroll without smoothing 1870 var wheelDelta = event.wheelDelta; 1871 var currentScrollPosition = window.pageYOffset; 1872 window.scrollTo(0, currentScrollPosition - wheelDelta); 1873 }); 1874 } 1875 1876 1877 1878 /* ******************************************************************************* 1879 1880 NO FLEXBOX 1881 flexbox fix for browsers like ie9 1882 1883 ********************************************************************************** */ 1884 1885 $.fn.rt_no_flexbox_column_support = function( row ) 1886 { 1887 1888 //there are many bugs so we consider no flexbox support for IE11 also 1889 var isIE11 = !!navigator.userAgent.match(/Trident.*rv\:11\./); 1890 if( isIE11 ){ 1891 $(html).addClass("ie11-flexbox"); 1892 } 1893 1894 var column_alignments = $('.no-flexboxlegacy .content_row.full-height-row, .ie11-flexbox .content_row.full-height-row'); 1895 1896 //columns 1897 var $this = row; 1898 var row_height = $this.innerHeight(); 1899 var item = $this.find(".content_row_wrapper:eq(0)");
1900 var item_height = item.innerHeight(); 1901 1902 if( $this.hasClass("row-content-bottom") ){ 1903 item.css({"margin-top":row_height-item_height+"px"}); 1904 }else if( $this.hasClass("row-content-middle") ){ 1905 item.css({"margin-top":(row_height-item_height)/2+"px"}); 1906 } 1907 1908 } 1909 1910 $.fn.rt_no_flexbox_content_support = function() 1911 { 1912 1913 var isIE9 = !!navigator.userAgent.match(/MSIE 9/); 1914 if( isIE9 ){ 1915 return; 1916 } 1917 1918 var content_alignments = $('.no-flexbox .content_row_wrapper.align-contents'); 1919 1920 //contents 1921 content_alignments.each(function(){ 1922 1923 var $this = $(this); 1924 var row_height = window.getComputedStyle( $this[0] , null) ; 1925 row_height = parseInt(row_height.getPropertyValue("height")); 1926 1927 var columns = $this.find("> .wpb_column"); 1928 1929 columns.each(function(){ 1930 var $thiscol = $(this); 1931 var item_height = $thiscol.outerHeight(); 1932 1933 if( $this.hasClass("content-align-bottom") ){ 1934 $thiscol.css({"margin-top":row_height-item_height+"px"}); 1935 }else if( $this.hasClass("content-align-middle") ){ 1936 $thiscol.css({"margin-top":(row_height-item_height)/2+"px"}); 1937 } 1938 1939 }); 1940 1941 }); 1942 1943 } 1944 1945 $(window).on('rt_images_loaded resize', function() { 1946 var s = setTimeout(function() { 1947 $.fn.rt_no_flexbox_content_support(); 1948 }, 20 ); 1949 }); 1950 1951 1952 /* ******************************************************************************* 1953 1954 RT Full Scrween Rows 1955 1956 ********************************************************************************** */ 1957 1958 $.fn.rt_full_screen_rows = function() { 1959 1960 $(this).each(function(){ 1961 var $this = $(this), 1962 window_height = $(window).height(), 1963 wp_admin_bar_height = $("#wpadminbar").outerHeight(), 1964 offset = $this.offset().top; 1965 1966 if( offset < window_height ){ 1967 $this.css({"min-height": window_height - offset +"px" }); 1968 }else{ 1969 $this.css({"min-height": window_height +"px" }); 1970 } 1971 1972 $.fn.rt_no_flexbox_column_support( $this ); 1973 }); 1974 1975 }; 1976 1977 $('.full-height-row').rt_full_screen_rows(); 1978 $(window).on('window_width_resize', function() { 1979 $('.full-height-row').rt_full_screen_rows(); 1980 }); 1981 1982 1983 /* ******************************************************************************* 1984 1985 ANIMATE COLUMNS 1986 1987 ********************************************************************************** */ 1988 $.fn.rt_col_animations = function() 1989 { 1990 $(this).each(function(){ 1991 1992 var $this = $(this); 1993 rt_animate_col($this); 1994 1995 $(window).on("scroll", function( event ){ 1996 1997 if( $this.hasClass("animated") ){ 1998 return; 1999 } 2000 2001 rt_animate_col($this); 2002 }); 2003 2004 }); 2005 2006 function rt_animate_col(wrapper){ 2007 var timer = 0.1; 2008 if(wrapper.offset().top + 50 < $(window).scrollTop() + $(window).outerHeight()) { 2009 wrapper.find(".wpb_column").each(function(){ 2010 timer = timer+0.15; 2011 $(this).css({ 2012 opacity:1, 2013 transition: 'opacity 0.4s ease-in '+timer+'s' 2014 }); 2015 }); 2016 wrapper.addClass("animated"); 2017 } 2018 } 2019 2020 } 2021 2022 $(".animate-cols > .content_row_wrapper").rt_col_animations(); 2023 2024 2025 2026 2027 /* ******************************************************************************* 2028 2029 REVSLIDER PAUSE / RESUME 2030 2031 ***********************************************************************************/ 2032 2033 if( ! $.fn.rt_rev_control ){ 2034 2035 $.fn.rt_rev_control = function(action) 2036 { 2037 $(".rev_slider_wrapper").each(function(){ 2038 var $this = $(this); 2039 var id_array = $this.attr("id").split("_"); 2040 var id = id_array[2]; 2041 2042 if(action == "pause"){ 2043 $.globalEval( 'revapi'+id+'.revpause();' ); 2044 }else{ 2045 $.globalEval( 'revapi'+id+'.revresume();' ); 2046 $.globalEval( 'revapi'+id+'.revredraw();' ); 2047 } 2048 2049 }); 2050 }; 2051 } 2052 2053 /* ******************************************************************************* 2054 2055 CATEGORY TREE 2056 2057 ***********************************************************************************/ 2058 if( ! $.fn.rt_category_tree ){ 2059 2060 $.fn.rt_category_tree = function() 2061 { 2062 var category = $(this); 2063 category.find('.cat-item:has(.children)').addClass('has-children'); 2064 $('<span></span>').prependTo(category.find('.cat-item:has(.children)')); 2065 2066 category.find('.cat-item:has(.children) > span').on("click", function(){ 2067 2068 var parent = $(this).parent(); 2069 2070 if( parent.hasClass("current-cat") || parent.hasClass("current-cat-ancestor") ){ 2071 parent.removeClass("current-cat current-cat-ancestor"); 2072 parent.addClass("active"); 2073 } 2074 2075 parent.toggleClass("active"); 2076 }); 2077 2078 }; 2079 } 2080 2081 $(".rt-category-tree").rt_category_tree(); 2082 /* ******************************************************************************* 2083 2084 MOBILE MENU 2085 2086 ***********************************************************************************/ 2087 function rt_toggle_mobile_menu(menu_button){ 2088 menu_button.toggleClass("icon-menu icon-menu-outline"); 2089 $("body").toggleClass("mobile-menu-active"); 2090 2091 if( $("body").hasClass("mobile-menu-active") ){ 2092 $.fn.rt_passive_close(); 2093 }else{ 2094 $("#main_content").off('touchstart click'); 2095 } 2096 } 2097 2098 //on menu button click 2099 $(".mobile-menu-button").on("click",function() { 2100 rt_toggle_mobile_menu($(this)); 2101 return false;
2102 }); 2103 2104 //click outside of mobile menu 2105 $.fn.rt_passive_close = function(){ 2106 $("#main_content").on('touchstart click', function(e) { 2107 if( $("body").hasClass("mobile-menu-active") ){ 2108 rt_toggle_mobile_menu($(".mobile-menu-button")); 2109 return false; 2110 } 2111 }); 2112 }; 2113 2114 $(window).on('window_width_resize load', function() { 2115 2116 if($.fn.is_mobile_menu()){ 2117 $("body").addClass("mobile-menu"); 2118 }else{ 2119 $("body").removeClass("mobile-menu"); 2120 $("body").removeClass("mobile-menu-active"); 2121 } 2122 2123 if( Modernizr.touch && is_layout1 ){ 2124 $("body").addClass("mobile-menu"); 2125 return false; 2126 } 2127 2128 }); 2129 2130 2131 2132 /* ******************************************************************************* 2133 2134 MOBILE DROP DOWN MENU 2135 2136 ********************************************************************************** */ 2137 2138 if( ! $.fn.rt_mobile_drop_down ){ 2139 2140 $.fn.rt_mobile_drop_down = function() 2141 { 2142 2143 $(this).on("click",function(e){ 2144 2145 if( ! $("body").hasClass("mobile-menu") ){ 2146 return ; 2147 } 2148 2149 var $this = $(this); 2150 2151 if( ! is_rtl ){ 2152 2153 if( ! $this.hasClass("menu-item-has-children") || e.pageX - $this.position().left < 225){ 2154 return ; 2155 } 2156 2157 }else{ 2158 2159 if( ! $this.hasClass("menu-item-has-children") || $(window).width() - e.pageX < 240 ){ 2160 return ; 2161 } 2162 } 2163 2164 2165 e.preventDefault(); 2166 2167 $this.toggleClass("current-menu-item"); 2168 2169 return false; 2170 2171 }); 2172 2173 }; 2174 } 2175 2176 $(window).on('load', function() { 2177 $('#navigation li').rt_mobile_drop_down(); 2178 }); 2179 2180 /* ******************************************************************************* 2181 2182 STICKY HEADER 2183 2184 ********************************************************************************** */ 2185 2186 if( ! $.fn.rt_sticky_header ){ 2187 2188 $.fn.rt_sticky_header = function() 2189 { 2190 2191 if( $(this).length == 0 ){ 2192 return; 2193 } 2194 2195 var header = $(this); 2196 var site_logo = $(".site-logo, .site-logo img"); 2197 var site_name = $(".site-logo .sitename > a"); 2198 var main_content = $("#container"); 2199 2200 if( Modernizr.touch || $.fn.is_mobile_menu() ){ 2201 header.removeClass( "stuck" ); 2202 main_content.removeAttr("style"); 2203 site_logo.removeAttr("style"); 2204 return; 2205 } 2206 2207 var header_right = $(".header-right"); 2208 var navigation_bar_height = header.outerHeight(); 2209 var header_top_position = header.position().top; 2210 var wp_admin_bar_height = $("#wpadminbar").length ? $("#wpadminbar").outerHeight() :Â 0; 2211 var top_distance = ( header.position().top - wp_admin_bar_height ) + navigation_bar_height ; 2212 2213 if( header.length > 0 ){ 2214 2215 //scroll function 2216 $(window).scroll(function(event) { 2217 2218 if( $.fn.is_mobile_menu() ){ 2219 return; 2220 } 2221 2222 var y = $(window).scrollTop(); 2223 2224 if( y > top_distance ){ 2225 header.addClass( "stuck" ); 2226 main_content.css({"padding-top":top_distance +"px"}); 2227 site_logo.css({"max-height":header_right.height()+"px"}); 2228 site_name.css({"line-height":header_right.height()+"px",padding:"0"}); 2229 }else{ 2230 header.removeClass( "stuck" ); 2231 main_content.removeAttr("style"); 2232 site_logo.removeAttr("style"); 2233 site_name.removeAttr("style"); 2234 } 2235 }); 2236 } 2237 2238 }; 2239 2240 } 2241 2242 $(window).on('window_width_resize load', function() { 2243 $(".sticky.top-header").rt_sticky_header(); 2244 }); 2245 2246 /* ******************************************************************************* 2247 2248 HORIZONTAL HEADER ELEMENTS 2249 2250 ***********************************************************************************/ 2251 $(window).on('window_width_resize load', function() { 2252 2253 if( $.fn.is_mobile_menu() ){ 2254 var nav_height = $(".header-right").outerHeight(); 2255 $(".header-elements").css({"min-height":nav_height+"px"}); 2256 }else{ 2257 $(".header-elements").css({"min-height":"auto"}); 2258 } 2259 }); 2260 2261 /* ******************************************************************************* 2262 2263 DROP DOWN MENU 2264 2265 ********************************************************************************** */ 2266 2267 if( ! $.fn.rt_drop_down ){ 2268 2269 $.fn.rt_drop_down = function() 2270 { 2271 2272 if( $.fn.is_mobile_menu() ){ 2273 return ; 2274 } 2275 2276 var $this = $(this); 2277 2278 $this.each(function(){ 2279 2280 var menu_items_with_sub = $(this).find(".menu-item-has-children"), 2281 max_depth = 0; 2282 2283 menu_items_with_sub.each(function(){ 2284 max_depth = Math.max( max_depth, $(this).data("depth") ); 2285 }); 2286 2287 if( ! is_rtl ){ 2288 2289 if( window_width < $(this).offset().left + ( ( max_depth + 1 ) * 240 ) ){ 2290 $(this).addClass("o-direction"); 2291 } 2292 2293 }else{ 2294 2295 if( 0 > ( $(this).offset().left - ( ( max_depth + 1 ) * 240 ) ) ){ 2296 $(this).addClass("o-direction"); 2297 } 2298 } 2299 }); 2300 2301 }; 2302 } 2303 2304 $("#navigation > li:not(.multicolumn).menu-item-has-children").rt_drop_down(); 2305 2306 2307 /* ******************************************************************************* 2308 2309 TABLET DROP-DOWN TOUCH FIX 2310 2311 ********************************************************************************** */ 2312 2313 $.fn.rt_menu_touch_fix = function() 2314 { 2315 2316 $(this).on("touchstart",function(e){ 2317 2318 if( $("body").hasClass("mobile-menu") ){ 2319 return ; 2320 } 2321 2322 e.preventDefault(); 2323 2324 var this_li = $(this).parent("li"); 2325 var this_link = $(this).attr("href"); 2326 2327 if( this_li.hasClass("hover") ){ 2328 window.location = this.href; 2329 return true; 2330 } 2331 2332 var hovered = $(this).parents("ul:eq(0)").find("> li.hover"); 2333 2334 if( ! hovered.is( $( this ) ) ){ 2335 hovered.removeClass("hover"); 2336 } 2337 2338 this_li.addClass("hover"); 2339 2340 return false;
2341 2342 }) 2343 2344 }; 2345 2346 if( Modernizr.touch ){//check touch support 2347 $( '.header-elements .menu li:has(ul) > a').rt_menu_touch_fix(); 2348 } /* ******************************************************************************* 2349 2350 FIXED FOOOTERS 2351 2352 ********************************************************************************** */ 2353 2354 if( ! $.fn.rt_fixed_footers ){ 2355 2356 $.fn.rt_fixed_footers = function() 2357 { 2358 2359 var footer = $(this), 2360 header = $(".top-header"), 2361 main_content = $("#main_content"), 2362 sub_page_header = $(".sub_page_header"), 2363 wp_admin_bar = $("#wpadminbar") || 0, 2364 footer_height = footer.outerHeight(true), 2365 header_top = header.length ? header.position().top : 0; 2366 2367 if ( Modernizr.touch ) { 2368 footer.removeClass( "fixed_footer" ); 2369 return ; 2370 } 2371 2372 if( 2373 $(window).height() - ( header.outerHeight() + header_top + wp_admin_bar.outerHeight() + sub_page_header.outerHeight() ) < footer_height 2374 || main_content.height() - 160 < footer_height 2375 || $("body").outerHeight() - $(window).height() < footer_height 2376 ){ 2377 footer.removeClass( "fixed_footer" ); 2378 main_content.css( { "margin-bottom" : "0px" }); 2379 }else{ 2380 footer.addClass( "fixed_footer" ); 2381 main_content.css( { "margin-bottom" : footer_height +"px" }); 2382 } 2383 }; 2384 } 2385 2386 if ( $.fn.rt_fixed_footers ) { 2387 2388 $(window).on('rt_pace_done resize', function() { 2389 $('[data-footer="fixed_footer"]').rt_fixed_footers(); 2390 }); 2391 } 2392 2393 /* ******************************************************************************* 2394 2395 TOOLS MENU 2396 2397 ********************************************************************************** */ 2398 2399 $("#tools > ul:first-child > li > span").on("click",function(e){ 2400 2401 if( ! $(this).hasClass("active") ){ 2402 $(this).addClass("active"); 2403 $("#tools > ul:last-child").addClass("active"); 2404 }else{ 2405 $(this).removeClass("active"); 2406 $("#tools > ul:last-child").removeClass("active"); 2407 } 2408 2409 }); 2410 2411 /* ******************************************************************************* 2412 2413 WOOCOMMERCE FLYING ADDED TO CART ITEM 2414 2415 ********************************************************************************** */ 2416 2417 $.fn.rt_disableScroll = function() { 2418 $('body').on('mousewheel.rt touchmove.rt', function(e) { 2419 e.preventDefault(); 2420 }); 2421 }; 2422 2423 $.fn.rt_enableScroll = function() { 2424 $('body').off('mousewheel.rt touchmove.rt'); 2425 }; 2426 2427 2428 if ( ! $.fn.rt_flying_cart ) { 2429 2430 $.fn.rt_flying_cart = function() 2431 { 2432 2433 if( typeof wc_cart_fragments_params == 'undefined' ){ 2434 return ; 2435 } 2436 2437 if( $(".product_holder.woocommerce").length == 0 || $("#tools").length == 0 ){ 2438 return ; 2439 } 2440 2441 var unfreeze = ""; 2442 2443 $( '.add_to_cart_button' ).on( 'click', function() { 2444 $("body").rt_disableScroll(); 2445 unfreeze = setTimeout(function(){ $("body").rt_enableScroll(); }, 5000); 2446 }); 2447 2448 2449 //bind to added_to_cart 2450 $( document.body ).on( 'added_to_cart', function( event, fragments, cart_hash, $button ) { 2451 2452 $button = typeof $button === 'undefined' ? false : $button; 2453 2454 if( ! $button ){ 2455 return; 2456 } 2457 2458 var y = $button.offset().top, 2459 x = $button.offset().left, 2460 number = $("#tools .cart .number"); 2461 2462 if( number.length == 0 ){ 2463 return; 2464 } 2465 2466 var ty = number.offset().top, 2467 tx = number.offset().left; 2468 2469 var img_src = $button.parents(".product_item_holder").find(".featured_image img").attr("src"), 2470 img_holder = $('<div></div>'); 2471 2472 img_holder.css({ 2473 "background-image" : "url("+img_src+")", 2474 "background-size" : "cover", 2475 "background-repeat" : "no-repeat", 2476 "background-position" : "center center", 2477 "border-radius" : "50%", 2478 "width" : "0px", 2479 "height" : "0px", 2480 "position" : "absolute", 2481 "z-index" : 9999999 2482 }); 2483 2484 img_holder.prependTo("body"); 2485 2486 img_holder.css({ 2487 "opacity": 0, 2488 "top": y+"px", 2489 "left": x+"px", 2490 }).animate({ 2491 "opacity": 1, 2492 "width": "150px", 2493 "height": "150px" 2494 },500).animate({ 2495 "top": +ty+"px", 2496 "left": +tx+"px", 2497 "padding": "0", 2498 "width": "18px", 2499 "height": "18px" 2500 },700).animate({ 2501 "opacity": 0 2502 },400,function(){ 2503 img_holder.remove(); 2504 2505 2506 $("body").rt_enableScroll(); 2507 clearTimeout(unfreeze); 2508 2509 }); 2510 }); 2511 2512 } 2513 } 2514 2515 $.fn.rt_flying_cart(); 2516 2517 2518 2519})(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.