Current Path : C:/xampp/htdocs/moodle/mod/lti/amd/build/ |
Current File : C:/xampp/htdocs/moodle/mod/lti/amd/build/external_registration.min.js |
define ("mod_lti/external_registration",["jquery","core/ajax","core/notification","core/templates","mod_lti/events","mod_lti/tool_proxy","mod_lti/tool_type","mod_lti/keys","core/str"],function(a,b,c,d,e,f,g,h,i){var j={EXTERNAL_REGISTRATION_CONTAINER:"#external-registration-page-container",EXTERNAL_REGISTRATION_TEMPLATE_CONTAINER:"#external-registration-template-container",EXTERNAL_REGISTRATION_CANCEL_BUTTON:"#cancel-external-registration",TOOL_TYPE_CAPABILITIES_CONTAINER:"#tool-type-capabilities-container",TOOL_TYPE_CAPABILITIES_TEMPLATE_CONTAINER:"#tool-type-capabilities-template-container",CAPABILITIES_AGREE_CONTAINER:".capabilities-container"},k=function(){return a(j.EXTERNAL_REGISTRATION_CANCEL_BUTTON)},l=function(){return a(j.EXTERNAL_REGISTRATION_CONTAINER)},m=function(){return a(j.EXTERNAL_REGISTRATION_TEMPLATE_CONTAINER)},n=function(){return a(j.TOOL_TYPE_CAPABILITIES_CONTAINER)},o=function(){return a(j.TOOL_TYPE_CAPABILITIES_TEMPLATE_CONTAINER)},p=function(){n().addClass("loading")},q=function(){n().removeClass("loading")},r=function(){k().addClass("loading")},s=function(){k().removeClass("loading")},t=function(){n().addClass("hidden")},u=function(){n().removeClass("hidden")},v=function(){l().addClass("hidden")},w=function(){l().removeClass("hidden")},x=function(a){var b=k();b.attr("data-tool-proxy-id",a)},y=function(){var a=k();return a.attr("data-tool-proxy-id")},z=function(){var a=k();a.removeAttr("data-tool-proxy-id")},A=function(){return y()?!0:!1},B=function(){var a=k();return a.attr("data-tool-proxy-new")&&A()},C=function(){var a=k();return a.attr("data-tool-proxy-new","new")},D=function(){var a=k();return a.removeAttr("data-tool-proxy-new")},E=function(a){return b.call([{methodname:"mod_lti_get_tool_proxy_registration_request",args:{id:a}}])[0]},F=function(){r();var b=a.Deferred();if(B()){var d=y();f.delete(d).done(function(){b.resolve()}).fail(function(a){b.reject(a)})}else{b.resolve()}b.done(function(){L();s()}).fail(function(b){c.exception(b);L();s();i.get_string("failedtodeletetoolproxy","mod_lti").done(function(b){a(document).trigger(e.REGISTRATION_FEEDBACK,{message:b,error:!0})}).fail(c.exception)});return b},G=function(a){var b=d.render("mod_lti/tool_proxy_registration_form",a);b.done(function(a,b){var c=m();c.append(a);d.runTemplateJS(b);c.find("form").submit();w()}).fail(c.exception);return b},H=function(a){return g.update({id:a.id,state:g.constants.state.configured})},I=function(b){var f=a.Deferred();d.render("mod_lti/tool_type_capabilities_agree",b).done(function(a,c){var g=o();v();u();d.replaceNodeContents(g,a,c);var h=g.find(j.CAPABILITIES_AGREE_CONTAINER);h.on(e.CAPABILITIES_AGREE,function(){p();H(b).always(function(){q();g.empty();f.resolve()})});h.on(e.CAPABILITIES_DECLINE,function(){g.empty();f.resolve()})}).fail(f.reject);f.done(function(){t()}).fail(c.exception);return f},J=function(b){var c=a.Deferred();if(!b||""===b){c.resolve()}else{f.create({regurl:b}).done(function(a){C();c=K(a.id)}).fail(function(b){F();var d={message:b.message,error:!0};a(document).trigger(e.REGISTRATION_FEEDBACK,d);c.reject(b)})}return c},K=function(b){var c=a.Deferred();x(b);E(b).done(function(a){G(a).done(function(){c.resolve()}).fail(c.fail)}).fail(c.fail);return c},L=function(){if(A()){z()}D(!1);v();var b=m();b.empty();a(document).trigger(e.STOP_EXTERNAL_REGISTRATION)},M=function(){a(document).on(e.START_EXTERNAL_REGISTRATION,function(a,b){if(!b){return}if(b.url){J(b.url)}if(b.proxyid){K(b.proxyid)}});var b=k();b.click(function(a){a.preventDefault();F()});b.keypress(function(a){if(!a.metaKey&&!a.shiftKey&&!a.altKey&&!a.ctrlKey){if(a.keyCode==h.ENTER||a.keyCode==h.SPACE){a.preventDefault();F()}}});window.triggerExternalRegistrationComplete=function(b){var d=a.Deferred(),f={message:"",error:!1};if("success"==b.status){i.get_string("successfullycreatedtooltype","mod_lti").done(function(a){f.message=a}).fail(c.exception);d.done(function(){L();a(document).trigger(e.REGISTRATION_FEEDBACK,f);a(document).trigger(e.NEW_TOOL_TYPE)}).fail(c.exception);if(B()){var h=y();g.getFromToolProxyId(h).done(function(a){if(a&&a.length){var b=a[0];if(b.hascapabilitygroups){I(b).always(function(){d.resolve()})}else{d.resolve()}}else{d.resolve()}}).fail(function(){d.resolve()})}}else{f.message=b.error;f.error=!0;d.done(function(){F().always(function(){a(document).trigger(e.REGISTRATION_FEEDBACK,f)})}).fail(c.exception);d.resolve()}return d}};return{init:function init(){M()}}}); //# sourceMappingURL=external_registration.min.js.map