Sha256: 9934204494f70ed37f03736716247c2649b647ffe8b27a95014a8ca2f08f7377

Contents?: true

Size: 982 Bytes

Versions: 2

Compression:

Stored size: 982 Bytes

Contents

(function($) {
  $(document).on('expando:present', function(event){
    var expando = $(event.target);
    var expando_elem = expando.find(".js-expando-elem").first();

    function toggleAriaExpanded() {
      var ariaExpanded = "false";
      if (expando.hasClass("open")) {
        ariaExpanded = "true";
      }
      expando_elem.attr("aria-expanded", ariaExpanded);
    }

    function toggleExpando() {
      expando.toggleClass("open");
      toggleAriaExpanded();
      return true;
    }

    function expandExpando(){
      if(!expando.hasClass('open')) {
        toggleExpando();
      }
    }

    expando_elem.attr("tabindex",0);
    toggleAriaExpanded();

    expando.bind("expandFilters", expandExpando);
    expando_elem.bind("click", toggleExpando);
    expando_elem.keydown(function(e) {
      if (e.keyCode == $.ui.keyCode.SPACE || e.keyCode == $.ui.keyCode.ENTER) {
        toggleExpando();
      } else {
        return true;
      }
    });
  });
})(jQuery);

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
undercase-0.2.57 app/assets/javascripts/undercase/patterns/expando.js
undercase-0.2.29 app/assets/javascripts/undercase/patterns/expando.js