Sha256: 8a2368eee75efc2f2626704a85223979938c3385475dad6031cd73ee49be21a1

Contents?: true

Size: 1.27 KB

Versions: 6

Compression:

Stored size: 1.27 KB

Contents

// This is a manifest file that'll be compiled into including all the files listed below.
// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
// be included in the compiled file accessible from http://example.com/assets/application.js
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// the compiled file.
//
//= require jquery
//= require jquery_ujs
//= require bootstrap-dropdown
//= require bootstrap-modal

$(document).ready(function(){

  $('.dropdown-toggle').dropdown();

  // fix sub nav on scroll
  var $win = $(window)
      , $nav = $('.subnav')
      , navTop = $('.subnav').length && $('.subnav').offset().top - 40
      , isFixed = 0;

  processScroll();

  // hack sad times - holdover until rewrite for 2.1
  $nav.on('click', function () {
      if (!isFixed) setTimeout(function () {  $win.scrollTop($win.scrollTop() - 47) }, 10)
  });

  $win.on('scroll', processScroll)

  function processScroll() {
      var i, scrollTop = $win.scrollTop();
      if (scrollTop >= navTop && !isFixed) {
          isFixed = 1;
          $nav.addClass('subnav-fixed')
      } else if (scrollTop <= navTop && isFixed) {
          isFixed = 0;
          $nav.removeClass('subnav-fixed')
      }
  }

});

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
wafflemix-0.0.6 app/assets/javascripts/wafflemix/application.js
wafflemix-0.0.5 app/assets/javascripts/wafflemix/application.js
wafflemix-0.0.4 app/assets/javascripts/wafflemix/application.js
wafflemix-0.0.3 app/assets/javascripts/wafflemix/application.js
wafflemix-0.0.2 app/assets/javascripts/wafflemix/application.js
wafflemix-0.0.1 app/assets/javascripts/wafflemix/application.js