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