/*! * # Semantic UI 1.11.4 - Sticky * http://github.com/semantic-org/semantic-ui/ * * * Copyright 2014 Contributorss * Released under the MIT license * http://opensource.org/licenses/MIT * */ !function(e,t,o,n){"use strict";e.fn.sticky=function(o){var i,s=e(this),c=s.selector||"",r=(new Date).getTime(),a=[],l=arguments[0],m="string"==typeof l,f=[].slice.call(arguments,1);return s.each(function(){var s,u,d,h=e.isPlainObject(o)?e.extend(!0,{},e.fn.sticky.settings,o):e.extend({},e.fn.sticky.settings),b=h.className,g=h.namespace,p=h.error,v="."+g,x="module-"+g,C=e(this),k=e(t),y=C.offsetParent(),S=e(h.scrollContext),T=(C.selector||"",C.data(x)),w=t.requestAnimationFrame||t.mozRequestAnimationFrame||t.webkitRequestAnimationFrame||t.msRequestAnimationFrame||function(e){setTimeout(e,0)},P=this;d={initialize:function(){d.determineContext(),d.verbose("Initializing sticky",h,y),d.save.positions(),d.checkErrors(),d.bind.events(),h.observeChanges&&d.observeChanges(),d.instantiate()},instantiate:function(){d.verbose("Storing instance of module",d),T=d,C.data(x,d)},destroy:function(){d.verbose("Destroying previous module"),d.reset(),u&&u.disconnect(),k.off("resize"+v,d.event.resize),S.off("scroll"+v,d.event.scroll),C.removeData(x)},observeChanges:function(){var e=s[0];"MutationObserver"in t&&(u=new MutationObserver(function(){clearTimeout(d.timer),d.timer=setTimeout(function(){d.verbose("DOM tree modified, updating sticky menu"),d.refresh()},20)}),u.observe(P,{childList:!0,subtree:!0}),u.observe(e,{childList:!0,subtree:!0}),d.debug("Setting up mutation observer",u))},determineContext:function(){return s=h.context?e(h.context):y,0===s.length?void d.error(p.invalidContext,h.context,C):void 0},checkErrors:function(){return d.is.hidden()&&d.error(p.visible,C),d.cache.element.height>d.cache.context.height?(d.reset(),void d.error(p.elementSize,C)):void 0},bind:{events:function(){k.on("resize"+v,d.event.resize),S.on("scroll"+v,d.event.scroll)}},event:{resize:function(){w(function(){d.refresh(),d.stick()})},scroll:function(){w(function(){d.stick(),h.onScroll.call(P)})}},refresh:function(e){d.reset(),e&&(y=C.offsetParent()),d.save.positions(),d.stick(),h.onReposition.call(P)},supports:{sticky:function(){{var t=e("
");t.get()}return t.addClass(b.supported),t.css("position").match("sticky")}},save:{scroll:function(e){d.lastScroll=e},positions:function(){var e={height:k.height()},t={margin:{top:parseInt(C.css("margin-top"),10),bottom:parseInt(C.css("margin-bottom"),10)},offset:C.offset(),width:C.outerWidth(),height:C.outerHeight()},o={offset:s.offset(),height:s.outerHeight(),bottomPadding:parseInt(s.css("padding-bottom"),10)};d.cache={fits:t.heighte&&(t="up")),t},scrollChange:function(e){return e=e||S.scrollTop(),d.lastScroll?e-d.lastScroll:0},currentElementScroll:function(){return d.is.top()?Math.abs(parseInt(C.css("top"),10))||0:Math.abs(parseInt(C.css("bottom"),10))||0},elementScroll:function(e){e=e||S.scrollTop();var t,o=d.cache.element,n=d.cache.window,i=d.get.scrollChange(e),s=o.height-n.height+h.offset,c=d.get.currentElementScroll(),r=c+i;return t=d.cache.fits||0>r?0:r>s?s:r}},remove:{offset:function(){C.css("margin-top","")}},set:{offset:function(){d.verbose("Setting offset on element",h.offset),C.css("margin-top",h.offset)},containerSize:function(){var e=y.get(0).tagName;"HTML"===e||"body"==e?y=C.offsetParent():(d.debug("Settings container size",d.cache.context.height),Math.abs(y.height()-d.cache.context.height)>5&&y.css({height:d.cache.context.height}))},scroll:function(e){d.debug("Setting scroll on element",e),d.is.top()&&C.css("bottom","").css("top",-e),d.is.bottom()&&C.css("top","").css("bottom",e)},size:function(){0!==d.cache.element.height&&0!==d.cache.element.width&&C.css({width:d.cache.element.width,height:d.cache.element.height})}},is:{top:function(){return C.hasClass(b.top)},bottom:function(){return C.hasClass(b.bottom)},initialPosition:function(){return!d.is.fixed()&&!d.is.bound()},hidden:function(){return!C.is(":visible")},bound:function(){return C.hasClass(b.bound)},fixed:function(){return C.hasClass(b.fixed)}},stick:function(){var e=d.cache,t=e.fits,o=e.element,n=e.window,i=e.context,s=d.is.bottom()&&h.pushing?h.bottomOffset:h.offset,c={top:S.scrollTop()+s,bottom:S.scrollTop()+s+n.height},r=(d.get.direction(c.top),d.get.elementScroll(c.top)),a=!t,l=0!==o.height;d.save.scroll(c.top),l&&(d.is.initialPosition()?c.top>=i.bottom?(console.log(c.top,i.bottom),d.debug("Element bottom of container"),d.bindBottom()):c.top>=o.top&&(d.debug("Element passed, fixing element to page"),d.fixTop()):d.is.fixed()?d.is.top()?c.topi.bottom?(d.debug("Fixed element reached bottom of container"),d.bindBottom()):a&&d.set.scroll(r):d.is.bottom()&&(c.bottom-o.heighti.bottom?(d.debug("Bottom fixed rail has reached bottom of container"),d.bindBottom()):a&&d.set.scroll(r)):d.is.bottom()&&(h.pushing?d.is.bound()&&c.bottom0&&(console.groupCollapsed(t),console.table?console.table(a):e.each(a,function(e,t){console.log(t.Name+": "+t["Execution Time"]+"ms")}),console.groupEnd()),a=[]}},invoke:function(t,o,s){var c,r,a,l=T;return o=o||f,s=P||s,"string"==typeof t&&l!==n&&(t=t.split(/[\. ]/),c=t.length-1,e.each(t,function(o,i){var s=o!=c?i+t[o+1].charAt(0).toUpperCase()+t[o+1].slice(1):t;if(e.isPlainObject(l[s])&&o!=c)l=l[s];else{if(l[s]!==n)return r=l[s],!1;if(!e.isPlainObject(l[i])||o==c)return l[i]!==n?(r=l[i],!1):!1;l=l[i]}})),e.isFunction(r)?a=r.apply(s,o):r!==n&&(a=r),e.isArray(i)?i.push(a):i!==n?i=[i,a]:a!==n&&(i=a),r}},m?(T===n&&d.initialize(),d.invoke(l)):(T!==n&&T.invoke("destroy"),d.initialize())}),i!==n?i:this},e.fn.sticky.settings={name:"Sticky",namespace:"sticky",debug:!1,verbose:!1,performance:!1,pushing:!1,context:!1,scrollContext:t,offset:0,bottomOffset:0,observeChanges:!0,onReposition:function(){},onScroll:function(){},onStick:function(){},onUnstick:function(){},onTop:function(){},onBottom:function(){},error:{container:"Sticky element must be inside a relative container",visible:"Element is hidden, you must call refresh after element becomes visible",method:"The method you called is not defined.",invalidContext:"Context specified does not exist",elementSize:"Sticky element is larger than its container, cannot create sticky."},className:{bound:"bound",fixed:"fixed",supported:"native",top:"top",bottom:"bottom"}}}(jQuery,window,document);