Autoría | Ultima modificación | Ver Log |
/**
* Completion Progress block progress bar behaviour.
*
* @module block_completion_progress/progressbar
* @copyright 2020 Jonathon Fowler <fowlerj@usq.edu.au>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define("block_completion_progress/progressbar",["jquery","core/pubsub","core/utils"],(function($,PubSub,Utils){function showInfo(event){var cell=$(this),container=cell.closest(".block_completion_progress .barContainer"),visibleinfo=container.siblings(".progressEventInfo:visible"),infotoshow=container.siblings("#"+cell.data("infoRef"));visibleinfo.is(infotoshow)||(visibleinfo.hide(),infotoshow.show()),event.preventDefault()}function showAllInfo(event){var initialinfo=$(this).closest(".progressEventInfo");initialinfo.siblings(".progressEventInfo").show(),initialinfo.hide(),event.preventDefault()}function viewActivity(){var cell=$(this),infolink=cell.closest(".block_completion_progress .barContainer").siblings("#"+cell.data("infoRef")).find("a.action_link");null!==infolink.prop("onclick")?infolink.click():document.location=infolink.prop("href")}function scrollContainer(event){var barrow=$(this).closest(".block_completion_progress .barContainer").find(".barRow"),amount=event.data*barrow.prop("scrollWidth")*.15;b
arrow.prop("scrollLeft",barrow.prop("scrollLeft")+amount),event.preventDefault()}function checkArrows(){var barrow=$(this),barcontainer=barrow.closest(".block_completion_progress .barContainer"),leftarrow=barcontainer.find(".left-arrow-svg"),rightarrow=barcontainer.find(".right-arrow-svg"),scrolled=barrow.prop("scrollLeft"),scrollWidth=barrow.prop("scrollWidth")-barrow.prop("offsetWidth"),threshold=Math.floor(.25*barrow.find(".progressBarCell:first-child").width());"rtl"===document.dir?((scrolled=-scrolled)>threshold?rightarrow.css("display","block"):rightarrow.css("display","none"),scrollWidth>threshold&&scrolled<scrollWidth-threshold?leftarrow.css("display","block"):leftarrow.css("display","none")):(scrolled>threshold?leftarrow.css("display","block"):leftarrow.css("display","none"),scrollWidth>threshold&&scrolled<scrollWidth-threshold?rightarrow.css("display","block"):rightarrow.css("display","none"))}function initialiseBar(instanceid){var barcontainers=$('.block_completion_progress .barContainer[data-inst
anceid="'+instanceid+'"]');barcontainers.on("touchstart mouseover",".progressBarCell",showInfo),barcontainers.on("click",".progressBarCell[data-haslink=true]",viewActivity),barcontainers.siblings(".progressEventInfo").find(".progressShowAllInfo").click(showAllInfo),function(barcontainers){var barrows=barcontainers.find(".barRow");function checkEachBar(){barrows.each(checkArrows)}barrows.scroll(checkArrows),$(window).resize(checkEachBar),PubSub.subscribe("nav-drawer-toggle-end",checkEachBar),$(document).on("theme_boost/drawers:shown theme_boost/drawers:hidden",Utils.debounce(checkEachBar,250)),$((function(){barcontainers.find(".nowicon").each((function(){var nowicon=$(this),barrow=nowicon.closest(".block_completion_progress .barRow");barrow.prop("scrollLeft",0),barrow.prop("scrollLeft",nowicon.offset().left-barrow.offset().left-barrow.width()/2)})),barrows.each(checkArrows)})),barcontainers.on("click",".left-arrow-svg",-1,scrollContainer),barcontainers.on("click",".right-arrow-svg",1,scrollContainer)}(barcont
ainers)}return{init:function(instanceids){for(var i=instanceids.length-1;i>=0;i--)initialiseBar(instanceids[i])}}}));
//# sourceMappingURL=progressbar.min.js.map