1// ------------------------------------------------------------------------------------------- 2// Toggle shortcode javascript 3// ------------------------------------------------------------------------------------------- 4(function($) 5{ 6 "use strict"; 7 8 $.fn.avia_sc_toggle = function(options) 9 { 10 var defaults = 11 { 12 single: '.single_toggle', 13 heading: '.toggler', 14 content: '.toggle_wrap', 15 sortContainer:'.taglist' 16 }; 17 18 var win = $(window), 19 options = $.extend(defaults, options); 20 21 return this.each(function() 22 { 23 var container = $(this).addClass('enable_toggles'), 24 toggles = $(options.single, container), 25 heading = $(options.heading, container), 26 activeStyle = $(container).attr('data-currentstyle'), 27 allContent = $(options.content, container), 28 sortLinks = $(options.sortContainer + " a", container); 29 30 31 heading.each(function(i) 32 { 33 var thisheading = $(this), 34 content = thisheading.next(options.content, container), 35 headingStyle = thisheading.attr('style'), 36 hoverStyle = thisheading.data( 'hoverstyle' ); 37 38 if( 'undefined' == typeof headingStyle ) 39 { 40 headingStyle = ''; 41 } 42 43 if( 'undefined' == typeof hoverStyle ) 44 { 45 hoverStyle = ''; 46 } 47 48 function scroll_to_viewport() 49 { 50 //check if toggle title is in viewport. if not scroll up 51 var el_offset = content.offset().top, 52 scoll_target = el_offset - 50 - parseInt($('html').css('margin-top'),10); 53 54 if(win.scrollTop() > el_offset) 55 { 56 $('html:not(:animated),body:not(:animated)').animate({scrollTop: scoll_target},200); 57 } 58 } 59 60 if(content.css('visibility') != "hidden") 61 { 62 thisheading.addClass('activeTitle').attr('style',activeStyle); 63 } 64 65 thisheading.on('keydown', function(objEvent) 66 { 67 if (objEvent.keyCode === 13) { // if user presses 'enter' 68 thisheading.trigger('click'); 69 } 70 }); 71 72 thisheading.on( 'click', function() 73 { 74 if(content.css('visibility') != "hidden") 75 { 76 content.slideUp(200, function() 77 { 78 content.removeClass('active_tc').attr({style:''}); 79 win.trigger('av-height-change'); 80 win.trigger('av-content-el-height-changed', this ); 81 82 location.replace(thisheading.data('fake-id') + "-closed"); 83 }); 84 85 thisheading.removeClass('activeTitle').attr('style',headingStyle); 86 87 } 88 else 89 { 90 if(container.is('.toggle_close_all')) 91 { 92 allContent.not(content).slideUp(200, function() 93 { 94 $(this).removeClass('active_tc').attr({style:''}); 95 scroll_to_viewport(); 96 }); 97 heading.removeClass('activeTitle').attr('style',headingStyle); 98 } 99 100 content.addClass('active_tc'); 101 102 setTimeout(function(){ 103 104 content.slideDown(200, 105 106 function() 107 { 108 if(!container.is('.toggle_close_all')) 109 { 110 scroll_to_viewport(); 111 } 112 113 win.trigger('av-height-change'); 114 win.trigger('av-content-el-height-changed', this ); 115 } 116 117 ); 118 119 }, 1); 120 121 thisheading.addClass('activeTitle').attr('style',activeStyle); 122 location.replace(thisheading.data('fake-id')); 123 } 124 125 }); 126 127 /* change style on hover */ 128 if( hoverStyle ) 129 { 130 thisheading.hover( 131 function() { 132 if ( ! thisheading.hasClass('activeTitle') ) 133 { 134 $(this).attr( 'style', hoverStyle ); 135 } 136 }, function() { 137 if ( ! thisheading.hasClass('activeTitle') ) 138 { 139 $(this).attr( 'style', headingStyle ); 140 } 141 } 142 ); 143 } 144 145 }); 146 147 148 sortLinks.on( 'click', function(e){
149 150 e.preventDefault(); 151 var show = toggles.filter('[data-tags~="'+$(this).data('tag')+'"]'), 152 hide = toggles.not('[data-tags~="'+$(this).data('tag')+'"]'); 153 154 sortLinks.removeClass('activeFilter'); 155 $(this).addClass('activeFilter'); 156 heading.filter('.activeTitle').trigger('click'); 157 show.slideDown(); 158 hide.slideUp(); 159 }); 160 161 162 function trigger_default_open(hash) 163 { 164 if(!hash && window.location.hash) hash = window.location.hash; 165 if(!hash) return; 166 167 var open = heading.filter('[data-fake-id="'+hash+'"]'); 168 169 if(open.length) 170 { 171 if(!open.is('.activeTitle')) open.trigger('click'); 172 window.scrollTo(0, container.offset().top - 70); 173 } 174 } 175 trigger_default_open(false); 176 177 $('a').on( 'click',function(){ 178 var hash = $(this).attr('href'); 179 if(typeof hash != "undefined" && hash) 180 { 181 hash = hash.replace(/^.*?#/,''); 182 trigger_default_open('#'+hash); 183 } 184 }); 185 186 }); 187 }; 188 189}(jQuery)); 190 191 192jQuery('.togglecontainer', "body").avia_sc_toggle();
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.