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 line
8.0 KiB

define(["jquery","core/modal_factory","core/config","core/templates","core/notification","core/ajax"],function(a,b,c,d,e,f){"use strict";var g,h,i={},j=a(window),k={toggleCompletion:".togglecompletion",modal:".modal",modalDialog:".modal-dialog",modalBody:".modal-body",sectionMain:".section.main",pageContent:"#page-content",regionMain:"#region-main",completionState:"#completionstate_",cmModalClose:".embed_cm_modal .close",cmModal:".embed_cm_modal",moodleMediaPlayer:".mediaplugin_videojs",urlModalLoadWarning:"#embed-url-error-msg-",closeBtn:"button.close",ACTIVITY:"li.activity",URLACTIVITYPOPUPLINK:".activity.modtype_url.urlpopup a",newWindowButton:".button_expand",modalHeader:".modal-header",embedModuleButtons:".embed-module-buttons"},l={launchResourceModal:"launch-tiles-resource-modal",launchModuleModal:"launch-tiles-module-modal",launchUrlModal:"launch-tiles-url-modal"},m=function(){return Math.min(j.width(),1e3)},n=function(b){var c=b.find("iframe");c.length>0&&b.find(k.closeBtn).click(function(b){a(b.currentTarget).closest(k.cmModal).find("iframe").each(function(b,c){c=a(c),c.attr("src",c.attr("src"))})});var d=b.find("object");d.length>0&&b.find(k.closeBtn).click(function(b){var c=a(b.currentTarget).closest(k.cmModal);c.find("object").each(function(b,c){c=a(c),c.attr("data","")}),i[c.attr("data-cmid")]=void 0});var e=b.find(k.moodleMediaPlayer);e.length>0&&(b.find(k.closeBtn).click(function(){b.find(k.moodleMediaPlayer).html("")}),i[b.attr("data-cmid")]=void 0)},o=function(f){var h=f.attr("data-cmid");return b.create({type:b.types.DEFAULT,title:f.attr("data-title"),body:g}).done(function(b){i[h]=b,b.setLarge(),b.show();var g=a(b.root);g.attr("id","embed_mod_modal_"+h),g.attr("data-cmid",h),g.addClass("embed_cm_modal");var l={id:h,pluginfileUrl:f.attr("data-url"),objectType:"text/html",width:"100%",height:Math.round(j.height()-60),cmid:h,tileid:f.closest(k.sectionMain).attr("data-section"),isediting:0,sesskey:c.sesskey,modtitle:f.attr("data-title"),config:{wwwroot:c.wwwroot},showDownload:0,showNewWindow:0,completionInUseForCm:0};if("resource_pdf"===f.attr("data-modtype")&&(l.objectType="application/pdf",l.showDownload=1,l.showNewWindow=1),d.render("format_tiles/embed_file_modal_body",l).done(function(a){b.setBody(a),g.find(k.modalBody).animate({"min-height":Math.round(j.height()-60)},"fast"),"resource_html"===f.attr("data-modtype")?(g.find(k.modal).animate({"max-width":"100%"},"fast"),g.find(k.modalDialog).animate({"max-width":"100%"},"fast"),g.find(k.modalBody).animate({"max-width":"100%"},"fast"),n(g)):(g.find(k.modal).animate({"max-width":m()},"fast"),g.find(k.modalDialog).animate({"max-width":m()},"fast"))}).fail(e.exception),0!==f.find(k.toggleCompletion).length){var o=parseInt(a(k.completionState+h).attr("value"));l.completionInUseForCm=1,l.completionstate=1-o,l.completionicon=1===o?"n":"y",l.completionstateInverse=o,l.completionIsManual=f.find(k.toggleCompletion).attr("data-ismanual")}return d.render("format_tiles/embed_module_modal_header_btns",l).done(function(a){g.find(k.modalHeader).append(a),g.find(k.closeBtn).detach().appendTo(g.find(k.embedModuleButtons))}).fail(e.exception),!0}),!1},p=function(f){var h=f.attr("data-cmid");return b.create({type:b.types.DEFAULT,title:f.attr("data-title"),body:g}).done(function(b){i[h]=b,b.setLarge(),b.show();var g=a(b.root);g.attr("id","embed_mod_modal_"+h),g.attr("data-cmid",h),g.addClass("embed_cm_modal");var l=Math.round(.9*j.width()),m=Math.round(.9*j.height()),o={id:h,pluginfileUrl:f.attr("data-url"),objectType:"text/html",width:l-30,height:m-30,cmid:h,tileid:f.closest(k.sectionMain).attr("data-section"),isediting:0,sesskey:c.sesskey,modtitle:f.attr("data-title"),config:{wwwroot:c.wwwroot},showDownload:0,showNewWindow:1,completionInUseForCm:0,secondaryurl:f.closest(k.ACTIVITY).attr("data-url-secondary")};if(d.render("format_tiles/embed_url_modal_body",o).done(function(a){b.setBody(a),g.find(k.modalBody).animate({"min-height":m},"fast"),g.find(k.modal).animate({"max-width":l},"fast"),g.find(k.modalDialog).animate({"max-width":l},"fast"),g.find(k.modalBody).animate({"