1// ------------------------------------------------------------------------------------------- 2// Tab Shortcode 3// ------------------------------------------------------------------------------------------- 4 5(function($) 6{ 7 "use strict"; 8 9 $.fn.avia_sc_tabs= function(options) 10 { 11 var defaults = 12 { 13 heading: '.tab', 14 content:'.tab_content', 15 active:'active_tab', 16 sidebar: false 17 }; 18 19 var win = $(window), 20 options = $.extend(defaults, options); 21 22 return this.each(function() 23 { 24 var container = $(this), 25 tab_titles = $('<div class="tab_titles"></div>').prependTo(container), 26 tabs = $(options.heading, container), 27 content = $(options.content, container), 28 newtabs = false, 29 oldtabs = false; 30 31 newtabs = tabs.clone(); 32 oldtabs = tabs.addClass('fullsize-tab').attr('aria-hidden', true ); 33 tabs = newtabs; 34 35 tabs.prependTo(tab_titles).each(function(i) 36 { 37 var tab = $(this), 38 the_oldtab = false; 39 40 if(newtabs) the_oldtab = oldtabs.filter(':eq('+i+')'); 41 42 tab.addClass('tab_counter_'+i).on('click', function() 43 { 44 open_content(tab, i, the_oldtab); 45 return false; 46 }); 47 48 tab.on('keydown', function(objEvent) 49 { 50 if (objEvent.keyCode === 13) // if user presses 'enter' 51 { 52 tab.trigger('click'); 53 } 54 }); 55 56 if(newtabs) 57 { 58 the_oldtab.on('click', function() 59 { 60 open_content(the_oldtab, i, tab); 61 return false; 62 }); 63 64 the_oldtab.on('keydown', function(objEvent) 65 { 66 if (objEvent.keyCode === 13) // if user presses 'enter' 67 { 68 the_oldtab.trigger('click'); 69 } 70 }); 71 } 72 }); 73 74 set_size(); 75 trigger_default_open(false); 76 win.on("debouncedresize", set_size); 77 78 $('a').on('click',function(){ 79 var hash = $(this).attr('href'); 80 if(typeof hash != "undefined" && hash) 81 { 82 hash = hash.replace(/^.*?#/,''); 83 trigger_default_open('#'+hash); 84 } 85 }); 86 87 function set_size() 88 { 89 if( ! options.sidebar) 90 { 91 return; 92 } 93 94 content.css({'min-height': tab_titles.outerHeight() + 1}); 95 } 96 97 function open_content(tab, i, alternate_tab) 98 { 99 if(!tab.is('.'+options.active)) 100 { 101 $('.'+options.active, container).removeClass(options.active); 102 $('.'+options.active+'_content', container).attr('aria-hidden', true).removeClass(options.active+'_content'); 103 104 tab.addClass(options.active); 105 106 var new_loc = tab.data('fake-id'); 107 if( typeof new_loc == 'string' ) 108 { 109 window.location.replace( new_loc ); 110 } 111 112 if( alternate_tab ) 113 { 114 alternate_tab.addClass(options.active); 115 } 116 117 var active_c = content.filter(':eq('+i+')').addClass(options.active+'_content').attr('aria-hidden', false); 118 119 if(typeof click_container != 'undefined' && click_container.length) 120 { 121 sidebar_shadow.height(active_c.outerHeight()); 122 } 123 124 //check if tab title is in viewport. if not scroll up 125 var el_offset = active_c.offset().top, 126 scoll_target = el_offset - 50 - parseInt($('html').css('margin-top'),10); 127 128 if(win.scrollTop() > el_offset) 129 { 130 $('html:not(:animated),body:not(:animated)').scrollTop(scoll_target); 131 } 132 } 133 134 win.trigger( 'av-content-el-height-changed', tab ); 135 } 136 137 function trigger_default_open(hash) 138 { 139 if( ! hash && window.location.hash ) 140 { 141 hash = window.location.hash; 142 } 143 144 if( ! hash ) 145 { 146 return; 147 } 148 149 var open = tabs.filter('[data-fake-id="'+hash+'"]'); 150 151 if(open.length) 152 { 153 if( ! open.is('.active_tab') ) 154 { 155 open.trigger('click'); 156 } 157 158 window.scrollTo(0, container.offset().top - 70); 159 } 160 } 161 162 }); 163 }; 164 165 166}(jQuery)); 167 168 169jQuery('.top_tab', "body").avia_sc_tabs(); 170jQuery('.sidebar_tab', "body").avia_sc_tabs({sidebar:true});
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.