1 line
2.1 KiB
JavaScript
1 line
2.1 KiB
JavaScript
theme.Footer=function(){function t(t){this.$container=$(t),this.namespace=".footer",this.onLoad()}return t.prototype=$.extend({},Section.prototype,t.prototype,{_back_to_top:{init:function(t){var o=this,i=$("[data-js-button-back-to-top]");t+=".buttonToTop";if(i.length){var e=i.attr("data-js-button-back-to-top")||1e3,n=function(){return 1e3*theme.animations.backtotop.scroll_duration},s=!1,a=!0;$(window).on("scroll"+t+" resize"+t,function(){var t=pageYOffset||Math.max($("body").scrollTop(),$("html").scrollTop());i.attr("data-bind")||i[e<t?"addClass":"removeClass"]("show"),e<t&&a&&i.removeAttr("data-bind")}),i.on("click",function(t){if(!s){s=!0;var o=i.attr("data-bind");if(o)$("html, body").velocity("stop").velocity("scroll",{offset:o,duration:n(),complete:function(){i.removeAttr("data-bind"),s=!1}});else{var e=pageYOffset||Math.max($("body").scrollTop(),$("html").scrollTop());a=!1,i.attr("data-bind",e),$("html, body").velocity("stop").velocity("scroll",{offset:0,duration:n(),complete:function(){a=!(s=!1)}})}}return t.preventDefault(),t.stopPropagation(),!1}),this.destroy=function(){$(window).unbind("scroll"+t+" resize"+t),i.off(),delete o.destroy}}},destroy:function(){this.destroy&&this.destroy()}},_fixed:{init:function(e,t){if(e.length&&e[0].hasAttribute("data-js-footer-fixed")){var i=e.parent(),n=$("#MainContent");function o(){var t=e.innerHeight(),o=n.innerHeight()>t+window.innerHeight;e[o&&theme.current.is_desktop?"addClass":"removeClass"]("footer--fixed"),e.css({width:theme.current.is_desktop&&i.hasClass("container")?i.width()+"px":""}),n.css({marginBottom:o&&theme.current.is_desktop?t+parseInt(e.css("margin-top")):""})}$window.on("theme.resize"+t,o),o()}},destroy:function(t){$window.unbind("theme.resize"+t)}},onLoad:function(){var t=$(".js-footer");this._fixed.init(t,this.namespace),this._back_to_top.init(this.namespace),theme.is_loaded&&theme.Tooltip&&theme.Tooltip.init()},onUnload:function(){this.$container.off(this.namespace),this._fixed.destroy(this.namespace),this._back_to_top.destroy(this.namespace),theme.Tooltip&&theme.Tooltip.destroy()}}),t}(),$(function(){theme.sections.register("footer",theme.Footer)}); |