芝麻web文件管理V1.00
编辑当前文件:/home2/sdektunc/.trash/cepali/mod/lti/amd/build/external_registration.min.js
define(["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()},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){var c={methodname:"mod_lti_get_tool_proxy_registration_request",args:{id:a}};return b.call([c])[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();return b.done(function(){L(),s()}).fail(function(b){c.exception(b),L(),s(),i.get_string("failedtodeletetoolproxy","mod_lti").done(function(b){var c={message:b,error:!0};a(document).trigger(e.REGISTRATION_FEEDBACK,c)}).fail(c.exception)}),b},G=function(a){var b=d.render("mod_lti/tool_proxy_registration_form",a);return b.done(function(a,b){var c=m();c.append(a),d.runTemplateJS(b),c.find("form").submit(),w()}).fail(c.exception),b},H=function(a){return g.update({id:a.id,state:g.constants.state.configured})},I=function(b){var f=a.Deferred();return 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),f},J=function(b){var c=a.Deferred();return b&&""!==b?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)}):c.resolve(),c},K=function(b){var c=a.Deferred();return x(b),E(b).done(function(a){G(a).done(function(){c.resolve()}).fail(c.fail)}).fail(c.fail),c},L=function(){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){b&&(b.url&&J(b.url),b.proxyid&&K(b.proxyid))});var b=k();b.click(function(a){a.preventDefault(),F()}),b.keypress(function(a){a.metaKey||a.shiftKey||a.altKey||a.ctrlKey||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){if(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),B()){var h=y();g.getFromToolProxyId(h).done(function(a){if(a&&a.length){var b=a[0];b.hascapabilitygroups?I(b).always(function(){d.resolve()}):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(){M()}}});