(function($){ $.extend({ smoothAnchors : function(speed, easing, redirect){ speed = speed || "fast"; easing = easing || null; redirect = (redirect === true || redirect == null) ? true : false; $("a").each(function(i){ if($(this).hasClass('ignore-smoothAnchors')) return false; var url = $(this).attr("href"); var onclick = $(this).attr("onclick"); if(url){ if(url.indexOf("#") != -1 && url.indexOf("#") == 0 && url.indexOf("#popup_menu_area") == -1 && !onclick){ var aParent = $(this).parent().get(0); var aParent2 = $(aParent).parent().get(0); if(!$(aParent2).hasClass('nav')) { var aParts = url.split("#",2); var anchor = $("a[name='"+aParts[1]+"']"); if(anchor){ var id = $(this).attr("id"); if(id.indexOf("component") == -1) { $(this).click(function(){ if($(document).height()-anchor.offset().top >= $(window).height() || anchor.offset().top > $(window).height() || $(document).width()-anchor.offset().left >= $(window).width() || anchor.offset().left > $(window).width()){ $('html, body').animate({ scrollTop: anchor.offset().top, scrollLeft: anchor.offset().left }, speed, easing, function(){ if(redirect){ window.location = url } }); } return false; }); } } } } } }); } }); })(jQuery);
