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.attr('data-hoverstyle'); 37 38 function scroll_to_viewport() 39 { 40 //check if toggle title is in viewport. if not scroll up 41 var el_offset = content.offset().top, 42 scoll_target = el_offset - 50 - parseInt($('html').css('margin-top'),10); 43 44 if(win.scrollTop() > el_offset) 45 { 46 $('html:not(:animated),body:not(:animated)').animate({scrollTop: scoll_target},200); 47 } 48 } 49 50 if(content.css('visibility') != "hidden") 51 { 52 thisheading.addClass('activeTitle').attr('style',activeStyle); 53 } 54 55 thisheading.on('click', function() 56 { 57 if(content.css('visibility') != "hidden") 58 { 59 content.slideUp(200, function() 60 { 61 content.removeClass('active_tc').attr({style:''}); 62 win.trigger('av-height-change'); 63 win.trigger('av-content-el-height-changed', this ); 64 65 location.replace(thisheading.data('fake-id') + "-closed"); 66 }); 67 thisheading.removeClass('activeTitle').attr('style',headingStyle); 68 69 } 70 else 71 { 72 if(container.is('.toggle_close_all')) 73 { 74 allContent.not(content).slideUp(200, function() 75 { 76 $(this).removeClass('active_tc').attr({style:''}); 77 scroll_to_viewport(); 78 }); 79 heading.removeClass('activeTitle').attr('style',headingStyle); 80 } 81 82 content.addClass('active_tc'); 83 84 setTimeout(function(){ 85 86 content.slideDown(200, 87 88 function() 89 { 90 if(!container.is('.toggle_close_all')) 91 { 92 scroll_to_viewport(); 93 } 94 95 win.trigger('av-height-change'); 96 win.trigger('av-content-el-height-changed', this ); 97 } 98 99 ); 100 101 }, 1); 102 103 thisheading.addClass('activeTitle').attr('style',activeStyle); 104 location.replace(thisheading.data('fake-id')); 105 } 106 107 }); 108 109 /* change style on hover */ 110 if (hoverStyle) { 111 112 thisheading.hover( 113 function() { 114 if ( ! thisheading.hasClass('activeTitle')) { 115 $(this).attr('style',hoverStyle); 116 } 117 }, function() { 118 if ( ! thisheading.hasClass('activeTitle')) { 119 $(this).attr('style', headingStyle); 120 } 121 } 122 ); 123 } 124 125 }); 126 127 128 sortLinks.click(function(e){ 129 130 e.preventDefault(); 131 var show = toggles.filter('[data-tags~="'+$(this).data('tag')+'"]'), 132 hide = toggles.not('[data-tags~="'+$(this).data('tag')+'"]'); 133 134 sortLinks.removeClass('activeFilter'); 135 $(this).addClass('activeFilter'); 136 heading.filter('.activeTitle').trigger('click'); 137 show.slideDown(); 138 hide.slideUp(); 139 }); 140 141 142 function trigger_default_open(hash) 143 { 144 if(!hash && window.location.hash) hash = window.location.hash; 145 if(!hash) return; 146 147 var open = heading.filter('[data-fake-id="'+hash+'"]'); 148 149 if(open.length) 150 { 151 if(!open.is('.activeTitle')) open.trigger('click'); 152 window.scrollTo(0, container.offset().top - 70); 153 } 154 } 155 trigger_default_open(false); 156 157 $('a').on('click',function(){ 158 var hash = $(this).attr('href'); 159 if(typeof hash != "undefined" && hash) 160 { 161 hash = hash.replace(/^.*?#/,''); 162 trigger_default_open('#'+hash); 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.