From 0f537c96191dd186b641412e9a2615ed3e535b3b Mon Sep 17 00:00:00 2001 From: Anders Rasmussen Date: Wed, 20 Sep 2023 09:32:58 +0200 Subject: [PATCH 1/2] #102 - Added activity copy button, if user has capability to back up activities, but not to manage activities --- README.md | 2 ++ amd/build/bulkdelete.min.js.map | 2 +- amd/build/script.min.js | 2 +- amd/build/script.min.js.map | 2 +- amd/src/script.js | 39 ++++++++++++++++++---------- block_sharing_cart.php | 45 ++++++++++++++++++++++++++++++++- classes/module.php | 15 +++++++++++ lang/en/block_sharing_cart.php | 5 ++++ settings.php | 8 ++++++ version.php | 4 +-- 10 files changed, 104 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index a660a6e..ad5a276 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,8 @@ Warning: PHP versions 7.2 and older are deprecated, and will cause problems, unr Change Log ---------- +* 4.1, release 3 2023.09.20 + * Added activity copy button, if user has capability to back up activities, but not to manage activities * 4.1, release 2 2023.07.05 * Return to original URL when inserting items & general code cleanup * 4.1, release 1 2023.03.23 diff --git a/amd/build/bulkdelete.min.js.map b/amd/build/bulkdelete.min.js.map index 7259e2b..94f3660 100644 --- a/amd/build/bulkdelete.min.js.map +++ b/amd/build/bulkdelete.min.js.map @@ -1 +1 @@ -{"version":3,"file":"bulkdelete.min.js","sources":["../src/bulkdelete.js"],"sourcesContent":["define(['jquery', 'core/modal_factory', 'core/modal_events'], function($, ModalFactory, ModalEvents) {\n\n return {\n init: function() {\n\n /**\n * Returns a localized string\n *\n * @param {String} identifier\n * @return {String}\n */\n function str(identifier) {\n return M.str.block_sharing_cart[identifier] || M.str.moodle[identifier];\n }\n\n /**\n *\n * @param object\n */\n function confirm_modal(object) {\n var trigger = $('#create-modal');\n ModalFactory.create({\n type: ModalFactory.types.SAVE_CANCEL,\n title: object.title,\n body: object.body,\n }, trigger).done(function(modal) {\n modal.setSaveButtonText(object.save_button);\n\n modal.getRoot().on(ModalEvents.save, function() {\n object.next();\n });\n\n // Remove modal from html.\n modal.getRoot().on(ModalEvents.hidden, function() {\n $('.modal.moodle-has-zindex').remove();\n });\n modal.show();\n });\n }\n\n /**\n *\n * @returns {any[]}\n */\n function get_checks() {\n var elements = $('form :checkbox[name^=\"delete\"]');\n return elements;\n }\n\n /**\n *\n * @param check\n */\n function check_all(check) {\n var checks = get_checks();\n $(checks).prop('checked', check.checked);\n\n $('form :button[name =\"delete_checked\"]').prop('disabled', !check.checked);\n }\n\n /**\n *\n */\n function check() {\n var delete_checked = $('form :button[name^=\"delete_checked\"]');\n var checks = get_checks();\n var checked_checkbox = false;\n\n $(checks).each(function(i, val) {\n if ($(val).prop('checked')) {\n checked_checkbox = true;\n return false;\n }\n });\n\n delete_checked.prop('disabled', !checked_checkbox);\n $('.bulk-delete-select-all :checkbox').prop('checked', checked_checkbox);\n }\n\n /**\n * Check activity button\n */\n $('.bulk-delete-item [id^=delete]').on('click', function() {\n check();\n });\n\n /**\n * Select all checkbox.\n */\n $('.bulk-delete-select-all input').on('click', function() {\n check_all(this);\n });\n\n /**\n * Delete selected, opens modal for confirmation.\n */\n $('.form_submit').on('click', function() {\n var modal_body = '';\n\n confirm_modal({\n 'title': str('modal_bulkdelete_title'),\n 'body': modal_body,\n 'save_button': str('modal_bulkdelete_confirm'),\n 'next': function() {\n $('#form').submit();\n }\n });\n });\n }\n };\n});\n"],"names":["define","$","ModalFactory","ModalEvents","init","str","identifier","M","block_sharing_cart","moodle","get_checks","on","delete_checked","checks","checked_checkbox","each","i","val","prop","check","checked","check_all","this","object","trigger","modal_body","selected_input","label","id","text","submit","create","type","types","SAVE_CANCEL","title","body","done","modal","setSaveButtonText","save_button","getRoot","save","next","hidden","remove","show"],"mappings":"AAAAA,uCAAO,CAAC,SAAU,qBAAsB,sBAAsB,SAASC,EAAGC,aAAcC,mBAE7E,CACHC,KAAM,oBAQOC,IAAIC,mBACFC,EAAEF,IAAIG,mBAAmBF,aAAeC,EAAEF,IAAII,OAAOH,qBAgCvDI,oBACUT,EAAE,kCAqCrBA,EAAE,kCAAkCU,GAAG,SAAS,eAlBxCC,eACAC,OACAC,iBAFAF,eAAiBX,EAAE,wCACnBY,OAASH,aACTI,kBAAmB,EAEvBb,EAAEY,QAAQE,MAAK,SAASC,EAAGC,QACnBhB,EAAEgB,KAAKC,KAAK,kBACZJ,kBAAmB,GACZ,KAIfF,eAAeM,KAAK,YAAaJ,kBACjCb,EAAE,qCAAqCiB,KAAK,UAAWJ,qBAa3Db,EAAE,iCAAiCU,GAAG,SAAS,qBApC5BQ,WACXN,OAASH,aACbT,EAAEY,QAAQK,KAAK,UAAWC,MAAMC,SAEhCnB,EAAE,wCAAwCiB,KAAK,YAAaC,MAAMC,SAiClEC,CAAUC,SAMdrB,EAAE,gBAAgBU,GAAG,SAAS,eA7EPY,OACfC,QA6EAC,WAAa,OACbC,eAAiBzB,EAAE,mCACvBA,EAAEyB,gBAAgBX,MAAK,eACfY,MAAQ1B,EAAE,cAAgBqB,KAAKM,GAAK,MACxCH,YAAc,OAASE,MAAME,OAAS,WAE1CJ,YAAc,QApFKF,OAsFL,OACDlB,IAAI,+BACLoB,uBACOpB,IAAI,iCACX,WACJJ,EAAE,SAAS6B,WA1FfN,QAAUvB,EAAE,iBAChBC,aAAa6B,OAAO,CAChBC,KAAM9B,aAAa+B,MAAMC,YACzBC,MAAOZ,OAAOY,MACdC,KAAMb,OAAOa,MACdZ,SAASa,MAAK,SAASC,OACtBA,MAAMC,kBAAkBhB,OAAOiB,aAE/BF,MAAMG,UAAU9B,GAAGR,YAAYuC,MAAM,WACjCnB,OAAOoB,UAIXL,MAAMG,UAAU9B,GAAGR,YAAYyC,QAAQ,WACnC3C,EAAE,4BAA4B4C,YAElCP,MAAMQ"} \ No newline at end of file +{"version":3,"file":"bulkdelete.min.js","sources":["../src/bulkdelete.js"],"sourcesContent":["define(['jquery', 'core/modal_factory', 'core/modal_events'], function($, ModalFactory, ModalEvents) {\n\n return {\n init: function() {\n\n /**\n * Returns a localized string\n *\n * @param {String} identifier\n * @return {String}\n */\n function str(identifier) {\n return M.str.block_sharing_cart[identifier] || M.str.moodle[identifier];\n }\n\n /**\n *\n * @param object\n */\n function confirm_modal(object) {\n var trigger = $('#create-modal');\n ModalFactory.create({\n type: ModalFactory.types.SAVE_CANCEL,\n title: object.title,\n body: object.body,\n }, trigger).done(function(modal) {\n modal.setSaveButtonText(object.save_button);\n\n modal.getRoot().on(ModalEvents.save, function() {\n object.next();\n });\n\n // Remove modal from html.\n modal.getRoot().on(ModalEvents.hidden, function() {\n $('.modal.moodle-has-zindex').remove();\n });\n modal.show();\n });\n }\n\n /**\n *\n * @returns {any[]}\n */\n function get_checks() {\n var elements = $('form :checkbox[name^=\"delete\"]');\n return elements;\n }\n\n /**\n *\n * @param check\n */\n function check_all(check) {\n var checks = get_checks();\n $(checks).prop('checked', check.checked);\n\n $('form :button[name =\"delete_checked\"]').prop('disabled', !check.checked);\n }\n\n /**\n *\n */\n function check() {\n var delete_checked = $('form :button[name^=\"delete_checked\"]');\n var checks = get_checks();\n var checked_checkbox = false;\n\n $(checks).each(function(i, val) {\n if ($(val).prop('checked')) {\n checked_checkbox = true;\n return false;\n }\n });\n\n delete_checked.prop('disabled', !checked_checkbox);\n $('.bulk-delete-select-all :checkbox').prop('checked', checked_checkbox);\n }\n\n /**\n * Check activity button\n */\n $('.bulk-delete-item [id^=delete]').on('click', function() {\n check();\n });\n\n /**\n * Select all checkbox.\n */\n $('.bulk-delete-select-all input').on('click', function() {\n check_all(this);\n });\n\n /**\n * Delete selected, opens modal for confirmation.\n */\n $('.form_submit').on('click', function() {\n var modal_body = '';\n\n confirm_modal({\n 'title': str('modal_bulkdelete_title'),\n 'body': modal_body,\n 'save_button': str('modal_bulkdelete_confirm'),\n 'next': function() {\n $('#form').submit();\n }\n });\n });\n }\n };\n});\n"],"names":["define","$","ModalFactory","ModalEvents","init","str","identifier","M","block_sharing_cart","moodle","get_checks","on","delete_checked","checks","checked_checkbox","each","i","val","prop","check","checked","check_all","this","object","trigger","modal_body","selected_input","label","id","text","title","body","save_button","next","submit","create","type","types","SAVE_CANCEL","done","modal","setSaveButtonText","getRoot","save","hidden","remove","show"],"mappings":"AAAAA,OAAO,gCAAA,CAAC,SAAU,qBAAsB,sBAAsB,SAASC,EAAGC,aAAcC,aAEpF,MAAO,CACHC,KAAM,WAQF,SAASC,IAAIC,YACT,OAAOC,EAAEF,IAAIG,mBAAmBF,aAAeC,EAAEF,IAAII,OAAOH,WAChE,CA+BA,SAASI,aAEL,OADeT,EAAE,iCAErB,CAmCAA,EAAE,kCAAkCU,GAAG,SAAS,WAnBhD,IACQC,eACAC,OACAC,iBAFAF,eAAiBX,EAAE,wCACnBY,OAASH,aACTI,kBAAmB,EAEvBb,EAAEY,QAAQE,MAAK,SAASC,EAAGC,KACvB,GAAIhB,EAAEgB,KAAKC,KAAK,WAEZ,OADAJ,kBAAmB,GACZ,CAEf,IAEAF,eAAeM,KAAK,YAAaJ,kBACjCb,EAAE,qCAAqCiB,KAAK,UAAWJ,iBAQ3D,IAKAb,EAAE,iCAAiCU,GAAG,SAAS,YApC/C,SAAmBQ,OACf,IAAIN,OAASH,aACbT,EAAEY,QAAQK,KAAK,UAAWC,MAAMC,SAEhCnB,EAAE,wCAAwCiB,KAAK,YAAaC,MAAMC,QACtE,CAgCIC,CAAUC,KACd,IAKArB,EAAE,gBAAgBU,GAAG,SAAS,WAC1B,IA9EmBY,OACfC,QA6EAC,WAAa,OACbC,eAAiBzB,EAAE,mCACvBA,EAAEyB,gBAAgBX,MAAK,WACnB,IAAIY,MAAQ1B,EAAE,cAAgBqB,KAAKM,GAAK,MACxCH,YAAc,OAASE,MAAME,OAAS,OAC1C,IACAJ,YAAc,QApFKF,OAsFL,CACVO,MAASzB,IAAI,0BACb0B,KAAQN,WACRO,YAAe3B,IAAI,4BACnB4B,KAAQ,WACJhC,EAAE,SAASiC,QACf,GA3FAV,QAAUvB,EAAE,iBAChBC,aAAaiC,OAAO,CAChBC,KAAMlC,aAAamC,MAAMC,YACzBR,MAAOP,OAAOO,MACdC,KAAMR,OAAOQ,MACdP,SAASe,MAAK,SAASC,OACtBA,MAAMC,kBAAkBlB,OAAOS,aAE/BQ,MAAME,UAAU/B,GAAGR,YAAYwC,MAAM,WACjCpB,OAAOU,MACX,IAGAO,MAAME,UAAU/B,GAAGR,YAAYyC,QAAQ,WACnC3C,EAAE,4BAA4B4C,QAClC,IACAL,MAAMM,MACV,GA4EJ,GACJ,EAER"} \ No newline at end of file diff --git a/amd/build/script.min.js b/amd/build/script.min.js index 5b7c78f..2b34d2d 100644 --- a/amd/build/script.min.js +++ b/amd/build/script.min.js @@ -5,6 +5,6 @@ * @copyright 2017 (C) VERSION2, INC. * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -define("block_sharing_cart/script",["jquery","core/modal_factory","core/modal_events"],(function($,ModalFactory,ModalEvents){return{init:function(addMethod){$(document).ready((function(){let isDragging=!1;function str(identifier){return M.str.block_sharing_cart[identifier]||M.str.moodle[identifier]}function get_action_url(name,args){var url=M.cfg.wwwroot+"/blocks/sharing_cart/"+name+".php";if(args){var q=[];for(var k in args)q.push(k+"="+encodeURIComponent(args[k]));url+="?"+q.join("&")}return url}function remove_basket(){if("drag_and_drop"===addMethod&&!isDragging){const footerIconContainer=document.getElementById("page-footer").querySelector('div[data-region="footer-container-popover"]'),sharingCartBasket=document.querySelector("button.sharing_cart_basket");sharingCartBasket&&(null==footerIconContainer||footerIconContainer.removeChild(sharingCartBasket),sharingCartBasket.classList.remove("shake_basket"))}}function confirm_modal(obj){obj.checkbox&&(obj.body+='"),ModalFactory.create({type:ModalFactory.types.SAVE_CANCEL,title:obj.title,body:obj.body}).done((function(modal){let is_submitted=!1;modal.setSaveButtonText(obj.save_button),modal.getRoot().on(ModalEvents.save,(function(e){var response={checkbox:$(e.target).find(".modal-checkbox").is(":checked")};obj.next(response),is_submitted=!0})),modal.getRoot().on(ModalEvents.cancel,(function(){remove_basket()})),modal.getRoot().on(ModalEvents.hidden,(function(){$("body").removeClass("modal-open"),is_submitted||remove_basket()})),modal.show()}))}function in_place_edit_section_name($section){var sectionName="",$inPlaceEditable=$section.find("h3.sectionname .inplaceeditable");return $inPlaceEditable.length&&(sectionName=$inPlaceEditable.data("value")),sectionName}function on_backup_modal(post_data,title_str,body_str,isSection){$.post(get_action_url("rest"),post_data,(function(response){!function(response){var checkbox=!1;"1"===response&&(checkbox=!0),confirm_modal({title:title_str,body:body_str,save_button:str("modal_confirm_backup"),checkbox:checkbox,next:function(data){!0===isSection?function(sectionId,sectionNumber,courseId,userdata){var $commands=$("span.inplaceeditable[data-itemtype=sectionname][data-itemid="+sectionId+"]"),$section=$commands.closest("li.section.main"),sectionName=$section.attr("aria-label")||$section.find(".sectionname").text().trim();null===sectionName&&(sectionName=String($("#region-main .section_action_menu[data-sectionid='"+sectionId+"']").parent().parent().find("h3.sectionname").text()));var inPlaceEditSectionName=in_place_edit_section_name($section);sectionName=""!==inPlaceEditSectionName?inPlaceEditSectionName:sectionName;var $spinner=add_spinner(),$node_spinner=add_node_spinner($commands);$.post(get_action_url("rest"),{action:"backup_section",sectionid:sectionId,sectionnumber:sectionNumber,courseid:courseId,sectionname:sectionName,userdata:userdata,sesskey:M.cfg.sesskey},(function(){reload_tree()})).fail((function(response){show_error(response)})).always((function(){$spinner.hide(),$node_spinner.hide(),remove_basket()}))}(post_data.sectionid,post_data.sectionnumber,post_data.courseid,data.checkbox):function(cmid,userdata){var $commands=$("#module-"+cmid+" .actions");$commands.length||($commands=$('[data-owner="#module-'+cmid+'"]'));var $spinner=add_spinner(),$node_spinner=add_node_spinner($commands);$.post(get_action_url("rest"),{action:"backup",cmid:cmid,userdata:userdata,sesskey:M.cfg.sesskey,courseid:course.id},(function(){reload_tree()})).fail((function(response){show_error(response)})).always((function(){$node_spinner.hide(),$spinner.hide(),remove_basket()}))}(post_data.cmid,data.checkbox),function(){if("drag_and_drop"===addMethod){const sharingCartBasket=document.querySelector("button.sharing_cart_basket");null==sharingCartBasket||sharingCartBasket.classList.add("shake_basket")}}()}})}(response)}),"text").fail((function(response){show_error(response)}))}var icon={backup:{css:"editing_backup",iconClass:"fa fa-frown-o"},movedir:{css:"editing_right",iconClass:"fa fa-arrow-right"},move:{css:"editing_move_",iconClass:"fa fa-arrows-v"},edit:{css:"editing_update",iconClass:"fa fa-pencil"},cancel:{css:"editing_cancel",iconClass:"fa fa-ban"},delete:{css:"editing_update",iconClass:"fa fa-trash"},restore:{css:"editing_restore",iconClass:"fa fa-clone"},"dir-open":{iconClass:"fa fa-folder-open-o"},"dir-closed":{iconClass:"fa fa-folder-o"}},$block=$(".block_sharing_cart"),course=new function(){var body=$("body");this.id=body.attr("class").match(/course-(\d+)/)[1],this.is_frontpage=body.hasClass("pagelayout-frontpage")};function show_error(response){try{var ex=JSON.parse(response.responseText);new M.core.exception({name:str("pluginname")+" - "+str("error"),message:ex.message})}catch(e){new M.core.exception({name:str("pluginname")+" - "+str("error"),message:response.responseText})}}function create_command(name){var iconElement=$("").attr("alt",str(name)).attr("class",icon[name].iconClass);return $('').addClass(icon[name].css).attr("title",str(name)).append(iconElement)}function add_spinner(){var $spinner=$('
');return $("section.block_sharing_cart").append($spinner),$spinner}function add_node_spinner($node){var $node_spinner=$('');return $node.append($node_spinner),$node_spinner}function reload_tree(){$.post(get_action_url("rest"),{action:"render_tree",courseid:course.id},(function(response){$block.find(".tree").replaceWith($(response)),$.init_item_tree()}),"html").fail((function(response){show_error(response)}))}$(document).on("click","a.restore",(function(){add_spinner()}));var directories=new function(){var param,readCookie,KEY="block_sharing_cart-dirs",opens=(param=KEY,readCookie=document.cookie.match("(^|;)\\s*"+param+"\\s*=\\s*([^;]+)"),readCookie?readCookie.pop():"").split(",").map((function(v){return parseInt(v)}));function save(){var expires=new Date;expires.setDate(expires.getDate()+30),function(name,value,expireTimeInMillisecond){var d=new Date;d.setTime(d.getTime()+expireTimeInMillisecond);var expires="expires="+d.toUTCString();document.cookie=name+"="+value+";"+expires}(KEY,opens.join(","),expires)}function open($dir,visible){var iconElement=icon[visible?"dir-open":"dir-closed"].iconClass;$dir.find("> div i.icon").attr("class","icon "+iconElement),$dir.find("> ul.list")[visible?"show":"hide"]()}this.init=function(){var i=0;$block.find("li.directory").each((function(index,dir){var $dir=$(dir);$dir.attr("id","block_sharing_cart-dir-"+i),i>=opens.length?opens.push(0):opens[i]&&open($dir,!0),$dir.find("> div div.toggle-wrapper").css("cursor","pointer").on("click",(function(e){!function(e){var $dir=$(e.target).closest("li.directory"),i=$dir.attr("id").match(/(\d+)$/)[1],v="none"===$dir.find("> ul.list").css("display");open($dir,v),opens[i]=v?1:0,save()}(e)})),i++}))},this.reset=function(){opens=[],this.init(),save()}},move_targets=new function(){var $cancel=null,targets=[];this.hide=function(){if(null!==$cancel){var $commands=$cancel.closest(".commands");$cancel.remove(),$cancel=null,$commands.closest("li.activity").css("opacity",1),$commands.find("a").each((function(){$(this).show()})),$.each(targets,(function(index,$target){$target.remove()})),targets=[]}},this.show=function(item_id){this.hide();var $current=$block.find("#block_sharing_cart-item-"+item_id),$next=$current.next(),$list=$current.closest("ul"),next_id=0;function create_target(item_id,area_to){var $anchor=$('
').addClass("move-"+item_id+"-to-"+area_to).attr("title",str("movehere")).append($("

"+str("clicktomove")+"

").attr("alt",str("movehere"))),$target=$('
  • ').append($anchor);return $anchor.on("click",(function(e){!function(e){var m=$(e.target).closest("a").attr("class").match(/move-(\d+)-to-(\d+)/),item_id=m[1],area_to=m[2],$spinner=add_spinner();$.post(get_action_url("rest"),{action:"move",item_id:item_id,area_to:area_to,sesskey:M.cfg.sesskey},(function(){reload_tree()})).fail((function(response){show_error(response)})).always((function(){$spinner.hide()}))}(e)})),$target}if($next.length&&(next_id=$next.attr("id").match(/item-(\d+)$/)[1]),$list.find("> li.activity").each((function(index,item){var $item=$(item),to=$item.attr("id").match(/item-(\d+)$/)[1];if(to===item_id){($cancel=create_command("cancel")).on("click",(function(){move_targets.hide()}));var $commands=$item.find(".commands");$commands.find("a").each((function(){$(this).hide()})),$commands.append($cancel),$item.css("opacity",.5)}else if(to!==next_id){var $target=create_target(item_id,to);$item.before($target),targets.push($target)}}),this),$next){var $target=create_target(item_id,0);$list.append($target),targets.push($target)}}},restore_targets=new function(){this.is_directory=null;var $clipboard=null,targets=[];function create_target(id,section){const href=get_action_url("restore",{directory:!0===restore_targets.is_directory,target:id,course:course.id,section:section,in_section:$("#copy-section-form").data("in-section"),sesskey:M.cfg.sesskey,returnurl:document.URL});let $target=$("").attr("href",href).attr("title",str("copyhere")).append($('').attr("alt",str("copyhere")).attr("src",M.util.image_url("dropzone_arrow","block_sharing_cart")));return targets.push($target),$target}this.hide=function(){null!==$clipboard&&($clipboard.remove(),$clipboard=null,$.each(targets,(function(index,$target){$target.remove()})),targets=[])},this.show=function(id){this.hide();var $view=$("");if(this.is_directory)$view.html(id).css("display","inline"),$view.prepend($("").addClass("icon").attr("alt",id));else{var $item=$block.find("#block_sharing_cart-item-"+id);($view=$($item.find("div")[0].cloneNode(!0)).css("display","inline")).attr("class",$view.attr("class").replace(/mod-indent-\d+/,"")),$view.find(".commands").remove()}var $cancel=create_command("cancel");if($cancel.on("click",this.hide),($clipboard=$('
    ')).append(str("clipboard")+": ").append($view).append($cancel),course.is_frontpage){var $sitetopic=$(".sitetopic"),$mainmenu=$(".block_site_main_menu");$sitetopic?$sitetopic.find("*").before($clipboard):$mainmenu&&$mainmenu.find(".content").before($clipboard),$mainmenu&&$mainmenu.find(".footer").before(create_target(id,0)),$sitetopic&&$sitetopic.find("ul.section").append(create_target(id,1))}else{var $container=$(".course-content");$container.prepend($clipboard),$container.find(M.course.format.get_section_wrapper(null)).each((function(index,sectionDOM){var $section=$(sectionDOM),section=$section.attr("id").match(/(\d+)$/)[1];$section.find("ul.section").first().append(create_target(id,section))}),this)}}};function init_footer_basket(){let currentDragging;const activities=document.querySelectorAll(".activity.activity-wrapper"),sections=document.querySelectorAll(".course-section-header"),sharingCartBlock=document.querySelector('section[data-block="sharing_cart"]');!function(){var _document$getElements;const courseSectionHeader=null!==(_document$getElements=document.getElementsByClassName("course-section-header")[0])&&void 0!==_document$getElements?_document$getElements:null;courseSectionHeader instanceof HTMLElement&&(courseSectionHeader.classList.add("draggable"),courseSectionHeader.setAttribute("draggable",!0))}();const footerIconContainer=document.getElementById("page-footer").querySelector('div[data-region="footer-container-popover"]');var basket=document.createElement("i");basket.setAttribute("class","fa fa-shopping-basket");var basketButton=document.createElement("button");basketButton.setAttribute("class","btn btn-icon bg-secondary icon-no-margin btn-footer-popover sharing_cart_basket"),basketButton.setAttribute("style","z-index: 1001;"),basketButton.append(basket);var dropAreaText=document.createElement("p");dropAreaText.setAttribute("class","font-weight-bold text-white"),dropAreaText.innerText=str("drop_here");var dropArea=document.createElement("div");function drag_event_listeners(draggable){draggable.addEventListener("dragstart",(e=>{basketButton.classList.remove("shake_basket"),null==footerIconContainer||footerIconContainer.prepend(basketButton),sharingCartBlock.children[0].classList.add("dragging_item"),sharingCartBlock.append(dropArea),currentDragging=e.target,isDragging=!0})),draggable.addEventListener("dragend",(()=>{currentDragging instanceof HTMLElement&&(null==footerIconContainer||footerIconContainer.removeChild(basketButton)),sharingCartBlock.children[0].classList.remove("dragging_item"),sharingCartBlock.removeChild(dropArea),isDragging=!1}))}dropArea.setAttribute("class","h-100 w-100 position-absolute d-flex justify-content-center align-items-center"),dropArea.append(dropAreaText),sections.forEach((section=>{drag_event_listeners(section)})),activities.forEach((activity=>{drag_event_listeners(activity)})),[basketButton,sharingCartBlock].forEach((dropzone=>{dropzone.addEventListener("dragover",(e=>{e.preventDefault(),dropzone.classList.add("drag_over")})),dropzone.addEventListener("dragenter",(e=>{e.preventDefault(),dropzone.classList.add("drag_over")})),dropzone.addEventListener("dragleave",(()=>{dropzone.classList.remove("drag_over")})),dropzone.addEventListener("drop",(()=>{currentDragging instanceof HTMLElement&¤tDragging.querySelector(".add-to-sharing-cart").click(),dropzone.classList.remove("drag_over"),currentDragging=void 0,isDragging=!1}))}))}$.get_plugin_name=function(){var $blockheader=$block.find("h2");return $blockheader.length||($blockheader=$block.find("h3")).length?$blockheader.html():""},$.on_backup=function(e,activityName){on_backup_modal({action:"is_userdata_copyable",cmid:function($backup){var $activity=$backup.closest("li.activity");if($activity.length)return $activity.attr("id").match(/(\d+)$/)[1];var $commands=$backup.closest(".commands"),dataowner=$commands.attr("data-owner");return dataowner.length?dataowner.match(/(\d+)$/)[1]:$commands.find("a.editing_delete").attr("href").match(/delete=(\d+)/)[1]}($(e.target))},activityName,str("confirm_backup"),!1)},$.on_movedir=function(e){var $commands=$(e.target).closest(".commands"),$current_dir=$commands.closest("li.directory"),current_path=$current_dir.length?$current_dir.attr("directory-path"):"/",item_id=$(e.target).closest("li.activity").attr("id").match(/(\d+)$/)[1],dirs=[];$block.find("li.directory").each((function(){dirs.push($(this).attr("directory-path"))}));var $form=$("
    ");function submit(){var folder_to=$form.find('[name="to"]').val(),$spinner=add_spinner();$.post(get_action_url("rest"),{action:"movedir",item_id:item_id,folder_to:folder_to,sesskey:M.cfg.sesskey},(function(){reload_tree(),directories.reset()})).fail((function(response){show_error(response)})).always((function(){$spinner.hide()}))}if($form.attr("action","javascript:void(0)"),$form.submit(submit),0===dirs.length){var $input=$('').val(current_path);setTimeout((function(){$input.focus()}),1),$form.append($input)}else{dirs.unshift("/");for(var $select=$('').val(current_path);$select.remove(),$edit.replaceWith($input),$input.focus()})),$form.append($edit)}var $cancel=create_command("cancel");$cancel.on("click",(function(){$form.remove(),$commands.find("a").show()})),$form.append($cancel),$commands.find("a").each((function(){$(this).hide()})),$commands.append($form)},$.on_move=function(e){var id=$(e.target).closest("li.activity").attr("id").match(/(\d+)$/)[1];move_targets.show(id)},$.on_delete=function(e){var modalBody,item,$item=$(e.target).closest("li"),liText=$item[0].innerText,isDirectory=!1,description_text="";$item.hasClass("directory")?(isDirectory=!0,item=str("folder_string"),description_text=str("delete_folder")):item=str("activity_string"),modalBody='

    '+item+" "+liText+description_text+"

    ",confirm_modal({title:str("confirm_delete"),body:modalBody,save_button:str("modal_confirm_delete"),checkbox:!1,next:function(){var data={};!0===isDirectory?data={action:"delete_directory",path:$item.attr("directory-path"),sesskey:M.cfg.sesskey}:$item.hasClass("activity")&&(data={action:"delete",id:$item.attr("id").match(/(\d+)$/)[1],sesskey:M.cfg.sesskey});var $spinner=add_spinner();$.post(get_action_url("rest"),data,(function(){reload_tree()})).fail((function(response){show_error(response)})).always((function(){$spinner.hide()})),e.stopPropagation()}})},$.on_restore=function(e){var $item=$(e.target).closest("li"),id=null;$item.hasClass("directory")?(id=$item.attr("directory-path"),restore_targets.is_directory=!0):$item.hasClass("activity")&&(id=$item.attr("id").match(/(\d+)$/)[1],restore_targets.is_directory=!1),restore_targets.show(id)},$.on_section_backup=function(sectionId,sectionNumber,courseId,sectionName){on_backup_modal({action:"is_userdata_copyable_section",sectionid:sectionId,sectionnumber:sectionNumber,courseid:courseId},sectionName,'

    '+str("backup_heavy_load_warning_message")+"

    "+str("confirm_backup_section"),!0)},$.init_bulk_delete=function(isspeciallayout){var bulkdelete=$block.find(".editing_bulkdelete");bulkdelete.length&&(isspeciallayout?(bulkdelete.attr("role","menuitem").addClass("dropdown-item menu-action"),bulkdelete.append($("").append(bulkdelete.attr("title"))),$block.find(".menubar .dropdown .dropdown-menu").append(bulkdelete)):$block.find(".header .commands").append(bulkdelete))},$.init_help_icon=function(isspeciallayout){var helpicon=$block.find(".header-commands > .help-icon");isspeciallayout?$block.find(".header-commands").parent().css("display","block"):$block.find(".header .commands").append(helpicon)},$.init_block_header=function(){var isspeciallayout=$block.find(".menubar .dropdown .dropdown-menu").length;$.init_bulk_delete(isspeciallayout),$.init_help_icon(isspeciallayout)},$.init_item_tree=function(){function add_actions(item,actions){var $commands=$(item).find(".commands").first();$.each(actions,(function(index,action){var $command=create_command(action);$command.on("click",(function(e){$["on_"+action](e)})),$commands.append($command)}),this)}var activity_actions=["movedir","move","delete"];course&&activity_actions.push("restore");var directory_actions=["delete","restore"];$block.find("li.activity").each((function(index,item){1!=$(item).attr("data-disable-copy")?add_actions(item,activity_actions):add_actions(item,["movedir","move","delete"])})),$block.find("li.directory").each((function(index,item){add_actions(item,directory_actions)})),directories.init()},$.init_activity_commands=function(){function create_backup_icon(){var $backupIcon=$('
    ').append($('')).attr("title",str("backup"));return"click_to_add"!==addMethod&&$backupIcon.addClass("d-none"),$backupIcon}function add_activity_backup_control($activity){var activityClass=$activity[0].className,modtype=activityClass.substr(activityClass.indexOf("modtype_")+8),activityName=str("activity_string");"label"!==modtype&&(activityName=$(".activity#"+$activity[0].id).find(".mod-indent-outer .activityinstance span.instancename").html());var $backupIcon=create_backup_icon();$backupIcon.on("click",(function(e){$.on_backup(e,activityName)}));var $actionMenuItem=$activity.find(".action-menu.section-cm-edit-actions").parent(".actions");$actionMenuItem.find(".add-to-sharing-cart").length||$actionMenuItem.append($backupIcon)}$(document).ajaxComplete((function(event,xhr,settings){var url=settings.url,lastslashindex=url.lastIndexOf("="),result=url.substring(lastslashindex+1);if("core_course_edit_module"===result||"core_course_get_module"===result){var data=JSON.parse(settings.data),action=data[0].args.action;if("delete"===action)return;setTimeout((function(){var activity_id=data[0].args.id,activity=$("#module-"+activity_id);(add_activity_backup_control(activity),"duplicate"===action)&&add_activity_backup_control(activity.next())}),1)}})),$("body.editing .course-content li.section").each((function(){!function($section){var sectionId=$section.find(".section_action_menu").data("sectionid"),sectionNumber=parseInt(String($section.attr("id")).match(/\d+/)[0]),sectionName=$section.attr("aria-label")||$section.find(".sectionname").text().trim(),isFlexibleCourseFormat=$("body[id$=flexsections]").length;isFlexibleCourseFormat&&null==sectionId&&(sectionId=$section.data("section-id"));var courseId=parseInt(String($("body").attr("class")).match(/course-([0-9]*)( |$)/)[1]),$backupIcon=create_backup_icon();$backupIcon.on("click",(function(){var inPlaceEditSectionName=in_place_edit_section_name($section);sectionName=""!==inPlaceEditSectionName?inPlaceEditSectionName:sectionName,$.on_section_backup(sectionId,sectionNumber,courseId,sectionName)}));var $sectionTitle=$section.find("h3.sectionname").first().find("a").last(),$inPlaceEditable=$section.find("h3.sectionname .inplaceeditable").first();$inPlaceEditable.length&&($sectionTitle=$inPlaceEditable),isFlexibleCourseFormat&&0===sectionNumber?($sectionTitle=$section.find("> .controls")).prepend($backupIcon):$backupIcon.insertAfter($sectionTitle);var $activities=$section.find("li.activity");$($activities).each((function(){add_activity_backup_control($(this))}))}($(this))}))},$.init=function(){M.str.block_sharing_cart.pluginname=this.get_plugin_name(),$.init_block_header(),$.init_item_tree(),$.init_activity_commands(),"drag_and_drop"===addMethod&&init_footer_basket()};var $spinner=$("").addClass("spinner fa fa-3x fa-circle-o-notch fa-spin");$("div#sharing-cart-spinner-modal div.spinner-container").prepend($spinner),$.init()})),$(".copy_section").on("click",(function(){var $section_selected=$(".section-dropdown option:selected"),sectionId=$section_selected.data("section-id"),sectionNumber=$section_selected.data("section-number"),courseId=$section_selected.data("course-id"),sectionName=$section_selected.data("section-name");$.on_section_backup(sectionId,sectionNumber,courseId,sectionName)}))}}})); +define("block_sharing_cart/script",["jquery","core/modal_factory","core/modal_events"],(function($,ModalFactory,ModalEvents){return{init:function(addMethod){$(document).ready((function(){let isDragging=!1;function str(identifier){return M.str.block_sharing_cart[identifier]||M.str.moodle[identifier]}function get_action_url(name,args){var url=M.cfg.wwwroot+"/blocks/sharing_cart/"+name+".php";if(args){var q=[];for(var k in args)q.push(k+"="+encodeURIComponent(args[k]));url+="?"+q.join("&")}return url}function remove_basket(){if("drag_and_drop"===addMethod&&!isDragging){const footerIconContainer=document.getElementById("page-footer").querySelector('div[data-region="footer-container-popover"]'),sharingCartBasket=document.querySelector("button.sharing_cart_basket");sharingCartBasket&&(footerIconContainer?.removeChild(sharingCartBasket),sharingCartBasket.classList.remove("shake_basket"))}}function confirm_modal(obj){obj.checkbox&&(obj.body+='"),ModalFactory.create({type:ModalFactory.types.SAVE_CANCEL,title:obj.title,body:obj.body}).done((function(modal){let is_submitted=!1;modal.setSaveButtonText(obj.save_button),modal.getRoot().on(ModalEvents.save,(function(e){var response={checkbox:$(e.target).find(".modal-checkbox").is(":checked")};obj.next(response),is_submitted=!0})),modal.getRoot().on(ModalEvents.cancel,(function(){remove_basket()})),modal.getRoot().on(ModalEvents.hidden,(function(){$("body").removeClass("modal-open"),is_submitted||remove_basket()})),modal.show()}))}function in_place_edit_section_name($section){var sectionName="",$inPlaceEditable=$section.find("h3.sectionname .inplaceeditable");return $inPlaceEditable.length&&(sectionName=$inPlaceEditable.data("value")),sectionName}function on_backup_modal(post_data,title_str,body_str,isSection){$.post(get_action_url("rest"),post_data,(function(response){!function(response){var copyable="1"===response,checkbox=!1;copyable&&(checkbox=!0),confirm_modal({title:title_str,body:body_str,save_button:str("modal_confirm_backup"),checkbox:checkbox,next:function(data){!0===isSection?function(sectionId,sectionNumber,courseId,userdata){var $commands=$("span.inplaceeditable[data-itemtype=sectionname][data-itemid="+sectionId+"]"),$section=$commands.closest("li.section.main"),sectionName=$section.attr("aria-label")||$section.find(".sectionname").text().trim();null===sectionName&&(sectionName=String($("#region-main .section_action_menu[data-sectionid='"+sectionId+"']").parent().parent().find("h3.sectionname").text()));var inPlaceEditSectionName=in_place_edit_section_name($section);sectionName=""!==inPlaceEditSectionName?inPlaceEditSectionName:sectionName;var $spinner=add_spinner(),$node_spinner=add_node_spinner($commands);$.post(get_action_url("rest"),{action:"backup_section",sectionid:sectionId,sectionnumber:sectionNumber,courseid:courseId,sectionname:sectionName,userdata:userdata,sesskey:M.cfg.sesskey},(function(){reload_tree()})).fail((function(response){show_error(response)})).always((function(){$spinner.hide(),$node_spinner.hide(),remove_basket()}))}(post_data.sectionid,post_data.sectionnumber,post_data.courseid,data.checkbox):function(cmid,userdata){var $commands=$("#module-"+cmid+" .actions");$commands.length||($commands=$('[data-owner="#module-'+cmid+'"]'));var $spinner=add_spinner(),$node_spinner=add_node_spinner($commands);$.post(get_action_url("rest"),{action:"backup",cmid:cmid,userdata:userdata,sesskey:M.cfg.sesskey,courseid:course.id},(function(){reload_tree()})).fail((function(response){show_error(response)})).always((function(){$node_spinner.hide(),$spinner.hide(),remove_basket()}))}(post_data.cmid,data.checkbox),function(){if("drag_and_drop"===addMethod){const sharingCartBasket=document.querySelector("button.sharing_cart_basket");sharingCartBasket?.classList.add("shake_basket")}}()}})}(response)}),"text").fail((function(response){show_error(response)}))}var icon={backup:{css:"editing_backup",iconClass:"fa fa-frown-o"},movedir:{css:"editing_right",iconClass:"fa fa-arrow-right"},move:{css:"editing_move_",iconClass:"fa fa-arrows-v"},edit:{css:"editing_update",iconClass:"fa fa-pencil"},cancel:{css:"editing_cancel",iconClass:"fa fa-ban"},delete:{css:"editing_update",iconClass:"fa fa-trash"},restore:{css:"editing_restore",iconClass:"fa fa-clone"},"dir-open":{iconClass:"fa fa-folder-open-o"},"dir-closed":{iconClass:"fa fa-folder-o"}},$block=$(".block_sharing_cart"),course=new function(){var body=$("body");this.id=body.attr("class").match(/course-(\d+)/)[1],this.is_frontpage=body.hasClass("pagelayout-frontpage")};function show_error(response){try{var ex=JSON.parse(response.responseText);new M.core.exception({name:str("pluginname")+" - "+str("error"),message:ex.message})}catch(e){new M.core.exception({name:str("pluginname")+" - "+str("error"),message:response.responseText})}}function create_command(name){var iconElement=$("").attr("alt",str(name)).attr("class",icon[name].iconClass);return $('').addClass(icon[name].css).attr("title",str(name)).append(iconElement)}function add_spinner(){var $spinner=$('
    ');return $("section.block_sharing_cart").append($spinner),$spinner}function add_node_spinner($node){var $node_spinner=$('');return $node.append($node_spinner),$node_spinner}function reload_tree(){$.post(get_action_url("rest"),{action:"render_tree",courseid:course.id},(function(response){$block.find(".tree").replaceWith($(response)),$.init_item_tree()}),"html").fail((function(response){show_error(response)}))}$(document).on("click","a.restore",(function(){add_spinner()}));var directories=new function(){var param,readCookie,KEY="block_sharing_cart-dirs",opens=(param=KEY,readCookie=document.cookie.match("(^|;)\\s*"+param+"\\s*=\\s*([^;]+)"),readCookie?readCookie.pop():"").split(",").map((function(v){return parseInt(v)}));function save(){var expires=new Date;expires.setDate(expires.getDate()+30),function(name,value,expireTimeInMillisecond){var d=new Date;d.setTime(d.getTime()+expireTimeInMillisecond);var expires="expires="+d.toUTCString();document.cookie=name+"="+value+";"+expires}(KEY,opens.join(","),expires)}function open($dir,visible){var iconElement=icon[visible?"dir-open":"dir-closed"].iconClass;$dir.find("> div i.icon").attr("class","icon "+iconElement),$dir.find("> ul.list")[visible?"show":"hide"]()}this.init=function(){var i=0;$block.find("li.directory").each((function(index,dir){var $dir=$(dir);$dir.attr("id","block_sharing_cart-dir-"+i),i>=opens.length?opens.push(0):opens[i]&&open($dir,!0),$dir.find("> div div.toggle-wrapper").css("cursor","pointer").on("click",(function(e){!function(e){var $dir=$(e.target).closest("li.directory"),i=$dir.attr("id").match(/(\d+)$/)[1],v="none"===$dir.find("> ul.list").css("display");open($dir,v),opens[i]=v?1:0,save()}(e)})),i++}))},this.reset=function(){opens=[],this.init(),save()}},move_targets=new function(){var $cancel=null,targets=[];this.hide=function(){if(null!==$cancel){var $commands=$cancel.closest(".commands");$cancel.remove(),$cancel=null,$commands.closest("li.activity").css("opacity",1),$commands.find("a").each((function(){$(this).show()})),$.each(targets,(function(index,$target){$target.remove()})),targets=[]}},this.show=function(item_id){this.hide();var $current=$block.find("#block_sharing_cart-item-"+item_id),$next=$current.next(),$list=$current.closest("ul"),next_id=0;function create_target(item_id,area_to){var $anchor=$('
    ').addClass("move-"+item_id+"-to-"+area_to).attr("title",str("movehere")).append($("

    "+str("clicktomove")+"

    ").attr("alt",str("movehere"))),$target=$('
  • ').append($anchor);return $anchor.on("click",(function(e){!function(e){var m=$(e.target).closest("a").attr("class").match(/move-(\d+)-to-(\d+)/),item_id=m[1],area_to=m[2],$spinner=add_spinner();$.post(get_action_url("rest"),{action:"move",item_id:item_id,area_to:area_to,sesskey:M.cfg.sesskey},(function(){reload_tree()})).fail((function(response){show_error(response)})).always((function(){$spinner.hide()}))}(e)})),$target}if($next.length&&(next_id=$next.attr("id").match(/item-(\d+)$/)[1]),$list.find("> li.activity").each((function(index,item){var $item=$(item),to=$item.attr("id").match(/item-(\d+)$/)[1];if(to===item_id){($cancel=create_command("cancel")).on("click",(function(){move_targets.hide()}));var $commands=$item.find(".commands");$commands.find("a").each((function(){$(this).hide()})),$commands.append($cancel),$item.css("opacity",.5)}else if(to!==next_id){var $target=create_target(item_id,to);$item.before($target),targets.push($target)}}),this),$next){var $target=create_target(item_id,0);$list.append($target),targets.push($target)}}},restore_targets=new function(){this.is_directory=null;var $clipboard=null,targets=[];function create_target(id,section){const href=get_action_url("restore",{directory:!0===restore_targets.is_directory,target:id,course:course.id,section:section,in_section:$("#copy-section-form").data("in-section"),sesskey:M.cfg.sesskey,returnurl:document.URL});let $target=$("").attr("href",href).attr("title",str("copyhere")).append($('').attr("alt",str("copyhere")).attr("src",M.util.image_url("dropzone_arrow","block_sharing_cart")));return targets.push($target),$target}this.hide=function(){null!==$clipboard&&($clipboard.remove(),$clipboard=null,$.each(targets,(function(index,$target){$target.remove()})),targets=[])},this.show=function(id){this.hide();var $view=$("");if(this.is_directory)$view.html(id).css("display","inline"),$view.prepend($("").addClass("icon").attr("alt",id));else{var $item=$block.find("#block_sharing_cart-item-"+id);($view=$($item.find("div")[0].cloneNode(!0)).css("display","inline")).attr("class",$view.attr("class").replace(/mod-indent-\d+/,"")),$view.find(".commands").remove()}var $cancel=create_command("cancel");if($cancel.on("click",this.hide),($clipboard=$('
    ')).append(str("clipboard")+": ").append($view).append($cancel),course.is_frontpage){var $sitetopic=$(".sitetopic"),$mainmenu=$(".block_site_main_menu");$sitetopic?$sitetopic.find("*").before($clipboard):$mainmenu&&$mainmenu.find(".content").before($clipboard),$mainmenu&&$mainmenu.find(".footer").before(create_target(id,0)),$sitetopic&&$sitetopic.find("ul.section").append(create_target(id,1))}else{var $container=$(".course-content");$container.prepend($clipboard),$container.find(M.course.format.get_section_wrapper(null)).each((function(index,sectionDOM){var $section=$(sectionDOM),section=$section.attr("id").match(/(\d+)$/)[1];$section.find("ul.section").first().append(create_target(id,section))}),this)}}};function init_footer_basket(){let currentDragging;const activities=document.querySelectorAll(".activity.activity-wrapper"),sections=document.querySelectorAll(".course-section-header"),sharingCartBlock=document.querySelector('section[data-block="sharing_cart"]');!function(){const courseSectionHeader=document.getElementsByClassName("course-section-header")[0]??null;courseSectionHeader instanceof HTMLElement&&(courseSectionHeader.classList.add("draggable"),courseSectionHeader.setAttribute("draggable",!0))}();const footerIconContainer=document.getElementById("page-footer").querySelector('div[data-region="footer-container-popover"]');var basket=document.createElement("i");basket.setAttribute("class","fa fa-shopping-basket");var basketButton=document.createElement("button");basketButton.setAttribute("class","btn btn-icon bg-secondary icon-no-margin btn-footer-popover sharing_cart_basket"),basketButton.setAttribute("style","z-index: 1001;"),basketButton.append(basket);var dropAreaText=document.createElement("p");dropAreaText.setAttribute("class","font-weight-bold text-white"),dropAreaText.innerText=str("drop_here");var dropArea=document.createElement("div");function drag_event_listeners(draggable){draggable.addEventListener("dragstart",(e=>{basketButton.classList.remove("shake_basket"),footerIconContainer?.prepend(basketButton),sharingCartBlock.children[0].classList.add("dragging_item"),sharingCartBlock.append(dropArea),currentDragging=e.target,isDragging=!0})),draggable.addEventListener("dragend",(()=>{currentDragging instanceof HTMLElement&&footerIconContainer?.removeChild(basketButton),sharingCartBlock.children[0].classList.remove("dragging_item"),sharingCartBlock.removeChild(dropArea),isDragging=!1}))}dropArea.setAttribute("class","h-100 w-100 position-absolute d-flex justify-content-center align-items-center"),dropArea.append(dropAreaText),sections.forEach((section=>{drag_event_listeners(section)})),activities.forEach((activity=>{drag_event_listeners(activity)})),[basketButton,sharingCartBlock].forEach((dropzone=>{dropzone.addEventListener("dragover",(e=>{e.preventDefault(),dropzone.classList.add("drag_over")})),dropzone.addEventListener("dragenter",(e=>{e.preventDefault(),dropzone.classList.add("drag_over")})),dropzone.addEventListener("dragleave",(()=>{dropzone.classList.remove("drag_over")})),dropzone.addEventListener("drop",(()=>{currentDragging instanceof HTMLElement&¤tDragging.querySelector(".add-to-sharing-cart").click(),dropzone.classList.remove("drag_over"),currentDragging=void 0,isDragging=!1}))}))}$.get_plugin_name=function(){var $blockheader=$block.find("h2");return $blockheader.length||($blockheader=$block.find("h3")).length?$blockheader.html():""},$.on_backup=function(e,activityName){let cmId=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;0===cmId&&(cmId=function($backup){var $activity=$backup.closest("li.activity");if($activity.length)return $activity.attr("id").match(/(\d+)$/)[1];var $commands=$backup.closest(".commands"),dataowner=$commands.attr("data-owner");return dataowner.length?dataowner.match(/(\d+)$/)[1]:$commands.find("a.editing_delete").attr("href").match(/delete=(\d+)/)[1]}($(e.target))),on_backup_modal({action:"is_userdata_copyable",cmid:cmId},activityName,str("confirm_backup"),!1)},$.on_movedir=function(e){var $commands=$(e.target).closest(".commands"),$current_dir=$commands.closest("li.directory"),current_path=$current_dir.length?$current_dir.attr("directory-path"):"/",item_id=$(e.target).closest("li.activity").attr("id").match(/(\d+)$/)[1],dirs=[];$block.find("li.directory").each((function(){dirs.push($(this).attr("directory-path"))}));var $form=$("");function submit(){var folder_to=$form.find('[name="to"]').val(),$spinner=add_spinner();$.post(get_action_url("rest"),{action:"movedir",item_id:item_id,folder_to:folder_to,sesskey:M.cfg.sesskey},(function(){reload_tree(),directories.reset()})).fail((function(response){show_error(response)})).always((function(){$spinner.hide()}))}if($form.attr("action","javascript:void(0)"),$form.submit(submit),0===dirs.length){var $input=$('').val(current_path);setTimeout((function(){$input.focus()}),1),$form.append($input)}else{dirs.unshift("/");for(var $select=$('').val(current_path);$select.remove(),$edit.replaceWith($input),$input.focus()})),$form.append($edit)}var $cancel=create_command("cancel");$cancel.on("click",(function(){$form.remove(),$commands.find("a").show()})),$form.append($cancel),$commands.find("a").each((function(){$(this).hide()})),$commands.append($form)},$.on_move=function(e){var id=$(e.target).closest("li.activity").attr("id").match(/(\d+)$/)[1];move_targets.show(id)},$.on_delete=function(e){var modalBody,item,$item=$(e.target).closest("li"),liText=$item[0].innerText,isDirectory=!1,description_text="";$item.hasClass("directory")?(isDirectory=!0,item=str("folder_string"),description_text=str("delete_folder")):item=str("activity_string"),modalBody='

    '+item+" "+liText+description_text+"

    ",confirm_modal({title:str("confirm_delete"),body:modalBody,save_button:str("modal_confirm_delete"),checkbox:!1,next:function(){var data={};!0===isDirectory?data={action:"delete_directory",path:$item.attr("directory-path"),sesskey:M.cfg.sesskey}:$item.hasClass("activity")&&(data={action:"delete",id:$item.attr("id").match(/(\d+)$/)[1],sesskey:M.cfg.sesskey});var $spinner=add_spinner();$.post(get_action_url("rest"),data,(function(){reload_tree()})).fail((function(response){show_error(response)})).always((function(){$spinner.hide()})),e.stopPropagation()}})},$.on_restore=function(e){var $item=$(e.target).closest("li"),id=null;$item.hasClass("directory")?(id=$item.attr("directory-path"),restore_targets.is_directory=!0):$item.hasClass("activity")&&(id=$item.attr("id").match(/(\d+)$/)[1],restore_targets.is_directory=!1),restore_targets.show(id)},$.on_section_backup=function(sectionId,sectionNumber,courseId,sectionName){on_backup_modal({action:"is_userdata_copyable_section",sectionid:sectionId,sectionnumber:sectionNumber,courseid:courseId},sectionName,'

    '+str("backup_heavy_load_warning_message")+"

    "+str("confirm_backup_section"),!0)},$.init_bulk_delete=function(isspeciallayout){var bulkdelete=$block.find(".editing_bulkdelete");bulkdelete.length&&(isspeciallayout?(bulkdelete.attr("role","menuitem").addClass("dropdown-item menu-action"),bulkdelete.append($("").append(bulkdelete.attr("title"))),$block.find(".menubar .dropdown .dropdown-menu").append(bulkdelete)):$block.find(".header .commands").append(bulkdelete))},$.init_help_icon=function(isspeciallayout){var helpicon=$block.find(".header-commands > .help-icon");isspeciallayout?$block.find(".header-commands").parent().css("display","block"):$block.find(".header .commands").append(helpicon)},$.init_block_header=function(){var isspeciallayout=$block.find(".menubar .dropdown .dropdown-menu").length;$.init_bulk_delete(isspeciallayout),$.init_help_icon(isspeciallayout)},$.init_item_tree=function(){function add_actions(item,actions){var $commands=$(item).find(".commands").first();$.each(actions,(function(index,action){var $command=create_command(action);$command.on("click",(function(e){$["on_"+action](e)})),$commands.append($command)}),this)}var activity_actions=["movedir","move","delete"];course&&activity_actions.push("restore");var directory_actions=["delete","restore"];$block.find("li.activity").each((function(index,item){1!=$(item).attr("data-disable-copy")?add_actions(item,activity_actions):add_actions(item,["movedir","move","delete"])})),$block.find("li.directory").each((function(index,item){add_actions(item,directory_actions)})),directories.init()},$.init_activity_commands=function(){function create_backup_icon(){var $backupIcon=$('
    ').append($('')).attr("title",str("backup"));return"click_to_add"!==addMethod&&$backupIcon.addClass("d-none"),$backupIcon}function add_activity_backup_control($activity){var activityClass=$activity[0].className,modtype=activityClass.substr(activityClass.indexOf("modtype_")+8),activityName=str("activity_string");"label"!==modtype&&(activityName=$(".activity#"+$activity[0].id).find(".mod-indent-outer .activityinstance span.instancename").html());var $backupIcon=create_backup_icon();$backupIcon.on("click",(function(e){$.on_backup(e,activityName)}));var $actionMenuItem=$activity.find(".action-menu.section-cm-edit-actions").parent(".actions");$actionMenuItem.find(".add-to-sharing-cart").length||$actionMenuItem.append($backupIcon)}$(document).ajaxComplete((function(event,xhr,settings){var url=settings.url,lastslashindex=url.lastIndexOf("="),result=url.substring(lastslashindex+1);if("core_course_edit_module"===result||"core_course_get_module"===result){var data=JSON.parse(settings.data),action=data[0].args.action;if("delete"===action)return;setTimeout((function(){var activity_id=data[0].args.id,activity=$("#module-"+activity_id);(add_activity_backup_control(activity),"duplicate"===action)&&add_activity_backup_control(activity.next())}),1)}})),$("body.editing .course-content li.section").each((function(){!function($section){var sectionId=$section.find(".section_action_menu").data("sectionid"),sectionNumber=parseInt(String($section.attr("id")).match(/\d+/)[0]),sectionName=$section.attr("aria-label")||$section.find(".sectionname").text().trim(),isFlexibleCourseFormat=$("body[id$=flexsections]").length;isFlexibleCourseFormat&&null==sectionId&&(sectionId=$section.data("section-id"));var courseId=parseInt(String($("body").attr("class")).match(/course-([0-9]*)( |$)/)[1]),$backupIcon=create_backup_icon();$backupIcon.on("click",(function(){var inPlaceEditSectionName=in_place_edit_section_name($section);sectionName=""!==inPlaceEditSectionName?inPlaceEditSectionName:sectionName,$.on_section_backup(sectionId,sectionNumber,courseId,sectionName)}));var $sectionTitle=$section.find("h3.sectionname").first().find("a").last(),$inPlaceEditable=$section.find("h3.sectionname .inplaceeditable").first();$inPlaceEditable.length&&($sectionTitle=$inPlaceEditable),isFlexibleCourseFormat&&0===sectionNumber?($sectionTitle=$section.find("> .controls")).prepend($backupIcon):$backupIcon.insertAfter($sectionTitle);var $activities=$section.find("li.activity");$($activities).each((function(){add_activity_backup_control($(this))}))}($(this))}))},$.init=function(){M.str.block_sharing_cart.pluginname=this.get_plugin_name(),$.init_block_header(),$.init_item_tree(),$.init_activity_commands(),"drag_and_drop"===addMethod&&init_footer_basket()};var $spinner=$("").addClass("spinner fa fa-3x fa-circle-o-notch fa-spin");$("div#sharing-cart-spinner-modal div.spinner-container").prepend($spinner),$.init()})),$(".copy_section").on("click",(function(){var $section_selected=$(".section-dropdown option:selected"),sectionId=$section_selected.data("section-id"),sectionNumber=$section_selected.data("section-number"),courseId=$section_selected.data("course-id"),sectionName=$section_selected.data("section-name");$.on_section_backup(sectionId,sectionNumber,courseId,sectionName)})),$(".copy_activity").on("click",(function(e){var activitySelected=$(".activity-dropdown option:selected"),activityId=activitySelected.data("activity-id"),activityName=activitySelected.data("activity-name");$.on_backup(e,activityName,activityId)}))}}})); //# sourceMappingURL=script.min.js.map \ No newline at end of file diff --git a/amd/build/script.min.js.map b/amd/build/script.min.js.map index 29db447..765afd5 100644 --- a/amd/build/script.min.js.map +++ b/amd/build/script.min.js.map @@ -1 +1 @@ -{"version":3,"file":"script.min.js","sources":["../src/script.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 * Sharing Cart\n *\n * @package block_sharing_cart\n * @copyright 2017 (C) VERSION2, INC.\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery', 'core/modal_factory', 'core/modal_events'], function($, ModalFactory, ModalEvents) {\n return {\n init: function(addMethod) {\n\n $(document).ready(function() {\n let isDragging = false;\n\n /**\n * Returns a localized string\n *\n * @param {String} identifier\n * @return {String}\n */\n function str(identifier) {\n return M.str.block_sharing_cart[identifier] || M.str.moodle[identifier];\n }\n\n /**\n * Get an action URL\n *\n * @param {String} name The action name\n * @param {Object} [args] The action parameters\n * @return {String}\n */\n function get_action_url(name, args) {\n var url = M.cfg.wwwroot + '/blocks/sharing_cart/' + name + '.php';\n if (args) {\n var q = [];\n for (var k in args) {\n q.push(k + '=' + encodeURIComponent(args[k]));\n }\n url += '?' + q.join('&');\n }\n return url;\n }\n\n /**\n * Shake the basket to indicate cancel/submit\n */\n function shake_basket() {\n if (addMethod === 'drag_and_drop') {\n const sharingCartBasket = document.querySelector('button.sharing_cart_basket');\n sharingCartBasket?.classList.add('shake_basket');\n }\n }\n\n /**\n * Remove the shake effect and basket icon\n */\n function remove_basket() {\n if (addMethod === 'drag_and_drop' && !isDragging) {\n const footer = document.getElementById('page-footer');\n const footerIconContainer = footer.querySelector('div[data-region=\"footer-container-popover\"]');\n const sharingCartBasket = document.querySelector('button.sharing_cart_basket');\n\n if (sharingCartBasket) {\n footerIconContainer?.removeChild(sharingCartBasket);\n sharingCartBasket.classList.remove('shake_basket');\n }\n }\n }\n\n /**\n * Modal called when confirming an action.\n *\n * @param obj\n */\n function confirm_modal(obj) {\n\n // Checkbox for copying userdata confirmation.\n if (obj.checkbox) {\n obj.body +=\n '
    ' +\n '' +\n '' +\n '
    ';\n }\n\n\n ModalFactory.create({\n type: ModalFactory.types.SAVE_CANCEL,\n title: obj.title,\n body: obj.body,\n }).done(function(modal) {\n let is_submitted = false;\n modal.setSaveButtonText(obj.save_button);\n\n // On save save check - if checkbox is checked.\n modal.getRoot().on(ModalEvents.save, function(e) {\n\n var response = {\n 'checkbox': $(e.target).find('.modal-checkbox').is(':checked'),\n };\n\n obj.next(response);\n is_submitted = true;\n });\n\n modal.getRoot().on(ModalEvents.cancel, function() {\n remove_basket();\n });\n\n // Remove modal from html.\n modal.getRoot().on(ModalEvents.hidden, function() {\n $('body').removeClass('modal-open');\n\n if (!is_submitted) {\n remove_basket();\n }\n });\n\n modal.show();\n });\n }\n\n /**\n * Get the section name from the section when\n * it's changed with the in place editor\n *\n * @param $section\n * @returns {*}\n */\n function in_place_edit_section_name($section) {\n var sectionName = '';\n var $inPlaceEditable = $section.find('h3.sectionname .inplaceeditable');\n if ($inPlaceEditable.length) {\n sectionName = $inPlaceEditable.data('value');\n }\n return sectionName;\n }\n\n /**\n * @param post_data\n * @param title_str\n * @param body_str\n * @param isSection\n */\n function on_backup_modal(post_data, title_str, body_str, isSection) {\n (function(on_success) {\n $.post(get_action_url('rest'), post_data,\n function(response) {\n on_success(response);\n }, \"text\")\n .fail(function(response) {\n show_error(response);\n });\n })(function(response) {\n var copyable = response === '1';\n var checkbox = false;\n\n if (copyable) {\n checkbox = true;\n }\n\n confirm_modal({\n 'title': title_str,\n 'body': body_str,\n 'save_button': str('modal_confirm_backup'),\n 'checkbox': checkbox,\n 'next': function(data) {\n if (isSection === true) {\n backup_section(post_data.sectionid, post_data.sectionnumber, post_data.courseid, data.checkbox);\n } else {\n backup(post_data.cmid, data.checkbox);\n }\n\n shake_basket();\n }\n });\n });\n }\n\n /** @var {Object} The icon configurations */\n var icon = {\n // Actions\n 'backup': {\n css: 'editing_backup',\n iconClass: 'fa fa-frown-o',\n },\n 'movedir': {\n css: 'editing_right',\n iconClass: 'fa fa-arrow-right',\n },\n 'move': {\n css: 'editing_move_',\n iconClass: 'fa fa-arrows-v',\n },\n 'edit': {\n css: 'editing_update',\n iconClass: 'fa fa-pencil',\n },\n 'cancel': {\n css: 'editing_cancel',\n iconClass: 'fa fa-ban',\n },\n 'delete': {\n css: 'editing_update',\n iconClass: 'fa fa-trash',\n },\n 'restore': {\n css: 'editing_restore',\n iconClass: 'fa fa-clone',\n },\n // Directories\n 'dir-open': {\n iconClass: 'fa fa-folder-open-o'\n },\n 'dir-closed': {\n iconClass: 'fa fa-folder-o'\n },\n };\n\n /** @var {Node} The Sharing Cart block container node */\n var $block = $('.block_sharing_cart');\n\n /** @var {Object} The current course */\n var course = new function() {\n var body = $('body');\n this.id = body.attr('class').match(/course-(\\d+)/)[1];\n this.is_frontpage = body.hasClass('pagelayout-frontpage');\n }();\n\n /**\n * Shows an error message with given Ajax error\n *\n * @param {Object} response The Ajax response\n */\n function show_error(response) {\n try {\n var ex = JSON.parse(response.responseText);\n new M.core.exception({\n name: str('pluginname') + ' - ' + str('error'),\n message: ex.message\n });\n } catch (e) {\n new M.core.exception({\n name: str('pluginname') + ' - ' + str('error'),\n message: response.responseText\n });\n }\n }\n\n /**\n * Check special layout (theme boost)\n *\n * @return {Boolean}\n */\n function verify_layout() {\n var menuelement = $block.find('.menubar .dropdown .dropdown-menu');\n return (menuelement.length);\n }\n\n /**\n * Set Cookie\n * @param name\n * @param value\n * @param expireTimeInMillisecond\n */\n function setCookie(name, value, expireTimeInMillisecond) {\n var d = new Date();\n d.setTime(d.getTime() + expireTimeInMillisecond);\n var expires = 'expires=' + d.toUTCString();\n document.cookie = name + '=' + value + ';' + expires + '';\n }\n\n /**\n * Get Cookie Value\n * @param param\n * @returns {*}\n */\n function getCookieValue(param) {\n var readCookie = document.cookie.match('(^|;)\\\\s*' + param + '\\\\s*=\\\\s*([^;]+)');\n return readCookie ? readCookie.pop() : '';\n }\n\n /**\n * Create a command icon\n *\n * @param {String} name The command name, predefined in icon\n * @param {String} [pix] The icon pix name to override\n */\n function create_command(name) {\n var iconElement = $('')\n .attr('alt', str(name))\n .attr('class', icon[name].iconClass);\n // If (verify_layout()) {\n // iconElement.addClass('iconcustom');\n // }\n\n return $('
    ')\n .addClass(icon[name].css)\n .attr('title', str(name))\n .append(iconElement);\n }\n\n /**\n * Create a spinner\n * @param $node\n * @returns {*|jQuery}\n */\n function add_spinner() {\n var $spinner = ($('
    '));\n $('section.block_sharing_cart').append($spinner);\n return $spinner;\n }\n\n /**\n *\n * @param $node\n * @returns {jQuery.fn.init}\n */\n function add_node_spinner($node) {\n var $node_spinner = $('');\n $node.append($node_spinner);\n return $node_spinner;\n }\n\n $(document).on('click', 'a.restore', function() {\n add_spinner();\n });\n\n /**\n *\n * Reload the Sharing Cart item tree\n */\n function reload_tree() {\n $.post(get_action_url(\"rest\"),\n {\n \"action\": \"render_tree\",\n \"courseid\": course.id\n },\n function(response) {\n $block.find(\".tree\").replaceWith($(response));\n $.init_item_tree();\n }, \"html\")\n .fail(function(response) {\n show_error(response);\n });\n }\n\n /**\n * Backup an activity\n *\n * @param {int} cmid\n * @param {Boolean} userdata\n */\n function backup(cmid, userdata) {\n var $commands = $('#module-' + cmid + ' .actions');\n if (!$commands.length) {\n $commands = $('[data-owner=\"#module-' + cmid + '\"]');\n }\n\n var $spinner = add_spinner();\n var $node_spinner = add_node_spinner($commands);\n\n $.post(get_action_url(\"rest\"),\n {\n \"action\": \"backup\",\n \"cmid\": cmid,\n \"userdata\": userdata,\n \"sesskey\": M.cfg.sesskey,\n \"courseid\": course.id\n },\n function() {\n reload_tree();\n })\n .fail(function(response) {\n show_error(response);\n })\n .always(function() {\n $node_spinner.hide();\n $spinner.hide();\n remove_basket();\n });\n }\n\n /**\n * Backup an activities in a section\n *\n * @param {int} sectionId\n * @param {int} sectionNumber\n * @param {int} courseId\n * @param {Boolean} userdata\n */\n function backup_section(sectionId, sectionNumber, courseId, userdata) {\n var $commands = $('span.inplaceeditable[data-itemtype=sectionname][data-itemid=' + sectionId + ']');\n var $section = $commands.closest(\"li.section.main\");\n var sectionName = $section.attr('aria-label') || $section.find('.sectionname').text().trim();\n\n if (sectionName === null) {\n sectionName = String($('#region-main .section_action_menu[data-sectionid=\\'' + sectionId + '\\']')\n .parent().parent().find('h3.sectionname').text());\n }\n\n var inPlaceEditSectionName = in_place_edit_section_name($section);\n sectionName = (inPlaceEditSectionName !== '') ? inPlaceEditSectionName : sectionName;\n\n var $spinner = add_spinner();\n var $node_spinner = add_node_spinner($commands);\n\n $.post(get_action_url(\"rest\"),\n {\n \"action\": \"backup_section\",\n \"sectionid\": sectionId,\n \"sectionnumber\": sectionNumber,\n \"courseid\": courseId,\n \"sectionname\": sectionName,\n \"userdata\": userdata,\n \"sesskey\": M.cfg.sesskey\n },\n function() {\n reload_tree();\n })\n .fail(function(response) {\n show_error(response);\n })\n .always(function() {\n $spinner.hide();\n $node_spinner.hide();\n remove_basket();\n });\n }\n\n\n // /////// CLASSES /////////\n\n /**\n * @class Directory states manager\n */\n var directories = new function() {\n var KEY = 'block_sharing_cart-dirs';\n\n var opens = getCookieValue(KEY).split(',').map(function(v) {\n return parseInt(v);\n });\n\n function save() {\n var expires = new Date();\n expires.setDate(expires.getDate() + 30);\n setCookie(KEY, opens.join(','), expires);\n }\n\n function open($dir, visible) {\n var iconIndex = visible ? 'dir-open' : 'dir-closed';\n var iconElement = icon[iconIndex].iconClass;\n $dir.find('> div i.icon').attr('class', 'icon ' + iconElement);\n $dir.find('> ul.list')[visible ? 'show' : 'hide']();\n }\n\n function toggle(e) {\n var $dir = $(e.target).closest('li.directory');\n var i = $dir.attr('id').match(/(\\d+)$/)[1];\n var v = $dir.find('> ul.list').css('display') === 'none';\n\n open($dir, v);\n opens[i] = v ? 1 : 0;\n save();\n }\n\n /**\n * Initialize directory states\n */\n this.init = function() {\n var i = 0;\n $block.find('li.directory').each(function(index, dir) {\n var $dir = $(dir);\n $dir.attr('id', 'block_sharing_cart-dir-' + i);\n if (i >= opens.length) {\n opens.push(0);\n } else if (opens[i]) {\n open($dir, true);\n }\n $dir.find('> div div.toggle-wrapper').css('cursor', 'pointer').on('click', function(e) {\n toggle(e);\n });\n i++;\n });\n };\n\n /**\n * Reset directory states\n */\n this.reset = function() {\n opens = [];\n this.init();\n save();\n };\n }();\n\n /**\n * @class Targets for moving an item directory\n */\n var move_targets = new function() {\n var $cancel = null,\n targets = [];\n\n /**\n * Hide move targets\n */\n this.hide = function() {\n if ($cancel !== null) {\n var $commands = $cancel.closest('.commands');\n $cancel.remove();\n $cancel = null;\n $commands.closest('li.activity').css('opacity', 1.0);\n $commands.find('a').each(function() {\n $(this).show();\n });\n $.each(targets, function(index, $target) {\n $target.remove();\n });\n targets = [];\n }\n };\n\n /**\n * Show move targets for a given item\n *\n * @param {int} id The item ID\n */\n this.show = function(item_id) {\n this.hide();\n\n function move(e) {\n\n var m = $(e.target).closest('a').attr('class').match(/move-(\\d+)-to-(\\d+)/);\n var item_id = m[1],\n area_to = m[2];\n\n var $spinner = add_spinner();\n $.post(get_action_url(\"rest\"),\n {\n \"action\": \"move\",\n \"item_id\": item_id,\n \"area_to\": area_to,\n \"sesskey\": M.cfg.sesskey\n },\n function() {\n reload_tree();\n })\n .fail(function(response) {\n show_error(response);\n })\n .always(function() {\n $spinner.hide();\n });\n }\n\n var $current = $block.find('#block_sharing_cart-item-' + item_id);\n var $next = $current.next();\n var $list = $current.closest('ul');\n\n var next_id = 0;\n if ($next.length) {\n next_id = $next.attr('id').match(/item-(\\d+)$/)[1];\n }\n\n /**\n *\n * @param item_id\n * @param area_to\n * @returns {jQuery}\n */\n function create_target(item_id, area_to) {\n var $anchor = $('
    ')\n .addClass('move-' + item_id + '-to-' + area_to)\n .attr('title', str('movehere'))\n .append(\n $('

    ' + str('clicktomove') + '

    ')\n .attr('alt', str('movehere'))\n );\n\n var $target = $('
  • ')\n .append($anchor);\n $anchor.on('click', function(e) {\n move(e);\n });\n\n return $target;\n }\n\n $list.find('> li.activity').each(function(index, item) {\n var $item = $(item);\n var to = $item.attr('id').match(/item-(\\d+)$/)[1];\n if (to === item_id) {\n $cancel = create_command('cancel', 't/left');\n $cancel.on('click', function() {\n move_targets.hide();\n });\n var $commands = $item.find('.commands');\n $commands.find('a').each(function() {\n $(this).hide();\n });\n $commands.append($cancel);\n $item.css('opacity', 0.5);\n } else if (to !== next_id) {\n var $target = create_target(item_id, to);\n $item.before($target);\n targets.push($target);\n }\n }, this);\n\n if ($next) {\n var $target = create_target(item_id, 0);\n $list.append($target);\n targets.push($target);\n }\n };\n }();\n\n /**\n * @class Targets for restoring an item\n */\n\n var restore_targets = new function() {\n this.is_directory = null;\n var $clipboard = null,\n targets = [];\n\n /**\n *\n * @param id\n * @param section\n * @returns {jQuery}\n */\n\n function create_target(id, section) {\n const href = get_action_url('restore', {\n 'directory': (restore_targets.is_directory === true),\n 'target': id,\n 'course': course.id,\n 'section': section,\n 'in_section': $('#copy-section-form').data('in-section'),\n 'sesskey': M.cfg.sesskey,\n 'returnurl': document.URL,\n });\n\n let $target = $('').attr('href', href).attr('title', str('copyhere')).append(\n $('').attr('alt', str('copyhere')).attr('src', M.util.image_url('dropzone_arrow', 'block_sharing_cart'))\n );\n\n targets.push($target);\n\n return $target;\n }\n\n /**\n * Hide restore targets\n */\n this.hide = function() {\n if ($clipboard !== null) {\n $clipboard.remove();\n $clipboard = null;\n $.each(targets, function(index, $target) {\n $target.remove();\n });\n targets = [];\n }\n };\n\n /**\n *\n *\n * @param {int} id The item ID\n */\n this.show = function(id) {\n this.hide();\n\n var $view = $(\"\");\n\n if (this.is_directory) {\n $view.html(id).css('display', 'inline');\n $view.prepend(\n $(\"\").addClass(\"icon\")\n .attr(\"alt\", id)\n // .attr(\"src\", M.util.image_url(icon['dir-closed'].pix, null))\n );\n } else {\n var $item = $block.find('#block_sharing_cart-item-' + id);\n $view = $($item.find('div')[0].cloneNode(true)).css('display', 'inline');\n $view.attr('class', $view.attr('class').replace(/mod-indent-\\d+/, ''));\n $view.find('.commands').remove();\n }\n\n var $cancel = create_command('cancel');\n\n $cancel.on('click', this.hide);\n\n $clipboard = $('
    ');\n $clipboard.append(str('clipboard') + \": \").append($view).append($cancel);\n\n if (course.is_frontpage) {\n var $sitetopic = $('.sitetopic');\n var $mainmenu = $('.block_site_main_menu');\n if ($sitetopic) {\n $sitetopic.find('*').before($clipboard);\n } else if ($mainmenu) {\n $mainmenu.find('.content').before($clipboard);\n }\n\n // Mainmenu = section #0, sitetopic = section #1\n if ($mainmenu) {\n $mainmenu.find('.footer').before(create_target(id, 0));\n }\n if ($sitetopic) {\n $sitetopic.find('ul.section').append(create_target(id, 1));\n }\n } else {\n var $container = $('.course-content');\n $container.prepend($clipboard);\n $container.find(M.course.format.get_section_wrapper(null)).each(function(index, sectionDOM) {\n var $section = $(sectionDOM);\n var section = $section.attr('id').match(/(\\d+)$/)[1];\n $section.find('ul.section').first().append(create_target(id, section));\n }, this);\n }\n };\n }();\n\n // /////// INITIALIZATION /////////\n\n /**\n *\n * @returns {string|*}\n */\n $.get_plugin_name = function() {\n var $blockheader = $block.find(\"h2\");\n\n if (!$blockheader.length) {\n $blockheader = $block.find(\"h3\");\n\n if ($blockheader.length) {\n return $blockheader.html();\n }\n } else {\n return $blockheader.html();\n }\n\n return \"\";\n };\n\n /**\n *\n * @param e\n * @param activityName\n */\n $.on_backup = function(e, activityName) {\n var cmid = (function($backup) {\n var $activity = $backup.closest('li.activity');\n if ($activity.length) {\n return $activity.attr('id').match(/(\\d+)$/)[1];\n }\n var $commands = $backup.closest('.commands');\n var dataowner = $commands.attr('data-owner');\n if (dataowner.length) {\n return dataowner.match(/(\\d+)$/)[1];\n }\n return $commands.find('a.editing_delete').attr('href').match(/delete=(\\d+)/)[1];\n })($(e.target));\n\n var data =\n {\n \"action\": \"is_userdata_copyable\",\n \"cmid\": cmid\n };\n\n on_backup_modal(data, activityName, str('confirm_backup'), false);\n };\n\n /**\n * On movedir command clicked\n *\n * @param {DOMEventFacade} e\n */\n $.on_movedir = function(e) {\n var $commands = $(e.target).closest('.commands');\n\n var $current_dir = $commands.closest('li.directory');\n var current_path = $current_dir.length ? $current_dir.attr('directory-path') : '/';\n\n var item_id = $(e.target).closest('li.activity').attr('id').match(/(\\d+)$/)[1];\n\n var dirs = [];\n $block.find('li.directory').each(function() {\n dirs.push($(this).attr('directory-path'));\n });\n\n var $form = $('');\n // eslint-disable-next-line no-script-url\n $form.attr('action', 'javascript:void(0)');\n\n function submit() {\n var folder_to = $form.find('[name=\"to\"]').val();\n var $spinner = add_spinner();\n $.post(get_action_url('rest'),\n {\n \"action\": \"movedir\",\n \"item_id\": item_id,\n \"folder_to\": folder_to,\n \"sesskey\": M.cfg.sesskey\n },\n function() {\n reload_tree();\n directories.reset();\n })\n .fail(function(response) {\n show_error(response);\n })\n .always(function() {\n $spinner.hide();\n });\n }\n\n $form.submit(submit);\n\n if (dirs.length === 0) {\n var $input = $('').val(current_path);\n setTimeout(function() {\n $input.focus();\n }, 1);\n $form.append($input);\n } else {\n dirs.unshift('/');\n\n var $select = $('').val(current_path);\n $select.remove();\n $edit.replaceWith($input);\n $input.focus();\n });\n\n $form.append($edit);\n }\n\n var $cancel = create_command('cancel');\n $cancel.on('click', function() {\n $form.remove();\n $commands.find('a').show();\n });\n $form.append($cancel);\n\n $commands.find('a').each(function() {\n $(this).hide();\n });\n $commands.append($form);\n };\n\n /**\n * On move command clicked\n *\n * @param {DOMEventFacade} e\n */\n $.on_move = function(e) {\n var $item = $(e.target).closest('li.activity');\n var id = $item.attr('id').match(/(\\d+)$/)[1];\n\n move_targets.show(id);\n };\n\n /**\n * On delete command clicked\n *\n * @param {DOMEventFacade} e\n */\n $.on_delete = function(e) {\n var $item = $(e.target).closest('li');\n var liText = $item[0].innerText;\n\n var isDirectory = false;\n var modalBody;\n var item;\n var description_text = '';\n\n if ($item.hasClass(\"directory\")) {\n isDirectory = true;\n item = str('folder_string');\n description_text = str('delete_folder');\n } else {\n item = str('activity_string');\n }\n\n modalBody = '

    ' + item + ' ' + liText + description_text + '

    ';\n\n confirm_modal({\n 'title': str('confirm_delete'),\n 'body': modalBody,\n 'save_button': str('modal_confirm_delete'),\n 'checkbox': false,\n 'next': function() {\n\n var data = {};\n\n if (isDirectory === true) {\n data = {\n \"action\": \"delete_directory\",\n \"path\": $item.attr(\"directory-path\"),\n \"sesskey\": M.cfg.sesskey\n };\n } else if ($item.hasClass(\"activity\")) {\n data = {\n \"action\": \"delete\",\n \"id\": $item.attr('id').match(/(\\d+)$/)[1],\n \"sesskey\": M.cfg.sesskey\n };\n }\n\n var $spinner = add_spinner();\n\n $.post(get_action_url(\"rest\"), data,\n function() {\n reload_tree();\n })\n .fail(function(response) {\n show_error(response);\n })\n .always(function() {\n $spinner.hide();\n });\n\n e.stopPropagation();\n }\n });\n };\n\n /**\n * On restore command clicked\n *\n * @param {DOMEventFacade} e\n */\n $.on_restore = function(e) {\n var $item = $(e.target).closest('li');\n var id = null;\n\n if ($item.hasClass(\"directory\")) {\n id = $item.attr(\"directory-path\");\n restore_targets.is_directory = true;\n } else if ($item.hasClass(\"activity\")) {\n id = $item.attr('id').match(/(\\d+)$/)[1];\n restore_targets.is_directory = false;\n }\n\n restore_targets.show(id);\n };\n\n /**\n * On backup the whole section as a folder\n *\n * @param {int} sectionId\n * @param {int} sectionNumber\n * @param {int} courseId\n * @param {string} sectionName\n */\n $.on_section_backup = function(sectionId, sectionNumber, courseId, sectionName) {\n var data =\n {\n \"action\": \"is_userdata_copyable_section\",\n \"sectionid\": sectionId,\n \"sectionnumber\": sectionNumber,\n \"courseid\": courseId,\n };\n\n var body_html = '

    ' + str('backup_heavy_load_warning_message') +\n '

    ' + str('confirm_backup_section');\n\n on_backup_modal(data, sectionName, body_html, true);\n };\n\n /**\n * Initialize the delete bulk\n */\n $.init_bulk_delete = function(isspeciallayout) {\n var bulkdelete = $block.find('.editing_bulkdelete');\n if (bulkdelete.length) {\n if (isspeciallayout) {\n bulkdelete.attr('role', 'menuitem').addClass('dropdown-item menu-action');\n bulkdelete.append($(\"\").append(bulkdelete.attr('title')));\n\n $block.find('.menubar .dropdown .dropdown-menu').append(bulkdelete);\n } else {\n $block.find('.header .commands').append(bulkdelete);\n }\n }\n };\n\n /**\n * Initialize the help icon\n */\n $.init_help_icon = function(isspeciallayout) {\n var helpicon = $block.find('.header-commands > .help-icon');\n\n if (isspeciallayout) {\n $block.find('.header-commands').parent().css('display', 'block');\n } else {\n $block.find('.header .commands').append(helpicon);\n }\n };\n\n /**\n * Initialize the Sharing Cart block header\n */\n $.init_block_header = function() {\n var isspeciallayout = verify_layout();\n $.init_bulk_delete(isspeciallayout);\n $.init_help_icon(isspeciallayout);\n };\n\n /**\n * Initialize the Sharing Cart item tree\n */\n $.init_item_tree = function() {\n function add_actions(item, actions) {\n var $item = $(item);\n var $commands = $item.find('.commands').first();\n\n $.each(actions, function(index, action) {\n var $command = create_command(action);\n $command.on('click', function(e) {\n $['on_' + action](e);\n });\n $commands.append($command);\n }, this);\n }\n\n var activity_actions = ['movedir', 'move', 'delete'];\n if (course) {\n activity_actions.push('restore');\n }\n\n var directory_actions = ['delete', 'restore'];\n\n // Initialize items\n $block.find('li.activity').each(function(index, item) {\n if($(item).attr('data-disable-copy') == 1) {\n add_actions(item, ['movedir', 'move', 'delete']);\n return;\n }\n add_actions(item, activity_actions);\n });\n\n // Initialize directory items\n $block.find('li.directory').each(function(index, item) {\n add_actions(item, directory_actions);\n });\n\n // Initialize directories\n directories.init();\n };\n\n /**\n * Extract html object from area where moodle ajax was called.\n *\n * Call add_activity_backup_control to re append sharing cart icon.\n */\n $.init_activity_commands = function() {\n $(document).ajaxComplete(function(event, xhr, settings) {\n\n var url = settings.url;\n var lastslashindex = url.lastIndexOf('=');\n var result = url.substring(lastslashindex + 1);\n\n if (result === 'core_course_edit_module' || result === 'core_course_get_module') {\n\n var data = JSON.parse(settings.data);\n var action = data[0].args.action;\n\n // Don't try to add icon if activity has been deleted.\n if (action === 'delete') {\n return;\n }\n\n setTimeout(function() {\n var activity_id = data[0].args.id;\n var activity = $('#module-' + activity_id);\n add_activity_backup_control(activity);\n\n if (action === 'duplicate') {\n var duplicated = activity.next();\n add_activity_backup_control(duplicated);\n }\n }, 1);\n }\n });\n\n /**\n * Create the backup icon\n *\n * @returns $backupIcon\n */\n function create_backup_icon() {\n\n var $backupIcon = $('
    ')\n .append($(''))\n .attr('title', str('backup'));\n\n if (addMethod !== 'click_to_add') {\n $backupIcon.addClass('d-none');\n }\n\n return $backupIcon;\n }\n\n /**\n * Add backup control with a click event to an activity\n * Added fix for copying an activity without backup routine\n *\n * @param $activity\n */\n function add_activity_backup_control($activity) {\n\n var activityClass = $activity[0].className;\n\n // Selecting modtype without prefix.\n var modtype = activityClass.substr(activityClass.indexOf('modtype_') + 8);\n\n // Default activity name.\n var activityName = str('activity_string');\n\n // Label is using a different html / css layout, so it's needed to get the name by using another $find.\n if (modtype !== 'label') {\n activityName = $('.activity#' + $activity[0].id)\n .find('.mod-indent-outer .activityinstance span.instancename')\n .html();\n }\n\n var $backupIcon = create_backup_icon();\n\n $backupIcon.on('click', function(e) {\n $.on_backup(e, activityName);\n });\n\n var $actionMenuItem = $activity.find('.action-menu.section-cm-edit-actions').parent('.actions');\n\n if (!$actionMenuItem.find('.add-to-sharing-cart').length) {\n $actionMenuItem.append($backupIcon);\n }\n }\n\n /**\n * Add backup control with a click event to a section\n *\n * @param $section\n */\n function add_section_backup_control($section) {\n\n var sectionId = $section.find('.section_action_menu').data('sectionid');\n var sectionNumber = parseInt(String($section.attr('id')).match(/\\d+/)[0]);\n var sectionName = $section.attr('aria-label') || $section.find('.sectionname').text().trim();\n\n var isFlexibleCourseFormat = $('body[id$=flexsections]').length;\n\n // Extract the section ID from the section if this is a Flexible\n // course format (since this format doesn't have an action menu)\n if (isFlexibleCourseFormat && (typeof sectionId === 'undefined' || sectionId === null)) {\n sectionId = $section.data('section-id');\n }\n\n // A bit unsafe to extract the course ID from the body but it's the best option we got at the moment\n var courseId = parseInt(String($('body').attr('class')).match(/course-([0-9]*)( |$)/)[1]);\n\n var $backupIcon = create_backup_icon();\n\n $backupIcon.on('click', function() {\n var inPlaceEditSectionName = in_place_edit_section_name($section);\n sectionName = (inPlaceEditSectionName !== '') ? inPlaceEditSectionName : sectionName;\n $.on_section_backup(sectionId, sectionNumber, courseId, sectionName);\n });\n\n var $sectionTitle = $section.find('h3.sectionname').first().find('a').last();\n\n var $inPlaceEditable = $section.find('h3.sectionname .inplaceeditable').first();\n if ($inPlaceEditable.length) {\n $sectionTitle = $inPlaceEditable;\n }\n\n // Add the backup icon after the cog wheel if this is a Flexible course format\n if (isFlexibleCourseFormat && sectionNumber === 0) {\n $sectionTitle = $section.find('> .controls');\n $sectionTitle.prepend($backupIcon);\n } else {\n $backupIcon.insertAfter($sectionTitle);\n }\n\n var activitySelector = 'li.activity';\n\n var $activities = $section.find(activitySelector);\n\n $($activities).each(function() {\n add_activity_backup_control($(this));\n });\n }\n\n $(\"body.editing .course-content li.section\").each(function() {\n add_section_backup_control($(this));\n });\n };\n\n /**\n * Initialize the Sharing Cart footer basket for 4.0+.\n */\n function init_footer_basket() {\n let currentDragging;\n const activities = document.querySelectorAll(\".activity.activity-wrapper\");\n const sections = document.querySelectorAll(\".course-section-header\");\n const sharingCartBlock = document.querySelector('section[data-block=\"sharing_cart\"]');\n\n add_draggable_to_first_section();\n\n const footer = document.getElementById('page-footer');\n const footerIconContainer = footer.querySelector('div[data-region=\"footer-container-popover\"]');\n\n var basket = document.createElement('i');\n basket.setAttribute('class', 'fa fa-shopping-basket');\n\n var basketButton = document.createElement('button');\n basketButton.setAttribute('class', 'btn btn-icon bg-secondary icon-no-margin btn-footer-popover sharing_cart_basket');\n basketButton.setAttribute('style', 'z-index: 1001;');\n basketButton.append(basket);\n\n var dropAreaText = document.createElement('p');\n dropAreaText.setAttribute('class', 'font-weight-bold text-white');\n dropAreaText.innerText = str('drop_here');\n\n var dropArea = document.createElement('div');\n dropArea.setAttribute('class',\n 'h-100 w-100 position-absolute d-flex justify-content-center align-items-center');\n dropArea.append(dropAreaText);\n\n sections.forEach(section => {\n drag_event_listeners(section);\n });\n\n activities.forEach(activity => {\n drag_event_listeners(activity);\n });\n\n /**\n * Initialize events for dragging\n * @param {object} draggable\n */\n function drag_event_listeners(draggable) {\n draggable.addEventListener('dragstart', (e) => {\n basketButton.classList.remove('shake_basket');\n\n footerIconContainer?.prepend(basketButton);\n sharingCartBlock.children[0].classList.add('dragging_item');\n sharingCartBlock.append(dropArea);\n currentDragging = e.target;\n isDragging = true;\n });\n\n draggable.addEventListener('dragend', () => {\n if (currentDragging instanceof HTMLElement) {\n footerIconContainer?.removeChild(basketButton);\n }\n\n sharingCartBlock.children[0].classList.remove('dragging_item');\n sharingCartBlock.removeChild(dropArea);\n isDragging = false;\n });\n }\n\n [basketButton, sharingCartBlock].forEach((dropzone) => {\n dropzone.addEventListener(\"dragover\", (e) => {\n e.preventDefault();\n dropzone.classList.add('drag_over');\n });\n\n dropzone.addEventListener(\"dragenter\", (e) => {\n e.preventDefault();\n dropzone.classList.add('drag_over');\n });\n\n dropzone.addEventListener(\"dragleave\", () => {\n dropzone.classList.remove('drag_over');\n });\n\n dropzone.addEventListener(\"drop\", () => {\n if (currentDragging instanceof HTMLElement) {\n currentDragging.querySelector('.add-to-sharing-cart').click();\n }\n\n dropzone.classList.remove('drag_over');\n currentDragging = undefined;\n isDragging = false;\n });\n });\n }\n\n /**\n * Make the first section (General) draggable\n */\n function add_draggable_to_first_section() {\n const courseSectionHeader = document.getElementsByClassName(\"course-section-header\")[0] ?? null;\n\n if (courseSectionHeader instanceof HTMLElement) {\n courseSectionHeader.classList.add('draggable');\n courseSectionHeader.setAttribute('draggable', true);\n }\n }\n\n /**\n * Initialize the Sharing Cart block\n */\n $.init = function() {\n M.str.block_sharing_cart.pluginname = this.get_plugin_name();\n\n // Arrange header icons (bulkdelete, help)\n $.init_block_header();\n $.init_item_tree();\n $.init_activity_commands();\n\n if (addMethod === 'drag_and_drop') {\n init_footer_basket();\n }\n };\n var $spinner = $('').addClass('spinner fa fa-3x fa-circle-o-notch fa-spin');\n $('div#sharing-cart-spinner-modal div.spinner-container').prepend($spinner);\n\n $.init();\n });\n\n $('.copy_section').on('click', function() {\n\n var $section_selected = ($('.section-dropdown option:selected'));\n var sectionId = $section_selected.data('section-id');\n var sectionNumber = $section_selected.data('section-number');\n var courseId = $section_selected.data('course-id');\n var sectionName = $section_selected.data('section-name');\n\n $.on_section_backup(sectionId, sectionNumber, courseId, sectionName);\n });\n }\n };\n});\n"],"names":["define","$","ModalFactory","ModalEvents","init","addMethod","document","ready","isDragging","str","identifier","M","block_sharing_cart","moodle","get_action_url","name","args","url","cfg","wwwroot","q","k","push","encodeURIComponent","join","remove_basket","footerIconContainer","getElementById","querySelector","sharingCartBasket","removeChild","classList","remove","confirm_modal","obj","checkbox","body","create","type","types","SAVE_CANCEL","title","done","modal","is_submitted","setSaveButtonText","save_button","getRoot","on","save","e","response","target","find","is","next","cancel","hidden","removeClass","show","in_place_edit_section_name","$section","sectionName","$inPlaceEditable","length","data","on_backup_modal","post_data","title_str","body_str","isSection","post","sectionId","sectionNumber","courseId","userdata","$commands","closest","attr","text","trim","String","parent","inPlaceEditSectionName","$spinner","add_spinner","$node_spinner","add_node_spinner","sesskey","reload_tree","fail","show_error","always","hide","backup_section","sectionid","sectionnumber","courseid","cmid","course","id","backup","add","shake_basket","on_success","icon","css","iconClass","$block","match","is_frontpage","hasClass","ex","JSON","parse","responseText","core","exception","message","create_command","iconElement","addClass","append","$node","replaceWith","init_item_tree","directories","param","readCookie","KEY","opens","cookie","pop","split","map","v","parseInt","expires","Date","setDate","getDate","value","expireTimeInMillisecond","d","setTime","getTime","toUTCString","setCookie","open","$dir","visible","i","each","index","dir","toggle","reset","move_targets","$cancel","targets","this","$target","item_id","$current","$next","$list","next_id","create_target","area_to","$anchor","m","move","item","$item","to","before","restore_targets","is_directory","$clipboard","section","href","URL","util","image_url","$view","html","prepend","cloneNode","replace","$sitetopic","$mainmenu","$container","format","get_section_wrapper","sectionDOM","first","init_footer_basket","currentDragging","activities","querySelectorAll","sections","sharingCartBlock","courseSectionHeader","getElementsByClassName","HTMLElement","setAttribute","add_draggable_to_first_section","basket","createElement","basketButton","dropAreaText","innerText","dropArea","drag_event_listeners","draggable","addEventListener","children","forEach","activity","dropzone","preventDefault","click","undefined","get_plugin_name","$blockheader","on_backup","activityName","$backup","$activity","dataowner","on_movedir","$current_dir","current_path","dirs","$form","submit","folder_to","val","$input","setTimeout","focus","unshift","$select","change","$edit","on_move","on_delete","modalBody","liText","isDirectory","description_text","stopPropagation","on_restore","on_section_backup","init_bulk_delete","isspeciallayout","bulkdelete","init_help_icon","helpicon","init_block_header","add_actions","actions","action","$command","activity_actions","directory_actions","init_activity_commands","create_backup_icon","$backupIcon","add_activity_backup_control","activityClass","className","modtype","substr","indexOf","$actionMenuItem","ajaxComplete","event","xhr","settings","lastslashindex","lastIndexOf","result","substring","activity_id","isFlexibleCourseFormat","$sectionTitle","last","insertAfter","$activities","add_section_backup_control","pluginname","$section_selected"],"mappings":";;;;;;;AAuBAA,mCAAO,CAAC,SAAU,qBAAsB,sBAAsB,SAASC,EAAGC,aAAcC,mBAC7E,CACHC,KAAM,SAASC,WAEXJ,EAAEK,UAAUC,OAAM,eACVC,YAAa,WAQRC,IAAIC,mBACFC,EAAEF,IAAIG,mBAAmBF,aAAeC,EAAEF,IAAII,OAAOH,qBAUvDI,eAAeC,KAAMC,UACtBC,IAAMN,EAAEO,IAAIC,QAAU,wBAA0BJ,KAAO,UACvDC,KAAM,KACFI,EAAI,OACH,IAAIC,KAAKL,KACVI,EAAEE,KAAKD,EAAI,IAAME,mBAAmBP,KAAKK,KAE7CJ,KAAO,IAAMG,EAAEI,KAAK,YAEjBP,aAgBFQ,mBACa,kBAAdpB,YAAkCG,WAAY,OAExCkB,oBADSpB,SAASqB,eAAe,eACJC,cAAc,+CAC3CC,kBAAoBvB,SAASsB,cAAc,8BAE7CC,oBACAH,MAAAA,qBAAAA,oBAAqBI,YAAYD,mBACjCA,kBAAkBE,UAAUC,OAAO,2BAUtCC,cAAcC,KAGfA,IAAIC,WACJD,IAAIE,MACA,uJAEiC3B,IAAI,kBAFrC,kBAORP,a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K+D,kBAG3C9N,EAAEkQ,oBACFlQ,EAAE4H,iBACF5H,EAAEyQ,yBAEgB,kBAAdrQ,WACA+L,0BAGJhH,SAAWnF,EAAE,QAAQwH,SAAS,8CAClCxH,EAAE,wDAAwDyL,QAAQtG,UAElEnF,EAAEG,UAGNH,EAAE,iBAAiB+C,GAAG,SAAS,eAEvBoP,kBAAqBnS,EAAE,qCACvBuE,UAAY4N,kBAAkBnO,KAAK,cACnCQ,cAAgB2N,kBAAkBnO,KAAK,kBACvCS,SAAW0N,kBAAkBnO,KAAK,aAClCH,YAAcsO,kBAAkBnO,KAAK,gBAEzChE,EAAE4P,kBAAkBrL,UAAWC,cAAeC,SAAUZ"} \ No newline at end of file +{"version":3,"file":"script.min.js","sources":["../src/script.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 * Sharing Cart\n *\n * @package block_sharing_cart\n * @copyright 2017 (C) VERSION2, INC.\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery', 'core/modal_factory', 'core/modal_events'], function($, ModalFactory, ModalEvents) {\n return {\n init: function(addMethod) {\n\n $(document).ready(function() {\n let isDragging = false;\n\n /**\n * Returns a localized string\n *\n * @param {String} identifier\n * @return {String}\n */\n function str(identifier) {\n return M.str.block_sharing_cart[identifier] || M.str.moodle[identifier];\n }\n\n /**\n * Get an action URL\n *\n * @param {String} name The action name\n * @param {Object} [args] The action parameters\n * @return {String}\n */\n function get_action_url(name, args) {\n var url = M.cfg.wwwroot + '/blocks/sharing_cart/' + name + '.php';\n if (args) {\n var q = [];\n for (var k in args) {\n q.push(k + '=' + encodeURIComponent(args[k]));\n }\n url += '?' + q.join('&');\n }\n return url;\n }\n\n /**\n * Shake the basket to indicate cancel/submit\n */\n function shake_basket() {\n if (addMethod === 'drag_and_drop') {\n const sharingCartBasket = document.querySelector('button.sharing_cart_basket');\n sharingCartBasket?.classList.add('shake_basket');\n }\n }\n\n /**\n * Remove the shake effect and basket icon\n */\n function remove_basket() {\n if (addMethod === 'drag_and_drop' && !isDragging) {\n const footer = document.getElementById('page-footer');\n const footerIconContainer = footer.querySelector('div[data-region=\"footer-container-popover\"]');\n const sharingCartBasket = document.querySelector('button.sharing_cart_basket');\n\n if (sharingCartBasket) {\n footerIconContainer?.removeChild(sharingCartBasket);\n sharingCartBasket.classList.remove('shake_basket');\n }\n }\n }\n\n /**\n * Modal called when confirming an action.\n *\n * @param obj\n */\n function confirm_modal(obj) {\n\n // Checkbox for copying userdata confirmation.\n if (obj.checkbox) {\n obj.body +=\n '
    ' +\n '' +\n '' +\n '
    ';\n }\n\n\n ModalFactory.create({\n type: ModalFactory.types.SAVE_CANCEL,\n title: obj.title,\n body: obj.body,\n }).done(function(modal) {\n let is_submitted = false;\n modal.setSaveButtonText(obj.save_button);\n\n // On save save check - if checkbox is checked.\n modal.getRoot().on(ModalEvents.save, function(e) {\n\n var response = {\n 'checkbox': $(e.target).find('.modal-checkbox').is(':checked'),\n };\n\n obj.next(response);\n is_submitted = true;\n });\n\n modal.getRoot().on(ModalEvents.cancel, function() {\n remove_basket();\n });\n\n // Remove modal from html.\n modal.getRoot().on(ModalEvents.hidden, function() {\n $('body').removeClass('modal-open');\n\n if (!is_submitted) {\n remove_basket();\n }\n });\n\n modal.show();\n });\n }\n\n /**\n * Get the section name from the section when\n * it's changed with the in place editor\n *\n * @param $section\n * @returns {*}\n */\n function in_place_edit_section_name($section) {\n var sectionName = '';\n var $inPlaceEditable = $section.find('h3.sectionname .inplaceeditable');\n if ($inPlaceEditable.length) {\n sectionName = $inPlaceEditable.data('value');\n }\n return sectionName;\n }\n\n /**\n * @param post_data\n * @param title_str\n * @param body_str\n * @param isSection\n */\n function on_backup_modal(post_data, title_str, body_str, isSection) {\n (function(on_success) {\n $.post(get_action_url('rest'), post_data,\n function(response) {\n on_success(response);\n }, \"text\")\n .fail(function(response) {\n show_error(response);\n });\n })(function(response) {\n var copyable = response === '1';\n var checkbox = false;\n\n if (copyable) {\n checkbox = true;\n }\n\n confirm_modal({\n 'title': title_str,\n 'body': body_str,\n 'save_button': str('modal_confirm_backup'),\n 'checkbox': checkbox,\n 'next': function(data) {\n if (isSection === true) {\n backup_section(post_data.sectionid, post_data.sectionnumber, post_data.courseid, data.checkbox);\n } else {\n backup(post_data.cmid, data.checkbox);\n }\n\n shake_basket();\n }\n });\n });\n }\n\n /** @var {Object} The icon configurations */\n var icon = {\n // Actions\n 'backup': {\n css: 'editing_backup',\n iconClass: 'fa fa-frown-o',\n },\n 'movedir': {\n css: 'editing_right',\n iconClass: 'fa fa-arrow-right',\n },\n 'move': {\n css: 'editing_move_',\n iconClass: 'fa fa-arrows-v',\n },\n 'edit': {\n css: 'editing_update',\n iconClass: 'fa fa-pencil',\n },\n 'cancel': {\n css: 'editing_cancel',\n iconClass: 'fa fa-ban',\n },\n 'delete': {\n css: 'editing_update',\n iconClass: 'fa fa-trash',\n },\n 'restore': {\n css: 'editing_restore',\n iconClass: 'fa fa-clone',\n },\n // Directories\n 'dir-open': {\n iconClass: 'fa fa-folder-open-o'\n },\n 'dir-closed': {\n iconClass: 'fa fa-folder-o'\n },\n };\n\n /** @var {Node} The Sharing Cart block container node */\n var $block = $('.block_sharing_cart');\n\n /** @var {Object} The current course */\n var course = new function() {\n var body = $('body');\n this.id = body.attr('class').match(/course-(\\d+)/)[1];\n this.is_frontpage = body.hasClass('pagelayout-frontpage');\n }();\n\n /**\n * Shows an error message with given Ajax error\n *\n * @param {Object} response The Ajax response\n */\n function show_error(response) {\n try {\n var ex = JSON.parse(response.responseText);\n new M.core.exception({\n name: str('pluginname') + ' - ' + str('error'),\n message: ex.message\n });\n } catch (e) {\n new M.core.exception({\n name: str('pluginname') + ' - ' + str('error'),\n message: response.responseText\n });\n }\n }\n\n /**\n * Check special layout (theme boost)\n *\n * @return {Boolean}\n */\n function verify_layout() {\n var menuelement = $block.find('.menubar .dropdown .dropdown-menu');\n return (menuelement.length);\n }\n\n /**\n * Set Cookie\n * @param name\n * @param value\n * @param expireTimeInMillisecond\n */\n function setCookie(name, value, expireTimeInMillisecond) {\n var d = new Date();\n d.setTime(d.getTime() + expireTimeInMillisecond);\n var expires = 'expires=' + d.toUTCString();\n document.cookie = name + '=' + value + ';' + expires + '';\n }\n\n /**\n * Get Cookie Value\n * @param param\n * @returns {*}\n */\n function getCookieValue(param) {\n var readCookie = document.cookie.match('(^|;)\\\\s*' + param + '\\\\s*=\\\\s*([^;]+)');\n return readCookie ? readCookie.pop() : '';\n }\n\n /**\n * Create a command icon\n *\n * @param {String} name The command name, predefined in icon\n * @param {String} [pix] The icon pix name to override\n */\n function create_command(name) {\n var iconElement = $('')\n .attr('alt', str(name))\n .attr('class', icon[name].iconClass);\n // If (verify_layout()) {\n // iconElement.addClass('iconcustom');\n // }\n\n return $('
    ')\n .addClass(icon[name].css)\n .attr('title', str(name))\n .append(iconElement);\n }\n\n /**\n * Create a spinner\n * @param $node\n * @returns {*|jQuery}\n */\n function add_spinner() {\n var $spinner = ($('
    '));\n $('section.block_sharing_cart').append($spinner);\n return $spinner;\n }\n\n /**\n *\n * @param $node\n * @returns {jQuery.fn.init}\n */\n function add_node_spinner($node) {\n var $node_spinner = $('');\n $node.append($node_spinner);\n return $node_spinner;\n }\n\n $(document).on('click', 'a.restore', function() {\n add_spinner();\n });\n\n /**\n *\n * Reload the Sharing Cart item tree\n */\n function reload_tree() {\n $.post(get_action_url(\"rest\"),\n {\n \"action\": \"render_tree\",\n \"courseid\": course.id\n },\n function(response) {\n $block.find(\".tree\").replaceWith($(response));\n $.init_item_tree();\n }, \"html\")\n .fail(function(response) {\n show_error(response);\n });\n }\n\n /**\n * Backup an activity\n *\n * @param {int} cmid\n * @param {Boolean} userdata\n */\n function backup(cmid, userdata) {\n var $commands = $('#module-' + cmid + ' .actions');\n if (!$commands.length) {\n $commands = $('[data-owner=\"#module-' + cmid + '\"]');\n }\n\n var $spinner = add_spinner();\n var $node_spinner = add_node_spinner($commands);\n\n $.post(get_action_url(\"rest\"),\n {\n \"action\": \"backup\",\n \"cmid\": cmid,\n \"userdata\": userdata,\n \"sesskey\": M.cfg.sesskey,\n \"courseid\": course.id\n },\n function() {\n reload_tree();\n })\n .fail(function(response) {\n show_error(response);\n })\n .always(function() {\n $node_spinner.hide();\n $spinner.hide();\n remove_basket();\n });\n }\n\n /**\n * Backup an activities in a section\n *\n * @param {int} sectionId\n * @param {int} sectionNumber\n * @param {int} courseId\n * @param {Boolean} userdata\n */\n function backup_section(sectionId, sectionNumber, courseId, userdata) {\n var $commands = $('span.inplaceeditable[data-itemtype=sectionname][data-itemid=' + sectionId + ']');\n var $section = $commands.closest(\"li.section.main\");\n var sectionName = $section.attr('aria-label') || $section.find('.sectionname').text().trim();\n\n if (sectionName === null) {\n sectionName = String($('#region-main .section_action_menu[data-sectionid=\\'' + sectionId + '\\']')\n .parent().parent().find('h3.sectionname').text());\n }\n\n var inPlaceEditSectionName = in_place_edit_section_name($section);\n sectionName = (inPlaceEditSectionName !== '') ? inPlaceEditSectionName : sectionName;\n\n var $spinner = add_spinner();\n var $node_spinner = add_node_spinner($commands);\n\n $.post(get_action_url(\"rest\"),\n {\n \"action\": \"backup_section\",\n \"sectionid\": sectionId,\n \"sectionnumber\": sectionNumber,\n \"courseid\": courseId,\n \"sectionname\": sectionName,\n \"userdata\": userdata,\n \"sesskey\": M.cfg.sesskey\n },\n function() {\n reload_tree();\n })\n .fail(function(response) {\n show_error(response);\n })\n .always(function() {\n $spinner.hide();\n $node_spinner.hide();\n remove_basket();\n });\n }\n\n\n // /////// CLASSES /////////\n\n /**\n * @class Directory states manager\n */\n var directories = new function() {\n var KEY = 'block_sharing_cart-dirs';\n\n var opens = getCookieValue(KEY).split(',').map(function(v) {\n return parseInt(v);\n });\n\n function save() {\n var expires = new Date();\n expires.setDate(expires.getDate() + 30);\n setCookie(KEY, opens.join(','), expires);\n }\n\n function open($dir, visible) {\n var iconIndex = visible ? 'dir-open' : 'dir-closed';\n var iconElement = icon[iconIndex].iconClass;\n $dir.find('> div i.icon').attr('class', 'icon ' + iconElement);\n $dir.find('> ul.list')[visible ? 'show' : 'hide']();\n }\n\n function toggle(e) {\n var $dir = $(e.target).closest('li.directory');\n var i = $dir.attr('id').match(/(\\d+)$/)[1];\n var v = $dir.find('> ul.list').css('display') === 'none';\n\n open($dir, v);\n opens[i] = v ? 1 : 0;\n save();\n }\n\n /**\n * Initialize directory states\n */\n this.init = function() {\n var i = 0;\n $block.find('li.directory').each(function(index, dir) {\n var $dir = $(dir);\n $dir.attr('id', 'block_sharing_cart-dir-' + i);\n if (i >= opens.length) {\n opens.push(0);\n } else if (opens[i]) {\n open($dir, true);\n }\n $dir.find('> div div.toggle-wrapper').css('cursor', 'pointer').on('click', function(e) {\n toggle(e);\n });\n i++;\n });\n };\n\n /**\n * Reset directory states\n */\n this.reset = function() {\n opens = [];\n this.init();\n save();\n };\n }();\n\n /**\n * @class Targets for moving an item directory\n */\n var move_targets = new function() {\n var $cancel = null,\n targets = [];\n\n /**\n * Hide move targets\n */\n this.hide = function() {\n if ($cancel !== null) {\n var $commands = $cancel.closest('.commands');\n $cancel.remove();\n $cancel = null;\n $commands.closest('li.activity').css('opacity', 1.0);\n $commands.find('a').each(function() {\n $(this).show();\n });\n $.each(targets, function(index, $target) {\n $target.remove();\n });\n targets = [];\n }\n };\n\n /**\n * Show move targets for a given item\n *\n * @param {int} id The item ID\n */\n this.show = function(item_id) {\n this.hide();\n\n function move(e) {\n\n var m = $(e.target).closest('a').attr('class').match(/move-(\\d+)-to-(\\d+)/);\n var item_id = m[1],\n area_to = m[2];\n\n var $spinner = add_spinner();\n $.post(get_action_url(\"rest\"),\n {\n \"action\": \"move\",\n \"item_id\": item_id,\n \"area_to\": area_to,\n \"sesskey\": M.cfg.sesskey\n },\n function() {\n reload_tree();\n })\n .fail(function(response) {\n show_error(response);\n })\n .always(function() {\n $spinner.hide();\n });\n }\n\n var $current = $block.find('#block_sharing_cart-item-' + item_id);\n var $next = $current.next();\n var $list = $current.closest('ul');\n\n var next_id = 0;\n if ($next.length) {\n next_id = $next.attr('id').match(/item-(\\d+)$/)[1];\n }\n\n /**\n *\n * @param item_id\n * @param area_to\n * @returns {jQuery}\n */\n function create_target(item_id, area_to) {\n var $anchor = $('
    ')\n .addClass('move-' + item_id + '-to-' + area_to)\n .attr('title', str('movehere'))\n .append(\n $('

    ' + str('clicktomove') + '

    ')\n .attr('alt', str('movehere'))\n );\n\n var $target = $('
  • ')\n .append($anchor);\n $anchor.on('click', function(e) {\n move(e);\n });\n\n return $target;\n }\n\n $list.find('> li.activity').each(function(index, item) {\n var $item = $(item);\n var to = $item.attr('id').match(/item-(\\d+)$/)[1];\n if (to === item_id) {\n $cancel = create_command('cancel', 't/left');\n $cancel.on('click', function() {\n move_targets.hide();\n });\n var $commands = $item.find('.commands');\n $commands.find('a').each(function() {\n $(this).hide();\n });\n $commands.append($cancel);\n $item.css('opacity', 0.5);\n } else if (to !== next_id) {\n var $target = create_target(item_id, to);\n $item.before($target);\n targets.push($target);\n }\n }, this);\n\n if ($next) {\n var $target = create_target(item_id, 0);\n $list.append($target);\n targets.push($target);\n }\n };\n }();\n\n /**\n * @class Targets for restoring an item\n */\n\n var restore_targets = new function() {\n this.is_directory = null;\n var $clipboard = null,\n targets = [];\n\n /**\n *\n * @param id\n * @param section\n * @returns {jQuery}\n */\n\n function create_target(id, section) {\n const href = get_action_url('restore', {\n 'directory': (restore_targets.is_directory === true),\n 'target': id,\n 'course': course.id,\n 'section': section,\n 'in_section': $('#copy-section-form').data('in-section'),\n 'sesskey': M.cfg.sesskey,\n 'returnurl': document.URL,\n });\n\n let $target = $('').attr('href', href).attr('title', str('copyhere')).append(\n $('').attr('alt', str('copyhere')).attr('src', M.util.image_url('dropzone_arrow', 'block_sharing_cart'))\n );\n\n targets.push($target);\n\n return $target;\n }\n\n /**\n * Hide restore targets\n */\n this.hide = function() {\n if ($clipboard !== null) {\n $clipboard.remove();\n $clipboard = null;\n $.each(targets, function(index, $target) {\n $target.remove();\n });\n targets = [];\n }\n };\n\n /**\n *\n *\n * @param {int} id The item ID\n */\n this.show = function(id) {\n this.hide();\n\n var $view = $(\"\");\n\n if (this.is_directory) {\n $view.html(id).css('display', 'inline');\n $view.prepend(\n $(\"\").addClass(\"icon\")\n .attr(\"alt\", id)\n // .attr(\"src\", M.util.image_url(icon['dir-closed'].pix, null))\n );\n } else {\n var $item = $block.find('#block_sharing_cart-item-' + id);\n $view = $($item.find('div')[0].cloneNode(true)).css('display', 'inline');\n $view.attr('class', $view.attr('class').replace(/mod-indent-\\d+/, ''));\n $view.find('.commands').remove();\n }\n\n var $cancel = create_command('cancel');\n\n $cancel.on('click', this.hide);\n\n $clipboard = $('
    ');\n $clipboard.append(str('clipboard') + \": \").append($view).append($cancel);\n\n if (course.is_frontpage) {\n var $sitetopic = $('.sitetopic');\n var $mainmenu = $('.block_site_main_menu');\n if ($sitetopic) {\n $sitetopic.find('*').before($clipboard);\n } else if ($mainmenu) {\n $mainmenu.find('.content').before($clipboard);\n }\n\n // Mainmenu = section #0, sitetopic = section #1\n if ($mainmenu) {\n $mainmenu.find('.footer').before(create_target(id, 0));\n }\n if ($sitetopic) {\n $sitetopic.find('ul.section').append(create_target(id, 1));\n }\n } else {\n var $container = $('.course-content');\n $container.prepend($clipboard);\n $container.find(M.course.format.get_section_wrapper(null)).each(function(index, sectionDOM) {\n var $section = $(sectionDOM);\n var section = $section.attr('id').match(/(\\d+)$/)[1];\n $section.find('ul.section').first().append(create_target(id, section));\n }, this);\n }\n };\n }();\n\n // /////// INITIALIZATION /////////\n\n /**\n *\n * @returns {string|*}\n */\n $.get_plugin_name = function() {\n var $blockheader = $block.find(\"h2\");\n\n if (!$blockheader.length) {\n $blockheader = $block.find(\"h3\");\n\n if ($blockheader.length) {\n return $blockheader.html();\n }\n } else {\n return $blockheader.html();\n }\n\n return \"\";\n };\n\n /**\n *\n * @param e\n * @param activityName\n * @param {int} cmId\n */\n $.on_backup = function(e, activityName, cmId = 0) {\n if (cmId === 0) {\n cmId = (function ($backup) {\n var $activity = $backup.closest('li.activity');\n if ($activity.length) {\n return $activity.attr('id').match(/(\\d+)$/)[1];\n }\n var $commands = $backup.closest('.commands');\n var dataowner = $commands.attr('data-owner');\n if (dataowner.length) {\n return dataowner.match(/(\\d+)$/)[1];\n }\n return $commands.find('a.editing_delete').attr('href').match(/delete=(\\d+)/)[1];\n })($(e.target));\n }\n\n var data =\n {\n \"action\": \"is_userdata_copyable\",\n \"cmid\": cmId\n };\n\n on_backup_modal(data, activityName, str('confirm_backup'), false);\n };\n\n /**\n * On movedir command clicked\n *\n * @param {DOMEventFacade} e\n */\n $.on_movedir = function(e) {\n var $commands = $(e.target).closest('.commands');\n\n var $current_dir = $commands.closest('li.directory');\n var current_path = $current_dir.length ? $current_dir.attr('directory-path') : '/';\n\n var item_id = $(e.target).closest('li.activity').attr('id').match(/(\\d+)$/)[1];\n\n var dirs = [];\n $block.find('li.directory').each(function() {\n dirs.push($(this).attr('directory-path'));\n });\n\n var $form = $('');\n // eslint-disable-next-line no-script-url\n $form.attr('action', 'javascript:void(0)');\n\n function submit() {\n var folder_to = $form.find('[name=\"to\"]').val();\n var $spinner = add_spinner();\n $.post(get_action_url('rest'),\n {\n \"action\": \"movedir\",\n \"item_id\": item_id,\n \"folder_to\": folder_to,\n \"sesskey\": M.cfg.sesskey\n },\n function() {\n reload_tree();\n directories.reset();\n })\n .fail(function(response) {\n show_error(response);\n })\n .always(function() {\n $spinner.hide();\n });\n }\n\n $form.submit(submit);\n\n if (dirs.length === 0) {\n var $input = $('').val(current_path);\n setTimeout(function() {\n $input.focus();\n }, 1);\n $form.append($input);\n } else {\n dirs.unshift('/');\n\n var $select = $('').val(current_path);\n $select.remove();\n $edit.replaceWith($input);\n $input.focus();\n });\n\n $form.append($edit);\n }\n\n var $cancel = create_command('cancel');\n $cancel.on('click', function() {\n $form.remove();\n $commands.find('a').show();\n });\n $form.append($cancel);\n\n $commands.find('a').each(function() {\n $(this).hide();\n });\n $commands.append($form);\n };\n\n /**\n * On move command clicked\n *\n * @param {DOMEventFacade} e\n */\n $.on_move = function(e) {\n var $item = $(e.target).closest('li.activity');\n var id = $item.attr('id').match(/(\\d+)$/)[1];\n\n move_targets.show(id);\n };\n\n /**\n * On delete command clicked\n *\n * @param {DOMEventFacade} e\n */\n $.on_delete = function(e) {\n var $item = $(e.target).closest('li');\n var liText = $item[0].innerText;\n\n var isDirectory = false;\n var modalBody;\n var item;\n var description_text = '';\n\n if ($item.hasClass(\"directory\")) {\n isDirectory = true;\n item = str('folder_string');\n description_text = str('delete_folder');\n } else {\n item = str('activity_string');\n }\n\n modalBody = '

    ' + item + ' ' + liText + description_text + '

    ';\n\n confirm_modal({\n 'title': str('confirm_delete'),\n 'body': modalBody,\n 'save_button': str('modal_confirm_delete'),\n 'checkbox': false,\n 'next': function() {\n\n var data = {};\n\n if (isDirectory === true) {\n data = {\n \"action\": \"delete_directory\",\n \"path\": $item.attr(\"directory-path\"),\n \"sesskey\": M.cfg.sesskey\n };\n } else if ($item.hasClass(\"activity\")) {\n data = {\n \"action\": \"delete\",\n \"id\": $item.attr('id').match(/(\\d+)$/)[1],\n \"sesskey\": M.cfg.sesskey\n };\n }\n\n var $spinner = add_spinner();\n\n $.post(get_action_url(\"rest\"), data,\n function() {\n reload_tree();\n })\n .fail(function(response) {\n show_error(response);\n })\n .always(function() {\n $spinner.hide();\n });\n\n e.stopPropagation();\n }\n });\n };\n\n /**\n * On restore command clicked\n *\n * @param {DOMEventFacade} e\n */\n $.on_restore = function(e) {\n var $item = $(e.target).closest('li');\n var id = null;\n\n if ($item.hasClass(\"directory\")) {\n id = $item.attr(\"directory-path\");\n restore_targets.is_directory = true;\n } else if ($item.hasClass(\"activity\")) {\n id = $item.attr('id').match(/(\\d+)$/)[1];\n restore_targets.is_directory = false;\n }\n\n restore_targets.show(id);\n };\n\n /**\n * On backup the whole section as a folder\n *\n * @param {int} sectionId\n * @param {int} sectionNumber\n * @param {int} courseId\n * @param {string} sectionName\n */\n $.on_section_backup = function(sectionId, sectionNumber, courseId, sectionName) {\n var data =\n {\n \"action\": \"is_userdata_copyable_section\",\n \"sectionid\": sectionId,\n \"sectionnumber\": sectionNumber,\n \"courseid\": courseId,\n };\n\n var body_html = '

    ' + str('backup_heavy_load_warning_message') +\n '

    ' + str('confirm_backup_section');\n\n on_backup_modal(data, sectionName, body_html, true);\n };\n\n /**\n * Initialize the delete bulk\n */\n $.init_bulk_delete = function(isspeciallayout) {\n var bulkdelete = $block.find('.editing_bulkdelete');\n if (bulkdelete.length) {\n if (isspeciallayout) {\n bulkdelete.attr('role', 'menuitem').addClass('dropdown-item menu-action');\n bulkdelete.append($(\"\").append(bulkdelete.attr('title')));\n\n $block.find('.menubar .dropdown .dropdown-menu').append(bulkdelete);\n } else {\n $block.find('.header .commands').append(bulkdelete);\n }\n }\n };\n\n /**\n * Initialize the help icon\n */\n $.init_help_icon = function(isspeciallayout) {\n var helpicon = $block.find('.header-commands > .help-icon');\n\n if (isspeciallayout) {\n $block.find('.header-commands').parent().css('display', 'block');\n } else {\n $block.find('.header .commands').append(helpicon);\n }\n };\n\n /**\n * Initialize the Sharing Cart block header\n */\n $.init_block_header = function() {\n var isspeciallayout = verify_layout();\n $.init_bulk_delete(isspeciallayout);\n $.init_help_icon(isspeciallayout);\n };\n\n /**\n * Initialize the Sharing Cart item tree\n */\n $.init_item_tree = function() {\n function add_actions(item, actions) {\n var $item = $(item);\n var $commands = $item.find('.commands').first();\n\n $.each(actions, function(index, action) {\n var $command = create_command(action);\n $command.on('click', function(e) {\n $['on_' + action](e);\n });\n $commands.append($command);\n }, this);\n }\n\n var activity_actions = ['movedir', 'move', 'delete'];\n if (course) {\n activity_actions.push('restore');\n }\n\n var directory_actions = ['delete', 'restore'];\n\n // Initialize items\n $block.find('li.activity').each(function(index, item) {\n if($(item).attr('data-disable-copy') == 1) {\n add_actions(item, ['movedir', 'move', 'delete']);\n return;\n }\n add_actions(item, activity_actions);\n });\n\n // Initialize directory items\n $block.find('li.directory').each(function(index, item) {\n add_actions(item, directory_actions);\n });\n\n // Initialize directories\n directories.init();\n };\n\n /**\n * Extract html object from area where moodle ajax was called.\n *\n * Call add_activity_backup_control to re append sharing cart icon.\n */\n $.init_activity_commands = function() {\n $(document).ajaxComplete(function(event, xhr, settings) {\n\n var url = settings.url;\n var lastslashindex = url.lastIndexOf('=');\n var result = url.substring(lastslashindex + 1);\n\n if (result === 'core_course_edit_module' || result === 'core_course_get_module') {\n\n var data = JSON.parse(settings.data);\n var action = data[0].args.action;\n\n // Don't try to add icon if activity has been deleted.\n if (action === 'delete') {\n return;\n }\n\n setTimeout(function() {\n var activity_id = data[0].args.id;\n var activity = $('#module-' + activity_id);\n add_activity_backup_control(activity);\n\n if (action === 'duplicate') {\n var duplicated = activity.next();\n add_activity_backup_control(duplicated);\n }\n }, 1);\n }\n });\n\n /**\n * Create the backup icon\n *\n * @returns $backupIcon\n */\n function create_backup_icon() {\n\n var $backupIcon = $('
    ')\n .append($(''))\n .attr('title', str('backup'));\n\n if (addMethod !== 'click_to_add') {\n $backupIcon.addClass('d-none');\n }\n\n return $backupIcon;\n }\n\n /**\n * Add backup control with a click event to an activity\n * Added fix for copying an activity without backup routine\n *\n * @param $activity\n */\n function add_activity_backup_control($activity) {\n\n var activityClass = $activity[0].className;\n\n // Selecting modtype without prefix.\n var modtype = activityClass.substr(activityClass.indexOf('modtype_') + 8);\n\n // Default activity name.\n var activityName = str('activity_string');\n\n // Label is using a different html / css layout, so it's needed to get the name by using another $find.\n if (modtype !== 'label') {\n activityName = $('.activity#' + $activity[0].id)\n .find('.mod-indent-outer .activityinstance span.instancename')\n .html();\n }\n\n var $backupIcon = create_backup_icon();\n\n $backupIcon.on('click', function(e) {\n $.on_backup(e, activityName);\n });\n\n var $actionMenuItem = $activity.find('.action-menu.section-cm-edit-actions').parent('.actions');\n\n if (!$actionMenuItem.find('.add-to-sharing-cart').length) {\n $actionMenuItem.append($backupIcon);\n }\n }\n\n /**\n * Add backup control with a click event to a section\n *\n * @param $section\n */\n function add_section_backup_control($section) {\n\n var sectionId = $section.find('.section_action_menu').data('sectionid');\n var sectionNumber = parseInt(String($section.attr('id')).match(/\\d+/)[0]);\n var sectionName = $section.attr('aria-label') || $section.find('.sectionname').text().trim();\n\n var isFlexibleCourseFormat = $('body[id$=flexsections]').length;\n\n // Extract the section ID from the section if this is a Flexible\n // course format (since this format doesn't have an action menu)\n if (isFlexibleCourseFormat && (typeof sectionId === 'undefined' || sectionId === null)) {\n sectionId = $section.data('section-id');\n }\n\n // A bit unsafe to extract the course ID from the body but it's the best option we got at the moment\n var courseId = parseInt(String($('body').attr('class')).match(/course-([0-9]*)( |$)/)[1]);\n\n var $backupIcon = create_backup_icon();\n\n $backupIcon.on('click', function() {\n var inPlaceEditSectionName = in_place_edit_section_name($section);\n sectionName = (inPlaceEditSectionName !== '') ? inPlaceEditSectionName : sectionName;\n $.on_section_backup(sectionId, sectionNumber, courseId, sectionName);\n });\n\n var $sectionTitle = $section.find('h3.sectionname').first().find('a').last();\n\n var $inPlaceEditable = $section.find('h3.sectionname .inplaceeditable').first();\n if ($inPlaceEditable.length) {\n $sectionTitle = $inPlaceEditable;\n }\n\n // Add the backup icon after the cog wheel if this is a Flexible course format\n if (isFlexibleCourseFormat && sectionNumber === 0) {\n $sectionTitle = $section.find('> .controls');\n $sectionTitle.prepend($backupIcon);\n } else {\n $backupIcon.insertAfter($sectionTitle);\n }\n\n var activitySelector = 'li.activity';\n\n var $activities = $section.find(activitySelector);\n\n $($activities).each(function() {\n add_activity_backup_control($(this));\n });\n }\n\n $(\"body.editing .course-content li.section\").each(function() {\n add_section_backup_control($(this));\n });\n };\n\n /**\n * Initialize the Sharing Cart footer basket for 4.0+.\n */\n function init_footer_basket() {\n let currentDragging;\n const activities = document.querySelectorAll(\".activity.activity-wrapper\");\n const sections = document.querySelectorAll(\".course-section-header\");\n const sharingCartBlock = document.querySelector('section[data-block=\"sharing_cart\"]');\n\n add_draggable_to_first_section();\n\n const footer = document.getElementById('page-footer');\n const footerIconContainer = footer.querySelector('div[data-region=\"footer-container-popover\"]');\n\n var basket = document.createElement('i');\n basket.setAttribute('class', 'fa fa-shopping-basket');\n\n var basketButton = document.createElement('button');\n basketButton.setAttribute('class', 'btn btn-icon bg-secondary icon-no-margin btn-footer-popover sharing_cart_basket');\n basketButton.setAttribute('style', 'z-index: 1001;');\n basketButton.append(basket);\n\n var dropAreaText = document.createElement('p');\n dropAreaText.setAttribute('class', 'font-weight-bold text-white');\n dropAreaText.innerText = str('drop_here');\n\n var dropArea = document.createElement('div');\n dropArea.setAttribute('class',\n 'h-100 w-100 position-absolute d-flex justify-content-center align-items-center');\n dropArea.append(dropAreaText);\n\n sections.forEach(section => {\n drag_event_listeners(section);\n });\n\n activities.forEach(activity => {\n drag_event_listeners(activity);\n });\n\n /**\n * Initialize events for dragging\n * @param {object} draggable\n */\n function drag_event_listeners(draggable) {\n draggable.addEventListener('dragstart', (e) => {\n basketButton.classList.remove('shake_basket');\n\n footerIconContainer?.prepend(basketButton);\n sharingCartBlock.children[0].classList.add('dragging_item');\n sharingCartBlock.append(dropArea);\n currentDragging = e.target;\n isDragging = true;\n });\n\n draggable.addEventListener('dragend', () => {\n if (currentDragging instanceof HTMLElement) {\n footerIconContainer?.removeChild(basketButton);\n }\n\n sharingCartBlock.children[0].classList.remove('dragging_item');\n sharingCartBlock.removeChild(dropArea);\n isDragging = false;\n });\n }\n\n [basketButton, sharingCartBlock].forEach((dropzone) => {\n dropzone.addEventListener(\"dragover\", (e) => {\n e.preventDefault();\n dropzone.classList.add('drag_over');\n });\n\n dropzone.addEventListener(\"dragenter\", (e) => {\n e.preventDefault();\n dropzone.classList.add('drag_over');\n });\n\n dropzone.addEventListener(\"dragleave\", () => {\n dropzone.classList.remove('drag_over');\n });\n\n dropzone.addEventListener(\"drop\", () => {\n if (currentDragging instanceof HTMLElement) {\n currentDragging.querySelector('.add-to-sharing-cart').click();\n }\n\n dropzone.classList.remove('drag_over');\n currentDragging = undefined;\n isDragging = false;\n });\n });\n }\n\n /**\n * Make the first section (General) draggable\n */\n function add_draggable_to_first_section() {\n const courseSectionHeader = document.getElementsByClassName(\"course-section-header\")[0] ?? null;\n\n if (courseSectionHeader instanceof HTMLElement) {\n courseSectionHeader.classList.add('draggable');\n courseSectionHeader.setAttribute('draggable', true);\n }\n }\n\n /**\n * Initialize the Sharing Cart block\n */\n $.init = function() {\n M.str.block_sharing_cart.pluginname = this.get_plugin_name();\n\n // Arrange header icons (bulkdelete, help)\n $.init_block_header();\n $.init_item_tree();\n $.init_activity_commands();\n\n if (addMethod === 'drag_and_drop') {\n init_footer_basket();\n }\n };\n var $spinner = $('').addClass('spinner fa fa-3x fa-circle-o-notch fa-spin');\n $('div#sharing-cart-spinner-modal div.spinner-container').prepend($spinner);\n\n $.init();\n });\n\n $('.copy_section').on('click', function() {\n\n var $section_selected = ($('.section-dropdown option:selected'));\n var sectionId = $section_selected.data('section-id');\n var sectionNumber = $section_selected.data('section-number');\n var courseId = $section_selected.data('course-id');\n var sectionName = $section_selected.data('section-name');\n\n $.on_section_backup(sectionId, sectionNumber, courseId, sectionName);\n });\n\n $('.copy_activity').on('click', function(e) {\n var activitySelected = ($('.activity-dropdown option:selected'));\n var activityId = activitySelected.data('activity-id');\n var activityName = activitySelected.data('activity-name');\n\n $.on_backup(e, activityName, activityId);\n });\n }\n };\n});\n"],"names":["define","$","ModalFactory","ModalEvents","init","addMethod","document","ready","isDragging","str","identifier","M","block_sharing_cart","moodle","get_action_url","name","args","url","cfg","wwwroot","q","k","push","encodeURIComponent","join","remove_basket","footerIconContainer","getElementById","querySelector","sharingCartBasket","removeChild","classList","remove","confirm_modal","obj","checkbox","body","create","type","types","SAVE_CANCEL","title","done","modal","is_submitted","setSaveButtonText","save_button","getRoot","on","save","e","response","target","find","is","next","cancel","hidden","removeClass","show","in_place_edit_section_name","$section","sectionName","$inPlaceEditable","length","data","on_backup_modal","post_data","title_str","body_str","isSection","post","copyable","sectionId","sectionNumber","courseId","userdata","$commands","closest","attr","text","trim","String","parent","inPlaceEditSectionName","$spinner","add_spinner","$node_spinner","add_node_spinner","action","sectionid","sectionnumber","courseid","sectionname","sesskey","reload_tree","fail","show_error","always","hide","backup_section","cmid","course","id","backup","add","shake_basket","on_success","icon","css","iconClass","movedir","move","edit","delete","restore","$block","this","match","is_frontpage","hasClass","ex","JSON","parse","responseText","core","exception","message","create_command","iconElement","addClass","append","$node","replaceWith","init_item_tree","directories","param","readCookie","KEY","opens","cookie","pop","split","map","v","parseInt","expires","Date","setDate","getDate","value","expireTimeInMillisecond","d","setTime","getTime","toUTCString","setCookie","open","$dir","visible","i","each","index","dir","toggle","reset","move_targets","$cancel","targets","$target","item_id","$current","$next","$list","next_id","create_target","area_to","$anchor","m","item","$item","to","before","restore_targets","is_directory","$clipboard","section","href","directory","in_section","returnurl","URL","util","image_url","$view","html","prepend","cloneNode","replace","$sitetopic","$mainmenu","$container","format","get_section_wrapper","sectionDOM","first","init_footer_basket","currentDragging","activities","querySelectorAll","sections","sharingCartBlock","courseSectionHeader","getElementsByClassName","HTMLElement","setAttribute","add_draggable_to_first_section","basket","createElement","basketButton","dropAreaText","innerText","dropArea","drag_event_listeners","draggable","addEventListener","children","forEach","activity","dropzone","preventDefault","click","undefined","get_plugin_name","$blockheader","on_backup","activityName","cmId","arguments","$backup","$activity","dataowner","on_movedir","$current_dir","current_path","dirs","$form","submit","folder_to","val","$input","setTimeout","focus","unshift","$select","change","$edit","on_move","on_delete","modalBody","liText","isDirectory","description_text","path","stopPropagation","on_restore","on_section_backup","init_bulk_delete","isspeciallayout","bulkdelete","init_help_icon","helpicon","init_block_header","add_actions","actions","$command","activity_actions","directory_actions","init_activity_commands","create_backup_icon","$backupIcon","add_activity_backup_control","activityClass","className","modtype","substr","indexOf","$actionMenuItem","ajaxComplete","event","xhr","settings","lastslashindex","lastIndexOf","result","substring","activity_id","isFlexibleCourseFormat","$sectionTitle","last","insertAfter","$activities","add_section_backup_control","pluginname","$section_selected","activitySelected","activityId"],"mappings":";;;;;;;AAuBAA,OAAO,4BAAA,CAAC,SAAU,qBAAsB,sBAAsB,SAASC,EAAGC,aAAcC,aACpF,MAAO,CACHC,KAAM,SAASC,WAEXJ,EAAEK,UAAUC,OAAM,WACd,IAAIC,YAAa,EAQjB,SAASC,IAAIC,YACT,OAAOC,EAAEF,IAAIG,mBAAmBF,aAAeC,EAAEF,IAAII,OAAOH,WAChE,CASA,SAASI,eAAeC,KAAMC,MAC1B,IAAIC,IAAMN,EAAEO,IAAIC,QAAU,wBAA0BJ,KAAO,OAC3D,GAAIC,KAAM,CACN,IAAII,EAAI,GACR,IAAK,IAAIC,KAAKL,KACVI,EAAEE,KAAKD,EAAI,IAAME,mBAAmBP,KAAKK,KAE7CJ,KAAO,IAAMG,EAAEI,KAAK,IACxB,CACA,OAAOP,GACX,CAeA,SAASQ,gBACL,GAAkB,kBAAdpB,YAAkCG,WAAY,CAC9C,MACMkB,oBADSpB,SAASqB,eAAe,eACJC,cAAc,+CAC3CC,kBAAoBvB,SAASsB,cAAc,8BAE7CC,oBACAH,qBAAqBI,YAAYD,mBACjCA,kBAAkBE,UAAUC,OAAO,gBAE3C,CACJ,CAOA,SAASC,cAAcC,KAGfA,IAAIC,WACJD,IAAIE,MACA,uJAEiC3B,IAAI,kBAFrC,kBAORP,aAAamC,OAAO,CAChBC,KAAMpC,aAAaqC,MAAMC,YACzBC,MAAOP,IAAIO,MACXL,KAAMF,IAAIE,OACXM,MAAK,SAASC,OACb,IAAIC,cAAe,EACnBD,MAAME,kBAAkBX,IAAIY,aAG5BH,MAAMI,UAAUC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amd/src/script.js index 340d442..b2cb36f 100644 --- a/amd/src/script.js +++ b/amd/src/script.js @@ -766,25 +766,28 @@ define(['jquery', 'core/modal_factory', 'core/modal_events'], function($, ModalF * * @param e * @param activityName + * @param {int} cmId */ - $.on_backup = function(e, activityName) { - var cmid = (function($backup) { - var $activity = $backup.closest('li.activity'); - if ($activity.length) { - return $activity.attr('id').match(/(\d+)$/)[1]; - } - var $commands = $backup.closest('.commands'); - var dataowner = $commands.attr('data-owner'); - if (dataowner.length) { - return dataowner.match(/(\d+)$/)[1]; - } - return $commands.find('a.editing_delete').attr('href').match(/delete=(\d+)/)[1]; - })($(e.target)); + $.on_backup = function(e, activityName, cmId = 0) { + if (cmId === 0) { + cmId = (function ($backup) { + var $activity = $backup.closest('li.activity'); + if ($activity.length) { + return $activity.attr('id').match(/(\d+)$/)[1]; + } + var $commands = $backup.closest('.commands'); + var dataowner = $commands.attr('data-owner'); + if (dataowner.length) { + return dataowner.match(/(\d+)$/)[1]; + } + return $commands.find('a.editing_delete').attr('href').match(/delete=(\d+)/)[1]; + })($(e.target)); + } var data = { "action": "is_userdata_copyable", - "cmid": cmid + "cmid": cmId }; on_backup_modal(data, activityName, str('confirm_backup'), false); @@ -1362,6 +1365,14 @@ define(['jquery', 'core/modal_factory', 'core/modal_events'], function($, ModalF $.on_section_backup(sectionId, sectionNumber, courseId, sectionName); }); + + $('.copy_activity').on('click', function(e) { + var activitySelected = ($('.activity-dropdown option:selected')); + var activityId = activitySelected.data('activity-id'); + var activityName = activitySelected.data('activity-name'); + + $.on_backup(e, activityName, activityId); + }); } }; }); diff --git a/block_sharing_cart.php b/block_sharing_cart.php index 8180d21..6f0b968 100644 --- a/block_sharing_cart.php +++ b/block_sharing_cart.php @@ -24,6 +24,7 @@ use block_sharing_cart\controller; use block_sharing_cart\section; +use block_sharing_cart\module; defined('MOODLE_INTERNAL') || die(); @@ -89,6 +90,9 @@ public function get_content() { $sectionsHandler = new section(); $sections = $sectionsHandler->all($COURSE->id); + $moduleHandler = new module(); + $activities = $moduleHandler->get_all_from_course($COURSE->id); + /* Place the