You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

2 lines
2.9 KiB

define ("theme_ilb/drawer",["jquery","core/custom_interaction_events","core/log","core/pubsub","core/aria"],function(a,b,c,d,e){var f={TOGGLE_REGION:"[data-region=\"drawer-toggle\"]",TOGGLE_ACTION:"[data-action=\"toggle-drawer\"]",TOGGLE_TARGET:"aria-controls",TOGGLE_SIDE:"left",BODY:"body",SECTION:".list-group-item[href*=\"#section-\"]",DRAWER:"#nav-drawer"},g=768>a(document).width(),h=function(){if(!a(f.TOGGLE_REGION).length){c.debug("Page is missing a drawer region")}if(!a(f.TOGGLE_ACTION).length){c.debug("Page is missing a drawer toggle link")}a(f.TOGGLE_REGION).each(function(b,c){var d=a(c).find(f.TOGGLE_ACTION),e=d.attr("aria-controls"),h=a(document.getElementById(e)),i="false"==d.attr("aria-expanded"),j=d.attr("data-side"),k=a(f.BODY),l=d.attr("data-preference");if(g){M.util.set_user_preference(l,"false")}h.on("mousewheel DOMMouseScroll",this.preventPageScroll);if(!i){k.addClass("drawer-open-"+j);d.attr("aria-expanded","true")}else{d.attr("aria-expanded","false")}}.bind(this));this.registerEventListeners();if(g){this.closeAll()}};h.prototype.closeAll=function(){a(f.TOGGLE_REGION).each(function(b,c){var d=a(c).find(f.TOGGLE_ACTION),h=d.attr("data-side"),i=a(f.BODY),j=d.attr("aria-controls"),k=a(document.getElementById(j)),l=d.attr("data-preference");d.attr("aria-expanded","false");i.removeClass("drawer-open-"+h);e.hide(k.get());k.addClass("closed");if(!g){M.util.set_user_preference(l,"false")}})};h.prototype.toggleDrawer=function(b){var c=a(b.target).closest("[data-action=toggle-drawer]"),h=c.attr("aria-controls"),i=a(document.getElementById(h)),j=a(f.BODY),k=c.attr("data-side"),l=c.attr("data-preference");if(g){M.util.set_user_preference(l,"false")}j.addClass("drawer-ease");var m="true"==c.attr("aria-expanded");if(!m){c.attr("aria-expanded","true");e.unhide(i.get());i.focus();j.addClass("drawer-open-"+k);i.removeClass("closed");if(!g){M.util.set_user_preference(l,"true")}}else{j.removeClass("drawer-open-"+k);c.attr("aria-expanded","false");i.addClass("closed").delay(500).queue(function(){if(a(this).hasClass("closed")){e.hide(this)}a(this).dequeue()});if(!g){M.util.set_user_preference(l,"false")}}d.publish("nav-drawer-toggle-start",m)};h.prototype.preventPageScroll=function(b){var c=b.wheelDelta||b.originalEvent&&b.originalEvent.wheelDelta||-b.originalEvent.detail,d=0<=this.scrollTop+a(this).outerHeight()-this.scrollHeight,e=0>=this.scrollTop;if(0>c&&d||0<c&&e){b.preventDefault()}};h.prototype.registerEventListeners=function(){a(f.TOGGLE_ACTION).each(function(c,d){b.define(a(d),[b.events.activate]);a(d).on(b.events.activate,function(a,b){this.toggleDrawer(b.originalEvent);b.originalEvent.preventDefault()}.bind(this))}.bind(this));a(f.SECTION).click(function(){if(g){this.closeAll()}}.bind(this));a(f.DRAWER).on("webkitTransitionEnd msTransitionEnd transitionend",function(b){var c=a(b.target).closest(f.DRAWER),e=!!c.attr("aria-hidden");d.publish("nav-drawer-toggle-end",e)})};return{init:function init(){return new h}}});
//# sourceMappingURL=drawer.min.js.map