Gitlab CSE Unil

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

masque dynamique des champs non cernés par le type d'outil choisi

parent 10db78d5
define(["jquery","core/notification","core/templates","core/fragment","core/ajax","core/str","assignfeedback_editpdfplus/annotation","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){var n=null,o=null,p=null,q=null,r=function(a,b){n=a,q=JSON.parse(b),this.init()},s=null;r.messageDelOk="",r.messageDelKo="",r.messageko="",r.messageaddok="",r.messageaddlibelleko="",r.messageEditOk="",r.prototype.selectTool=null,r.prototype.init=function(){a("#editpdlplus_axes").on("change",function(){a(".toolbar").hide();var b=a("#editpdlplus_axes").val();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").addClass("disabled"):a("#assignfeedback_editpdfplus_widget_admin_button_delaxis").removeClass("disabled"):(a("#editpdlplus_axes option[value='"+b+"']").data("delete",0),a("#assignfeedback_editpdfplus_widget_admin_button_delaxis").removeClass("disabled")),a("#toolworkspace").html("")}),a("#editpdlplus_axes").change(),a(".editpdlplus_tool").on("click",x),this.selectTool=a(".editpdlplus_tool").first(),this.initTool(),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(),t()};var t=function(){f.get_string("admindeltool_messageok","assignfeedback_editpdfplus").done(function(a){r.messageDelOk=a}).fail(b.exception),f.get_string("admindeltool_messageko","assignfeedback_editpdfplus").done(function(a){r.messageDelKo=a}).fail(b.exception),f.get_string("adminaddtool_messageok","assignfeedback_editpdfplus").done(function(a){r.messageaddok=a}).fail(b.exception),f.get_string("admin_messageko","assignfeedback_editpdfplus").done(function(a){r.messageko=a}).fail(b.exception),f.get_string("adminedittool_messageok","assignfeedback_editpdfplus").done(function(a){r.messageEditOk=a}).fail(b.exception),f.get_string("adminaddtool_messagelibelleko","assignfeedback_editpdfplus").done(function(a){r.messageaddlibelleko=a}).fail(b.exception)};r.prototype.test=function(){alert("test"),x()},r.prototype.initTool=function(){a(this.selectTool).removeClass("btn-default"),a(this.selectTool).addClass("btn-primary")},r.prototype.refreshPrevisu=function(){o.typetool=a("#typetool").val(),o.color=a("#color").val(),o.libelle=a("#libelle").val(),o.catridgecolor=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)),o.texts=a("#texts").val(),o.button=a("#button").val(),o.enabled=a("#enabled").val(),o.reply=0,a("#reply").is(":checked")&&(o.reply=1),o.order=a("#order").val(),v()};var u=function(a){for(var b=0;b<q.length;b++)if(q[b].id==a)return q[b]},v=function(){a("#canevas").html(""),s=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)s=new h;else if(3===b)s=new i;else if(4===b){s=new j;var c=new j}else 5===b?s=new l:6===b?s=new m:7===b&&(s=new k);if(s){var d=u(b);o.reply=0,a("#reply").is(":checked")&&(o.reply=1),s.initAdminDemo(o,d),s.draw(a("#canevas")),c&&(c.initChildAdminDemo(s),c.draw(a("#canevas")))}};r.prototype.openDivAddAxis=function(){a("#message_edit_tool").hide(),a("#axistool").hide(),a("#assignfeedback_editpdfplus_widget_admin_div_addaxis").show(),a("#assignfeedback_editpdfplus_widget_admin_div_addaxis > .panel-body").html(""),a("#assignfeedback_editpdfplus_widget_admin_toolheader").hide(),a("#assignfeedback_editpdfplus_widget_admin_toolworkspace").hide(),a("#editpdlplus_axes").prop("disabled","disabled");var e={};d.loadFragment("assignfeedback_editpdfplus","axisadd",n,e).done(function(a,b){c.appendNodeContents("#assignfeedback_editpdfplus_widget_admin_div_addaxis > .panel-body",a,b)}.bind(this)).fail(b.exception)},r.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 > .panel-body").html(""),a("#assignfeedback_editpdfplus_widget_admin_toolheader").hide(),a("#assignfeedback_editpdfplus_widget_admin_toolworkspace").hide(),a("#editpdlplus_axes").prop("disabled","disabled");var e=a("#editpdlplus_axes option:selected").val(),f={axeid:e};d.loadFragment("assignfeedback_editpdfplus","axisedit",n,f).done(function(a,b){c.appendNodeContents("#assignfeedback_editpdfplus_widget_admin_div_editaxis > .panel-body",a,b)}.bind(this)).fail(b.exception)},r.prototype.openDivDelAxis=function(){var e=a("#editpdlplus_axes option:selected").data("delete");if(null!==e&&0===parseInt(e)){a("#message_edit_tool").hide(),a("#axistool").hide(),a("#assignfeedback_editpdfplus_widget_admin_div_delaxis").show(),a("#assignfeedback_editpdfplus_widget_admin_div_delaxis > .panel-body").html(""),a("#assignfeedback_editpdfplus_widget_admin_toolheader").hide(),a("#assignfeedback_editpdfplus_widget_admin_toolworkspace").hide(),a("#editpdlplus_axes").prop("disabled","disabled");var f=a("#editpdlplus_axes option:selected").val(),g={axeid:f};d.loadFragment("assignfeedback_editpdfplus","axisdel",n,g).done(function(a,b){c.appendNodeContents("#assignfeedback_editpdfplus_widget_admin_div_delaxis > .panel-body",a,b)}.bind(this)).fail(b.exception)}};var w=function(b,d,e){var f=a.Deferred();return b.fadeOut("fast",function(){c.replaceNodeContents(b,d,e),b.fadeIn("fast",function(){f.resolve()})}),f.promise()},x=function(){var c=a(this).val();a(".editpdlplus_tool").each(function(){a(this).removeClass("btn-primary"),a(this).removeClass("btn-default");var b=a(this).data("enable");1===b&&a(this).val()!==c&&a(this).addClass("btn-default")}),a(this).addClass("btn-primary"),o&&o.id===c||a("#message_edit_tool").hide(),a("#editpdlplus_tool_item").html("");var f={toolid:c};d.loadFragment("assignfeedback_editpdfplus","tooledit",n,f).done(function(d,f){w(a("#editpdlplus_tool_item"),d,f).done(function(){o=new Object,o.id=c,o.typetool=a("#typetool").val();var d=u(o.typetool),f=a("#realcolor").val();f.length>0?o.color=a("#color").val():(a("#color").val(d.color),o.color=null),o.libelle=a("#libelle").val(),a("#realcartridgecolor").val().length>0?o.catridgecolor=a("#cartridgecolor").val():(a("#cartridgecolor").val(d.cartridge_color),o.catridgecolor=null),o.texts=a("#texts").val(),o.button=a("#button").val(),o.enabled=a("#enabled").val(),o.reply=a("#reply").val(),o.order=a("#order").val(),a("#toolFormSubmit").on("click",function(){var c="";a("input[name^='text[']").each(function(){a(this).val()&&a(this).val().length>0&&(c+='"'+a(this).val().replace(/"/g,"")+'",')}),c.length>0&&a("#texts").val(c.substring(0,c.length-1));var d=a("#assignfeedback_editpdfplus_edit_tool"),f=d.serialize();e.call([{methodname:"assignfeedback_editpdfplus_submit_tool_edit_form",args:{jsonformdata:JSON.stringify(f)}}])[0].done(function(b){if(""===b[0].message){a("#message_edit_tool").show(),a("#message_edit_tool").html(r.messageEditOk),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).html("");for(var c=0;c<b.length;c++){var d="btn-default";1!==b[c].enable&&(d=""),b[c].toolid===b[c].selecttool&&(d="btn-primary");var e="";4!==b[c].typetool&&1!==b[c].typetool||(e="text-decoration: underline;");var f=b[c].button;4!==b[c].typetool&&5!==b[c].typetool||(f="| "+f,4===b[c].typetool&&(f+=" |"));var g="<button class='btn "+d+" editpdlplus_tool' id='editpdlplus_tool_"+b[c].toolid+"' style='"+e+"' value='"+b[c].toolid+"' data-enable='"+b[c].enable+"'>"+f+"</button>";a("#editpdlplus_toolbar_"+b[0].axeid).append(g)}a(".editpdlplus_tool").on("click",x),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(b.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(){p="clone",a("#assignfeedback_editpdfplus_widget_admin_button_addtool").click()}),a("#toolRemove").on("click",function(){if(!a(this).hasClass("disabled")){var c=a("#assignfeedback_editpdfplus_edit_tool"),d=c.serialize();e.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(r.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).html(""),parseInt(b[0].toolid)>0){for(var c=0;c<b.length;c++){var d="btn-default";1!==b[c].enable&&(d=""),b[c].toolid===b[c].selecttool&&(d="btn-primary");var e="";4!==b[c].typetool&&1!==b[c].typetool||(e="text-decoration: underline;");var f=b[c].button;4!==b[c].typetool&&5!==b[c].typetool||(f="| "+f,4===b[c].typetool&&(f+=" |"));var g="<button class='btn "+d+" editpdlplus_tool' id='editpdlplus_tool_"+b[c].toolid+"' style='"+e+"' value='"+b[c].toolid+"' data-enable='"+b[c].enable+"'>"+f+"</button>";a("#editpdlplus_toolbar_"+b[0].axeid).append(g)}a(".editpdlplus_tool").on("click",x)}else{var h=b[0].axeid,i=a("#editpdlplus_axes option[value='"+h+"']");i.data("delete",0);var j=a("#assignfeedback_editpdfplus_widget_admin_button_delaxis");j.removeClass("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(b.exception)}}),a("#toolRefesh").on("click",function(){r.prototype.refreshPrevisu()}),v()}.bind(this)).fail(b.exception)}.bind(this)).fail(b.exception)};return r.prototype.openDivAddTool=function(){a("#message_edit_tool").hide(),a("#editpdlplus_tool_item").html(""),a(".btn-primary").addClass("btn-default"),a(".editpdlplus_tool").removeClass("btn-primary");var c=a("#editpdlplus_axes option:selected").val(),f={axisid:c};d.loadFragment("assignfeedback_editpdfplus","tooladd",n,f).done(function(c,d){w(a("#editpdlplus_tool_item"),c,d).done(function(){a("#canevas").hide(),"clone"===p?(a("#typetool").val(o.typetool),a("#color").val(o.color),a("#libelle").val(o.libelle),a("#cartridgecolor").val(o.catridgecolor),a("#texts").val(o.texts),a("#button").val(o.button),a("#enabled").val(o.enabled),a("#reply").val(o.reply),a("#order").val(o.order),o=new Object,p=null):(o=new Object,a("#typetool").on("change",function(){o.typetool=a("#typetool").val();var b=u(o.typetool);o.color=b.color,o.catridgecolor=b.cartridge_color,a("#color").val(o.color),a("#cartridgecolor").val(o.catridgecolor)}),a("#typetool").change()),a("#toolFormSubmit").on("click",function(){if(""===a("#button").val())a("#message_edit_tool").show(),a("#message_edit_tool").html(r.messageaddlibelleko),a("#message_edit_tool").addClass("alert-warning"),a("#message_edit_tool").removeClass("alert-danger"),a("#message_edit_tool").removeClass("alert-success");else{var c="";a("input[name^='text[']").each(function(){a(this).val()&&a(this).val().length>0&&(c+='"'+a(this).val().replace(/"/g,"")+'",')}),c.length>0&&a("#texts").val(c.substring(0,c.length-1));var d=a("#assignfeedback_editpdfplus_edit_tool"),f=d.serialize();e.call([{methodname:"assignfeedback_editpdfplus_submit_tool_add_form",args:{jsonformdata:JSON.stringify(f)}}])[0].done(function(b){if(""===b[0].message){a("#message_edit_tool").show(),a("#message_edit_tool").html(r.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).html("");for(var c=0;c<b.length;c++){var d="btn-default";1!==b[c].enable&&(d=""),b[c].toolid===b[c].selecttool&&(d="btn-primary");var e="";4!==b[c].typetool&&1!==b[c].typetool||(e="text-decoration: underline;");var f=b[c].button;4!==b[c].typetool&&5!==b[c].typetool||(f="| "+f,4===b[c].typetool&&(f+=" |"));var g="<button class='btn "+d+" editpdlplus_tool' id='editpdlplus_tool_"+b[c].toolid+"' style='"+e+"' value='"+b[c].toolid+"' data-enable='"+b[c].enable+"'>"+f+"</button>";a("#editpdlplus_toolbar_"+b[0].axeid).append(g)}a(".editpdlplus_tool").on("click",x),a("#toolworkspace").html("");var h=b[0].axeid,i=a("#editpdlplus_axes option[value='"+h+"']");i.data("delete",1);var j=a("#assignfeedback_editpdfplus_widget_admin_button_delaxis");j.addClass("disabled")}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(b.exception)}})}.bind(this)).fail(b.exception)}.bind(this)).fail(b.exception)},r});
\ No newline at end of file
define(["jquery","core/notification","core/templates","core/fragment","core/ajax","core/str","assignfeedback_editpdfplus/annotation","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){var n=null,o=null,p=null,q=null,r=function(a,b){n=a,q=JSON.parse(b),this.init()},s=null;r.messageDelOk="",r.messageDelKo="",r.messageko="",r.messageaddok="",r.messageaddlibelleko="",r.messageEditOk="",r.prototype.selectTool=null,r.prototype.init=function(){a("#editpdlplus_axes").on("change",function(){a(".toolbar").hide();var b=a("#editpdlplus_axes").val();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").addClass("disabled"):a("#assignfeedback_editpdfplus_widget_admin_button_delaxis").removeClass("disabled"):(a("#editpdlplus_axes option[value='"+b+"']").data("delete",0),a("#assignfeedback_editpdfplus_widget_admin_button_delaxis").removeClass("disabled")),a("#toolworkspace").html("")}),a("#editpdlplus_axes").change(),a(".editpdlplus_tool").on("click",y),this.selectTool=a(".editpdlplus_tool").first(),this.initTool(),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(),t()};var t=function(){f.get_string("admindeltool_messageok","assignfeedback_editpdfplus").done(function(a){r.messageDelOk=a}).fail(b.exception),f.get_string("admindeltool_messageko","assignfeedback_editpdfplus").done(function(a){r.messageDelKo=a}).fail(b.exception),f.get_string("adminaddtool_messageok","assignfeedback_editpdfplus").done(function(a){r.messageaddok=a}).fail(b.exception),f.get_string("admin_messageko","assignfeedback_editpdfplus").done(function(a){r.messageko=a}).fail(b.exception),f.get_string("adminedittool_messageok","assignfeedback_editpdfplus").done(function(a){r.messageEditOk=a}).fail(b.exception),f.get_string("adminaddtool_messagelibelleko","assignfeedback_editpdfplus").done(function(a){r.messageaddlibelleko=a}).fail(b.exception)};r.prototype.test=function(){alert("test"),y()},r.prototype.initTool=function(){a(this.selectTool).removeClass("btn-default"),a(this.selectTool).addClass("btn-primary")},r.prototype.refreshPrevisu=function(){o.typetool=a("#typetool").val(),o.color=a("#color").val(),o.libelle=a("#libelle").val(),o.catridgecolor=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)),o.texts=a("#texts").val(),o.button=a("#button").val(),o.enabled=a("#enabled").val(),o.reply=0,a("#reply").is(":checked")&&(o.reply=1),o.order=a("#order").val(),w()};var u=function(a){for(var b=0;b<q.length;b++)if(q[b].id==a)return q[b]},v=function(){var b=parseInt(a("#typetool").val()),c=u(b),d=!1,e=!1;c.configurable_cartridge&&0===parseInt(c.configurable_cartridge)?(a("#libelle").hide(),a("label[for='libelle']").hide(),d=!0):(a("#libelle").show(),a("label[for='libelle']").show()),c.configurable_cartridge_color&&0===parseInt(c.configurable_cartridge_color)?(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.configurable_color&&0===parseInt(c.configurable_color)?(a("#color").hide(),a("label[for='color']").hide(),f=!0):(a("#color").show(),a("label[for='color']").show()),c.configurable_texts&&0===parseInt(c.configurable_texts)?(a(".textform").hide(),a("label[for='texts']").hide(),g=!0):(a(".textform").show(),a("label[for='texts']").show()),c.configurable_question&&0===parseInt(c.configurable_question)?(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()},w=function(){a("#canevas").html(""),s=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)s=new h;else if(3===b)s=new i;else if(4===b){s=new j;var c=new j}else 5===b?s=new l:6===b?s=new m:7===b&&(s=new k);if(s){var d=u(b);o.reply=0,a("#reply").is(":checked")&&(o.reply=1),s.initAdminDemo(o,d),s.draw(a("#canevas")),c&&(c.initChildAdminDemo(s),c.draw(a("#canevas")))}};r.prototype.openDivAddAxis=function(){a("#message_edit_tool").hide(),a("#axistool").hide(),a("#assignfeedback_editpdfplus_widget_admin_div_addaxis").show(),a("#assignfeedback_editpdfplus_widget_admin_div_addaxis > .panel-body").html(""),a("#assignfeedback_editpdfplus_widget_admin_toolheader").hide(),a("#assignfeedback_editpdfplus_widget_admin_toolworkspace").hide(),a("#editpdlplus_axes").prop("disabled","disabled");var e={};d.loadFragment("assignfeedback_editpdfplus","axisadd",n,e).done(function(a,b){c.appendNodeContents("#assignfeedback_editpdfplus_widget_admin_div_addaxis > .panel-body",a,b)}.bind(this)).fail(b.exception)},r.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 > .panel-body").html(""),a("#assignfeedback_editpdfplus_widget_admin_toolheader").hide(),a("#assignfeedback_editpdfplus_widget_admin_toolworkspace").hide(),a("#editpdlplus_axes").prop("disabled","disabled");var e=a("#editpdlplus_axes option:selected").val(),f={axeid:e};d.loadFragment("assignfeedback_editpdfplus","axisedit",n,f).done(function(a,b){c.appendNodeContents("#assignfeedback_editpdfplus_widget_admin_div_editaxis > .panel-body",a,b)}.bind(this)).fail(b.exception)},r.prototype.openDivDelAxis=function(){var e=a("#editpdlplus_axes option:selected").data("delete");if(null!==e&&0===parseInt(e)){a("#message_edit_tool").hide(),a("#axistool").hide(),a("#assignfeedback_editpdfplus_widget_admin_div_delaxis").show(),a("#assignfeedback_editpdfplus_widget_admin_div_delaxis > .panel-body").html(""),a("#assignfeedback_editpdfplus_widget_admin_toolheader").hide(),a("#assignfeedback_editpdfplus_widget_admin_toolworkspace").hide(),a("#editpdlplus_axes").prop("disabled","disabled");var f=a("#editpdlplus_axes option:selected").val(),g={axeid:f};d.loadFragment("assignfeedback_editpdfplus","axisdel",n,g).done(function(a,b){c.appendNodeContents("#assignfeedback_editpdfplus_widget_admin_div_delaxis > .panel-body",a,b)}.bind(this)).fail(b.exception)}};var x=function(b,d,e){var f=a.Deferred();return b.fadeOut("fast",function(){c.replaceNodeContents(b,d,e),b.fadeIn("fast",function(){f.resolve()})}),f.promise()},y=function(){var c=a(this).val();a(".editpdlplus_tool").each(function(){a(this).removeClass("btn-primary"),a(this).removeClass("btn-default");var b=a(this).data("enable");1===b&&a(this).val()!==c&&a(this).addClass("btn-default")}),a(this).addClass("btn-primary"),o&&o.id===c||a("#message_edit_tool").hide(),a("#editpdlplus_tool_item").html("");var f={toolid:c};d.loadFragment("assignfeedback_editpdfplus","tooledit",n,f).done(function(d,f){x(a("#editpdlplus_tool_item"),d,f).done(function(){o=new Object,o.id=c,o.typetool=a("#typetool").val();var d=u(o.typetool),f=a("#realcolor").val();f.length>0?o.color=a("#color").val():(a("#color").val(d.color),o.color=null),o.libelle=a("#libelle").val(),a("#realcartridgecolor").val().length>0?o.catridgecolor=a("#cartridgecolor").val():(a("#cartridgecolor").val(d.cartridge_color),o.catridgecolor=null),o.texts=a("#texts").val(),o.button=a("#button").val(),o.enabled=a("#enabled").val(),o.reply=a("#reply").val(),o.order=a("#order").val(),a("#toolFormSubmit").on("click",function(){var c="";a("input[name^='text[']").each(function(){a(this).val()&&a(this).val().length>0&&(c+='"'+a(this).val().replace(/"/g,"")+'",')}),c.length>0&&a("#texts").val(c.substring(0,c.length-1));var d=a("#assignfeedback_editpdfplus_edit_tool"),f=d.serialize();e.call([{methodname:"assignfeedback_editpdfplus_submit_tool_edit_form",args:{jsonformdata:JSON.stringify(f)}}])[0].done(function(b){if(""===b[0].message){a("#message_edit_tool").show(),a("#message_edit_tool").html(r.messageEditOk),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).html("");for(var c=0;c<b.length;c++){var d="btn-default";1!==b[c].enable&&(d=""),b[c].toolid===b[c].selecttool&&(d="btn-primary");var e="";4!==b[c].typetool&&1!==b[c].typetool||(e="text-decoration: underline;");var f=b[c].button;4!==b[c].typetool&&5!==b[c].typetool||(f="| "+f,4===b[c].typetool&&(f+=" |"));var g="<button class='btn "+d+" editpdlplus_tool' id='editpdlplus_tool_"+b[c].toolid+"' style='"+e+"' value='"+b[c].toolid+"' data-enable='"+b[c].enable+"'>"+f+"</button>";a("#editpdlplus_toolbar_"+b[0].axeid).append(g)}a(".editpdlplus_tool").on("click",y),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(b.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(){p="clone",a("#assignfeedback_editpdfplus_widget_admin_button_addtool").click()}),a("#toolRemove").on("click",function(){if(!a(this).hasClass("disabled")){var c=a("#assignfeedback_editpdfplus_edit_tool"),d=c.serialize();e.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(r.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).html(""),parseInt(b[0].toolid)>0){for(var c=0;c<b.length;c++){var d="btn-default";1!==b[c].enable&&(d=""),b[c].toolid===b[c].selecttool&&(d="btn-primary");var e="";4!==b[c].typetool&&1!==b[c].typetool||(e="text-decoration: underline;");var f=b[c].button;4!==b[c].typetool&&5!==b[c].typetool||(f="| "+f,4===b[c].typetool&&(f+=" |"));var g="<button class='btn "+d+" editpdlplus_tool' id='editpdlplus_tool_"+b[c].toolid+"' style='"+e+"' value='"+b[c].toolid+"' data-enable='"+b[c].enable+"'>"+f+"</button>";a("#editpdlplus_toolbar_"+b[0].axeid).append(g)}a(".editpdlplus_tool").on("click",y)}else{var h=b[0].axeid,i=a("#editpdlplus_axes option[value='"+h+"']");i.data("delete",0);var j=a("#assignfeedback_editpdfplus_widget_admin_button_delaxis");j.removeClass("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(b.exception)}}),a("#toolRefesh").on("click",function(){r.prototype.refreshPrevisu()}),w(),v()}.bind(this)).fail(b.exception)}.bind(this)).fail(b.exception)};return r.prototype.openDivAddTool=function(){a("#message_edit_tool").hide(),a("#editpdlplus_tool_item").html(""),a(".btn-primary").addClass("btn-default"),a(".editpdlplus_tool").removeClass("btn-primary");var c=a("#editpdlplus_axes option:selected").val(),f={axisid:c};d.loadFragment("assignfeedback_editpdfplus","tooladd",n,f).done(function(c,d){x(a("#editpdlplus_tool_item"),c,d).done(function(){a("#canevas").hide(),"clone"===p?(a("#typetool").val(o.typetool),a("#color").val(o.color),a("#libelle").val(o.libelle),a("#cartridgecolor").val(o.catridgecolor),a("#texts").val(o.texts),a("#button").val(o.button),a("#enabled").val(o.enabled),a("#reply").val(o.reply),a("#order").val(o.order),o=new Object,p=null):(o=new Object,a("#typetool").on("change",function(){o.typetool=a("#typetool").val();var b=u(o.typetool);o.color=b.color,o.catridgecolor=b.cartridge_color,a("#color").val(o.color),a("#cartridgecolor").val(o.catridgecolor)}),a("#typetool").change()),a("#toolFormSubmit").on("click",function(){if(""===a("#button").val())a("#message_edit_tool").show(),a("#message_edit_tool").html(r.messageaddlibelleko),a("#message_edit_tool").addClass("alert-warning"),a("#message_edit_tool").removeClass("alert-danger"),a("#message_edit_tool").removeClass("alert-success");else{var c="";a("input[name^='text[']").each(function(){a(this).val()&&a(this).val().length>0&&(c+='"'+a(this).val().replace(/"/g,"")+'",')}),c.length>0&&a("#texts").val(c.substring(0,c.length-1));var d=a("#assignfeedback_editpdfplus_edit_tool"),f=d.serialize();e.call([{methodname:"assignfeedback_editpdfplus_submit_tool_add_form",args:{jsonformdata:JSON.stringify(f)}}])[0].done(function(b){if(""===b[0].message){a("#message_edit_tool").show(),a("#message_edit_tool").html(r.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).html("");for(var c=0;c<b.length;c++){var d="btn-default";1!==b[c].enable&&(d=""),b[c].toolid===b[c].selecttool&&(d="btn-primary");var e="";4!==b[c].typetool&&1!==b[c].typetool||(e="text-decoration: underline;");var f=b[c].button;4!==b[c].typetool&&5!==b[c].typetool||(f="| "+f,4===b[c].typetool&&(f+=" |"));var g="<button class='btn "+d+" editpdlplus_tool' id='editpdlplus_tool_"+b[c].toolid+"' style='"+e+"' value='"+b[c].toolid+"' data-enable='"+b[c].enable+"'>"+f+"</button>";a("#editpdlplus_toolbar_"+b[0].axeid).append(g)}a(".editpdlplus_tool").on("click",y),a("#toolworkspace").html("");var h=b[0].axeid,i=a("#editpdlplus_axes option[value='"+h+"']");i.data("delete",1);var j=a("#assignfeedback_editpdfplus_widget_admin_button_delaxis");j.addClass("disabled")}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(b.exception)}})}.bind(this)).fail(b.exception)}.bind(this)).fail(b.exception)},r});
\ No newline at end of file
......@@ -154,6 +154,65 @@ define(['jquery'/*, 'core/yui'*/, 'core/notification', 'core/templates', 'core/f
}
}
};
var initToolDisplay = function () {
var typetool = parseInt($("#typetool").val());
var typetoolEntity = getTypeTool(typetool);
var confCartridge = false;
var confCartridgeColor = false;
if (typetoolEntity.configurable_cartridge && parseInt(typetoolEntity.configurable_cartridge) === 0) {
$("#libelle").hide();
$("label[for='libelle']").hide();
confCartridge = true;
} else {
$("#libelle").show();
$("label[for='libelle']").show();
}
if (typetoolEntity.configurable_cartridge_color && parseInt(typetoolEntity.configurable_cartridge_color) === 0) {
$("#cartridgecolor").hide();
$("label[for='cartridgecolor']").hide();
confCartridgeColor = true;
} else {
$("#cartridgecolor").show();
$("label[for='cartridgecolor']").show();
}
if (confCartridge && confCartridgeColor) {
$("#collapse3").parent().hide();
} else {
$("#collapse3").parent().show();
}
var confAnnotColor = false,
confAnnotTexts = false,
confAnnotReply = false;
if (typetoolEntity.configurable_color && parseInt(typetoolEntity.configurable_color) === 0) {
$("#color").hide();
$("label[for='color']").hide();
confAnnotColor = true;
} else {
$("#color").show();
$("label[for='color']").show();
}
if (typetoolEntity.configurable_texts && parseInt(typetoolEntity.configurable_texts) === 0) {
$(".textform").hide();
$("label[for='texts']").hide();
confAnnotTexts = true;
} else {
$(".textform").show();
$("label[for='texts']").show();
}
if (typetoolEntity.configurable_question && parseInt(typetoolEntity.configurable_question) === 0) {
$("#reply").hide();
$("label[for='reply']").hide();
confAnnotReply = true;
} else {
$("#reply").show();
$("label[for='reply']").show();
}
if (confAnnotColor && confAnnotReply && confAnnotTexts) {
$("#collapse4").parent().hide();
} else {
$("#collapse4").parent().show();
}
};
//
var initCanevas = function () {
$('#canevas').html("");
......@@ -490,6 +549,8 @@ define(['jquery'/*, 'core/yui'*/, 'core/notification', 'core/templates', 'core/f
});
//maj affichage previsu
initCanevas();
//maj tool worspkace
initToolDisplay();
}.bind(this)).fail(notification.exception);
//templates.appendNodeContents('#editpdlplus_tool_item', html, js).done(function () {
//alert("jdikdi");
......
......@@ -46,7 +46,7 @@ class backup_assignfeedback_editpdfplus_subplugin extends backup_subplugin {
$subpluginelementfiles = new backup_nested_element('feedback_editpdfplus_files', null, array('gradeid'));
$subpluginelementannotations = new backup_nested_element('feedback_editpdfplus_annotations');
$subpluginelementannotation = new backup_nested_element('feedback_editpdfplus_annotation', null, array('gradeid', 'pageno', 'type', 'x', 'y', 'endx', 'endy', 'colour', 'path', 'draft'));
// Connect XML elements into the tree.
$subplugin->add_child($subpluginwrapper);
$subpluginelementannotations->add_child($subpluginelementannotation);
......@@ -64,5 +64,5 @@ class backup_assignfeedback_editpdfplus_subplugin extends backup_subplugin {
$subpluginelementfiles->annotate_files('assignfeedback_editpdfplus', 'stamps', 'gradeid');
return $subplugin;
}
}
......@@ -51,7 +51,7 @@ class restore_assignfeedback_editpdfplus_subplugin extends restore_subplugin {
// Now we have the list of comments and annotations per grade.
$elename = $this->get_namefor('feedback_editpdfplus_annotation');
$elepath = $this->get_pathfor('/feedback_editpdfplus_annotations/feedback_editpdfplus_annotation');
$elepath = $this->get_pathfor('/feedback_editpdfplus_annotations/feedback_editpdfplus_annotation');
$paths[] = new restore_path_element($elename, $elepath);
return $paths;
......@@ -64,11 +64,11 @@ class restore_assignfeedback_editpdfplus_subplugin extends restore_subplugin {
public function process_assignfeedback_editpdfplus_files($data) {
$data = (object)$data;
// In this case the id is the old gradeid which will be mapped.
$this->add_related_files('assignfeedback_editpdfplus',
\assignfeedback_editpdfplus\document_services::FINAL_PDF_FILEAREA, 'grade', null, $data->gradeid);
$this->add_related_files('assignfeedback_editpdfplus',
\assignfeedback_editpdfplus\document_services::PAGE_IMAGE_READONLY_FILEAREA, 'grade', null, $data->gradeid);
// In this case the id is the old gradeid which will be mapped.
$this->add_related_files('assignfeedback_editpdfplus',
\assignfeedback_editpdfplus\document_services::FINAL_PDF_FILEAREA, 'grade', null, $data->gradeid);
$this->add_related_files('assignfeedback_editpdfplus',
\assignfeedback_editpdfplus\document_services::PAGE_IMAGE_READONLY_FILEAREA, 'grade', null, $data->gradeid);
$this->add_related_files('assignfeedback_editpdfplus', 'stamps', 'grade', null, $data->gradeid);
}
......@@ -79,13 +79,13 @@ class restore_assignfeedback_editpdfplus_subplugin extends restore_subplugin {
public function process_assignfeedback_editpdfplus_feedback_editpdfplus_annotation($data) {
global $DB;
$data = (object)$data;
$oldgradeid = $data->gradeid;
// The mapping is set in the restore for the core assign activity
// when a grade node is processed.
$data->gradeid = $this->get_mappingid('grade', $data->gradeid);
$data = (object)$data;
$oldgradeid = $data->gradeid;
// The mapping is set in the restore for the core assign activity
// when a grade node is processed.
$data->gradeid = $this->get_mappingid('grade', $data->gradeid);
$DB->insert_record('assignfeedback_editpp_annot', $data);
$DB->insert_record('assignfeedback_editpp_annot', $data);
}
......
......@@ -56,6 +56,21 @@ class type_tool {
/** @var type */
public $configurable = 1;
/** @var type */
public $configurable_cartridge = 1;
/** @var type */
public $configurable_cartridge_color = 1;
/** @var type */
public $configurable_color = 1;
/** @var type */
public $configurable_texts = 1;
/** @var type */
public $configurable_question = 1;
/**
* Convert a compatible stdClass into an instance of this class.
* @param stdClass $record
......
......@@ -26,27 +26,6 @@
defined('MOODLE_INTERNAL') || die();
$capabilities = array(
/*'mod/assignfeedback_editpdfplus:use' => array(
'captype' => 'write',
'contextlevel' => CONTEXT_MODULE,
'archetypes' => array(
)
),*/
/*'mod/assignfeedback_editpdfplus:notify' => array(
'captype' => 'read',
'contextlevel' => CONTEXT_MODULE,
'archetypes' => array(
'teacher' => CAP_ALLOW,
'editingteacher' => CAP_ALLOW
)
),*/
/*'mod/assignfeedback_editpdfplus:managetools' => array(
'captype' => 'write',
'contextlevel' => CONTEXT_MODULE,
'archetypes' => array(
'editingteacher' => CAP_ALLOW
)
),*/
'assignfeedback/editpdfplus:use' => array(
'captype' => 'write',
'contextlevel' => CONTEXT_MODULE,
......
......@@ -108,7 +108,7 @@ function xmldb_assignfeedback_editpdfplus_upgrade($oldversion) {
// Editpdf savepoint reached.
upgrade_plugin_savepoint(true, 2017071202, 'assignfeedback', 'editpdfplus');
}
if ($oldversion < 2017081306) {
$sql = "UPDATE {assignfeedback_editpp_typet}
SET color = :htmlcolor
......@@ -150,6 +150,67 @@ function xmldb_assignfeedback_editpdfplus_upgrade($oldversion) {
];
// Execute DB update for assign instances.
$DB->execute($sql, $params);
// Editpdf savepoint reached.
upgrade_plugin_savepoint(true, 2017081306, 'assignfeedback', 'editpdfplus');
}
if ($oldversion < 2017081601) {
$table = new xmldb_table('assignfeedback_editpp_typet');
$field = new xmldb_field('configurable_cartridge', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, 1);
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
$field = new xmldb_field('configurable_cartridge_color', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, 1);
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
$field = new xmldb_field('configurable_color', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, 1);
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
$field = new xmldb_field('configurable_texts', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, 1);
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
$field = new xmldb_field('configurable_question', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, 1);
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
$sql = "UPDATE {assignfeedback_editpp_typet}
SET configurable_cartridge = 0,
configurable_cartridge_color = 0,
configurable_texts = 0,
configurable_question = 0
WHERE id = 3";
// Update query params.
$params = [];
// Execute DB update for assign instances.
$DB->execute($sql, $params);
$sql = "UPDATE {assignfeedback_editpp_typet}
SET configurable_cartridge_color = 0,
configurable_color = 0
WHERE id = 4";
// Execute DB update for assign instances.
$DB->execute($sql, []);
$sql = "UPDATE {assignfeedback_editpp_typet}
SET configurable_color = 0,
configurable_texts = 0
WHERE id = 7";
// Execute DB update for assign instances.
$DB->execute($sql, []);
$sql = "UPDATE {assignfeedback_editpp_typet}
SET configurable_color = 0
WHERE id = 6";
// Execute DB update for assign instances.
$DB->execute($sql, []);
// Editpdf savepoint reached.
upgrade_plugin_savepoint(true, 2017081601, 'assignfeedback', 'editpdfplus');
}
return true;
......
......@@ -24,7 +24,7 @@
defined('MOODLE_INTERNAL') || die();
$plugin->version = 2017081306;
$plugin->version = 2017081601;
$plugin->requires = 2017050500; // Requires this Moodle version.
$plugin->dependencies = array(
'assignfeedback_editpdf' => 2017050500
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment