https://www.registroimprese.it/o/registroimprese-theme/js/plugins/jquery.menu-anchor.js?v=2015-09-13
1(function($) { 2 3 $.MenuAnchor = function(elem, options) { 4 var self = this; 5 var docu = $('body'); 6 7 // default settings 8 self.settings = $.extend({ 9 window: window.top, 10 pluralId: 'menu-anchor-', 11 contentPostfix: '-content', 12 scroll: true 13 }, options); 14 15 self.scroll = true; 16 17 self.init = function() { 18 19 $(elem).find('[id^=' + self.settings.pluralId + ']').each(function(i, e) { 20 // event click 21 $(e).click(function(evt) { 22 evt.preventDefault(); 23 if (self.settings.scroll){ 24 console.log("self.scroll = false") 25 self.scroll = false; 26 } 27 28 29 var pos = $('#' + e.id + self.settings.contentPostfix).offset(); 30 console.log(pos.top); 31 32 $(self.settings.window.document).find('html, body').animate( 33 {scrollTop: pos.top - 60}, 34 {duration: 'slow', 35 complete: function() { 36 if (self.settings.scroll) 37 self.scroll = true; 38 self.setSelectedLink(e.id); 39 }, 40 error: function() { 41 if (self.settings.scroll) 42 self.scroll = true; 43 self.setSelectedLink(e.id); 44 } 45 } 46 ); 47 }); 48 }); 49 50 // scroll event 51 if (self.settings.scroll) { 52 $(self.settings.window).scroll(function() { 53 if (self.scroll) { 54 self.setSelectedLink(); 55 } 56 }); 57 } 58 59 }; 60 61 self.setSelectedLink = function(anchorId) { 62 var currPos = -1; 63 var currId = ''; 64 65 $(elem).find('[id^=' + self.settings.pluralId + ']').each(function(i, e) { 66 if (typeof self.settings.window !== 'undefined') { 67 // remove selected class 68 if ($('#' + e.id).hasClass('selected')) { 69 $('#' + e.id).removeClass('selected'); 70 } 71 72 var xOffset = $('#' + e.id + self.settings.contentPostfix).offset(); 73 74 var yOffset = self.settings.window.pageYOffset; 75 76 var scrPos = xOffset.top - yOffset; 77 78 if ((scrPos >= 0 && currPos >= scrPos) || currPos <= 0 || currId === '') { 79 currPos = scrPos; 80 currId = e.id; 81 } 82 } 83 84 }); 85 86 if (anchorId) 87 currId = anchorId; 88 89 if (currId !== '') 90 $('#' + currId).addClass('selected'); 91 92 }; 93 94 self.init(); 95 self.setSelectedLink(); 96 }; 97 98 $.fn.MenuAnchor = function(options) { 99 return this.each(function() { 100 (new $.MenuAnchor(this, options)); 101 }); 102 }; 103}(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.