diff --git a/amd/build/designer_section.min.js b/amd/build/designer_section.min.js index 622004f..b5e6ed5 100644 --- a/amd/build/designer_section.min.js +++ b/amd/build/designer_section.min.js @@ -5,6 +5,6 @@ * @copyright 2021 bdecent gmbh * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -define("format_designer/designer_section",["jquery","core/fragment","core/templates","core/loadingicon","core/ajax","core_course/actions","core_message/toggle_contact_button","theme_boost/popover","core/notification"],(function($,Fragment,Templates,Loadingicon,Ajax,Actions,Contact,Notification){var SELECTOR={ACTIVITYLI:"li.activity",SECTIONLI:"li.section",ACTIVITYACTION:"a.cm-edit-action",SECTIONACTIONMENU:".section_action_menu.designer-menu"};Y.use("moodle-course-coursebase",(function(){var courseformatselector=M.course.format.get_section_selector();courseformatselector&&(SELECTOR.SECTIONLI=courseformatselector)}));let DesignerSection=function(courseId,contextId,popupActivities,videoTime,issubpanel){var self=this;self.courseId=courseId,self.contextId=contextId,self.popupActivities=popupActivities,self.videoTime=videoTime,self.isSubpanel=issubpanel,$(".course-info-block .carousel .carousel-item:nth-child(1)").addClass("active"),$(".course-info-block #courseStaffinfoControls.carousel").addClass("active"),$("body").delegate(self.SectionController,"click",self.sectionLayoutaction.bind(this)),$("body").delegate(self.SectionSubmenuSwitcher,"click",self.sectionLayoutaction.bind(this)),$("body").delegate(self.RestrictInfo,"click",self.moduleHandler.bind(this)),$("body").delegate(self.sectionRestricted,"click",this.sectionRestrictHandler.bind(this)),$("body").delegate(self.fullDescription,"click",self.fullmodcontentHandler.bind(this)),$("body").delegate(self.trimDescription,"click",self.trimmodcontentHandler.bind(this)),$("body").delegate(self.goToURL,"click",self.redirectToModule.bind(this)),$("body").delegate(self.goToSectionURL,"click",self.redirectToSection.bind(this)),window.onhashchange=function(){self.expandSection()},this.expandSection(),$(".course-type-flow").length>0&&$(".collapse").on("show.bs.collapse",(function(){$(this).parents("li.section").addClass("stack-header-collapsing");var sectionid=$(this).parents("li.section").attr("id"),distance=document.getElementById(sectionid).offsetTop-document.body.scrollTop;setTimeout((()=>window.scroll(0,distance)),50)})).on("shown.bs.collapse",(function(){$(this).parents("li.section").removeClass("stack-header-collapsing")}));var contactModal=document.getElementsByClassName("toggle-contact-button");Array.from(contactModal).forEach((function(element){element.addEventListener("click",(function(e){e.preventDefault(),null!=e.currentTarget.dataset.userid&&Contact.enhance(e.currentTarget)}))})),$('.progress .progress-bar[data-toggle="popover"]').popover()};return DesignerSection.prototype.goToURL='.designer [data-action="go-to-url"]',DesignerSection.prototype.goToSectionURL='.designer [data-action="go-to-section-url"]',DesignerSection.prototype.SectionController=".designer #section-designer-action .dropdown-menu a",DesignerSection.prototype.SectionSubmenuSwitcher=".designer .section_action_menu .dropdown-subpanel a[data-value=section-designer-action] + .dropdown-menu a",DesignerSection.prototype.RestrictInfo=".designer .designer-section-content .call-action-block",DesignerSection.prototype.moduleBlock=".designer .designer-section-content li.activity",DesignerSection.prototype.loadingElement=".icon-loader-block",DesignerSection.prototype.sectionRestricted=".designer .availability-section-block .section-restricted-action",DesignerSection.prototype.fullDescription=".designer-section-content li .fullcontent-summary .mod-description-action",DesignerSection.prototype.trimDescription=".designer-section-content li .trim-summary .mod-description-action",DesignerSection.prototype.modules=null,DesignerSection.prototype.redirectToModule=function(event){let nodeName=event.target.nodeName,iscircle=event.target.closest("li.activity").classList.contains("circle-layout"),isDescription=event.target.classList.contains("mod-description-action"),isPadlock=event.target.classList.contains("fa-lock"),ispopupModule=event.target.closest("li.activity").classList.contains("popmodule"),isModHasURL=event.target.closest('li.activity div[data-action="go-to-url"]').getAttribute("data-url"),isCompletionButton=event.target.closest('button[data-action="toggle-manual-completion"]');if(nodeName in["a","button","form"]||document.body.classList.contains("editing")||iscircle||isDescription||isPadlock||ispopupModule||""==isModHasURL||isCompletionButton){if(ispopupModule&&!document.body.classList.contains("editing"))if(null===event.target.closest("button[data-action='toggle-manual-completion']")&&null===event.target.closest(".mod-description-action"))event.target.closest("li.activity").querySelector("a[href]").click();return null}let modurl=event.target.closest("[data-action=go-to-url]").getAttribute("data-url");return window.location.href=modurl,!0},DesignerSection.prototype.redirectToSection=function(event){let isPadlock=event.target.classList.contains("fa-lock");if(document.body.classList.contains("editing")||isPadlock)return null;var singlesection=event.target.closest("[data-action=go-to-section-url]");let sectionurl=singlesection.getAttribute("data-url"),sectiontarget="_self",target=singlesection.getAttribute("data-target");return target&&(sectiontarget=target),window.open(sectionurl,sectiontarget),!0},DesignerSection.prototype.expandSection=()=>{var sectionID=window.location.hash;if(sectionID){var id=sectionID.substring(1),section=document.getElementById(id);if(section){var title=section.querySelector(".section-header-content");title&&(title.classList.remove("collapsed"),title.setAttribute("aria-expanded",!0));var content=section.querySelector(".content");content&&content.classList.add("show"),null!==document.getElementById("section-course-accordion")&&(document.getElementById("section-head-0").classList.add("collapsed"),document.getElementById("section-content-0").classList.remove("show")),section.scrollIntoView()}}},DesignerSection.prototype.fullmodcontentHandler=function(event){var THIS=$(event.currentTarget);let fullContent=$(THIS).closest("li.activity").find(".fullcontent-summary"),trimcontent=$(THIS).closest("li.activity").find(".trim-summary");trimcontent.hasClass("summary-hide")&&(trimcontent.removeClass("summary-hide"),fullContent.addClass("summary-hide"))},DesignerSection.prototype.trimmodcontentHandler=function(event){var THIS=$(event.currentTarget);let fullContent=$(THIS).closest("li.activity").find(".fullcontent-summary"),trimcontent=$(THIS).closest("li.activity").find(".trim-summary");fullContent.hasClass("summary-hide")&&(fullContent.removeClass("summary-hide"),trimcontent.addClass("summary-hide"))},DesignerSection.prototype.sectionRestrictHandler=function(event){var sectionRestrictInfo=$(event.currentTarget).prev();sectionRestrictInfo&&(sectionRestrictInfo.hasClass("show")?sectionRestrictInfo.removeClass("show"):sectionRestrictInfo.addClass("show"))},DesignerSection.prototype.moduleHandler=function(event){event.preventDefault();var restrictBlock=$(event.currentTarget).parents(".restrict-block");restrictBlock.length&&(restrictBlock.hasClass("show")?restrictBlock.removeClass("show"):restrictBlock.addClass("show"))},DesignerSection.prototype.updateVideoTimeInstance=function(sectionId){var sectionVideotimes="body "+("#"+sectionId)+" .activity.videotime";0!=$(sectionVideotimes).length&&$(sectionVideotimes).each(function(index,module){this.CreateInstance(module)}.bind(this))},DesignerSection.prototype.CreateInstance=function(module){if($(module).find(".instancename").length&&($(module).find(".vimeo-embed").length||$(module).find(".video-js").length)){var args={cmid:module.getAttribute("data-id")};Ajax.call([{methodname:"format_designer_get_videotime_instace",args:args}],!0)[0].then((function(data){var template=JSON.parse(data);if("videojs"==template.playertype)var uniqueid=$(module).find(".video-js").first().attr("id").replace("vimeo-embed-","");else uniqueid=$(module).find(".vimeo-embed").first().attr("id").replace("vimeo-embed-","");template.uniqueid=uniqueid,Templates.render(template.templatename,template).then((function(html,js){return Templates.runTemplateJS(js),!0})).fail(Notification.exception)}))}},DesignerSection.prototype.sectionLayoutaction=function(event){event.preventDefault();var self=this;let sectionId=event.target.closest("li.section").getAttribute("id");var sectionid=event.target.closest("li.section").getAttribute("data-id"),sectionitem=document.getElementById(sectionId),iconBlock="#"+sectionId+" "+self.loadingElement,layout=$(event.currentTarget).data("value"),layouttext=$(event.currentTarget).text();$(event.target).parents(".dropdown").find(".btn").html(layouttext),$(event.target).parents(".dropdown").find(".btn").val(layout),$(event.target).parent().find("a.dropdown-item").each((function(){$(this).removeClass("active")})),$(event.target).addClass("active");let dataid=event.target.closest("li.section").getAttribute("data-id");var args={courseid:self.courseId,sectionid:dataid,options:[{name:$(event.currentTarget).data("option"),value:layout}]},promises=Ajax.call([{methodname:"format_designer_set_section_options",args:args}],!0);$.when.apply($,promises).done((function(){if(self.isSubpanel){Fragment.loadFragment("core_courseformat","section",self.contextId,{id:sectionid,courseid:self.courseId}).then(((html,js)=>{Templates.replaceNode(sectionitem,html,js)})).catch()}else{Actions.refreshSection("#"+sectionId,dataid,0).then((()=>"")).catch()}})),Loadingicon.addIconToContainerRemoveOnCompletion(iconBlock,promises),setTimeout((function(){self.videoTime&&self.updateVideoTimeInstance(sectionId)}),2e3)},{init:function(courseId,contextId,popupActivities,videoTime,issubpanel){return new DesignerSection(courseId,contextId,popupActivities,videoTime,issubpanel)}}})); +define("format_designer/designer_section",["jquery","core/fragment","core/templates","core/loadingicon","core/ajax","core_course/actions","core_message/toggle_contact_button","theme_boost/popover","core/notification"],(function($,Fragment,Templates,Loadingicon,Ajax,Actions,Contact,Notification){var SELECTOR={ACTIVITYLI:"li.activity",SECTIONLI:"li.section",ACTIVITYACTION:"a.cm-edit-action",SECTIONACTIONMENU:".section_action_menu.designer-menu"};Y.use("moodle-course-coursebase",(function(){var courseformatselector=M.course.format.get_section_selector();courseformatselector&&(SELECTOR.SECTIONLI=courseformatselector)}));let DesignerSection=function(courseId,contextId,popupActivities,videoTime,issubpanel,sectionreturn){var self=this;self.courseId=courseId,self.contextId=contextId,self.popupActivities=popupActivities,self.videoTime=videoTime,self.isSubpanel=issubpanel,self.sectionReturn=sectionreturn,$(".course-info-block .carousel .carousel-item:nth-child(1)").addClass("active"),$(".course-info-block #courseStaffinfoControls.carousel").addClass("active"),$("body").delegate(self.SectionController,"click",self.sectionLayoutaction.bind(this)),$("body").delegate(self.SectionSubmenuSwitcher,"click",self.sectionLayoutaction.bind(this)),$("body").delegate(self.RestrictInfo,"click",self.moduleHandler.bind(this)),$("body").delegate(self.sectionRestricted,"click",this.sectionRestrictHandler.bind(this)),$("body").delegate(self.fullDescription,"click",self.fullmodcontentHandler.bind(this)),$("body").delegate(self.trimDescription,"click",self.trimmodcontentHandler.bind(this)),$("body").delegate(self.goToURL,"click",self.redirectToModule.bind(this)),$("body").delegate(self.goToSectionURL,"click",self.redirectToSection.bind(this)),window.onhashchange=function(){self.expandSection()},this.expandSection(),$(".course-type-flow").length>0&&$(".collapse").on("show.bs.collapse",(function(){$(this).parents("li.section").addClass("stack-header-collapsing");var sectionid=$(this).parents("li.section").attr("id"),distance=document.getElementById(sectionid).offsetTop-document.body.scrollTop;setTimeout((()=>window.scroll(0,distance)),50)})).on("shown.bs.collapse",(function(){$(this).parents("li.section").removeClass("stack-header-collapsing")}));var contactModal=document.getElementsByClassName("toggle-contact-button");Array.from(contactModal).forEach((function(element){element.addEventListener("click",(function(e){e.preventDefault(),null!=e.currentTarget.dataset.userid&&Contact.enhance(e.currentTarget)}))})),$('.progress .progress-bar[data-toggle="popover"]').popover()};return DesignerSection.prototype.goToURL='.designer [data-action="go-to-url"]',DesignerSection.prototype.goToSectionURL='.designer [data-action="go-to-section-url"]',DesignerSection.prototype.SectionController=".designer #section-designer-action .dropdown-menu a",DesignerSection.prototype.SectionSubmenuSwitcher=".designer .section_action_menu .dropdown-subpanel a[data-value=section-designer-action] + .dropdown-menu a",DesignerSection.prototype.RestrictInfo=".designer .designer-section-content .call-action-block",DesignerSection.prototype.moduleBlock=".designer .designer-section-content li.activity",DesignerSection.prototype.loadingElement=".icon-loader-block",DesignerSection.prototype.sectionRestricted=".designer .availability-section-block .section-restricted-action",DesignerSection.prototype.fullDescription=".designer-section-content li .fullcontent-summary .mod-description-action",DesignerSection.prototype.trimDescription=".designer-section-content li .trim-summary .mod-description-action",DesignerSection.prototype.modules=null,DesignerSection.prototype.redirectToModule=function(event){let nodeName=event.target.nodeName,iscircle=event.target.closest("li.activity").classList.contains("circle-layout"),isDescription=event.target.classList.contains("mod-description-action"),isPadlock=event.target.classList.contains("fa-lock"),ispopupModule=event.target.closest("li.activity").classList.contains("popmodule"),isModHasURL=event.target.closest('li.activity div[data-action="go-to-url"]').getAttribute("data-url"),isCompletionButton=event.target.closest('button[data-action="toggle-manual-completion"]');if(nodeName in["a","button","form"]||document.body.classList.contains("editing")||iscircle||isDescription||isPadlock||ispopupModule||""==isModHasURL||isCompletionButton){if(ispopupModule&&!document.body.classList.contains("editing"))if(null===event.target.closest("button[data-action='toggle-manual-completion']")&&null===event.target.closest(".mod-description-action"))event.target.closest("li.activity").querySelector("a[href]").click();return null}let modurl=event.target.closest("[data-action=go-to-url]").getAttribute("data-url");return window.location.href=modurl,!0},DesignerSection.prototype.redirectToSection=function(event){let isPadlock=event.target.classList.contains("fa-lock");if(document.body.classList.contains("editing")||isPadlock)return null;var singlesection=event.target.closest("[data-action=go-to-section-url]");let sectionurl=singlesection.getAttribute("data-url"),sectiontarget="_self",target=singlesection.getAttribute("data-target");return target&&(sectiontarget=target),window.open(sectionurl,sectiontarget),!0},DesignerSection.prototype.expandSection=()=>{var sectionID=window.location.hash;if(sectionID){var id=sectionID.substring(1),section=document.getElementById(id);if(section){var title=section.querySelector(".section-header-content");title&&(title.classList.remove("collapsed"),title.setAttribute("aria-expanded",!0));var content=section.querySelector(".content");content&&content.classList.add("show"),null!==document.getElementById("section-course-accordion")&&(document.getElementById("section-head-0").classList.add("collapsed"),document.getElementById("section-content-0").classList.remove("show")),section.scrollIntoView()}}},DesignerSection.prototype.fullmodcontentHandler=function(event){var THIS=$(event.currentTarget);let fullContent=$(THIS).closest("li.activity").find(".fullcontent-summary"),trimcontent=$(THIS).closest("li.activity").find(".trim-summary");trimcontent.hasClass("summary-hide")&&(trimcontent.removeClass("summary-hide"),fullContent.addClass("summary-hide"))},DesignerSection.prototype.trimmodcontentHandler=function(event){var THIS=$(event.currentTarget);let fullContent=$(THIS).closest("li.activity").find(".fullcontent-summary"),trimcontent=$(THIS).closest("li.activity").find(".trim-summary");fullContent.hasClass("summary-hide")&&(fullContent.removeClass("summary-hide"),trimcontent.addClass("summary-hide"))},DesignerSection.prototype.sectionRestrictHandler=function(event){var sectionRestrictInfo=$(event.currentTarget).prev();sectionRestrictInfo&&(sectionRestrictInfo.hasClass("show")?sectionRestrictInfo.removeClass("show"):sectionRestrictInfo.addClass("show"))},DesignerSection.prototype.moduleHandler=function(event){event.preventDefault();var restrictBlock=$(event.currentTarget).parents(".restrict-block");restrictBlock.length&&(restrictBlock.hasClass("show")?restrictBlock.removeClass("show"):restrictBlock.addClass("show"))},DesignerSection.prototype.updateVideoTimeInstance=function(sectionId){var sectionVideotimes="body "+("#"+sectionId)+" .activity.videotime";0!=$(sectionVideotimes).length&&$(sectionVideotimes).each(function(index,module){this.CreateInstance(module)}.bind(this))},DesignerSection.prototype.CreateInstance=function(module){if($(module).find(".instancename").length&&($(module).find(".vimeo-embed").length||$(module).find(".video-js").length)){var args={cmid:module.getAttribute("data-id")};Ajax.call([{methodname:"format_designer_get_videotime_instace",args:args}],!0)[0].then((function(data){var template=JSON.parse(data);if("videojs"==template.playertype)var uniqueid=$(module).find(".video-js").first().attr("id").replace("vimeo-embed-","");else uniqueid=$(module).find(".vimeo-embed").first().attr("id").replace("vimeo-embed-","");template.uniqueid=uniqueid,Templates.render(template.templatename,template).then((function(html,js){return Templates.runTemplateJS(js),!0})).fail(Notification.exception)}))}},DesignerSection.prototype.sectionLayoutaction=function(event){event.preventDefault();var self=this;let sectionId=event.target.closest("li.section").getAttribute("id");var sectionid=event.target.closest("li.section").getAttribute("data-id"),sectionitem=document.getElementById(sectionId),iconBlock="#"+sectionId+" "+self.loadingElement,layout=$(event.currentTarget).data("value"),layouttext=$(event.currentTarget).text();$(event.target).parents(".dropdown").find(".btn").html(layouttext),$(event.target).parents(".dropdown").find(".btn").val(layout),$(event.target).parent().find("a.dropdown-item").each((function(){$(this).removeClass("active")})),$(event.target).addClass("active");let dataid=event.target.closest("li.section").getAttribute("data-id");var args={courseid:self.courseId,sectionid:dataid,options:[{name:$(event.currentTarget).data("option"),value:layout}]},promises=Ajax.call([{methodname:"format_designer_set_section_options",args:args}],!0);$.when.apply($,promises).done((function(){if(self.isSubpanel){Fragment.loadFragment("core_courseformat","section",self.contextId,{id:sectionid,courseid:self.courseId,sr:self.sectionReturn}).then(((html,js)=>{Templates.replaceNode(sectionitem,html,js)})).catch()}else{Actions.refreshSection("#"+sectionId,dataid,0).then((()=>"")).catch()}})),Loadingicon.addIconToContainerRemoveOnCompletion(iconBlock,promises),setTimeout((function(){self.videoTime&&self.updateVideoTimeInstance(sectionId)}),2e3)},{init:function(courseId,contextId,popupActivities,videoTime,issubpanel,sectionreturn){return new DesignerSection(courseId,contextId,popupActivities,videoTime,issubpanel,sectionreturn)}}})); //# sourceMappingURL=designer_section.min.js.map \ No newline at end of file diff --git a/amd/build/designer_section.min.js.map b/amd/build/designer_section.min.js.map index b342ff8..695033b 100644 --- a/amd/build/designer_section.min.js.map +++ b/amd/build/designer_section.min.js.map @@ -1 +1 @@ -{"version":3,"file":"designer_section.min.js","sources":["../src/designer_section.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n\n/**\n * Implemented designer format js.\n *\n * @module format_designer/designer_section\n * @copyright 2021 bdecent gmbh \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n define(['jquery', 'core/fragment', 'core/templates', 'core/loadingicon', 'core/ajax',\n 'core_course/actions', 'core_message/toggle_contact_button', 'theme_boost/popover', 'core/notification',],\n function($, Fragment, Templates, Loadingicon, Ajax, Actions, Contact, Notification) {\n\n var SELECTOR = {\n ACTIVITYLI: 'li.activity',\n SECTIONLI: 'li.section',\n ACTIVITYACTION: 'a.cm-edit-action',\n SECTIONACTIONMENU: '.section_action_menu.designer-menu',\n };\n\n Y.use('moodle-course-coursebase', function() {\n var courseformatselector = M.course.format.get_section_selector();\n if (courseformatselector) {\n SELECTOR.SECTIONLI = courseformatselector;\n }\n });\n\n\n /**\n * Control designer format action\n * @param {int} courseId\n * @param {int} contextId\n * @param {array} popupActivities\n * @param {bool} videoTime\n * @param {bool} issubpanel\n */\n let DesignerSection = function(courseId, contextId, popupActivities, videoTime, issubpanel) {\n var self = this;\n self.courseId = courseId;\n self.contextId = contextId;\n self.popupActivities = popupActivities;\n self.videoTime = videoTime;\n self.isSubpanel = issubpanel;\n\n $(\".course-info-block .carousel .carousel-item:nth-child(1)\").addClass('active');\n $(\".course-info-block #courseStaffinfoControls.carousel\").addClass('active');\n\n $('body').delegate(self.SectionController, 'click', self.sectionLayoutaction.bind(this));\n $('body').delegate(self.SectionSubmenuSwitcher, 'click', self.sectionLayoutaction.bind(this));\n\n $(\"body\").delegate(self.RestrictInfo, \"click\", self.moduleHandler.bind(this));\n $(\"body\").delegate(self.sectionRestricted, \"click\", this.sectionRestrictHandler.bind(this));\n $('body').delegate(self.fullDescription, \"click\", self.fullmodcontentHandler.bind(this));\n $('body').delegate(self.trimDescription, \"click\", self.trimmodcontentHandler.bind(this));\n $('body').delegate(self.goToURL, \"click\", self.redirectToModule.bind(this));\n $('body').delegate(self.goToSectionURL, \"click\", self.redirectToSection.bind(this));\n window.onhashchange = function() {\n self.expandSection();\n };\n this.expandSection();\n\n if ($('.course-type-flow').length > 0) {\n $('.collapse').on('show.bs.collapse', function() {\n $(this).parents('li.section').addClass('stack-header-collapsing');\n var sectionid = $(this).parents('li.section').attr('id');\n var section = document.getElementById(sectionid);\n var distance = section.offsetTop - document.body.scrollTop;\n setTimeout(() => window.scroll(0, distance), 50);\n }).on('shown.bs.collapse', function() {\n $(this).parents('li.section').removeClass('stack-header-collapsing');\n });\n }\n\n var contactModal = document.getElementsByClassName('toggle-contact-button');\n Array.from(contactModal).forEach(function(element) {\n element.addEventListener('click', function(e) {\n e.preventDefault();\n if (e.currentTarget.dataset.userid != undefined) {\n Contact.enhance(e.currentTarget);\n }\n });\n });\n\n $('.progress .progress-bar[data-toggle=\"popover\"]').popover();\n\n };\n\n /**\n * Selector section controller.\n */\n DesignerSection.prototype.goToURL = '.designer [data-action=\"go-to-url\"]';\n\n DesignerSection.prototype.goToSectionURL = '.designer [data-action=\"go-to-section-url\"]';\n\n DesignerSection.prototype.SectionController = \".designer #section-designer-action .dropdown-menu a\";\n\n DesignerSection.prototype.SectionSubmenuSwitcher\n = \".designer .section_action_menu .dropdown-subpanel a[data-value=section-designer-action] + .dropdown-menu a\";\n\n DesignerSection.prototype.RestrictInfo = \".designer .designer-section-content .call-action-block\";\n\n DesignerSection.prototype.moduleBlock = \".designer .designer-section-content li.activity\";\n\n DesignerSection.prototype.loadingElement = \".icon-loader-block\";\n\n DesignerSection.prototype.sectionRestricted = \".designer .availability-section-block .section-restricted-action\";\n\n DesignerSection.prototype.fullDescription = \".designer-section-content li .fullcontent-summary .mod-description-action\";\n\n DesignerSection.prototype.trimDescription = \".designer-section-content li .trim-summary .mod-description-action\";\n\n DesignerSection.prototype.modules = null;\n\n DesignerSection.prototype.redirectToModule = function(event) {\n let nodeName = event.target.nodeName;\n let preventionNodes = ['a', 'button', 'form'];\n let iscircle = event.target.closest('li.activity').classList.contains('circle-layout');\n let isDescription = event.target.classList.contains('mod-description-action');\n let isPadlock = event.target.classList.contains('fa-lock');\n let ispopupModule = event.target.closest('li.activity').classList.contains('popmodule');\n let isModHasURL = event.target.closest('li.activity div[data-action=\"go-to-url\"]').getAttribute('data-url');\n let isCompletionButton = event.target.closest('button[data-action=\"toggle-manual-completion\"]');\n if ((nodeName in preventionNodes)\n || document.body.classList.contains('editing') || iscircle || isDescription || isPadlock || ispopupModule\n || isModHasURL == '' || isCompletionButton) {\n if (ispopupModule && !document.body.classList.contains('editing')) {\n if (event.target.closest(\"button[data-action='toggle-manual-completion']\") === null &&\n event.target.closest(\".mod-description-action\") === null) {\n var li = event.target.closest('li.activity');\n li.querySelector('a[href]').click();\n }\n }\n return null;\n }\n var card = event.target.closest(\"[data-action=go-to-url]\");\n let modurl = card.getAttribute('data-url');\n window.location.href = modurl;\n return true;\n };\n\n DesignerSection.prototype.redirectToSection = function(event) {\n let isPadlock = event.target.classList.contains('fa-lock');\n if (document.body.classList.contains('editing') || isPadlock) {\n return null;\n }\n var singlesection = event.target.closest(\"[data-action=go-to-section-url]\");\n let sectionurl = singlesection.getAttribute('data-url');\n let sectiontarget = \"_self\";\n let target = singlesection.getAttribute('data-target');\n if (target) {\n sectiontarget = target;\n }\n window.open(sectionurl, sectiontarget);\n return true;\n };\n\n DesignerSection.prototype.expandSection = () => {\n var sectionID = window.location.hash;\n if (sectionID) {\n var id = sectionID.substring(1);\n var section = document.getElementById(id);\n if (section) {\n var title = section.querySelector('.section-header-content');\n if (title) {\n title.classList.remove('collapsed');\n title.setAttribute('aria-expanded', true);\n }\n var content = section.querySelector('.content');\n if (content) {\n content.classList.add('show');\n }\n if (document.getElementById('section-course-accordion') !== null) {\n document.getElementById('section-head-0').classList.add('collapsed');\n document.getElementById('section-content-0').classList.remove('show');\n }\n section.scrollIntoView();\n }\n }\n };\n\n DesignerSection.prototype.fullmodcontentHandler = function(event) {\n var THIS = $(event.currentTarget);\n let fullContent = $(THIS).closest('li.activity').find('.fullcontent-summary');\n let trimcontent = $(THIS).closest('li.activity').find('.trim-summary');\n if (trimcontent.hasClass('summary-hide')) {\n trimcontent.removeClass('summary-hide');\n fullContent.addClass('summary-hide');\n }\n };\n\n DesignerSection.prototype.trimmodcontentHandler = function(event) {\n var THIS = $(event.currentTarget);\n let fullContent = $(THIS).closest('li.activity').find('.fullcontent-summary');\n let trimcontent = $(THIS).closest('li.activity').find('.trim-summary');\n if (fullContent.hasClass('summary-hide')) {\n fullContent.removeClass('summary-hide');\n trimcontent.addClass('summary-hide');\n }\n };\n\n DesignerSection.prototype.sectionRestrictHandler = function(event) {\n var sectionRestrictInfo = $(event.currentTarget).prev();\n if (sectionRestrictInfo) {\n if (!sectionRestrictInfo.hasClass('show')) {\n sectionRestrictInfo.addClass('show');\n } else {\n sectionRestrictInfo.removeClass('show');\n }\n }\n };\n\n DesignerSection.prototype.moduleHandler = function(event) {\n event.preventDefault();\n var restrictBlock = $(event.currentTarget).parents('.restrict-block');\n if (restrictBlock.length) {\n if (!restrictBlock.hasClass('show')) {\n restrictBlock.addClass('show');\n } else {\n restrictBlock.removeClass('show');\n }\n }\n };\n\n DesignerSection.prototype.updateVideoTimeInstance = function(sectionId) {\n var section = \"#\" + sectionId;\n var sectionVideotimes = \"body \"+ section + \" .activity.videotime\";\n if ($(sectionVideotimes).length == 0) {\n return;\n }\n $(sectionVideotimes).each(function(index, module) {\n this.CreateInstance(module);\n }.bind(this));\n };\n\n DesignerSection.prototype.CreateInstance = function (module) {\n if (\n $(module).find('.instancename').length\n && ($(module).find('.vimeo-embed').length\n || $(module).find('.video-js').length)\n ) {\n var cmId = module.getAttribute(\"data-id\");\n var args = {cmid : cmId};\n // Get module instance.\n var promises = Ajax.call([{\n methodname: 'format_designer_get_videotime_instace',\n args: args\n }], true);\n promises[0].then(function(data) {\n var template = JSON.parse(data);\n if (template.playertype == 'videojs') {\n var uniqueid = $(module).find('.video-js').first().attr('id').replace('vimeo-embed-', '');\n } else {\n var uniqueid = $(module).find('.vimeo-embed').first().attr('id').replace('vimeo-embed-', '');\n }\n template.uniqueid = uniqueid;\n Templates.render(template.templatename, template).then(function(html, js) {\n Templates.runTemplateJS(js);\n return true;\n }).fail(Notification.exception);\n });\n }\n };\n\n /**\n * Implementaion swith the section layout.\n * @param {object} event\n */\n DesignerSection.prototype.sectionLayoutaction = function(event) {\n event.preventDefault();\n var self = this;\n let sectionId = event.target.closest('li.section').getAttribute('id');\n var sectionid = event.target.closest('li.section').getAttribute('data-id');\n var sectionitem = document.getElementById(sectionId);\n var iconBlock = \"#\" + sectionId + \" \" + self.loadingElement;\n var layout = $(event.currentTarget).data('value');\n var layouttext = $(event.currentTarget).text();\n $(event.target).parents(\".dropdown\").find(\".btn\").html(layouttext);\n $(event.target).parents(\".dropdown\").find(\".btn\").val(layout);\n $(event.target).parent().find(\"a.dropdown-item\").each(function() {\n $(this).removeClass('active');\n });\n $(event.target).addClass('active');\n let dataid = event.target.closest('li.section').getAttribute('data-id');\n var args = {\n courseid: self.courseId,\n sectionid: dataid,\n options: [{name: $(event.currentTarget).data('option'), value: layout}]\n };\n var promises = Ajax.call([{\n methodname: 'format_designer_set_section_options',\n args: args\n }], true);\n $.when.apply($, promises)\n .done(function() {\n if (self.isSubpanel) {\n const promise = Fragment.loadFragment(\n 'core_courseformat',\n 'section',\n self.contextId,\n {\n id: sectionid,\n courseid: self.courseId,\n }\n );\n promise.then((html, js) => {\n Templates.replaceNode(sectionitem, html, js);\n }).catch();\n } else {\n const sectionpromise = Actions.refreshSection('#' + sectionId, dataid, 0);\n sectionpromise.then(() => {\n return '';\n }).catch();\n }\n });\n Loadingicon.addIconToContainerRemoveOnCompletion(iconBlock, promises);\n // If videotime exist update the module.\n setTimeout(function() {\n if (self.videoTime) {\n self.updateVideoTimeInstance(sectionId);\n }\n }, 2000);\n };\n\n return {\n init: function(courseId, contextId, popupActivities, videoTime, issubpanel) {\n return new DesignerSection(courseId, contextId, popupActivities, videoTime, issubpanel);\n }\n };\n});\n"],"names":["define","$","Fragment","Templates","Loadingicon","Ajax","Actions","Contact","Notification","SELECTOR","ACTIVITYLI","SECTIONLI","ACTIVITYACTION","SECTIONACTIONMENU","Y","use","courseformatselector","M","course","format","get_section_selector","DesignerSection","courseId","contextId","popupActivities","videoTime","issubpanel","self","this","isSubpanel","addClass","delegate","SectionController","sectionLayoutaction","bind","SectionSubmenuSwitcher","RestrictInfo","moduleHandler","sectionRestricted","sectionRestrictHandler","fullDescription","fullmodcontentHandler","trimDescription","trimmodcontentHandler","goToURL","redirectToModule","goToSectionURL","redirectToSection","window","onhashchange","expandSection","length","on","parents","sectionid","attr","distance","document","getElementById","offsetTop","body","scrollTop","setTimeout","scroll","removeClass","contactModal","getElementsByClassName","Array","from","forEach","element","addEventListener","e","preventDefault","undefined","currentTarget","dataset","userid","enhance","popover","prototype","moduleBlock","loadingElement","modules","event","nodeName","target","iscircle","closest","classList","contains","isDescription","isPadlock","ispopupModule","isModHasURL","getAttribute","isCompletionButton","querySelector","click","modurl","location","href","singlesection","sectionurl","sectiontarget","open","sectionID","hash","id","substring","section","title","remove","setAttribute","content","add","scrollIntoView","THIS","fullContent","find","trimcontent","hasClass","sectionRestrictInfo","prev","restrictBlock","updateVideoTimeInstance","sectionId","sectionVideotimes","each","index","module","CreateInstance","args","cmid","call","methodname","then","data","template","JSON","parse","playertype","uniqueid","first","replace","render","templatename","html","js","runTemplateJS","fail","exception","sectionitem","iconBlock","layout","layouttext","text","val","parent","dataid","courseid","options","name","value","promises","when","apply","done","loadFragment","replaceNode","catch","refreshSection","addIconToContainerRemoveOnCompletion","init"],"mappings":";;;;;;;AAuBCA,0CAAO,CAAC,SAAU,gBAAiB,iBAAkB,mBAAoB,YACtE,sBAAuB,qCAAsC,sBAAuB,sBACvF,SAASC,EAAGC,SAAUC,UAAWC,YAAaC,KAAMC,QAASC,QAASC,kBAE/DC,SAAW,CACXC,WAAY,cACZC,UAAW,aACXC,eAAgB,mBAChBC,kBAAmB,sCAGvBC,EAAEC,IAAI,4BAA4B,eAC1BC,qBAAuBC,EAAEC,OAAOC,OAAOC,uBACvCJ,uBACAP,SAASE,UAAYK,6BAazBK,gBAAkB,SAASC,SAAUC,UAAWC,gBAAiBC,UAAWC,gBACxEC,KAAOC,KACXD,KAAKL,SAAWA,SAChBK,KAAKJ,UAAYA,UACjBI,KAAKH,gBAAkBA,gBACvBG,KAAKF,UAAYA,UACjBE,KAAKE,WAAaH,WAElBzB,EAAE,4DAA4D6B,SAAS,UACvE7B,EAAE,wDAAwD6B,SAAS,UAEnE7B,EAAE,QAAQ8B,SAASJ,KAAKK,kBAAmB,QAASL,KAAKM,oBAAoBC,KAAKN,OAClF3B,EAAE,QAAQ8B,SAASJ,KAAKQ,uBAAwB,QAASR,KAAKM,oBAAoBC,KAAKN,OAEvF3B,EAAE,QAAQ8B,SAASJ,KAAKS,aAAc,QAAST,KAAKU,cAAcH,KAAKN,OACvE3B,EAAE,QAAQ8B,SAASJ,KAAKW,kBAAmB,QAASV,KAAKW,uBAAuBL,KAAKN,OACrF3B,EAAE,QAAQ8B,SAASJ,KAAKa,gBAAiB,QAASb,KAAKc,sBAAsBP,KAAKN,OAClF3B,EAAE,QAAQ8B,SAASJ,KAAKe,gBAAiB,QAASf,KA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AAQwE,SAASvC,KAAK,mBAAmBS,MAAK,WAClD/H,EAAE2B,MAAMoC,YAAY,aAExB/D,EAAEmF,MAAME,QAAQxD,SAAS,cACrBiI,OAAS3E,MAAME,OAAOE,QAAQ,cAAcO,aAAa,eACzDqC,KAAO,CACP4B,SAAUrI,KAAKL,SACfgC,UAAWyG,OACXE,QAAS,CAAC,CAACC,KAAMjK,EAAEmF,MAAMT,eAAe8D,KAAK,UAAW0B,MAAOT,UAE/DU,SAAW/J,KAAKiI,KAAK,CAAC,CAClBC,WAAY,sCACZH,KAAMA,QACN,GACJnI,EAAEoK,KAAKC,MAAMrK,EAAGmK,UACfG,MAAK,cACE5I,KAAKE,WAAY,CACD3B,SAASsK,aACrB,oBACA,UACA7I,KAAKJ,UACL,CACIqF,GAAItD,UACJ0G,SAAUrI,KAAKL,WAGfkH,MAAK,CAACW,KAAMC,MAChBjJ,UAAUsK,YAAYjB,YAAaL,KAAMC,OAC1CsB,YACA,CACoBpK,QAAQqK,eAAe,IAAM7C,UAAWiC,OAAQ,GACxDvB,MAAK,IACT,KACRkC,YAGftK,YAAYwK,qCAAqCnB,UAAWW,UAE5DtG,YAAW,WACHnC,KAAKF,WACLE,KAAKkG,wBAAwBC,aAElC,MAGA,CACH+C,KAAM,SAASvJ,SAAUC,UAAWC,gBAAiBC,UAAWC,mBACrD,IAAIL,gBAAgBC,SAAUC,UAAWC,gBAAiBC,UAAWC"} \ No newline at end of file +{"version":3,"file":"designer_section.min.js","sources":["../src/designer_section.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n\n/**\n * Implemented designer format js.\n *\n * @module format_designer/designer_section\n * @copyright 2021 bdecent gmbh \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n define(['jquery', 'core/fragment', 'core/templates', 'core/loadingicon', 'core/ajax',\n 'core_course/actions', 'core_message/toggle_contact_button', 'theme_boost/popover', 'core/notification',],\n function($, Fragment, Templates, Loadingicon, Ajax, Actions, Contact, Notification) {\n\n var SELECTOR = {\n ACTIVITYLI: 'li.activity',\n SECTIONLI: 'li.section',\n ACTIVITYACTION: 'a.cm-edit-action',\n SECTIONACTIONMENU: '.section_action_menu.designer-menu',\n };\n\n Y.use('moodle-course-coursebase', function() {\n var courseformatselector = M.course.format.get_section_selector();\n if (courseformatselector) {\n SELECTOR.SECTIONLI = courseformatselector;\n }\n });\n\n\n /**\n * Control designer format action\n * @param {int} courseId\n * @param {int} contextId\n * @param {array} popupActivities\n * @param {bool} videoTime\n * @param {bool} issubpanel\n */\n let DesignerSection = function(courseId, contextId, popupActivities, videoTime, issubpanel, sectionreturn) {\n var self = this;\n self.courseId = courseId;\n self.contextId = contextId;\n self.popupActivities = popupActivities;\n self.videoTime = videoTime;\n self.isSubpanel = issubpanel;\n self.sectionReturn = sectionreturn;\n\n $(\".course-info-block .carousel .carousel-item:nth-child(1)\").addClass('active');\n $(\".course-info-block #courseStaffinfoControls.carousel\").addClass('active');\n\n $('body').delegate(self.SectionController, 'click', self.sectionLayoutaction.bind(this));\n $('body').delegate(self.SectionSubmenuSwitcher, 'click', self.sectionLayoutaction.bind(this));\n\n $(\"body\").delegate(self.RestrictInfo, \"click\", self.moduleHandler.bind(this));\n $(\"body\").delegate(self.sectionRestricted, \"click\", this.sectionRestrictHandler.bind(this));\n $('body').delegate(self.fullDescription, \"click\", self.fullmodcontentHandler.bind(this));\n $('body').delegate(self.trimDescription, \"click\", self.trimmodcontentHandler.bind(this));\n $('body').delegate(self.goToURL, \"click\", self.redirectToModule.bind(this));\n $('body').delegate(self.goToSectionURL, \"click\", self.redirectToSection.bind(this));\n window.onhashchange = function() {\n self.expandSection();\n };\n this.expandSection();\n\n if ($('.course-type-flow').length > 0) {\n $('.collapse').on('show.bs.collapse', function() {\n $(this).parents('li.section').addClass('stack-header-collapsing');\n var sectionid = $(this).parents('li.section').attr('id');\n var section = document.getElementById(sectionid);\n var distance = section.offsetTop - document.body.scrollTop;\n setTimeout(() => window.scroll(0, distance), 50);\n }).on('shown.bs.collapse', function() {\n $(this).parents('li.section').removeClass('stack-header-collapsing');\n });\n }\n\n var contactModal = document.getElementsByClassName('toggle-contact-button');\n Array.from(contactModal).forEach(function(element) {\n element.addEventListener('click', function(e) {\n e.preventDefault();\n if (e.currentTarget.dataset.userid != undefined) {\n Contact.enhance(e.currentTarget);\n }\n });\n });\n\n $('.progress .progress-bar[data-toggle=\"popover\"]').popover();\n\n };\n\n /**\n * Selector section controller.\n */\n DesignerSection.prototype.goToURL = '.designer [data-action=\"go-to-url\"]';\n\n DesignerSection.prototype.goToSectionURL = '.designer [data-action=\"go-to-section-url\"]';\n\n DesignerSection.prototype.SectionController = \".designer #section-designer-action .dropdown-menu a\";\n\n DesignerSection.prototype.SectionSubmenuSwitcher\n = \".designer .section_action_menu .dropdown-subpanel a[data-value=section-designer-action] + .dropdown-menu a\";\n\n DesignerSection.prototype.RestrictInfo = \".designer .designer-section-content .call-action-block\";\n\n DesignerSection.prototype.moduleBlock = \".designer .designer-section-content li.activity\";\n\n DesignerSection.prototype.loadingElement = \".icon-loader-block\";\n\n DesignerSection.prototype.sectionRestricted = \".designer .availability-section-block .section-restricted-action\";\n\n DesignerSection.prototype.fullDescription = \".designer-section-content li .fullcontent-summary .mod-description-action\";\n\n DesignerSection.prototype.trimDescription = \".designer-section-content li .trim-summary .mod-description-action\";\n\n DesignerSection.prototype.modules = null;\n\n DesignerSection.prototype.redirectToModule = function(event) {\n let nodeName = event.target.nodeName;\n let preventionNodes = ['a', 'button', 'form'];\n let iscircle = event.target.closest('li.activity').classList.contains('circle-layout');\n let isDescription = event.target.classList.contains('mod-description-action');\n let isPadlock = event.target.classList.contains('fa-lock');\n let ispopupModule = event.target.closest('li.activity').classList.contains('popmodule');\n let isModHasURL = event.target.closest('li.activity div[data-action=\"go-to-url\"]').getAttribute('data-url');\n let isCompletionButton = event.target.closest('button[data-action=\"toggle-manual-completion\"]');\n if ((nodeName in preventionNodes)\n || document.body.classList.contains('editing') || iscircle || isDescription || isPadlock || ispopupModule\n || isModHasURL == '' || isCompletionButton) {\n if (ispopupModule && !document.body.classList.contains('editing')) {\n if (event.target.closest(\"button[data-action='toggle-manual-completion']\") === null &&\n event.target.closest(\".mod-description-action\") === null) {\n var li = event.target.closest('li.activity');\n li.querySelector('a[href]').click();\n }\n }\n return null;\n }\n var card = event.target.closest(\"[data-action=go-to-url]\");\n let modurl = card.getAttribute('data-url');\n window.location.href = modurl;\n return true;\n };\n\n DesignerSection.prototype.redirectToSection = function(event) {\n let isPadlock = event.target.classList.contains('fa-lock');\n if (document.body.classList.contains('editing') || isPadlock) {\n return null;\n }\n var singlesection = event.target.closest(\"[data-action=go-to-section-url]\");\n let sectionurl = singlesection.getAttribute('data-url');\n let sectiontarget = \"_self\";\n let target = singlesection.getAttribute('data-target');\n if (target) {\n sectiontarget = target;\n }\n window.open(sectionurl, sectiontarget);\n return true;\n };\n\n DesignerSection.prototype.expandSection = () => {\n var sectionID = window.location.hash;\n if (sectionID) {\n var id = sectionID.substring(1);\n var section = document.getElementById(id);\n if (section) {\n var title = section.querySelector('.section-header-content');\n if (title) {\n title.classList.remove('collapsed');\n title.setAttribute('aria-expanded', true);\n }\n var content = section.querySelector('.content');\n if (content) {\n content.classList.add('show');\n }\n if (document.getElementById('section-course-accordion') !== null) {\n document.getElementById('section-head-0').classList.add('collapsed');\n document.getElementById('section-content-0').classList.remove('show');\n }\n section.scrollIntoView();\n }\n }\n };\n\n DesignerSection.prototype.fullmodcontentHandler = function(event) {\n var THIS = $(event.currentTarget);\n let fullContent = $(THIS).closest('li.activity').find('.fullcontent-summary');\n let trimcontent = $(THIS).closest('li.activity').find('.trim-summary');\n if (trimcontent.hasClass('summary-hide')) {\n trimcontent.removeClass('summary-hide');\n fullContent.addClass('summary-hide');\n }\n };\n\n DesignerSection.prototype.trimmodcontentHandler = function(event) {\n var THIS = $(event.currentTarget);\n let fullContent = $(THIS).closest('li.activity').find('.fullcontent-summary');\n let trimcontent = $(THIS).closest('li.activity').find('.trim-summary');\n if (fullContent.hasClass('summary-hide')) {\n fullContent.removeClass('summary-hide');\n trimcontent.addClass('summary-hide');\n }\n };\n\n DesignerSection.prototype.sectionRestrictHandler = function(event) {\n var sectionRestrictInfo = $(event.currentTarget).prev();\n if (sectionRestrictInfo) {\n if (!sectionRestrictInfo.hasClass('show')) {\n sectionRestrictInfo.addClass('show');\n } else {\n sectionRestrictInfo.removeClass('show');\n }\n }\n };\n\n DesignerSection.prototype.moduleHandler = function(event) {\n event.preventDefault();\n var restrictBlock = $(event.currentTarget).parents('.restrict-block');\n if (restrictBlock.length) {\n if (!restrictBlock.hasClass('show')) {\n restrictBlock.addClass('show');\n } else {\n restrictBlock.removeClass('show');\n }\n }\n };\n\n DesignerSection.prototype.updateVideoTimeInstance = function(sectionId) {\n var section = \"#\" + sectionId;\n var sectionVideotimes = \"body \"+ section + \" .activity.videotime\";\n if ($(sectionVideotimes).length == 0) {\n return;\n }\n $(sectionVideotimes).each(function(index, module) {\n this.CreateInstance(module);\n }.bind(this));\n };\n\n DesignerSection.prototype.CreateInstance = function (module) {\n if (\n $(module).find('.instancename').length\n && ($(module).find('.vimeo-embed').length\n || $(module).find('.video-js').length)\n ) {\n var cmId = module.getAttribute(\"data-id\");\n var args = {cmid : cmId};\n // Get module instance.\n var promises = Ajax.call([{\n methodname: 'format_designer_get_videotime_instace',\n args: args\n }], true);\n promises[0].then(function(data) {\n var template = JSON.parse(data);\n if (template.playertype == 'videojs') {\n var uniqueid = $(module).find('.video-js').first().attr('id').replace('vimeo-embed-', '');\n } else {\n var uniqueid = $(module).find('.vimeo-embed').first().attr('id').replace('vimeo-embed-', '');\n }\n template.uniqueid = uniqueid;\n Templates.render(template.templatename, template).then(function(html, js) {\n Templates.runTemplateJS(js);\n return true;\n }).fail(Notification.exception);\n });\n }\n };\n\n /**\n * Implementaion swith the section layout.\n * @param {object} event\n */\n DesignerSection.prototype.sectionLayoutaction = function(event) {\n event.preventDefault();\n var self = this;\n let sectionId = event.target.closest('li.section').getAttribute('id');\n var sectionid = event.target.closest('li.section').getAttribute('data-id');\n var sectionitem = document.getElementById(sectionId);\n var iconBlock = \"#\" + sectionId + \" \" + self.loadingElement;\n var layout = $(event.currentTarget).data('value');\n var layouttext = $(event.currentTarget).text();\n $(event.target).parents(\".dropdown\").find(\".btn\").html(layouttext);\n $(event.target).parents(\".dropdown\").find(\".btn\").val(layout);\n $(event.target).parent().find(\"a.dropdown-item\").each(function() {\n $(this).removeClass('active');\n });\n $(event.target).addClass('active');\n let dataid = event.target.closest('li.section').getAttribute('data-id');\n var args = {\n courseid: self.courseId,\n sectionid: dataid,\n options: [{name: $(event.currentTarget).data('option'), value: layout}]\n };\n var promises = Ajax.call([{\n methodname: 'format_designer_set_section_options',\n args: args\n }], true);\n $.when.apply($, promises)\n .done(function() {\n if (self.isSubpanel) {\n const promise = Fragment.loadFragment(\n 'core_courseformat',\n 'section',\n self.contextId,\n {\n id: sectionid,\n courseid: self.courseId,\n sr: self.sectionReturn,\n }\n );\n promise.then((html, js) => {\n Templates.replaceNode(sectionitem, html, js);\n }).catch();\n } else {\n const sectionpromise = Actions.refreshSection('#' + sectionId, dataid, 0);\n sectionpromise.then(() => {\n return '';\n }).catch();\n }\n });\n Loadingicon.addIconToContainerRemoveOnCompletion(iconBlock, promises);\n // If videotime exist update the module.\n setTimeout(function() {\n if (self.videoTime) {\n self.updateVideoTimeInstance(sectionId);\n }\n }, 2000);\n };\n\n return {\n init: function(courseId, contextId, popupActivities, videoTime, issubpanel, sectionreturn) {\n return new DesignerSection(courseId, contextId, popupActivities, videoTime, issubpanel, sectionreturn);\n }\n };\n});\n"],"names":["define","$","Fragment","Templates","Loadingicon","Ajax","Actions","Contact","Notification","SELECTOR","ACTIVITYLI","SECTIONLI","ACTIVITYACTION","SECTIONACTIONMENU","Y","use","courseformatselector","M","course","format","get_section_selector","DesignerSection","courseId","contextId","popupActivities","videoTime","issubpanel","sectionreturn","self","this","isSubpanel","sectionReturn","addClass","delegate","SectionController","sectionLayoutaction","bind","SectionSubmenuSwitcher","RestrictInfo","moduleHandler","sectionRestricted","sectionRestrictHandler","fullDescription","fullmodcontentHandler","trimDescription","trimmodcontentHandler","goToURL","redirectToModule","goToSectionURL","redirectToSection","window","onhashchange","expandSection","length","on","parents","sectionid","attr","distance","document","getElementById","offsetTop","body","scrollTop","setTimeout","scroll","removeClass","contactModal","getElementsByClassName","Array","from","forEach","element","addEventListener","e","preventDefault","undefined","currentTarget","dataset","userid","enhance","popover","prototype","moduleBlock","loadingElement","modules","event","nodeName","target","iscircle","closest","classList","contains","isDescription","isPadlock","ispopupModule","isModHasURL","getAttribute","isCompletionButton","querySelector","click","modurl","location","href","singlesection","sectionurl","sectiontarget","open","sectionID","hash","id","substring","section","title","remove","setAttribute","content","add","scrollIntoView","THIS","fullContent","find","trimcontent","hasClass","sectionRestrictInfo","prev","restrictBlock","updateVideoTimeInstance","sectionId","sectionVideotimes","each","index","module","CreateInstance","args","cmid","call","methodname","then","data","template","JSON","parse","playertype","uniqueid","first","replace","render","templatename","html","js","runTemplateJS","fail","exception","sectionitem","iconBlock","layout","layouttext","text","val","parent","dataid","courseid","options","name","value","promises","when","apply","done","loadFragment","sr","replaceNode","catch","refreshSection","addIconToContainerRemoveOnCompletion","init"],"mappings":";;;;;;;AAuBCA,0CAAO,CAAC,SAAU,gBAAiB,iBAAkB,mBAAoB,YACtE,sBAAuB,qCAAsC,sBAAuB,sBACvF,SAASC,EAAGC,SAAUC,UAAWC,YAAaC,KAAMC,QAASC,QAASC,kBAE/DC,SAAW,CACXC,WAAY,cACZC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AAGqK,UACfG,MAAK,cACE7I,KAAKE,WAAY,CACD5B,SAASwK,aACrB,oBACA,UACA9I,KAAKL,UACL,CACIuF,GAAItD,UACJ0G,SAAUtI,KAAKN,SACfqJ,GAAI/I,KAAKG,gBAGT2G,MAAK,CAACW,KAAMC,MAChBnJ,UAAUyK,YAAYlB,YAAaL,KAAMC,OAC1CuB,YACA,CACoBvK,QAAQwK,eAAe,IAAM9C,UAAWiC,OAAQ,GACxDvB,MAAK,IACT,KACRmC,YAGfzK,YAAY2K,qCAAqCpB,UAAWW,UAE5DtG,YAAW,WACHpC,KAAKH,WACLG,KAAKmG,wBAAwBC,aAElC,MAGA,CACHgD,KAAM,SAAS1J,SAAUC,UAAWC,gBAAiBC,UAAWC,WAAYC,sBACjE,IAAIN,gBAAgBC,SAAUC,UAAWC,gBAAiBC,UAAWC,WAAYC"} \ No newline at end of file diff --git a/amd/src/designer_section.js b/amd/src/designer_section.js index 28580b3..a3edc6c 100644 --- a/amd/src/designer_section.js +++ b/amd/src/designer_section.js @@ -48,13 +48,14 @@ * @param {bool} videoTime * @param {bool} issubpanel */ - let DesignerSection = function(courseId, contextId, popupActivities, videoTime, issubpanel) { + let DesignerSection = function(courseId, contextId, popupActivities, videoTime, issubpanel, sectionreturn) { var self = this; self.courseId = courseId; self.contextId = contextId; self.popupActivities = popupActivities; self.videoTime = videoTime; self.isSubpanel = issubpanel; + self.sectionReturn = sectionreturn; $(".course-info-block .carousel .carousel-item:nth-child(1)").addClass('active'); $(".course-info-block #courseStaffinfoControls.carousel").addClass('active'); @@ -314,6 +315,7 @@ { id: sectionid, courseid: self.courseId, + sr: self.sectionReturn, } ); promise.then((html, js) => { @@ -336,8 +338,8 @@ }; return { - init: function(courseId, contextId, popupActivities, videoTime, issubpanel) { - return new DesignerSection(courseId, contextId, popupActivities, videoTime, issubpanel); + init: function(courseId, contextId, popupActivities, videoTime, issubpanel, sectionreturn) { + return new DesignerSection(courseId, contextId, popupActivities, videoTime, issubpanel, sectionreturn); } }; }); diff --git a/classes/output/courseformat/content/section/controlmenu.php b/classes/output/courseformat/content/section/controlmenu.php index 47abc3c..d368844 100644 --- a/classes/output/courseformat/content/section/controlmenu.php +++ b/classes/output/courseformat/content/section/controlmenu.php @@ -73,6 +73,12 @@ public function export_for_template(\renderer_base $output): stdClass { $section = $this->section; + $hassectiontypes = true; + if (($this->course->coursedisplay == COURSE_DISPLAY_MULTIPAGE && !$this->format->get_section_number()) + || $this->course->coursetype == DESIGNER_TYPE_FLOW) { + $hassectiontypes = false; + } + $controls = $this->section_control_items(); if (empty($controls)) { @@ -140,7 +146,7 @@ public function export_for_template(\renderer_base $output): stdClass { 'id' => $section->id, 'seciontypes' => $sectiontypes, 'is_subpanel' => format_designer_is_support_subpanel(), - 'hassectiontypes' => ($this->course->coursetype != DESIGNER_TYPE_FLOW), + 'hassectiontypes' => $hassectiontypes, ]; return $data; @@ -153,7 +159,6 @@ public function export_for_template(\renderer_base $output): stdClass { * method is almost a clone of the previous section_control_items from the course/renderer.php. * * This method must remain public until the final deprecation of section_edit_control_items. - * * @return array of edit control items */ public function section_control_items() { @@ -191,9 +196,15 @@ public function section_control_items() { 'attr' => ['class' => 'icon edit'], ]; - if (format_designer_is_support_subpanel() && $course->coursetype != DESIGNER_TYPE_FLOW) { + $hassectiontypes = true; + if (($this->course->coursedisplay == COURSE_DISPLAY_MULTIPAGE && !$this->format->get_section_number()) + || $this->course->coursetype == DESIGNER_TYPE_FLOW) { + $hassectiontypes = false; + } + + if (format_designer_is_support_subpanel() && $hassectiontypes) { $controls['sectionlayout'] = new action_menu_subpanel( - 'Section Layout', + get_string('strsectionlayout', 'format_designer'), $this->get_choice_list($section), ['data-value' => 'section-designer-action'], new pix_icon('t/hide', '', 'moodle', ['class' => 'iconsmall']) diff --git a/classes/output/renderer.php b/classes/output/renderer.php index 942abc2..27f6a85 100644 --- a/classes/output/renderer.php +++ b/classes/output/renderer.php @@ -102,7 +102,7 @@ public function render_content($widget) { } $data->startid = $startid; $data->issectionpageclass = ($data->initialsection->sectionreturnid != 0) ? 'section-page-layout' : ''; - + if (!format_designer_has_pro()) { $data->headermetadata = $this->course_header_metadata_details($course); } @@ -1419,7 +1419,6 @@ public function course_section_updated( $output = $this->page->get_renderer('format_designer'); $sectionclass = $format->get_output_classname('content\\section'); $sectionobj = new $sectionclass($format, $section); - $format->set_section_number($section->section); return $this->render_from_template('format_designer/section', $sectionobj->export_for_template($output)); } diff --git a/lang/en/format_designer.php b/lang/en/format_designer.php index 5f88f2a..8f94e9a 100644 --- a/lang/en/format_designer.php +++ b/lang/en/format_designer.php @@ -550,3 +550,4 @@ $string['purposeclass'] = "Custom class for styling"; $string['sectionlink'] = 'Permalink'; $string['courseindicator'] = "Course status: "; +$string['strsectionlayout'] = "Section Layout"; \ No newline at end of file diff --git a/lib.php b/lib.php index 6605877..89de67e 100644 --- a/lib.php +++ b/lib.php @@ -2108,6 +2108,7 @@ function format_designer_extend_navigation_course($navigation, $course, $context 'popupactivities' => $ispopupactivities, 'isvideotime' => $isvideotime, 'issubpanel' => format_designer_is_support_subpanel(), + 'sectionreturn' => optional_param('section', 0, PARAM_INT), ]; $PAGE->requires->js_call_amd('format_designer/designer_section', 'init', $jsparams); diff --git a/tests/behat/behat_format_designer.php b/tests/behat/behat_format_designer.php index ff46bb2..f5ba6b8 100644 --- a/tests/behat/behat_format_designer.php +++ b/tests/behat/behat_format_designer.php @@ -124,6 +124,7 @@ public function i_check_heroactivity_not_in_the_position($name, $pos): void { * * @Given /^I set the designer manual completion$/ * @throws DriverException The step is not available when Javascript is disabled + * @param string $selector */ public function i_set_the_manual_completion() { global $CFG; @@ -139,7 +140,7 @@ public function i_set_the_manual_completion() { * * @Given /^I set the designer completion expected "(?P(?:[^"]|\\")*)"$/ * @throws DriverException The step is not available when Javascript is disabled - * @param string $value + * @param string $selector */ public function i_set_completion_expected($value) { global $CFG; diff --git a/version.php b/version.php index afa162a..4dbb708 100644 --- a/version.php +++ b/version.php @@ -24,7 +24,7 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2024022600; // The current plugin version (Date: YYYYMMDDXX). +$plugin->version = 2024031900; // The current plugin version (Date: YYYYMMDDXX). $plugin->requires = 2020061500; // Requires this Moodle version. $plugin->component = 'format_designer'; // Full name of the plugin (used for diagnostics). $plugin->release = 'Version 1.5';