1if (typeof ga_sidebar_options != 'undefined' && ga_sidebar_options.length > 0) { 2 if (window.jQuery) { 3 if (ga_sidebar_options[0].window_load_hook) { 4 jQuery(window).load(ga_sidebar_init()); 5 } else { 6 jQuery(document).ready(ga_sidebar_init()); 7 } 8 } else { 9 console.log('jQuery is not loaded!'); 10 } 11} else { 12 console.log('ga_sidebar_options not found!'); 13} 14 15function ga_sidebar_init() { 16 for (var i = 0; i < ga_sidebar_options.length; i++) { 17 ga_sidebar(ga_sidebar_options[i]); 18 } 19 jQuery(window).on('resize', function () { 20 for (var i = 0; i < ga_sidebar_options.length; i++) { 21 ga_sidebar(ga_sidebar_options[i]); 22 } 23 }); 24 var MutationObserver = (function () { 25 var prefixes = ['WebKit', 'Moz', 'O', 'Ms', '']; 26 for (var i = 0; i < prefixes.length; i++) { 27 if (prefixes[i] + 'MutationObserver' in window) { 28 return window[prefixes[i] + 'MutationObserver']; 29 } 30 } 31 return false; 32 }()); 33 if (ga_sidebar_options[0].disable_mo_api == false && MutationObserver) { 34 gaRefresh = false 35 var htmlObserver = new MutationObserver(function (mutations) { 36 mutations.forEach(function (mutation) { 37 if (ga_exclude_mutations_array(ga_sidebar_options).indexOf(mutation.target.id) == -1) { 38 gaRefresh = true; 39 //console.log('Mutation detected!'); 40 } 41 }); 42 }); 43 htmlObserver.observe(document.body, {childList: true, attributes: true, attributeFilter: ['style', 'class'], subtree: true}); 44 setInterval(function () { 45 if (gaRefresh) { 46 for (var i = 0; i < ga_sidebar_options.length; i++) { 47 ga_sidebar(ga_sidebar_options[i]); 48 } 49 gaRefresh = false; 50 } 51 }, 300); 52 } else { 53 console.log('MutationObserver not supported or disabled!'); 54 if (ga_sidebar_options[0].refresh_interval > 0) { 55 setInterval(function () { 56 for (var i = 0; i < ga_sidebar_options.length; i++) { 57 ga_sidebar(ga_sidebar_options[i]); 58 } 59 }, ga_sidebar_options[0].refresh_interval); 60 } 61 } 62} 63 64function ga_exclude_mutations_array(ga_sidebar_options) { 65 var out = new Array(); 66 for (var i = 0; i < ga_sidebar_options.length; i++) { 67 if (ga_sidebar_options[i].widgets.length > 0) { 68 for (var k = 0; k < ga_sidebar_options[i].widgets.length; k++) { 69 out.push(ga_sidebar_options[i].widgets[k]); 70 out.push(ga_sidebar_options[i].widgets[k] + '_clone'); 71 } 72 } 73 } 74 return out; 75} 76 77function ga_sidebar(options) { 78 79 if (!options) 80 return false; 81 82 if (!options.widgets) 83 return false; 84 85 if (options.widgets.length < 1) 86 return false; 87 88 if (!options.sidebar) 89 options.sidebar = 'ga-default-sidebar'; 90 91 //console.log(options.sidebar + ' call'); 92 93 function widget() {} // widget class 94 95 var widgets = new Array(); 96 97 var window_height = jQuery(window).height(); 98 var document_height = jQuery(document).height(); 99 var fixed_margin_top = options.margin_top; 100 101 if (jQuery('#wpadminbar').length) { // WordPress admin bar 102 fixed_margin_top = options.margin_top + jQuery('#wpadminbar').height(); 103 } 104 105 jQuery('.ga-widget-clone-' + options.sidebar).remove(); // clear fixed mode p1 106 107 for (var i = 0; i < options.widgets.length; i++) { 108 widget_obj = jQuery('#' + options.widgets[i]); 109 widget_obj.css('position', ''); // clear fixed mode p2 110 if (widget_obj.attr('id')) { 111 widgets[i] = new widget(); 112 widgets[i].obj = widget_obj; 113 widgets[i].clone = widget_obj.clone(); 114 widgets[i].clone.children().remove(); 115 widgets[i].clone_id = widget_obj.attr('id') + '_clone'; 116 widgets[i].clone.addClass('ga-widget-clone-' + options.sidebar); 117 widgets[i].clone.attr('id', widgets[i].clone_id); 118 widgets[i].clone.css('height', widget_obj.height()); 119 widgets[i].clone.css('visibility', 'hidden'); 120 widgets[i].offset_top = widget_obj.offset().top; 121 widgets[i].fixed_margin_top = fixed_margin_top; 122 widgets[i].height = widget_obj.outerHeight(true); 123 widgets[i].fixed_margin_bottom = fixed_margin_top + widgets[i].height; 124 fixed_margin_top += widgets[i].height; 125 } else { 126 widgets[i] = false;
127 } 128 } 129 130 var next_widgets_height = 0; 131 132 var widget_parent_container; 133 134 for (var i = widgets.length - 1; i >= 0; i--) { 135 if (widgets[i]) { 136 widgets[i].next_widgets_height = next_widgets_height; 137 widgets[i].fixed_margin_bottom += next_widgets_height; 138 next_widgets_height += widgets[i].height; 139 if (!widget_parent_container) { 140 widget_parent_container = widget_obj.parent(); 141 widget_parent_container.addClass('ga-fixed-widget-container'); 142 widget_parent_container.css('height', ''); 143 widget_parent_container.height(widget_parent_container.height()); 144 } 145 } 146 } 147 148 jQuery(window).off('scroll.' + options.sidebar); 149 150 for (var i = 0; i < widgets.length; i++) { 151 if (widgets[i]) 152 fixed_widget(widgets[i]); 153 } 154 155 function fixed_widget(widget) { 156 157 //console.log('fixed_widget call: ' + widget.obj.attr('id') + '==>' +options.sidebar); 158 159 var trigger_top = widget.offset_top - widget.fixed_margin_top; 160 var trigger_bottom = document_height - options.margin_bottom; 161 162 if (options.stop_id && jQuery('#' + options.stop_id).length) { 163 trigger_bottom = jQuery('#' + options.stop_id).offset().top - options.margin_bottom; 164 } 165 166 var widget_width; 167 if (options.width_inherit) 168 widget_width = 'inherit'; 169 else 170 widget_width = widget.obj.css('width'); 171 172 var style_applied_top = false; 173 var style_applied_bottom = false; 174 var style_applied_normal = false; 175 176 jQuery(window).on('scroll.' + options.sidebar, function (event) { 177 178 if (jQuery(window).width() <= options.screen_max_width || jQuery(window).height() <= options.screen_max_height) { 179 if (!style_applied_normal) { 180 widget.obj.css('position', ''); 181 widget.obj.css('top', ''); 182 widget.obj.css('bottom', ''); 183 widget.obj.css('width', ''); 184 widget.obj.css('margin', ''); 185 widget.obj.css('padding', ''); 186 widget_obj.parent().css('height', ''); 187 if (jQuery('#' + widget.clone_id).length > 0) 188 jQuery('#' + widget.clone_id).remove(); 189 style_applied_normal = true; 190 style_applied_top = false; 191 style_applied_bottom = false; 192 } 193 //console.log('jQuery(window).width() <= options.screen_max_width'); 194 } else { 195 var scroll = jQuery(this).scrollTop(); 196 //console.log('Srcoll: ' + scroll + ' | Trigger top: ' + trigger_top + ' | Trigger bottom: ' + trigger_bottom); 197 if (scroll + widget.fixed_margin_bottom >= trigger_bottom) { // fixed bottom 198 if (!style_applied_bottom) { 199 widget.obj.css('position', 'fixed'); 200 widget.obj.css('top', ''); 201 widget.obj.css('width', widget_width); 202 if (jQuery('#' + widget.clone_id).length <= 0) 203 widget.obj.before(widget.clone); 204 style_applied_bottom = true; 205 style_applied_top = false; 206 style_applied_normal = false; 207 } 208 widget.obj.css('bottom', scroll + window_height + widget.next_widgets_height - trigger_bottom); 209 } else if (scroll >= trigger_top) { // fixed top 210 if (!style_applied_top) { 211 widget.obj.css('position', 'fixed'); 212 widget.obj.css('top', widget.fixed_margin_top); 213 widget.obj.css('bottom', ''); 214 widget.obj.css('width', widget_width); 215 if (jQuery('#' + widget.clone_id).length <= 0) 216 widget.obj.before(widget.clone); 217 style_applied_top = true; 218 style_applied_bottom = false;
219 style_applied_normal = false; 220 } 221 } else { // normal 222 if (!style_applied_normal) { 223 widget.obj.css('position', ''); 224 widget.obj.css('top', ''); 225 widget.obj.css('bottom', ''); 226 widget.obj.css('width', ''); 227 if (jQuery('#' + widget.clone_id).length > 0) 228 jQuery('#' + widget.clone_id).remove(); 229 style_applied_normal = true; 230 style_applied_top = false; 231 style_applied_bottom = false; 232 } 233 } 234 } 235 236 var widget_position = jQuery('#'+widget.obj.attr('id')).css('position'); 237 238 if(widget_position == 'fixed' && typeof wct == 'undefined'){ 239 wct = jQuery(window).scrollTop(); 240 } 241 242 if (widget_position == 'fixed' && jQuery(window).scrollTop()>(wct+ga_sidebar_remove_fixed)) 243 { 244 widget.obj.css('position', ''); 245 widget.obj.css('top', ''); 246 widget.obj.css('bottom', ''); 247 widget.obj.css('width', ''); 248 if (jQuery('#' + widget.clone_id).length > 0) 249 jQuery('#' + widget.clone_id).remove(); 250 style_applied_normal = true; 251 style_applied_top = false; 252 style_applied_bottom = false; 253 } 254 255 }).trigger('scroll.' + options.sidebar); 256 257 } 258 259}
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.