-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathunity-facets.js
More file actions
1 lines (1 loc) · 1 KB
/
unity-facets.js
File metadata and controls
1 lines (1 loc) · 1 KB
1
(function($,Drupal){Drupal.behaviors.nicsdruUnityFacets={attach:function attach(context){$(once("facetDropdown",".facet--dropdown-links .facet--title",context)).each(function(index,widget){var $widget=$(widget);var $widgetLinks=$widget.nextAll(".facets-widget-links");var $facetId=$widgetLinks.attr("id");var $wrapper=$("<a />",{class:"facet--btn",href:"#",role:"button","aria-expanded":"false","aria-controls":$facetId});$widget.append('<svg aria-hidden="true" class="ico ico-arrow-down"><use xlink:href="#arrow"></use></svg>');$widget.wrapInner($wrapper);$widgetLinks.toggle();var $widgetBtn=$widget.find("a.facet--btn");var clickHandler=function(e){e.preventDefault();$widgetBtn.attr("aria-expanded",function(i,attr){return attr=="true"?"false":"true"});$widgetBtn.toggleClass("active");$widgetLinks.toggle()};$widgetBtn.on("click",clickHandler);if($widgetLinks.find(".facet-item--link").hasClass("is-active")){$widgetBtn.attr("aria-expanded","true");$widgetBtn.addClass("active");$widgetLinks.toggle()}})}}})(jQuery,Drupal);