Gitlab CSE Unil

Commit dcff1e14 authored by M. Chardon's avatar M. Chardon
Browse files

- modèle/favoris d'axes

- suppression facilité des axes
parent 0d967ff5
define(["jquery","jqueryui","core/notification","core/templates","core/fragment","core/ajax","core/str","assignfeedback_editpdfplus/tool","assignfeedback_editpdfplus/tooltype","assignfeedback_editpdfplus/annotationhighlightplus","assignfeedback_editpdfplus/annotationstampplus","assignfeedback_editpdfplus/annotationframe","assignfeedback_editpdfplus/annotationcommentplus","assignfeedback_editpdfplus/annotationverticalline","assignfeedback_editpdfplus/annotationstampcomment"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o){var p=null,q=null,r=null,s=null,t=null,u=function(a,b){p=a,this.initTypeTool(b),this.init()};u.messageDelOk="",u.messageDelKo="",u.messageko="",u.messageaddok="",u.messageaddlibelleko="",u.messageEditOk="",u.prototype.selectTool=null;var v=function(){g.get_string("admindeltool_messageok","assignfeedback_editpdfplus").done(function(a){u.messageDelOk=a}).fail(c.exception),g.get_string("admindeltool_messageko","assignfeedback_editpdfplus").done(function(a){u.messageDelKo=a}).fail(c.exception),g.get_string("adminaddtool_messageok","assignfeedback_editpdfplus").done(function(a){u.messageaddok=a}).fail(c.exception),g.get_string("admin_messageko","assignfeedback_editpdfplus").done(function(a){u.messageko=a}).fail(c.exception),g.get_string("adminedittool_messageok","assignfeedback_editpdfplus").done(function(a){u.messageEditOk=a}).fail(c.exception),g.get_string("adminaddtool_messagelibelleko","assignfeedback_editpdfplus").done(function(a){u.messageaddlibelleko=a}).fail(c.exception)};u.prototype.initTypeTool=function(a){var b=JSON.parse(a);s=[];for(var c=0;c<b.length;c++){var d=new i;d.initAdmin(b[c]),s[c]=d}},u.prototype.init=function(){a("#editpdlplus_axes").on("change",function(){a(".toolbar").hide();var b=a("#editpdlplus_axes").val();if(b&&""!==b){a("#editpdlplus_toolbar_"+b).show();var c=a("#editpdlplus_axes option:selected").data("delete");c?parseInt(c)>0?a("#assignfeedback_editpdfplus_widget_admin_button_delaxis").prop("disabled",!0):a("#assignfeedback_editpdfplus_widget_admin_button_delaxis").removeAttr("disabled"):(a("#editpdlplus_axes option[value='"+b+"']").data("delete",0),a("#assignfeedback_editpdfplus_widget_admin_button_delaxis").removeAttr("disabled"))}else a("#assignfeedback_editpdfplus_widget_admin_workspace").hide(),a("#assignfeedback_editpdfplus_widget_admin_toolheader").hide();a("#toolworkspace").html("")}),a("#editpdlplus_axes").change(),a(".editpdlplus_tool").on("click",B),this.selectTool=a(".editpdlplus_tool").first(),this.initToolUI(),a("#assignfeedback_editpdfplus_widget_admin_button_addaxis").on("click",this.openDivAddAxis),a("#assignfeedback_editpdfplus_widget_admin_button_editaxis").on("click",this.openDivEditAxis),a("#assignfeedback_editpdfplus_widget_admin_button_delaxis").on("click",this.openDivDelAxis),a("#assignfeedback_editpdfplus_widget_admin_button_addtool").on("click",this.openDivAddTool),a(".btn-primary").click(),a(".btnimport").on("click",this.importAxis),v()},u.prototype.initToolUI=function(){a(this.selectTool).addClass("btn-primary"),w()};var w=function(){a(".sortable").sortable({placeholder:"alert-warning",handle:"button",cancel:"",stop:function(b,d){var e=a(d.item).prev().find("button").val(),g=a(d.item).next().find("button").val(),h=a(d.item).find("button").val();a("input[name^='previoustoolid']").val(e),a("input[name^='toolid']").val(h),a("input[name^='nexttoolid']").val(g);var i=a("#assignfeedback_editpdfplus_order_tool"),j=i.serialize()+"&contextid="+p;f.call([{methodname:"assignfeedback_editpdfplus_submit_tool_order_form",args:{jsonformdata:JSON.stringify(j)}}])[0].done(function(b){"ok"===b.message?(a("#message_order_tool").show(),a("#message_order_tool").html(u.messageEditOk),a("#message_order_tool").addClass("alert-success"),a("#message_order_tool").removeClass("alert-danger"),a("#message_order_tool").removeClass("alert-warning"),a("#message_order_tool").fadeOut(5e3)):(a("#message_order_tool").show(),a("#message_order_tool").html(u.messageko),a("#message_order_tool").addClass("alert-danger"),a("#message_order_tool").removeClass("alert-success"),a("#message_order_tool").fadeOut(5e3))}).fail(c.exception)}}),a(".sortable").disableSelection()};u.prototype.refreshPrevisu=function(){q.axis=a("#toolaxis").val(),q.typetool=a("#typetool").val(),q.colors=a("#color").val(),q.cartridge=a("#libelle").val(),q.cartridgeColor=a("#cartridgecolor").val();var b="";a("input[name^='text[']").each(function(){a(this).val()&&a(this).val().length>0&&(b+='"'+a(this).val().replace(/"/g,"")+'",')}),b.length>0&&a("#texts").val(b.substring(0,b.length-1)),q.texts=a("#texts").val(),q.label=a("#button").val(),q.enabled=a("#enabled").val(),q.reply=0,a("#reply").is(":checked")&&(q.reply=1),q.orderTool=a("#order").val(),z(),y()};var x=function(a){for(var b=0;b<s.length;b++)if(s[b].id==a)return s[b]},y=function(){var b=parseInt(a("#typetool").val()),c=x(b),d=!1,e=!1;c.configurableCartridge&&0===parseInt(c.configurableCartridge)?(a("#libelle").hide(),a("label[for='libelle']").hide(),d=!0):(a("#libelle").show(),a("label[for='libelle']").show()),c.configurableCartridgeColor&&0===parseInt(c.configurableCartridgeColor)?(a("#cartridgecolor").hide(),a("label[for='cartridgecolor']").hide(),e=!0):(a("#cartridgecolor").show(),a("label[for='cartridgecolor']").show()),d&&e?a("#collapse3").parent().hide():a("#collapse3").parent().show();var f=!1,g=!1,h=!1;c.configurableColor&&0===parseInt(c.configurableColor)?(a("#color").hide(),a("label[for='color']").hide(),f=!0):(a("#color").show(),a("label[for='color']").show()),c.configurableTexts&&0===parseInt(c.configurableTexts)?(a(".textform").hide(),a("label[for='texts']").hide(),g=!0):(a(".textform").show(),a("label[for='texts']").show()),c.configurableQuestion&&0===parseInt(c.configurableQuestion)?(a("#reply").hide(),a("label[for='reply']").hide(),h=!0):(a("#reply").show(),a("label[for='reply']").show()),f&&h&&g?a("#collapse4").parent().hide():a("#collapse4").parent().show()},z=function(){a("#canevas").html(""),t=null;var b=parseInt(a("#typetool").val());if(3===b||4===b||7===b?a("#canevas").css("background-image","url("+a("#map01").val()+")"):1===b||6===b?a("#canevas").css("background-image","url("+a("#map02").val()+")"):5===b&&a("#canevas").css("background-image","url("+a("#map03").val()+")"),1===b)t=new j;else if(3===b)t=new k;else if(4===b){t=new l;var c=new l}else 5===b?t=new n:6===b?t=new o:7===b&&(t=new m);if(t){var d=x(b);q.type=d,q.reply=0,a("#reply").is(":checked")&&(q.reply=1),t.initAdminDemo(q),t.draw(a("#canevas")),c&&(c.initChildAdminDemo(t),c.draw(a("#canevas")))}};u.prototype.openDivAddAxis=function(){var b=a("#editpdlplus_axes").val();b&&""!==b?(a("#message_edit_tool").hide(),a("#axistool").hide()):(a("#assignfeedback_editpdfplus_widget_admin_workspace").show(),a("#editpdlplus_axes_worspace").hide()),a("#assignfeedback_editpdfplus_widget_admin_div_addaxis").show(),a("#assignfeedback_editpdfplus_widget_admin_div_addaxis").html(""),a("#assignfeedback_editpdfplus_widget_admin_toolheader").hide(),a("#assignfeedback_editpdfplus_widget_admin_toolworkspace").hide(),a("#editpdlplus_axes").prop("disabled",!0);var f={};e.loadFragment("assignfeedback_editpdfplus","axisadd",p,f).done(function(a,b){d.appendNodeContents("#assignfeedback_editpdfplus_widget_admin_div_addaxis",a,b)}.bind(this)).fail(c.exception)},u.prototype.openDivEditAxis=function(){a("#message_edit_tool").hide(),a("#axistool").hide(),a("#assignfeedback_editpdfplus_widget_admin_div_editaxis").show(),a("#assignfeedback_editpdfplus_widget_admin_div_editaxis").html(""),a("#assignfeedback_editpdfplus_widget_admin_toolheader").hide(),a("#assignfeedback_editpdfplus_widget_admin_toolworkspace").hide(),a("#editpdlplus_axes").prop("disabled",!0);var b=a("#editpdlplus_axes option:selected").val(),f={axeid:b};e.loadFragment("assignfeedback_editpdfplus","axisedit",p,f).done(function(a,b){d.appendNodeContents("#assignfeedback_editpdfplus_widget_admin_div_editaxis",a,b)}.bind(this)).fail(c.exception)},u.prototype.openDivDelAxis=function(){var b=a("#editpdlplus_axes option:selected").data("delete");if(null!==b&&0===parseInt(b)){a("#message_edit_tool").hide(),a("#axistool").hide(),a("#assignfeedback_editpdfplus_widget_admin_div_delaxis").show(),a("#assignfeedback_editpdfplus_widget_admin_div_delaxis").html(""),a("#assignfeedback_editpdfplus_widget_admin_toolheader").hide(),a("#assignfeedback_editpdfplus_widget_admin_toolworkspace").hide(),a("#editpdlplus_axes").prop("disabled",!0);var f=a("#editpdlplus_axes option:selected").val(),g={axeid:f};e.loadFragment("assignfeedback_editpdfplus","axisdel",p,g).done(function(a,b){d.appendNodeContents("#assignfeedback_editpdfplus_widget_admin_div_delaxis",a,b)}.bind(this)).fail(c.exception)}};var A=function(b,c,e){var f=a.Deferred();return b.fadeOut("fast",function(){d.replaceNodeContents(b,c,e),b.fadeIn("fast",function(){f.resolve()})}),f.promise()};u.prototype.importAxis=function(){var b=a(this).data("axis");if(b&&parseInt(b)>0){a("#assignfeedback_editpdfplus_import_axis > div > input[name^='axeid']").val(b);var d=a("#assignfeedback_editpdfplus_import_axis"),e=d.serialize()+"&contextid="+p;f.call([{methodname:"assignfeedback_editpdfplus_submit_axis_import_form",args:{jsonformdata:JSON.stringify(e)}}])[0].done(function(b){if(""===b[0].message){a("#message_import_axis").show(),a("#message_import_axis").html(u.messageaddok),a("#message_import_axis").addClass("alert-success"),a("#message_import_axis").removeClass("alert-danger"),a("#message_import_axis").removeClass("alert-warning"),a("#message_import_axis").fadeOut(5e3);var c="<div id='editpdlplus_toolbar_"+b[0].axeid+"' class='btn-group toolbar' style='display: none;'><ul class='sortable' style='list-style-type: none;margin: 0;padding: 0;width: 100%;'></ul></div>";a("#editpdlplus_toolbars").append(c),w();var d=new Option(b[0].axelabel,b[0].axeid,(!0),(!0));a("#editpdlplus_axes").append(d);var e=a("#editpdlplus_axes option[value='"+b[0].axeid+"']");e.data("delete",1);var f=a("#assignfeedback_editpdfplus_widget_admin_button_delaxis");if(f.prop("disabled",!0),a("#editpdlplus_tool_item").html(""),b[0].toolid&&b[0].toolid>0)for(var g=0;g<b.length;g++){var i=new h;i.initAdmin(b[g]);var j=i.getButtonSortable(b[g].selecttool);a("#editpdlplus_toolbar_"+b[0].axeid+" > ul").append(j)}else{var k=b[0].axeid,e=a("#editpdlplus_axes option[value='"+k+"']");e.data("delete",0);var f=a("#assignfeedback_editpdfplus_widget_admin_button_delaxis");f.removeAttr("disabled")}a(".editpdlplus_tool").on("click",B),a("#editpdlplus_axes").change(),a("a[href^='#collapseadmin1'").click(),a("#axistool").show(),a("#assignfeedback_editpdfplus_widget_admin_toolheader").show(),a("#assignfeedback_editpdfplus_widget_admin_workspace").show(),a("#assignfeedback_editpdfplus_widget_admin_toolworkspace").show()}else a("#message_import_axis").show(),a("#message_import_axis").html(b[0].message),a("#message_import_axis").addClass("alert-danger"),a("#message_import_axis").removeClass("alert-success"),a("#message_import_axis").fadeOut(5e3)}).fail(c.exception)}};var B=function(){var b=a(this).val();a(".editpdlplus_tool").each(function(){a(this).removeClass("btn-primary"),a(this).css("background-image",""),a(this).css("background-color","");var c=a(this).data("enable");1!==c&&a(this).val()!==b&&(a(this).css("background-image","none"),a(this).css("background-color","#CCCCCC"))}),a(this).addClass("btn-primary"),q&&q.id===b||a("#message_edit_tool").hide(),a("#editpdlplus_tool_item").html("");var d={toolid:b};e.loadFragment("assignfeedback_editpdfplus","tooledit",p,d).done(function(d,e){A(a("#editpdlplus_tool_item"),d,e).done(function(){q=new h,q.id=b,q.axis=a("#toolaxis").val(),q.typetool=a("#typetool").val();var d=x(q.typetool);q.type=d;var e=a("#realcolor").val();e.length>0?q.colors=a("#color").val():(a("#color").val(d.color),q.colors=null),q.cartridge=a("#libelle").val(),a("#realcartridgecolor").val()&&a("#realcartridgecolor").val().length>0?q.cartridgeColor=a("#cartridgecolor").val():(a("#cartridgecolor").val(d.get_color_cartridge()),q.cartridgeColor=null),q.texts=a("#texts").val(),q.label=a("#button").val(),q.enabled=a("#enabled").val(),q.reply=a("#reply").val(),q.orderTool=a("#order").val(),a("#typetool").on("change",function(){q.typetool=a("#typetool").val();var b=x(q.typetool);q.type=b,q.colors=b.get_color(),q.cartridgeColor=b.get_color_cartridge(),a("#color").val(q.colors),a("#cartridgecolor").val(q.cartridgeColor),y(),z()}),a("#toolFormSubmit").on("click",function(){var b="";a("input[name^='text[']").each(function(){a(this).val()&&a(this).val().length>0&&(b+='"'+a(this).val().replace(/"/g,"")+'",')}),b.length>0&&a("#texts").val(b.substring(0,b.length-1));var d=a("#assignfeedback_editpdfplus_edit_tool"),e=d.serialize();f.call([{methodname:"assignfeedback_editpdfplus_submit_tool_edit_form",args:{jsonformdata:JSON.stringify(e)}}])[0].done(function(b){if(""===b[0].message){a("#message_edit_tool").show(),a("#message_edit_tool").html(u.messageEditOk),a("#message_edit_tool").addClass("alert-success"),a("#message_edit_tool").removeClass("alert-danger"),a("#message_edit_tool").removeClass("alert-warning"),a("#editpdlplus_tool_"+b[0].selecttool).remove(),a("#editpdlplus_toolbar_"+b[0].axeid+" > ul").html("");for(var c=0;c<b.length;c++){var d=new h;d.initAdmin(b[c]);var e=d.getButtonSortable(b[c].selecttool);a("#editpdlplus_toolbar_"+b[0].axeid+" > ul").append(e)}a(".editpdlplus_tool").on("click",B);var f=a("#axisid").val();f!==b[0].axeid&&(a("#editpdlplus_axes").val(b[0].axeid),a("#editpdlplus_axes").change()),a("#editpdlplus_tool_"+b[0].selecttool).click()}else a("#message_edit_tool").show(),a("#message_edit_tool").html(b[0].message),a("#message_edit_tool").addClass("alert-danger"),a("#message_edit_tool").removeClass("alert-success")}).fail(c.exception)}),a("#toolEnabled").on("click",function(){var b=a("#toolenabled").val();1==b?(a("#toolEnabled > i").addClass("fa-eye-slash"),a("#toolEnabled > i").removeClass("fa-eye"),a("#toolenabled").val(0)):(a("#toolEnabled > i").addClass("fa-eye"),a("#toolEnabled > i").removeClass("fa-eye-slash"),a("#toolenabled").val(1)),a("#toolFormSubmit").click()}),a("#toolClone").on("click",function(){r="clone",a("#assignfeedback_editpdfplus_widget_admin_button_addtool").click()}),a("#toolRemove").on("click",function(){if(!a(this).prop("disabled")){var b=a("#assignfeedback_editpdfplus_edit_tool"),d=b.serialize();f.call([{methodname:"assignfeedback_editpdfplus_submit_tool_del_form",args:{jsonformdata:JSON.stringify(d)}}])[0].done(function(b){if(""===b[0].message||"1"===b[0].message){if(a("#message_edit_tool").show(),a("#message_edit_tool").html(u.messageDelOk),a("#message_edit_tool").addClass("alert-success"),a("#message_edit_tool").removeClass("alert-danger"),a("#message_edit_tool").removeClass("alert-warning"),a("#editpdlplus_toolbar_"+b[0].axeid+" > ul").html(""),parseInt(b[0].toolid)>0){for(var c=0;c<b.length;c++){var d=new h;d.initAdmin(b[c]);var e=d.getButtonSortable(b[c].selecttool);a("#editpdlplus_toolbar_"+b[0].axeid+" > ul").append(e)}a(".editpdlplus_tool").on("click",B)}else{var f=b[0].axeid,g=a("#editpdlplus_axes option[value='"+f+"']");g.data("delete",0);var i=a("#assignfeedback_editpdfplus_widget_admin_button_delaxis");i.removeAttr("disabled")}a("#toolworkspace").html("")}else a("#message_edit_tool").show(),a("#message_edit_tool").html(b[0].message),a("#message_edit_tool").addClass("alert-danger"),a("#message_edit_tool").removeClass("alert-success")}).fail(c.exception)}}),a("#toolRefesh").on("click",function(){u.prototype.refreshPrevisu()}),z(),y()}.bind(this)).fail(c.exception)}.bind(this)).fail(c.exception)};return u.prototype.openDivAddTool=function(){a("#message_edit_tool").hide(),a("#editpdlplus_tool_item").html(""),a(".editpdlplus_tool").removeClass("btn-primary");var b=a("#editpdlplus_axes option:selected").val(),d={axisid:b};e.loadFragment("assignfeedback_editpdfplus","tooladd",p,d).done(function(d,e){A(a("#editpdlplus_tool_item"),d,e).done(function(){a("#canevas").hide(),a("#toolaxis").val(b),"clone"===r?(a("#toolaxis").val(q.axis),a("#typetool").val(q.typetool),a("#color").val(q.colors),a("#libelle").val(q.cartridge),a("#cartridgecolor").val(q.cartridgeColor),a("#texts").val(q.texts),a("#button").val(q.label),a("#enabled").val(q.enabled),a("#reply").val(q.reply),a("#order").val(q.orderTool),q=new h,r=null):(q=new h,a("#typetool").on("change",function(){q=new h,q.axis=a("#toolaxis").val(),q.typetool=a("#typetool").val();var b=x(q.typetool);q.type=b,q.colors=b.get_color(),q.cartridgeColor=b.get_color_cartridge(),a("#color").val(q.colors),a("#cartridgecolor").val(q.cartridgeColor),y()}),a("#typetool").change()),a("#toolFormSubmit").on("click",function(){if(""===a("#button").val())a("#message_edit_tool").show(),a("#message_edit_tool").html(u.messageaddlibelleko),a("#message_edit_tool").addClass("alert-warning"),a("#message_edit_tool").removeClass("alert-danger"),a("#message_edit_tool").removeClass("alert-success");else{var b="";a("input[name^='text[']").each(function(){a(this).val()&&a(this).val().length>0&&(b+='"'+a(this).val().replace(/"/g,"")+'",')}),b.length>0&&a("#texts").val(b.substring(0,b.length-1));var d=a("#assignfeedback_editpdfplus_edit_tool"),e=d.serialize();f.call([{methodname:"assignfeedback_editpdfplus_submit_tool_add_form",args:{jsonformdata:JSON.stringify(e)}}])[0].done(function(b){if(""===b[0].message){a("#message_edit_tool").show(),a("#message_edit_tool").html(u.messageaddok),a("#message_edit_tool").addClass("alert-success"),a("#message_edit_tool").removeClass("alert-danger"),a("#message_edit_tool").removeClass("alert-warning"),a("#editpdlplus_toolbar_"+b[0].axeid+" > ul").html("");for(var c=0;c<b.length;c++){var d=new h;d.initAdmin(b[c]);var e=d.getButtonSortable(b[c].selecttool);a("#editpdlplus_toolbar_"+b[0].axeid+" > ul").append(e)}a(".editpdlplus_tool").on("click",B),a("#toolworkspace").html("");var f=b[0].axeid,g=a("#editpdlplus_axes option[value='"+f+"']");g.data("delete",1);var i=a("#assignfeedback_editpdfplus_widget_admin_button_delaxis");i.prop("disabled",!0)}else a("#message_edit_tool").show(),a("#message_edit_tool").html(b[0].message),a("#message_edit_tool").addClass("alert-danger"),a("#message_edit_tool").removeClass("alert-success")}).fail(c.exception)}})}.bind(this)).fail(c.exception)}.bind(this)).fail(c.exception)},u}); define(["jquery","jqueryui","core/notification","core/templates","core/fragment","core/ajax","core/str","core/modal_factory","core/modal_events","assignfeedback_editpdfplus/tool","assignfeedback_editpdfplus/tooltype","assignfeedback_editpdfplus/annotationhighlightplus","assignfeedback_editpdfplus/annotationstampplus","assignfeedback_editpdfplus/annotationframe","assignfeedback_editpdfplus/annotationcommentplus","assignfeedback_editpdfplus/annotationverticalline","assignfeedback_editpdfplus/annotationstampcomment"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q){var r=null,s=null,t=null,u=null,v=null,w=function(a,b){r=a,this.initTypeTool(b),this.init()};w.messageDelOk="",w.messageDelKo="",w.messageko="",w.messageaddok="",w.messageaddlibelleko="",w.messageEditOk="",w.prototype.selectTool=null;var x=function(){g.get_string("admindeltool_messageok","assignfeedback_editpdfplus").done(function(a){w.messageDelOk=a}).fail(c.exception),g.get_string("admindeltool_messageko","assignfeedback_editpdfplus").done(function(a){w.messageDelKo=a}).fail(c.exception),g.get_string("adminaddtool_messageok","assignfeedback_editpdfplus").done(function(a){w.messageaddok=a}).fail(c.exception),g.get_string("admin_messageko","assignfeedback_editpdfplus").done(function(a){w.messageko=a}).fail(c.exception),g.get_string("adminedittool_messageok","assignfeedback_editpdfplus").done(function(a){w.messageEditOk=a}).fail(c.exception),g.get_string("adminaddtool_messagelibelleko","assignfeedback_editpdfplus").done(function(a){w.messageaddlibelleko=a}).fail(c.exception)};w.prototype.initTypeTool=function(a){var b=JSON.parse(a);u=[];for(var c=0;c<b.length;c++){var d=new k;d.initAdmin(b[c]),u[c]=d}},w.prototype.init=function(){a("#editpdlplus_axes").on("change",function(){a(".toolbar").hide();var b=a("#editpdlplus_axes").val();if(b&&""!==b){a("#editpdlplus_toolbar_"+b).show();var c=a("#editpdlplus_axes option:selected").data("delete");c?parseInt(c)>0?a("#assignfeedback_editpdfplus_widget_admin_button_delaxis").prop("disabled",!0):a("#assignfeedback_editpdfplus_widget_admin_button_delaxis").removeAttr("disabled"):(a("#editpdlplus_axes option[value='"+b+"']").data("delete",0),a("#assignfeedback_editpdfplus_widget_admin_button_delaxis").removeAttr("disabled"))}else a("#assignfeedback_editpdfplus_widget_admin_workspace").hide(),a("#assignfeedback_editpdfplus_widget_admin_toolheader").hide();a("#toolworkspace").html("")}),a("#editpdlplus_axes").change(),a(".editpdlplus_tool").on("click",D),this.selectTool=a(".editpdlplus_tool").first(),this.initToolUI(),a("#assignfeedback_editpdfplus_widget_admin_button_addaxis").on("click",this.openDivAddAxis),a("#assignfeedback_editpdfplus_widget_admin_button_editaxis").on("click",this.openDivEditAxis),a("#assignfeedback_editpdfplus_widget_admin_button_delaxis").on("click",this.openDivDelAxis),a("#assignfeedback_editpdfplus_widget_admin_button_exportaxis").on("click",this.openDivExportAxis),a("#assignfeedback_editpdfplus_widget_admin_button_addtool").on("click",this.openDivAddTool),a(".btn-primary").click(),a(".btnimport").on("click",this.importAxis),a(".btnimportdel").on("click",this.deleteModel),x()},w.prototype.initToolUI=function(){a(this.selectTool).addClass("btn-primary"),y()};var y=function(){a(".sortable").sortable({placeholder:"alert-warning",handle:"button",cancel:"",stop:function(b,d){var e=a(d.item).prev().find("button").val(),g=a(d.item).next().find("button").val(),h=a(d.item).find("button").val();a("input[name^='previoustoolid']").val(e),a("input[name^='toolid']").val(h),a("input[name^='nexttoolid']").val(g);var i=a("#assignfeedback_editpdfplus_order_tool"),j=i.serialize()+"&contextid="+r;f.call([{methodname:"assignfeedback_editpdfplus_submit_tool_order_form",args:{jsonformdata:JSON.stringify(j)}}])[0].done(function(a){"ok"===a.message?w.prototype.displayMessageInformation("message_order_tool",w.messageEditOk,1,0,0):w.prototype.displayMessageInformation("message_order_tool",w.messageko,0,1,0)}).fail(c.exception)}}),a(".sortable").disableSelection()};w.prototype.refreshPrevisu=function(){s.axis=a("#toolaxis").val(),s.typetool=a("#typetool").val(),s.colors=a("#color").val(),s.cartridge=a("#libelle").val(),s.cartridgeColor=a("#cartridgecolor").val();var b="";a("input[name^='text[']").each(function(){a(this).val()&&a(this).val().length>0&&(b+='"'+a(this).val().replace(/"/g,"")+'",')}),b.length>0&&a("#texts").val(b.substring(0,b.length-1)),s.texts=a("#texts").val(),s.label=a("#button").val(),s.enabled=a("#enabled").val(),s.reply=0,a("#reply").is(":checked")&&(s.reply=1),s.orderTool=a("#order").val(),B(),A()};var z=function(a){for(var b=0;b<u.length;b++)if(u[b].id==a)return u[b]},A=function(){var b=parseInt(a("#typetool").val()),c=z(b),d=!1,e=!1;c.configurableCartridge&&0===parseInt(c.configurableCartridge)?(a("#libelle").hide(),a("label[for='libelle']").hide(),d=!0):(a("#libelle").show(),a("label[for='libelle']").show()),c.configurableCartridgeColor&&0===parseInt(c.configurableCartridgeColor)?(a("#cartridgecolor").hide(),a("label[for='cartridgecolor']").hide(),e=!0):(a("#cartridgecolor").show(),a("label[for='cartridgecolor']").show()),d&&e?a("#collapse3").parent().hide():a("#collapse3").parent().show();var f=!1,g=!1,h=!1;c.configurableColor&&0===parseInt(c.configurableColor)?(a("#color").hide(),a("label[for='color']").hide(),f=!0):(a("#color").show(),a("label[for='color']").show()),c.configurableTexts&&0===parseInt(c.configurableTexts)?(a(".textform").hide(),a("label[for='texts']").hide(),g=!0):(a(".textform").show(),a("label[for='texts']").show()),c.configurableQuestion&&0===parseInt(c.configurableQuestion)?(a("#reply").hide(),a("label[for='reply']").hide(),h=!0):(a("#reply").show(),a("label[for='reply']").show()),f&&h&&g?a("#collapse4").parent().hide():a("#collapse4").parent().show()},B=function(){a("#canevas").html(""),v=null;var b=parseInt(a("#typetool").val());if(3===b||4===b||7===b?a("#canevas").css("background-image","url("+a("#map01").val()+")"):1===b||6===b?a("#canevas").css("background-image","url("+a("#map02").val()+")"):5===b&&a("#canevas").css("background-image","url("+a("#map03").val()+")"),1===b)v=new l;else if(3===b)v=new m;else if(4===b){v=new n;var c=new n}else 5===b?v=new p:6===b?v=new q:7===b&&(v=new o);if(v){var d=z(b);s.type=d,s.reply=0,a("#reply").is(":checked")&&(s.reply=1),v.initAdminDemo(s),v.draw(a("#canevas")),c&&(c.initChildAdminDemo(v),c.draw(a("#canevas")))}};w.prototype.openDivAddAxis=function(){var b=a("#editpdlplus_axes").val();b&&""!==b?(a("#message_edit_tool").hide(),a("#axistool").hide()):(a("#assignfeedback_editpdfplus_widget_admin_workspace").show(),a("#editpdlplus_axes_worspace").hide()),a("#assignfeedback_editpdfplus_widget_admin_div_addaxis").show(),a("#assignfeedback_editpdfplus_widget_admin_div_addaxis").html(""),a("#assignfeedback_editpdfplus_widget_admin_toolheader").hide(),a("#assignfeedback_editpdfplus_widget_admin_toolworkspace").hide(),a("#editpdlplus_axes").prop("disabled",!0);var f={};e.loadFragment("assignfeedback_editpdfplus","axisadd",r,f).done(function(a,b){d.appendNodeContents("#assignfeedback_editpdfplus_widget_admin_div_addaxis",a,b)}.bind(this)).fail(c.exception)},w.prototype.openDivEditAxis=function(){a("#message_edit_tool").hide(),a("#axistool").hide(),a("#assignfeedback_editpdfplus_widget_admin_div_editaxis").show(),a("#assignfeedback_editpdfplus_widget_admin_div_editaxis").html(""),a("#assignfeedback_editpdfplus_widget_admin_toolheader").hide(),a("#assignfeedback_editpdfplus_widget_admin_toolworkspace").hide(),a("#editpdlplus_axes").prop("disabled",!0);var b=a("#editpdlplus_axes option:selected").val(),f={axeid:b};e.loadFragment("assignfeedback_editpdfplus","axisedit",r,f).done(function(a,b){d.appendNodeContents("#assignfeedback_editpdfplus_widget_admin_div_editaxis",a,b)}.bind(this)).fail(c.exception)},w.prototype.openDivExportAxis=function(){a("#message_edit_tool").hide(),a("#axistool").hide(),a("#assignfeedback_editpdfplus_widget_admin_div_exportaxis").show(),a("#assignfeedback_editpdfplus_widget_admin_div_exportaxis").html(""),a("#assignfeedback_editpdfplus_widget_admin_toolheader").hide(),a("#assignfeedback_editpdfplus_widget_admin_toolworkspace").hide(),a("#editpdlplus_axes").prop("disabled",!0);var b=a("#editpdlplus_axes option:selected").val(),h={axeid:b};e.loadFragment("assignfeedback_editpdfplus","axisexport",r,h).done(function(b,e){d.appendNodeContents("#assignfeedback_editpdfplus_widget_admin_div_exportaxis",b,e),a("#axisExportSubmit").on("click",function(){var b=a("#assignfeedback_editpdfplus_widget_admin_div_exportaxis form"),d=b.serialize();f.call([{methodname:"assignfeedback_editpdfplus_submit_axis_export_form",args:{jsonformdata:JSON.stringify(d)}}])[0].done(function(b){if(""===b[0].message){var c=a("<tr></tr>");c.append("<td>"+b[0].axelabel+"</td>");for(var d=b,e=a('<td><div class="btn-group"></div></td>'),f=0;f<d.length;f++)e.append('<button class="btn" style="'+d[f].style+'">'+d[f].button+"</button>");c.append(e),c.append("<td><button class='btn btn-primary btn-sm btnimport' data-axis='"+b[0].axeid+"'><i class='fa fa-download'></i></button></td>"),c.append("<td><button class='btn btn-danger btn-sm btnimportdel' data-model='"+b[0].modelid+"'><i class='fa fa-remove'></i></button></td>"),a("div#import tbody").append(c),a(".btnimport").on("click",w.prototype.importAxis),a(".btnimportdel").on("click",w.prototype.deleteModel),w.prototype.resetDivAction("assignfeedback_editpdfplus_widget_admin_div_exportaxis"),a("#axistool").show();var h=a("#editpdlplus_axes").val();h&&""!==h?w.prototype.showWorkspace():(a("#assignfeedback_editpdfplus_widget_admin_workspace").hide(),a("#assignfeedback_editpdfplus_widget_admin_toolheader").hide(),a("#assignfeedback_editpdfplus_widget_admin_toolworkspace").hide()),a("#editpdlplus_axes").removeAttr("disabled");var i=g.get_string("adminexport_messageok","assignfeedback_editpdfplus");w.prototype.displayMessageInformation("message_export_axis",i,1,0,0)}else a("#assignfeedback_editpdfplus_widget_admin_div_exportaxis").append("<div class='alert alert-danger' style='margin-top: 5px;'>"+b[0].message+"</div>")}).fail(c.exception)}),a("#axisExportCancel").on("click",function(){w.prototype.resetDivAction("assignfeedback_editpdfplus_widget_admin_div_exportaxis"),w.prototype.showWorkspace(),a("#editpdlplus_axes").removeAttr("disabled")})}.bind(this)).fail(c.exception)},w.prototype.openDivDelAxis=function(){var b=a("#editpdlplus_axes option:selected").data("delete");if(!(null===b||parseInt(b)>0)){var d=a("#editpdlplus_axes option:selected").val();a("#assignfeedback_editpdfplus_del_axis input[name='axeid']").val(d),h.create({type:h.types.SAVE_CANCEL,title:g.get_string("adminaxisimport_delete","assignfeedback_editpdfplus"),body:g.get_string("adminaxisdelete_question","assignfeedback_editpdfplus")}).then(function(b){b.setSaveButtonText(g.get_string("adminaxisimport_delete","assignfeedback_editpdfplus"));var d=b.getRoot();d.on(i.save,function(){var b=a("#assignfeedback_editpdfplus_del_axis"),d=b.serialize()+"&contextid="+r;f.call([{methodname:"assignfeedback_editpdfplus_submit_axis_del_form",args:{jsonformdata:JSON.stringify(d)}}])[0].done(function(b){"1"===b[0].message?(a("#editpdlplus_axes option:selected").remove(),a("#editpdlplus_axes").change()):a("#assignfeedback_editpdfplus_widget_admin_div_delaxis").append("<div class='alert alert-danger' style='margin-top: 5px;'>"+b[0].message+"</div>")}).fail(c.exception)}),b.show()})}};var C=function(b,c,e){var f=a.Deferred();return b.fadeOut("fast",function(){d.replaceNodeContents(b,c,e),b.fadeIn("fast",function(){f.resolve()})}),f.promise()};w.prototype.deleteModel=function(){var b=a(this).parents("tr"),d=a(this).data("model");!d||parseInt(d)<=0||(a("#assignfeedback_editpdfplus_del_model input[name='modelid']").val(d),h.create({type:h.types.SAVE_CANCEL,title:g.get_string("adminaxisimport_delete","assignfeedback_editpdfplus"),body:g.get_string("delete_model_question","assignfeedback_editpdfplus")}).then(function(d){d.setSaveButtonText(g.get_string("adminaxisimport_delete","assignfeedback_editpdfplus"));var e=d.getRoot();e.on(i.save,function(){var d=a("#assignfeedback_editpdfplus_del_model"),e=d.serialize()+"&contextid="+r;f.call([{methodname:"assignfeedback_editpdfplus_submit_model_del_form",args:{jsonformdata:JSON.stringify(e)}}])[0].done(function(a){"1"===a[0].message?b.remove():w.prototype.displayMessageInformation("message_del_modal",a[0].message,1,0,0)}).fail(c.exception)}),d.show()}))},w.prototype.importAxis=function(){var b=a(this).data("axis");if(b&&!(parseInt(b)<=0)){a("#assignfeedback_editpdfplus_import_axis > div > input[name^='axeid']").val(b);var d=a("#assignfeedback_editpdfplus_import_axis"),e=d.serialize()+"&contextid="+r;f.call([{methodname:"assignfeedback_editpdfplus_submit_axis_import_form",args:{jsonformdata:JSON.stringify(e)}}])[0].done(function(b){if(""===b[0].message){var c=g.get_string("adminimport_messageok","assignfeedback_editpdfplus");w.prototype.displayMessageInformation("message_import_axis",c,1,0,0);var d="<div id='editpdlplus_toolbar_"+b[0].axeid+"' class='btn-group toolbar' style='display: none;'><ul class='sortable' style='list-style-type: none;margin: 0;padding: 0;width: 100%;'></ul></div>";a("#editpdlplus_toolbars").append(d),y();var e=new Option(b[0].axelabel,b[0].axeid,(!0),(!0));a("#editpdlplus_axes").append(e);var f=a("#editpdlplus_axes option[value='"+b[0].axeid+"']");if(f.data("delete",0),a("#editpdlplus_tool_item").html(""),b[0].toolid&&b[0].toolid>0)for(var h=0;h<b.length;h++){var i=new j;i.initAdmin(b[h]);var k=i.getButtonSortable(b[h].selecttool);a("#editpdlplus_toolbar_"+b[0].axeid+" > ul").append(k)}else{var l=b[0].axeid,f=a("#editpdlplus_axes option[value='"+l+"']");f.data("delete",0)}a(".editpdlplus_tool").on("click",D),a("#editpdlplus_axes").change(),a("a[href^='#currenttoolbar'").click(),a("#axistool").show(),a("#assignfeedback_editpdfplus_widget_admin_toolheader").show(),a("#assignfeedback_editpdfplus_widget_admin_workspace").show(),a("#assignfeedback_editpdfplus_widget_admin_toolworkspace").show()}else w.prototype.displayMessageInformation("message_import_axis",b[0].message,0,1,0)}).fail(c.exception)}};var D=function(){var b=a(this).val();a(".editpdlplus_tool").each(function(){a(this).removeClass("btn-primary"),a(this).css("background-image",""),a(this).css("background-color","");var c=a(this).data("enable");1!==c&&a(this).val()!==b&&(a(this).css("background-image","none"),a(this).css("background-color","#CCCCCC"))}),a(this).addClass("btn-primary"),s&&s.id===b||a("#message_edit_tool").hide(),a("#editpdlplus_tool_item").html("");var d={toolid:b};e.loadFragment("assignfeedback_editpdfplus","tooledit",r,d).done(function(d,e){C(a("#editpdlplus_tool_item"),d,e).done(function(){s=new j,s.id=b,s.axis=a("#toolaxis").val(),s.typetool=a("#typetool").val();var d=z(s.typetool);s.type=d;var e=a("#realcolor").val();e.length>0?s.colors=a("#color").val():(a("#color").val(d.color),s.colors=null),s.cartridge=a("#libelle").val(),a("#realcartridgecolor").val()&&a("#realcartridgecolor").val().length>0?s.cartridgeColor=a("#cartridgecolor").val():(a("#cartridgecolor").val(d.get_color_cartridge()),s.cartridgeColor=null),s.texts=a("#texts").val(),s.label=a("#button").val(),s.enabled=a("#enabled").val(),s.reply=a("#reply").val(),s.orderTool=a("#order").val(),a("#typetool").on("change",function(){s.typetool=a("#typetool").val();var b=z(s.typetool);s.type=b,s.colors=b.get_color(),s.cartridgeColor=b.get_color_cartridge(),a("#color").val(s.colors),a("#cartridgecolor").val(s.cartridgeColor),A(),B()}),a("#toolFormSubmit").on("click",function(){var b="";a("input[name^='text[']").each(function(){a(this).val()&&a(this).val().length>0&&(b+='"'+a(this).val().replace(/"/g,"")+'",')}),b.length>0&&a("#texts").val(b.substring(0,b.length-1));var d=a("#assignfeedback_editpdfplus_edit_tool"),e=d.serialize();f.call([{methodname:"assignfeedback_editpdfplus_submit_tool_edit_form",args:{jsonformdata:JSON.stringify(e)}}])[0].done(function(b){if(""===b[0].message){a("#message_edit_tool").show(),a("#message_edit_tool").html(w.messageEditOk),a("#message_edit_tool").addClass("alert-success"),a("#message_edit_tool").removeClass("alert-danger"),a("#message_edit_tool").removeClass("alert-warning"),a("#editpdlplus_tool_"+b[0].selecttool).remove(),a("#editpdlplus_toolbar_"+b[0].axeid+" > ul").html("");for(var c=0;c<b.length;c++){var d=new j;d.initAdmin(b[c]);var e=d.getButtonSortable(b[c].selecttool);a("#editpdlplus_toolbar_"+b[0].axeid+" > ul").append(e)}a(".editpdlplus_tool").on("click",D);var f=a("#axisid").val();f!==b[0].axeid&&(a("#editpdlplus_axes").val(b[0].axeid),a("#editpdlplus_axes").change()),a("#editpdlplus_tool_"+b[0].selecttool).click()}else a("#message_edit_tool").show(),a("#message_edit_tool").html(b[0].message),a("#message_edit_tool").addClass("alert-danger"),a("#message_edit_tool").removeClass("alert-success")}).fail(c.exception)}),a("#toolEnabled").on("click",function(){var b=a("#toolenabled").val();1==b?(a("#toolEnabled > i").addClass("fa-eye-slash"),a("#toolEnabled > i").removeClass("fa-eye"),a("#toolenabled").val(0)):(a("#toolEnabled > i").addClass("fa-eye"),a("#toolEnabled > i").removeClass("fa-eye-slash"),a("#toolenabled").val(1)),a("#toolFormSubmit").click()}),a("#toolClone").on("click",function(){t="clone",a("#assignfeedback_editpdfplus_widget_admin_button_addtool").click()}),a("#toolRemove").on("click",function(){if(!a(this).prop("disabled")){var b=a("#assignfeedback_editpdfplus_edit_tool"),d=b.serialize();f.call([{methodname:"assignfeedback_editpdfplus_submit_tool_del_form",args:{jsonformdata:JSON.stringify(d)}}])[0].done(function(b){if(""===b[0].message||"1"===b[0].message){if(a("#message_edit_tool").show(),a("#message_edit_tool").html(w.messageDelOk),a("#message_edit_tool").addClass("alert-success"),a("#message_edit_tool").removeClass("alert-danger"),a("#message_edit_tool").removeClass("alert-warning"),a("#editpdlplus_toolbar_"+b[0].axeid+" > ul").html(""),parseInt(b[0].toolid)>0){for(var c=0;c<b.length;c++){var d=new j;d.initAdmin(b[c]);var e=d.getButtonSortable(b[c].selecttool);a("#editpdlplus_toolbar_"+b[0].axeid+" > ul").append(e)}a(".editpdlplus_tool").on("click",D)}a("#toolworkspace").html("")}else a("#message_edit_tool").show(),a("#message_edit_tool").html(b[0].message),a("#message_edit_tool").addClass("alert-danger"),a("#message_edit_tool").removeClass("alert-success")}).fail(c.exception)}}),a("#toolRefesh").on("click",function(){w.prototype.refreshPrevisu()}),B(),A()}.bind(this)).fail(c.exception)}.bind(this)).fail(c.exception)};return w.prototype.openDivAddTool=function(){a("#message_edit_tool").hide(),a("#editpdlplus_tool_item").html(""),a(".editpdlplus_tool").removeClass("btn-primary");var b=a("#editpdlplus_axes option:selected").val(),d={axisid:b};e.loadFragment("assignfeedback_editpdfplus","tooladd",r,d).done(function(d,e){C(a("#editpdlplus_tool_item"),d,e).done(function(){a("#canevas").hide(),a("#toolaxis").val(b),"clone"===t?(a("#toolaxis").val(s.axis),a("#typetool").val(s.typetool),a("#color").val(s.colors),a("#libelle").val(s.cartridge),a("#cartridgecolor").val(s.cartridgeColor),a("#texts").val(s.texts),a("#button").val(s.label),a("#enabled").val(s.enabled),a("#reply").val(s.reply),a("#order").val(s.orderTool),s=new j,t=null):(s=new j,a("#typetool").on("change",function(){s=new j,s.axis=a("#toolaxis").val(),s.typetool=a("#typetool").val();var b=z(s.typetool);s.type=b,s.colors=b.get_color(),s.cartridgeColor=b.get_color_cartridge(),a("#color").val(s.colors),a("#cartridgecolor").val(s.cartridgeColor),A()}),a("#typetool").change()),a("#toolFormSubmit").on("click",function(){if(""===a("#button").val())a("#message_edit_tool").show(),a("#message_edit_tool").html(w.messageaddlibelleko),a("#message_edit_tool").addClass("alert-warning"),a("#message_edit_tool").removeClass("alert-danger"),a("#message_edit_tool").removeClass("alert-success");else{var b="";a("input[name^='text[']").each(function(){a(this).val()&&a(this).val().length>0&&(b+='"'+a(this).val().replace(/"/g,"")+'",')}),b.length>0&&a("#texts").val(b.substring(0,b.length-1));var d=a("#assignfeedback_editpdfplus_edit_tool"),e=d.serialize();f.call([{methodname:"assignfeedback_editpdfplus_submit_tool_add_form",args:{jsonformdata:JSON.stringify(e)}}])[0].done(function(b){if(""===b[0].message){a("#message_edit_tool").show(),a("#message_edit_tool").html(w.messageaddok),a("#message_edit_tool").addClass("alert-success"),a("#message_edit_tool").removeClass("alert-danger"),a("#message_edit_tool").removeClass("alert-warning"),a("#editpdlplus_toolbar_"+b[0].axeid+" > ul").html("");for(var c=0;c<b.length;c++){var d=new j;d.initAdmin(b[c]);var e=d.getButtonSortable(b[c].selecttool);a("#editpdlplus_toolbar_"+b[0].axeid+" > ul").append(e)}a(".editpdlplus_tool").on("click",D),a("#toolworkspace").html("")}else a("#message_edit_tool").show(),a("#message_edit_tool").html(b[0].message),a("#message_edit_tool").addClass("alert-danger"),a("#message_edit_tool").removeClass("alert-success")}).fail(c.exception)}})}.bind(this)).fail(c.exception)}.bind(this)).fail(c.exception)},w.prototype.showWorkspace=function(){a("#axistool").show(),a("#assignfeedback_editpdfplus_widget_admin_toolheader").show(),a("#assignfeedback_editpdfplus_widget_admin_workspace").show(),a("#assignfeedback_editpdfplus_widget_admin_toolworkspace").show()},w.prototype.resetDivAction=function(b){a("#"+b).html(),a("#"+b).hide()},w.prototype.displayMessageInformation=function(b,c,d,e,f){a("#"+b).show(),a("#"+b).html(c),d?a("#"+b).addClass("alert-success"):a("#"+b).removeClass("alert-success"),e?a("#"+b).addClass("alert-danger"):a("#"+b).removeClass("alert-danger"),f?a("#"+b).addClass("alert-warning"):a("#"+b).removeClass("alert-warning"),a("#"+b).fadeOut(5e3)},w});
\ No newline at end of file \ No newline at end of file
...@@ -36,12 +36,13 @@ ...@@ -36,12 +36,13 @@
* @param {assignfeedback_editpdfplus/annotationstampcomment} AnnotationStampcomment * @param {assignfeedback_editpdfplus/annotationstampcomment} AnnotationStampcomment
*/ */
define(['jquery', 'jqueryui', 'core/notification', 'core/templates', 'core/fragment', define(['jquery', 'jqueryui', 'core/notification', 'core/templates', 'core/fragment',
'core/ajax', 'core/str', 'assignfeedback_editpdfplus/tool', 'assignfeedback_editpdfplus/tooltype', 'core/ajax', 'core/str', 'core/modal_factory', 'core/modal_events',
'assignfeedback_editpdfplus/tool', 'assignfeedback_editpdfplus/tooltype',
'assignfeedback_editpdfplus/annotationhighlightplus', 'assignfeedback_editpdfplus/annotationhighlightplus',
'assignfeedback_editpdfplus/annotationstampplus', 'assignfeedback_editpdfplus/annotationframe', 'assignfeedback_editpdfplus/annotationstampplus', 'assignfeedback_editpdfplus/annotationframe',
'assignfeedback_editpdfplus/annotationcommentplus', 'assignfeedback_editpdfplus/annotationverticalline', 'assignfeedback_editpdfplus/annotationcommentplus', 'assignfeedback_editpdfplus/annotationverticalline',
'assignfeedback_editpdfplus/annotationstampcomment'], 'assignfeedback_editpdfplus/annotationstampcomment'],
function ($, jqui, notification, templates, fragment, ajax, str, Tool, ToolType, function ($, jqui, notification, templates, fragment, ajax, str, ModalFactory, ModalEvents, Tool, ToolType,
AnnotationHighlightplus, AnnotationStampplus, AnnotationFrame, AnnotationHighlightplus, AnnotationStampplus, AnnotationFrame,
AnnotationCommentplus, AnnotationVerticalline, AnnotationStampcomment) { AnnotationCommentplus, AnnotationVerticalline, AnnotationStampcomment) {
...@@ -183,10 +184,8 @@ define(['jquery', 'jqueryui', 'core/notification', 'core/templates', 'core/fragm ...@@ -183,10 +184,8 @@ define(['jquery', 'jqueryui', 'core/notification', 'core/templates', 'core/fragm
var canBeDelete = $("#editpdlplus_axes option:selected").data('delete'); var canBeDelete = $("#editpdlplus_axes option:selected").data('delete');
if (canBeDelete) { if (canBeDelete) {
if (parseInt(canBeDelete) > 0) { if (parseInt(canBeDelete) > 0) {
//$("#assignfeedback_editpdfplus_widget_admin_button_delaxis").addClass("disabled");
$('#assignfeedback_editpdfplus_widget_admin_button_delaxis').prop('disabled', true); $('#assignfeedback_editpdfplus_widget_admin_button_delaxis').prop('disabled', true);
} else { } else {
//$("#assignfeedback_editpdfplus_widget_admin_button_delaxis").removeClass("disabled");
$('#assignfeedback_editpdfplus_widget_admin_button_delaxis').removeAttr('disabled'); $('#assignfeedback_editpdfplus_widget_admin_button_delaxis').removeAttr('disabled');
} }
} else { } else {
...@@ -207,11 +206,13 @@ define(['jquery', 'jqueryui', 'core/notification', 'core/templates', 'core/fragm ...@@ -207,11 +206,13 @@ define(['jquery', 'jqueryui', 'core/notification', 'core/templates', 'core/fragm
$("#assignfeedback_editpdfplus_widget_admin_button_addaxis").on("click", this.openDivAddAxis); $("#assignfeedback_editpdfplus_widget_admin_button_addaxis").on("click", this.openDivAddAxis);
$("#assignfeedback_editpdfplus_widget_admin_button_editaxis").on("click", this.openDivEditAxis); $("#assignfeedback_editpdfplus_widget_admin_button_editaxis").on("click", this.openDivEditAxis);
$("#assignfeedback_editpdfplus_widget_admin_button_delaxis").on("click", this.openDivDelAxis); $("#assignfeedback_editpdfplus_widget_admin_button_delaxis").on("click", this.openDivDelAxis);
$("#assignfeedback_editpdfplus_widget_admin_button_exportaxis").on("click", this.openDivExportAxis);
$("#assignfeedback_editpdfplus_widget_admin_button_addtool").on("click", this.openDivAddTool); $("#assignfeedback_editpdfplus_widget_admin_button_addtool").on("click", this.openDivAddTool);
$(".btn-primary").click(); $(".btn-primary").click();
$(".btnimport").on('click', this.importAxis); $(".btnimport").on('click', this.importAxis);
$(".btnimportdel").on('click', this.deleteModel);
initMessages(); initMessages();
}; };
...@@ -251,18 +252,11 @@ define(['jquery', 'jqueryui', 'core/notification', 'core/templates', 'core/fragm ...@@ -251,18 +252,11 @@ define(['jquery', 'jqueryui', 'core/notification', 'core/templates', 'core/fragm
])[0].done(function (retour) { ])[0].done(function (retour) {
if (retour.message === "ok") { if (retour.message === "ok") {
//mise à jour du message //mise à jour du message
$("#message_order_tool").show(); AdminPanel.prototype.displayMessageInformation(
$("#message_order_tool").html(AdminPanel.messageEditOk); 'message_order_tool', AdminPanel.messageEditOk, 1, 0, 0);
$("#message_order_tool").addClass("alert-success");
$("#message_order_tool").removeClass("alert-danger");
$("#message_order_tool").removeClass("alert-warning");
$("#message_order_tool").fadeOut(5000);
} else { } else {
$("#message_order_tool").show(); AdminPanel.prototype.displayMessageInformation(
$("#message_order_tool").html(AdminPanel.messageko); 'message_order_tool', AdminPanel.messageko, 0, 1, 0);
$("#message_order_tool").addClass("alert-danger");
$("#message_order_tool").removeClass("alert-success");
$("#message_order_tool").fadeOut(5000);
} }
}).fail(notification.exception); }).fail(notification.exception);
} }
...@@ -465,27 +459,135 @@ define(['jquery', 'jqueryui', 'core/notification', 'core/templates', 'core/fragm ...@@ -465,27 +459,135 @@ define(['jquery', 'jqueryui', 'core/notification', 'core/templates', 'core/fragm
}.bind(this)).fail(notification.exception); }.bind(this)).fail(notification.exception);
}; };
/**
* Load content for exporting an axis
*/
AdminPanel.prototype.openDivExportAxis = function () {
$("#message_edit_tool").hide();
$("#axistool").hide();
$('#assignfeedback_editpdfplus_widget_admin_div_exportaxis').show();
$('#assignfeedback_editpdfplus_widget_admin_div_exportaxis').html("");
$('#assignfeedback_editpdfplus_widget_admin_toolheader').hide();
$('#assignfeedback_editpdfplus_widget_admin_toolworkspace').hide();
$("#editpdlplus_axes").prop('disabled', true);
var axeid = $("#editpdlplus_axes option:selected").val();
var params = {axeid: axeid};
fragment.loadFragment('assignfeedback_editpdfplus', 'axisexport', contextid, params)
.done(function (html, js) {
templates.appendNodeContents('#assignfeedback_editpdfplus_widget_admin_div_exportaxis',
html, js);
$("#axisExportSubmit").on("click", function () {
var form = $('#assignfeedback_editpdfplus_widget_admin_div_exportaxis form');
var data = form.serialize();
ajax.call([
{
methodname: 'assignfeedback_editpdfplus_submit_axis_export_form',
args: {jsonformdata: JSON.stringify(data)}
}
])[0].done(function (message) {
if (message[0].message === "") {
//add model to export page
var newRow = $('<tr></tr>');
newRow.append('<td>' + message[0].axelabel + '</td>');
var toolbar = message;
var newCell = $('<td><div class="btn-group"></div></td>');
for (var i = 0; i < toolbar.length; i++) {
newCell.append('<button class="btn" style="' + toolbar[i].style + '">'
+ toolbar[i].button
+ '</button>');
}
newRow.append(newCell);
newRow.append('<td>'
+ "<button class='btn btn-primary btn-sm btnimport' data-axis='"
+ message[0].axeid + "'>"
+ "<i class='fa fa-download'></i>"
+ "</button>"
+ '</td>');
newRow.append('<td>'
+ "<button class='btn btn-danger btn-sm btnimportdel' data-model='"
+ message[0].modelid + "'>"
+ "<i class='fa fa-remove'></i>"
+ "</button>"
+ '</td>');
$('div#import tbody').append(newRow);
$(".btnimport").on('click', AdminPanel.prototype.importAxis);
$(".btnimportdel").on('click', AdminPanel.prototype.deleteModel);
AdminPanel.prototype
.resetDivAction('assignfeedback_editpdfplus_widget_admin_div_exportaxis');
$("#axistool").show();
var selectAxis = $("#editpdlplus_axes").val();
if (selectAxis && selectAxis !== "") {
AdminPanel.prototype.showWorkspace();
} else {
$("#assignfeedback_editpdfplus_widget_admin_workspace").hide();
$('#assignfeedback_editpdfplus_widget_admin_toolheader').hide();
$('#assignfeedback_editpdfplus_widget_admin_toolworkspace').hide();
}
$("#editpdlplus_axes").removeAttr('disabled');
//mise à jour du message
var messageok = str.get_string('adminexport_messageok', 'assignfeedback_editpdfplus');
AdminPanel.prototype.displayMessageInformation(
'message_export_axis', messageok, 1, 0, 0);
} else {
$('#assignfeedback_editpdfplus_widget_admin_div_exportaxis')
.append("<div class='alert alert-danger' style='margin-top: 5px;'>"
+ message[0].message + "</div>");
}
}).fail(notification.exception);
});
$("#axisExportCancel").on("click", function () {
AdminPanel.prototype.resetDivAction('assignfeedback_editpdfplus_widget_admin_div_exportaxis');
AdminPanel.prototype.showWorkspace();
$("#editpdlplus_axes").removeAttr('disabled');
});
}.bind(this)).fail(notification.exception);
};
/** /**
* Load content for deleting an axis * Load content for deleting an axis
*/ */
AdminPanel.prototype.openDivDelAxis = function () { AdminPanel.prototype.openDivDelAxis = function () {
var canBeDelete = $("#editpdlplus_axes option:selected").data('delete'); var canBeDelete = $("#editpdlplus_axes option:selected").data('delete');
if (canBeDelete !== null && parseInt(canBeDelete) === 0) { if (canBeDelete === null || parseInt(canBeDelete) > 0) {
$("#message_edit_tool").hide(); return;
$("#axistool").hide();
$('#assignfeedback_editpdfplus_widget_admin_div_delaxis').show();
$('#assignfeedback_editpdfplus_widget_admin_div_delaxis').html("");
$('#assignfeedback_editpdfplus_widget_admin_toolheader').hide();
$('#assignfeedback_editpdfplus_widget_admin_toolworkspace').hide();
$("#editpdlplus_axes").prop('disabled', true);
var axeid = $("#editpdlplus_axes option:selected").val();
var params = {axeid: axeid};
fragment.loadFragment('assignfeedback_editpdfplus', 'axisdel', contextid, params)
.done(function (html, js) {
templates.appendNodeContents('#assignfeedback_editpdfplus_widget_admin_div_delaxis',
html, js);
}.bind(this)).fail(notification.exception);
} }
var axeid = $("#editpdlplus_axes option:selected").val();
$("#assignfeedback_editpdfplus_del_axis input[name='axeid']").val(axeid);
ModalFactory.create({
type: ModalFactory.types.SAVE_CANCEL,
title: str.get_string('adminaxisimport_delete', 'assignfeedback_editpdfplus'),
body: str.get_string('adminaxisdelete_question', 'assignfeedback_editpdfplus')
}).then(function (modal) {
modal.setSaveButtonText(str.get_string('adminaxisimport_delete', 'assignfeedback_editpdfplus'));
var root = modal.getRoot();
root.on(ModalEvents.save, function () {
// Stop the default save button behaviour which is to close the modal.
//e.preventDefault();
//remove the current stream
var form = $('#assignfeedback_editpdfplus_del_axis');
var data = form.serialize() + "&contextid=" + contextid;
ajax.call([
{
methodname: 'assignfeedback_editpdfplus_submit_axis_del_form',
args: {jsonformdata: JSON.stringify(data)}
}
])[0].done(function (message) {
if (message[0].message === "1") {
$("#editpdlplus_axes option:selected").remove();
$("#editpdlplus_axes").change();
} else {
$('#assignfeedback_editpdfplus_widget_admin_div_delaxis')
.append("<div class='alert alert-danger' style='margin-top: 5px;'>"
+ message[0].message
+ "</div>");
}
}).fail(notification.exception);
});
modal.show();
});
}; };
/** /**
...@@ -509,76 +611,107 @@ define(['jquery', 'jqueryui', 'core/notification', 'core/templates', 'core/fragm ...@@ -509,76 +611,107 @@ define(['jquery', 'jqueryui', 'core/notification', 'core/templates', 'core/fragm
return promise.promise(); return promise.promise();
}; };
/**
* Delete a model
* - Display a moodle popup to delete a selected model
* - Delete it and display ok/ko message
*/
AdminPanel.prototype.deleteModel = function () {
var tr = $(this).parents('tr');
var modelid = $(this).data('model');
if (!modelid || parseInt(modelid) <= 0) {
return;
}
$("#assignfeedback_editpdfplus_del_model input[name='modelid']").val(modelid);
ModalFactory.create({
type: ModalFactory.types.SAVE_CANCEL,
title: str.get_string('adminaxisimport_delete', 'assignfeedback_editpdfplus'),
body: str.get_string('delete_model_question', 'assignfeedback_editpdfplus')
}).then(function (modal) {
modal.setSaveButtonText(str.get_string('adminaxisimport_delete', 'assignfeedback_editpdfplus'));
var root = modal.getRoot();
root.on(ModalEvents.save, function () {
// Stop the default save button behaviour which is to close the modal.
//e.preventDefault();
//remove the current stream
var form = $('#assignfeedback_editpdfplus_del_model');
var data = form.serialize() + "&contextid=" + contextid;
ajax.call([
{
methodname: 'assignfeedback_editpdfplus_submit_model_del_form',
args: {jsonformdata: JSON.stringify(data)}
}
])[0].done(function (message) {
if (message[0].message === "1") {
tr.remove();
} else {
AdminPanel.prototype.displayMessageInformation('message_del_modal', message[0].message, 1, 0, 0);
}
}).fail(notification.exception);
});
modal.show();
});
};
/** /**
* Import an axis to the current's user's toolbar * Import an axis to the current's user's toolbar
*/ */
AdminPanel.prototype.importAxis = function () { AdminPanel.prototype.importAxis = function () {
var axisimportid = $(this).data('axis'); var axisimportid = $(this).data('axis');
if (axisimportid && parseInt(axisimportid) > 0) { if (!axisimportid || parseInt(axisimportid) <= 0) {
$("#assignfeedback_editpdfplus_import_axis > div > input[name^='axeid']").val(axisimportid); return;
var form = $('#assignfeedback_editpdfplus_import_axis'); }
var data = form.serialize() + "&contextid=" + contextid; $("#assignfeedback_editpdfplus_import_axis > div > input[name^='axeid']").val(axisimportid);
ajax.call([ var form = $('#assignfeedback_editpdfplus_import_axis');
{ var data = form.serialize() + "&contextid=" + contextid;
methodname: 'assignfeedback_editpdfplus_submit_axis_import_form', ajax.call([
args: {jsonformdata: JSON.stringify(data)} {
} methodname: 'assignfeedback_editpdfplus_submit_axis_import_form',
])[0].done(function (toolbar) { args: {jsonformdata: JSON.stringify(data)}
if (toolbar[0].message === "") { }
//mise à jour du message ])[0].done(function (toolbar) {
$("#message_import_axis").show(); if (toolbar[0].message === "") {
$("#message_import_axis").html(AdminPanel.messageaddok); //mise à jour du message
$("#message_import_axis").addClass("alert-success"); var messageok = str.get_string('adminimport_messageok', 'assignfeedback_editpdfplus');
$("#message_import_axis").removeClass("alert-danger"); AdminPanel.prototype.displayMessageInformation('message_import_axis', messageok, 1, 0, 0);
$("#message_import_axis").removeClass("alert-warning"); //maj axis
$("#message_import_axis").fadeOut(5000); var divAxis = "<div id='editpdlplus_toolbar_"
//maj axis + toolbar[0].axeid
var divAxis = "<div id='editpdlplus_toolbar_" + "' class='btn-group toolbar' style='display: none;'>"
+ toolbar[0].axeid + "<ul class='sortable' style='list-style-type: none;margin: 0;padding: 0;width: 100%;'></ul>"
+ "' class='btn-group toolbar' style='display: none;'>" + "</div>";
+ "<ul class='sortable' style='list-style-type: none;margin: 0;padding: 0;width: 100%;'></ul>" $('#editpdlplus_toolbars').append(divAxis);
+ "</div>"; initSortableToolBar();
$('#editpdlplus_toolbars').append(divAxis); var option = new Option(toolbar[0].axelabel, toolbar[0].axeid, true, true);
initSortableToolBar(); $("#editpdlplus_axes").append(option);
var option = new Option(toolbar[0].axelabel, toolbar[0].axeid, true, true); var axeOption = $("#editpdlplus_axes option[value='" + toolbar[0].axeid + "']");
$("#editpdlplus_axes").append(option); axeOption.data('delete', 0);
var axeOption = $("#editpdlplus_axes option[value='" + toolbar[0].axeid + "']"); $('#editpdlplus_tool_item').html("");
axeOption.data('delete', 1); //maj toolbar
var btr = $("#assignfeedback_editpdfplus_widget_admin_button_delaxis"); if (toolbar[0].toolid && toolbar[0].toolid > 0) {
btr.prop("disabled", true); for (var i = 0; i < toolbar.length; i++) {
$('#editpdlplus_tool_item').html(""); var toolTmp = new Tool();
//maj toolbar toolTmp.initAdmin(toolbar[i]);
if (toolbar[0].toolid && toolbar[0].toolid > 0) { var buttonTmp = toolTmp.getButtonSortable(toolbar[i].selecttool);
for (var i = 0; i < toolbar.length; i++) { $("#editpdlplus_toolbar_" + toolbar[0].axeid + " > ul").append(buttonTmp);
var toolTmp = new Tool();
toolTmp.initAdmin(toolbar[i]);
var buttonTmp = toolTmp.getButtonSortable(toolbar[i].selecttool);
$("#editpdlplus_toolbar_" + toolbar[0].axeid + " > ul").append(buttonTmp);
}
} else {
var axeid = toolbar[0].axeid;
var axeOption = $("#editpdlplus_axes option[value='" + axeid + "']");
axeOption.data('delete', 0);
var btr = $("#assignfeedback_editpdfplus_widget_admin_button_delaxis");
btr.removeAttr("disabled");