Current Path : C:/xampp/htdocs/moodle/mod/lti/amd/build/ |
Current File : C:/xampp/htdocs/moodle/mod/lti/amd/build/tool_card_controller.min.js |
define ("mod_lti/tool_card_controller",["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?!0:!1},q=function(a){return a.find(j.CAPABILITIES_CONTAINER)},r=function(a){return q(a).length?!0:!1},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();t(b);b.addClass("announcement success");setTimeout(function(){b.removeClass("announcement success");c.resolve()},k);return c},x=function(b){var c=a.Deferred();t(b);b.addClass("announcement fail");setTimeout(function(){b.removeClass("announcement fail");c.resolve()},k);return c},y=function(b){var d=a.Deferred(),e=s(b);u(b);if(""===e){return 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)});return 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")){return}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});i.done(function(a){e.removeClass("loading");e.text(a.description)}).fail(c.exception);i.fail(function(){e.removeClass("loading")});return i},D=function(a){var b=m(a);if(b.hasClass("loading")){return}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});h.done(function(a){d.removeClass("loading");d.text(a.name)});h.fail(function(){d.removeClass("loading")});return 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});e.then(function(a){v(b);w(b);return 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)});return e},G=function(a){a.addClass("announcement capabilities")},H=function(a){a.removeClass("announcement capabilities")},I=function(a){if(r(a)){G(a)}else{F(a)}},J=function(a){var b=l(a);b.click(function(b){b.preventDefault();y(a)});b.keypress(function(a){if(!a.metaKey&&!a.shiftKey&&!a.altKey&&!a.ctrlKey){if(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){if(!a.metaKey&&!a.shiftKey&&!a.altKey&&!a.ctrlKey){if(a.keyCode==h.ENTER){a.preventDefault();c.blur()}}});var d=m(a);d.focus(function(b){b.preventDefault();D(a)});d.blur(function(b){b.preventDefault();E(a)});d.keypress(function(a){if(!a.metaKey&&!a.shiftKey&&!a.altKey&&!a.ctrlKey){if(a.keyCode==h.ENTER){a.preventDefault();d.blur()}}});if(p(a)){var f=o(a);f.click(function(b){b.preventDefault();I(a)});f.keypress(function(a){if(!a.metaKey&&!a.shiftKey&&!a.altKey&&!a.ctrlKey){if(a.keyCode==h.ENTER||a.keyCode==h.SPACE){a.preventDefault();f.click()}}})}if(r(a)){var i=q(a);i.on(g.CAPABILITIES_AGREE,function(){F(a)});i.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 init(a){J(a);K(a)}}}); //# sourceMappingURL=tool_card_controller.min.js.map