Sha256: 2e7a11f4b00b7d0de748037729363205bd9863d9e8e9947b5740767f0ecbabd1

Contents?: true

Size: 1.1 KB

Versions: 2

Compression:

Stored size: 1.1 KB

Contents

<section class="dropdown">
  <div class="js-dropdown-link dropdown-link">Dropdown</div>
  <div class="js-dropdown-menu dropdown-menu">
    <ul>
      <li>
      <a href="#">Lettuce</a>
      </li>
      <li>
      <a href="#">Tomato</a>
      </li>
      <li>
      <a href="#">Onion</a>
      </li>
    </ul>
  </div>
</section>

<script>
  (function($) {
    $.fn.clickToggle = function(func1, func2) {
      var funcs = [func1, func2];
      this.data('toggleclicked', 0);
      this.click(function() {
        var data = $(this).data();
        var tc = data.toggleclicked;
        $.proxy(funcs[tc], this)();
        data.toggleclicked = (tc + 1) % 2;
      });
      return this;
    };
  }(jQuery));

  $(document).ready(function () {
    $('.js-dropdown-link').clickToggle(function() {
      var menu = $(this).siblings('.js-dropdown-menu');
      menu.css('top', $(this).outerHeight() + 15);
      menu.fadeIn(150);
      $(this).addClass("is-active");
    }, function() {
      var menu = $(this).siblings('.dropdown-menu');
      menu.fadeOut(150);
      $(this).removeClass("is-active");
    });
  });
</script>

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
refills-0.0.2 source/_dropdown-menu.html.erb
refills-0.0.1 source/_dropdown-menu.html.erb