1(function($) 2{ 3 "use strict"; 4 5 // ------------------------------------------------------------------------------------------- 6 // Tab Section 7 // ------------------------------------------------------------------------------------------- 8 9 $.fn.avia_sc_tab_section= function() 10 { 11 var win = $(window), 12 browserPrefix = $.avia_utilities.supports('transition'), 13 cssActive = this.browserPrefix !== false ? true : false, 14 isMobile = $.avia_utilities.isMobile, 15 transform3d = document.documentElement.className.indexOf('avia_transform3d') !== -1 ? true : false, 16 transition = {}; 17 18 return this.each(function() 19 { 20 var container = $(this), 21 tabs = container.find('.av-section-tab-title'), 22 tab_outer = container.find('.av-tab-section-outer-container'), 23 tab_wrap = container.find('.av-tab-section-tab-title-container'), 24 tab_nav = container.find('.av_tab_navigation'), 25 content_wrap = container.find('.av-tab-section-inner-container'), 26 single_tabs = container.find('.av-animation-delay-container'), //for elements inside the tab that receive waypoint animation 27 inner_content = container.find('.av-layout-tab-inner'), 28 sliding_active = container.is('.av-tab-slide-transition'), 29 flexible = container.is('.av-tab-content-auto'), 30 current_content = container.find('.__av_init_open'), 31 min_width = 0, 32 change_tab = function(e, prevent_hash) 33 { 34 e.preventDefault(); 35 36 var current_tab = $(e.currentTarget), 37 current_arrow = current_tab.find('.av-tab-arrow-container span'), 38 tab_nr = current_tab.data('av-tab-section-title'); 39 40 current_content = container.find('[data-av-tab-section-content="'+tab_nr+'"]'); 41 42 var new_bg = current_content.data('av-tab-bg-color'), 43 new_font = current_content.data('av-tab-color'), 44 prev_container = container.find('.av-active-tab-content').not('[data-av-tab-section-content="'+tab_nr+'"]'); 45 46 tabs.attr('style','').removeClass('av-active-tab-title'); 47 current_tab.removeClass('no-scroll'); 48 current_tab.addClass('av-active-tab-title'); 49 current_content.addClass("av-active-tab-content"); 50 51 if(new_bg !== "") current_arrow.css('background-color', new_bg); 52 if(new_font !== "") current_tab.css('color', new_font); 53 54 var new_pos = ((parseInt(tab_nr,10) - 1) * -100 ); 55 if ($('body').hasClass('rtl')) { 56 new_pos = ((parseInt(tab_nr,10) - 1) * 100 ); 57 } 58 59 if(cssActive) 60 { 61 //move the slides 62 new_pos = new_pos / tabs.length; 63 transition['transform'] = transform3d ? "translate3d(" + new_pos + "%, 0, 0)" : "translate(" + new_pos + "%,0)"; //3d or 2d transform? 64 transition['left'] = "0%"; 65 content_wrap.css(transition); 66 } 67 else 68 { 69 content_wrap.css('left', new_pos + "%"); 70 } 71 72 set_tab_titlte_pos(); 73 set_slide_height(); 74 75 if(!prevent_hash) location.hash = current_tab.attr('href'); 76 77 setTimeout(function() 78 { 79 current_content.trigger('avia_start_animation_if_current_slide_is_active'); 80 single_tabs.not(current_content).trigger('avia_remove_animation'); 81 82 }, 600); 83 84 }, 85 set_min_width = function() 86 { 87 min_width = 0; 88 tabs.each(function() 89 { 90 min_width += $(this).outerWidth(); 91 }); 92 93 tab_wrap.css('min-width',min_width); 94 }, 95 96 set_slide_height = function() 97 { 98 if(current_content.length && flexible) 99 { 100 var old_height = inner_content.height(); 101 inner_content.height('auto'); 102 103 var height = current_content.find('.av-layout-tab-inner').height(), 104 add_height = tab_wrap.height(); 105 106 tab_outer.css('max-height', height + add_height + 100); 107 inner_content.height(old_height); 108 inner_content.height(height); 109 110 inner_content.css( 'overflow', 'hidden' ); 111 112 setTimeout(function() { win.trigger('av-height-change'); }, 600); 113 } 114 }, 115 116 set_tab_titlte_pos = function() 117 { 118 // scroll the tabs if there is not enough room to display them all - rtl allign right to left !! 119 var current_tab = container.find('.av-active-tab-title'), 120 viewport = container.width(), 121 left_pos = ( current_tab.position().left * - 1) - (current_tab.outerWidth() / 2) + (viewport / 2); 122 123 if( ! $('body').hasClass("rtl") ) 124 { 125 if( viewport >= min_width ) 126 { 127 left_pos = 0; 128 } 129 130 if(left_pos + min_width < viewport) left_pos = (min_width - viewport) * -1; 131 if(left_pos > 0) left_pos = 0; 132 133 tab_wrap.css('left',left_pos ); 134 } 135 else 136 { 137 var right_pos = 0; 138 139 if( viewport < min_width ) 140 { 141 if( left_pos + min_width > viewport ) 142 { 143 if( left_pos > 0 ) left_pos = 0; 144 145 var right_pos = (left_pos + min_width - viewport) * -1; 146 tab_wrap.css('left', 'auto' ); 147 tab_wrap.css('right', right_pos ); 148 } 149 } 150 tab_wrap.css('left', 'auto' ); 151 tab_wrap.css('right', right_pos ); 152 } 153 }, 154 switch_to_next_prev = function(e) 155 { 156 if(!isMobile) return; 157 158 var clicked = $(e.currentTarget), 159 current_tab = container.find('.av-active-tab-title'); 160 161 if(clicked.is('.av_prev_tab_section')) 162 { 163 current_tab.prev('.av-section-tab-title').trigger('click'); 164 } 165 else 166 { 167 current_tab.next('.av-section-tab-title').trigger('click'); 168 } 169 }, 170 171 get_init_open = function() 172 { 173 if(!hash && window.location.hash) var hash = window.location.hash; 174 175 var open = tabs.filter('[href="'+hash+'"]'); 176 177 if(open.length) 178 { 179 if(!open.is('.active_tab')) open.trigger('click'); 180 } 181 else 182 { 183 //set correct color 184 container.find('.av-active-tab-title').trigger('click', true); 185 } 186 }; 187 188 $.avia_utilities.preload({ 189 190 container: current_content ,
191 single_callback: function(){ 192 193 tabs.on('click', change_tab); 194 tab_nav.on('click', switch_to_next_prev); 195 win.on('debouncedresize', set_tab_titlte_pos); 196 197 /** 198 * We had to remove av-height-change because this event is recursivly triggered in set_slide_height and lead to performance problems 199 * AND broken layout - content was not displayed completly 200 * 201 * Content elements that can can change their height and trigger av-height-change should trigger this additional event after to 202 * allow layout elements like tab section to react on this and then call av-height-change by themself 203 * 204 * @since 4.2.3 205 */ 206 win.on('debouncedresize av-content-el-height-changed', set_slide_height); 207 208 set_min_width(); 209 set_slide_height(); 210 get_init_open(); 211 } 212 213 }); 214 215 content_wrap.avia_swipe_trigger({prev:'.av_prev_tab_section', next:'.av_next_tab_section'}); 216 217 }); 218 }; 219 220 221}(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.