芝麻web文件管理V1.00
编辑当前文件:/home2/sdektunc/www/cepali/mod/lti/amd/build/tool_card_controller.min.js
define(["jquery","core/ajax","core/notification","core/templates","core/modal_factory","mod_lti/tool_type","mod_lti/events","mod_lti/keys","core/str"],function(a,b,c,d,e,f,g,h,i){var j={DELETE_BUTTON:".delete",NAME_ELEMENT:".name",DESCRIPTION_ELEMENT:".description",CAPABILITIES_CONTAINER:".capabilities-container",ACTIVATE_BUTTON:".tool-card-footer a.activate"},k=2e3,l=function(a){return a.find(j.DELETE_BUTTON)},m=function(a){return a.find(j.NAME_ELEMENT)},n=function(a){return a.find(j.DESCRIPTION_ELEMENT)},o=function(a){return a.find(j.ACTIVATE_BUTTON)},p=function(a){return!!o(a).length},q=function(a){return a.find(j.CAPABILITIES_CONTAINER)},r=function(a){return!!q(a).length},s=function(a){return a.attr("data-type-id")},t=function(a){a.removeClass("announcement loading success fail capabilities")},u=function(a){t(a),a.addClass("announcement loading")},v=function(a){a.removeClass("announcement loading")},w=function(b){var c=a.Deferred();return t(b),b.addClass("announcement success"),setTimeout(function(){b.removeClass("announcement success"),c.resolve()},k),c},x=function(b){var c=a.Deferred();return t(b),b.addClass("announcement fail"),setTimeout(function(){b.removeClass("announcement fail"),c.resolve()},k),c},y=function(b){var d=a.Deferred(),e=s(b);return u(b),""===e?a.Deferred().resolve():(i.get_strings([{key:"delete",component:"mod_lti"},{key:"delete_confirmation",component:"mod_lti"},{key:"delete",component:"mod_lti"},{key:"cancel",component:"core"}]).done(function(a){c.confirm(a[0],a[1],a[2],a[3],function(){f["delete"](e).done(function(){v(b),w(b).done(function(){b.remove()}).fail(c.exception).always(function(){d.resolve()})}).fail(function(a){x(b),d.reject(a)})},function(){v(b),d.resolve()})}).fail(function(a){v(b),c.exception(a),d.reject(a)}),d)},z=function(a,b){a.attr("data-val-snapshot",b)},A=function(a){return a.attr("data-val-snapshot")},B=function(a){var b=n(a);if(!b.hasClass("loading")){var c=b.text().trim();z(b,c)}},C=function(b){var d=s(b);if(""===d)return a.Deferred().resolve();var e=n(b);if(e.hasClass("loading"))return a.Deferred().resolve();var g=e.text().trim(),h=A(e);if(h==g)return a.Deferred().resolve();e.addClass("loading");var i=f.update({id:d,description:g});return i.done(function(a){e.removeClass("loading"),e.text(a.description)}).fail(c.exception),i.fail(function(){e.removeClass("loading")}),i},D=function(a){var b=m(a);if(!b.hasClass("loading")){var c=b.text().trim();z(b,c)}},E=function(b){var c=s(b);if(""===c)return a.Deferred().resolve();var d=m(b);if(d.hasClass("loading"))return a.Deferred().resolve();var e=d.text().trim(),g=A(d);if(g==e)return a.Deferred().resolve();d.addClass("loading");var h=f.update({id:c,name:e});return h.done(function(a){d.removeClass("loading"),d.text(a.name)}),h.fail(function(){d.removeClass("loading")}),h},F=function(b){var c=s(b);if(""===c)return a.Deferred().resolve();u(b);var e=f.update({id:c,state:f.constants.state.configured});return e.then(function(a){return v(b),w(b),a}).then(function(a){return d.render("mod_lti/tool_card",a)}).then(function(a){var c=a[0],e=a[1];d.replaceNode(b,c,e)})["catch"](function(){v(b),x(b)}),e},G=function(a){a.addClass("announcement capabilities")},H=function(a){a.removeClass("announcement capabilities")},I=function(a){r(a)?G(a):F(a)},J=function(a){var b=l(a);b.click(function(b){b.preventDefault(),y(a)}),b.keypress(function(a){a.metaKey||a.shiftKey||a.altKey||a.ctrlKey||a.keyCode!=h.ENTER&&a.keyCode!=h.SPACE||(a.preventDefault(),b.click())});var c=n(a);c.focus(function(b){b.preventDefault(),B(a)}),c.blur(function(b){b.preventDefault(),C(a)}),c.keypress(function(a){a.metaKey||a.shiftKey||a.altKey||a.ctrlKey||a.keyCode==h.ENTER&&(a.preventDefault(),c.blur())});var d=m(a);if(d.focus(function(b){b.preventDefault(),D(a)}),d.blur(function(b){b.preventDefault(),E(a)}),d.keypress(function(a){a.metaKey||a.shiftKey||a.altKey||a.ctrlKey||a.keyCode==h.ENTER&&(a.preventDefault(),d.blur())}),p(a)){var e=o(a);e.click(function(b){b.preventDefault(),I(a)}),e.keypress(function(a){a.metaKey||a.shiftKey||a.altKey||a.ctrlKey||a.keyCode!=h.ENTER&&a.keyCode!=h.SPACE||(a.preventDefault(),e.click())})}if(r(a)){var f=q(a);f.on(g.CAPABILITIES_AGREE,function(){F(a)}),f.on(g.CAPABILITIES_DECLINE,function(){H(a)})}},K=function(b){var c=a("#"+b.data("uniqid")+"-"+b.data("deploymentid")),f={uniqid:b.data("uniqid"),platformid:b.data("platformid"),clientid:b.data("clientid"),deploymentid:b.data("deploymentid"),urls:{publickeyset:b.data("publickeyseturl"),accesstoken:b.data("accesstokenurl"),authrequest:b.data("authrequesturl")}},g=d.render("mod_lti/tool_config_modal_body",f),h="mailto:?subject="+encodeURIComponent(b.data("mailtosubject"))+"&body="+encodeURIComponent(b.data("platformidstr"))+":%20"+encodeURIComponent(b.data("platformid"))+"%0D%0A"+encodeURIComponent(b.data("clientidstr"))+":%20"+encodeURIComponent(b.data("clientid"))+"%0D%0A"+encodeURIComponent(b.data("deploymentidstr"))+":%20"+encodeURIComponent(b.data("deploymentid"))+"%0D%0A"+encodeURIComponent(b.data("publickeyseturlstr"))+":%20"+encodeURIComponent(b.data("publickeyseturl"))+"%0D%0A"+encodeURIComponent(b.data("accesstokenurlstr"))+":%20"+encodeURIComponent(b.data("accesstokenurl"))+"%0D%0A"+encodeURIComponent(b.data("authrequesturlstr"))+":%20"+encodeURIComponent(b.data("authrequesturl"))+"%0D%0A";f={mailto:h};var i=d.render("mod_lti/tool_config_modal_footer",f);e.create({large:!0,title:b.data("modaltitle"),body:g,footer:i},c)};return{init:function(a){J(a),K(a)}}});