/*! * theia sticky sidebar v1.7.0 * https://github.com/wecodepixels/theia-sticky-sidebar * * glues your website's sidebars, making them permanently visible while scrolling. * * copyright 2013-2016 wecodepixels and other contributors * released under the mit license */ (function ($) { $.fn.theiastickysidebar = function (options) { var defaults = { 'containerselector': '', 'additionalmargintop': 0, 'additionalmarginbottom': 0, 'updatesidebarheight': true, 'minwidth': 0, 'disableonresponsivelayouts': true, 'sidebarbehavior': 'modern', 'defaultposition': 'relative', 'namespace': 'tss' }; options = $.extend(defaults, options); // validate options options.additionalmargintop = parseint(options.additionalmargintop) || 0; options.additionalmarginbottom = parseint(options.additionalmarginbottom) || 0; tryinitorhookintoevents(options, this); // try doing init, otherwise hook into window.resize and document.scroll and try again then. function tryinitorhookintoevents(options, $that) { var success = tryinit(options, $that); if (!success) { console.log('tss: body width smaller than options.minwidth. init is delayed.'); $(document).on('scroll.' + options.namespace, function (options, $that) { return function (evt) { var success = tryinit(options, $that); if (success) { $(this).unbind(evt); } }; }(options, $that)); $(window).on('resize.' + options.namespace, function (options, $that) { return function (evt) { var success = tryinit(options, $that); if (success) { $(this).unbind(evt); } }; }(options, $that)) } } // try doing init if proper conditions are met. function tryinit(options, $that) { if (options.initialized === true) { return true; } if ($('body').width() < options.minwidth) { return false; } init(options, $that); return true; } // init the sticky sidebar(s). function init(options, $that) { options.initialized = true; // add css var existingstylesheet = $('#theia-sticky-sidebar-stylesheet-' + options.namespace); if (existingstylesheet.length === 0) { $('head').append($('')); } $that.each(function () { var o = {}; o.sidebar = $(this); // save options o.options = options || {}; // get container o.container = $(o.options.containerselector); if (o.container.length == 0) { o.container = o.sidebar.parent(); } // create sticky sidebar o.sidebar.parents().css('-webkit-transform', 'none'); // fix for webkit bug - https://code.google.com/p/chromium/issues/detail?id=20574 o.sidebar.css({ 'position': o.options.defaultposition, 'overflow': 'visible', // the "box-sizing" must be set to "content-box" because we set a fixed height to this element when the sticky sidebar has a fixed position. '-webkit-box-sizing': 'border-box', '-moz-box-sizing': 'border-box', 'box-sizing': 'border-box' }); // get the sticky sidebar element. if none has been found, then create one. o.stickysidebar = o.sidebar.find('.theiastickysidebar'); if (o.stickysidebar.length == 0) { // remove