You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 lines
5.4 KiB
1 lines
5.4 KiB
define(["jquery","core/ajax","core/templates","core/notification","core/str","core/url","core/config"],function(a,b,c,d,e,f,g){"use strict";var h={},i=a("html,body"),j=a("#page"),k={MENU_ACTION:".menu-action-text",SUBTILE:".subtile",SPACER:".spacer",AVAIL_INFO:".availabilityinfo",ACTIVITY_INSTANCE:".subtile-activityinstance",INSTANCE_NAME:".instancename",SECTION_CM_EDIT_ACTIONS:".section-cm-edit-actions",EDITING_MOVE:".editing_move",LABEL_CONVERT:".editing_labelconvert",CM_EDIT_ACTION:".cm-edit-action",ACTIVITY_ICON:".activityicon",EDITING_DELETE:".editing_delete",SECTION_MAIN:".section.main",STEALTH_UNAVAIL_LINK:".editing_makeunavailable"},l={SHOW:"show",HIDE:"hide",FA_EYE_SLASH:"fa-eye-slash",FA_EYE:"fa-eye",DIMMED:"dimmed",EDITING:"editing_",ACTIVITY:"activity",LABEL:"label",SECTION_DRAGGABLE:"sectiondraggable"},m={CLICK:"click",MODULE_ADDED:"filter-content-updated",MOUSEDOWN:"mousedown"},n=function(c){var d,e=a(c.currentTarget);if("tiles-hide"===e.attr("data-action")?(d={changeTo:l.HIDE,old:l.SHOW},a(k.STEALTH_UNAVAIL_LINK).hide()):"tiles-show"===e.attr("data-action")&&(d={changeTo:l.SHOW,old:l.HIDE}),d){c.preventDefault(),e.attr("data-action","tiles-"+d.old);var f=b.call([{methodname:"core_course_edit_module",args:{id:e.attr("data-cmid"),action:d.changeTo}}],!0);f[0].done(function(b){e.removeClass(l.EDITING+d.old).addClass(l.EDITING+d.changeTo),e.attr("href",e.attr("href").replace("&"+d.old+"=","&"+d.changeTo+"="));var c=e.find(k.MENU_ACTION),f=e.closest(k.SUBTILE);d.changeTo===l.SHOW?(c.html(c.html().replace(h.show,h.hide)),e.find("i").removeClass(l.FA_EYE_SLASH).addClass(l.FA_EYE),f.removeClass(l.DIMMED)):d.changeTo===l.HIDE&&(c.html(c.html().replace(h.hide,h.show)),e.find("i").removeClass(l.FA_EYE).addClass(l.FA_EYE_SLASH),f.addClass(l.DIMMED));var g=a(b).find(k.AVAIL_INFO),i=f.find(k.AVAIL_INFO);g?i.length?i.replaceWith(g):g.appendTo(f.find(k.ACTIVITY_INSTANCE)):i.hide()}),f[0].fail(function(){window.location.replace(e.attr("href"))})}},o=function(a){var b={powerpoint:"ppt",document:"doc",spreadsheet:"xls",archive:"zip",pdf:"pdf",mp3:"mp3",mpeg:"mp4",jpeg:"jpeg",text:"txt",html:"html"};return b[a.split("/").slice(-1)[0].split("-")[0]]},p=function(b,c,d){void 0!==d&&""!==d||(d=h.other),b.find("a.cm-edit-action").each(function(b,c){a(c).attr("data-action","")}),b.find("a.editing_moveright").remove();var e={cmid:b.attr("id").split("-").slice(-1)[0],modtitle:b.find(k.INSTANCE_NAME).html().split("<")[0],cmeditmenu:b.find(k.SECTION_CM_EDIT_ACTIONS)[0].outerHTML.replace(/\n/g,""),cmmove:b.find(k.EDITING_MOVE)[0].outerHTML,modname:"resource",modResourceType:c,modnameDisplay:d,useSubtiles:1,isEmbeddedResource:0,clickable:1,isediting:1,visible:1};return e.isPdf="pdf"===e.modResourceType,e},q=function(b,d,j,n){if(j.hasClass(l.SECTION_DRAGGABLE)&&window.location.href.indexOf("expand=")===-1)window.location=g.wwwroot+"/course/view.php?id="+b+"&expand="+j.attr("data-section")+"#section-"+j.attr("data-section");else if(d.hasClass(l.LABEL)&&d.closest("ul").hasClass("subtiles"))window.location.reload();else if(d.hasClass(l.ACTIVITY)&&d.closest("ul").hasClass("subtiles")){d.children().hide(),d.append(a("<img/>").attr("src",f.imageUrl("loading","format_tiles")).addClass("loading-subtile").attr("title",h.loading));var q=d.prevAll(k.SUBTILE).not(k.SPACER).first();d.prevUntil(q,k.SPACER).hide();var r=o(d.find(k.ACTIVITY_ICON).attr("src"));void 0===r&&window.location.reload();var s="displaytitle_mod_"+r;if(void 0===h[s])e.get_string(s,"format_tiles").done(function(b){"[["!==b.substring(0,2)?h[s]=b:b="";var e=p(d,r,b);c.render("format_tiles/course_module",e).done(function(b){d.replaceWith(b);var c=a("#"+a(n).attr("id"));i.animate({scrollTop:c.offset().top-130},"fast");for(var f=0;f<3;f++)c.fadeOut(300).fadeIn(300);a("#module-"+e.cmid).find(".editing_move").attr("data-action","").on(m.MOUSEDOWN,function(){window.location.reload()})})});else{var t=p(d,r,h[s]);c.render("format_tiles/course_module",t).done(function(b){d.replaceWith(b),a("#module-"+t.cmid).find(".editing_move").attr("data-action","").on(m.MOUSEDOWN,function(){window.location.reload()})})}}else d.find("div.mod-indent-outer").css("position","absolute").css("top","0").css("width","100%").css("padding-left","0")};return{init:function(b,c,f){a(document).ready(function(){if(Y.use("moodle-course-coursebase",function(){"undefined"!=typeof M.course&&setTimeout(function(){M.course.coursebase.registermodules=[]},500)}),a(k.LABEL_CONVERT).on(m.CLICK,function(b){b.preventDefault(),d.confirm(h.areyousure,h.converttopage_confirm,h.yes,h.no,function(){window.location=a(b.currentTarget).attr("href")},null)}),0!==f){var c=a("#module-"+f);i.animate({scrollTop:c.offset().top-130},"fast");for(var g=0;g<3;g++)c.fadeOut(300).fadeIn(300)}j.on("click",k.CM_EDIT_ACTION,function(a){n(a)}),a(document).on(m.MODULE_ADDED,function(c,d){var e=a("#"+a(d).attr("id")),f=e.closest(k.SECTION_MAIN);f.length>=1&&q(b,e,f,d)}),j.on(m.CLICK,k.EDITING_DELETE,function(b){var c=a(b.currentTarget).closest("li"+l.ACTIVITY),d=c.prevAll(k.SUBTILE).not(k.SPACER).first();c.hasClass(l.LABEL)&&c.prevUntil(d,k.SPACER).hide()}),e.get_strings([{key:"yes"},{key:"no"},{key:"show"},{key:"hide"},{key:"converttopage_confirm",component:"format_tiles"},{key:"areyousure"},{key:"complete",component:"format_tiles"},{key:"fileaddedtobottom",component:"format_tiles"},{key:"loading",component:"format_tiles"}]).done(function(a){h={yes:a[0],no:a[1],show:a[2],hide:a[3],converttopage_confirm:a[4],areyousure:a[5],complete:a[6],fileaddedtobottom:a[7],loading:a[8]}})})}}});
|