Gitlab CSE Unil

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

déplacement d'un outil par drag and drop

parent fef32ab6
define(["jquery","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){var o=null,p=null,q=null,r=null,s=null,t=function(a,b){o=a,this.initTypeTool(b),this.init()};t.messageDelOk="",t.messageDelKo="",t.messageko="",t.messageaddok="",t.messageaddlibelleko="",t.messageEditOk="",t.prototype.selectTool=null;var u=function(){f.get_string("admindeltool_messageok","assignfeedback_editpdfplus").done(function(a){t.messageDelOk=a}).fail(b.exception),f.get_string("admindeltool_messageko","assignfeedback_editpdfplus").done(function(a){t.messageDelKo=a}).fail(b.exception),f.get_string("adminaddtool_messageok","assignfeedback_editpdfplus").done(function(a){t.messageaddok=a}).fail(b.exception),f.get_string("admin_messageko","assignfeedback_editpdfplus").done(function(a){t.messageko=a}).fail(b.exception),f.get_string("adminedittool_messageok","assignfeedback_editpdfplus").done(function(a){t.messageEditOk=a}).fail(b.exception),f.get_string("adminaddtool_messagelibelleko","assignfeedback_editpdfplus").done(function(a){t.messageaddlibelleko=a}).fail(b.exception)};t.prototype.initTypeTool=function(a){var b=JSON.parse(a);r=[];for(var c=0;c<b.length;c++){var d=new h;d.initAdmin(b[c]),r[c]=d}},t.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").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"))}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",z),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),u()},t.prototype.initToolUI=function(){a(this.selectTool).removeClass("btn-default"),a(this.selectTool).addClass("btn-primary")},t.prototype.refreshPrevisu=function(){p.axis=a("#toolaxis").val(),p.typetool=a("#typetool").val(),p.colors=a("#color").val(),p.cartridge=a("#libelle").val(),p.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)),p.texts=a("#texts").val(),p.label=a("#button").val(),p.enabled=a("#enabled").val(),p.reply=0,a("#reply").is(":checked")&&(p.reply=1),p.orderTool=a("#order").val(),x(),w()};var v=function(a){for(var b=0;b<r.length;b++)if(r[b].id==a)return r[b]},w=function(){var b=parseInt(a("#typetool").val()),c=v(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()},x=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 i;else if(3===b)s=new j;else if(4===b){s=new k;var c=new k}else 5===b?s=new m:6===b?s=new n:7===b&&(s=new l);if(s){var d=v(b);p.type=d,p.reply=0,a("#reply").is(":checked")&&(p.reply=1),s.initAdminDemo(p),s.draw(a("#canevas")),c&&(c.initChildAdminDemo(s),c.draw(a("#canevas")))}};t.prototype.openDivAddAxis=function(){var e=a("#editpdlplus_axes").val();e&&""!==e?(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 > .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={};d.loadFragment("assignfeedback_editpdfplus","axisadd",o,f).done(function(a,b){c.appendNodeContents("#assignfeedback_editpdfplus_widget_admin_div_addaxis > .panel-body",a,b)}.bind(this)).fail(b.exception)},t.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",o,f).done(function(a,b){c.appendNodeContents("#assignfeedback_editpdfplus_widget_admin_div_editaxis > .panel-body",a,b)}.bind(this)).fail(b.exception)},t.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",o,g).done(function(a,b){c.appendNodeContents("#assignfeedback_editpdfplus_widget_admin_div_delaxis > .panel-body",a,b)}.bind(this)).fail(b.exception)}};var y=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()};t.prototype.importAxis=function(){var c=a(this).data("axis");if(c&&parseInt(c)>0){a("#assignfeedback_editpdfplus_import_axis > div > input[name^='axeid']").val(c);var d=a("#assignfeedback_editpdfplus_import_axis"),f=d.serialize()+"&courseid="+a("#courseid").val();e.call([{methodname:"assignfeedback_editpdfplus_submit_axis_import_form",args:{jsonformdata:JSON.stringify(f)}}])[0].done(function(b){if(""===b[0].message){a("#message_import_axis").show(),a("#message_import_axis").html(t.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;'></div>";a("#editpdlplus_toolbars").append(c);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.addClass("disabled"),a("#editpdlplus_tool_item").html(""),b[0].toolid&&b[0].toolid>0)for(var h=0;h<b.length;h++){var i=new g;i.initAdmin(b[h]);var j=i.getButton(b[h].selecttool);a("#editpdlplus_toolbar_"+b[0].axeid).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.removeClass("disabled")}a(".editpdlplus_tool").on("click",z),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(b.exception)}};var z=function(){var c=a(this).val();a(".editpdlplus_tool").each(function(){a(this).removeClass("btn-primary"),a(this).removeClass("btn-default"),a(this).css("background-image",""),a(this).css("background-color","");var b=a(this).data("enable");1===b&&a(this).val()!==c?a(this).addClass("btn-default"):a(this).val()!==c&&(a(this).css("background-image","none"),a(this).css("background-color","#CCCCCC"))}),a(this).addClass("btn-primary"),p&&p.id===c||a("#message_edit_tool").hide(),a("#editpdlplus_tool_item").html("");var f={toolid:c};d.loadFragment("assignfeedback_editpdfplus","tooledit",o,f).done(function(d,f){y(a("#editpdlplus_tool_item"),d,f).done(function(){p=new g,p.id=c,p.axis=a("#toolaxis").val(),p.typetool=a("#typetool").val();var d=v(p.typetool);p.type=d;var f=a("#realcolor").val();f.length>0?p.colors=a("#color").val():(a("#color").val(d.color),p.colors=null),p.cartridge=a("#libelle").val(),a("#realcartridgecolor").val().length>0?p.cartridgeColor=a("#cartridgecolor").val():(a("#cartridgecolor").val(d.cartridge_color),p.cartridgeColor=null),p.texts=a("#texts").val(),p.label=a("#button").val(),p.enabled=a("#enabled").val(),p.reply=a("#reply").val(),p.orderTool=a("#order").val(),a("#typetool").on("change",function(){p.typetool=a("#typetool").val();var b=v(p.typetool);p.type=b,p.colors=b.get_color(),p.cartridgeColor=b.get_color_cartridge(),a("#color").val(p.colors),a("#cartridgecolor").val(p.cartridgeColor),w(),x()}),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(t.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).html("");for(var c=0;c<b.length;c++){var d=new g;d.initAdmin(b[c]);var e=d.getButton(b[c].selecttool);a("#editpdlplus_toolbar_"+b[0].axeid).append(e)}a(".editpdlplus_tool").on("click",z);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(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(){q="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(t.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=new g;d.initAdmin(b[c]);var e=d.getButton(b[c].selecttool);a("#editpdlplus_toolbar_"+b[0].axeid).append(e)}a(".editpdlplus_tool").on("click",z)}else{var f=b[0].axeid,h=a("#editpdlplus_axes option[value='"+f+"']");h.data("delete",0);var i=a("#assignfeedback_editpdfplus_widget_admin_button_delaxis");i.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(){t.prototype.refreshPrevisu()}),x(),w()}.bind(this)).fail(b.exception)}.bind(this)).fail(b.exception)};return t.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",o,f).done(function(c,d){y(a("#editpdlplus_tool_item"),c,d).done(function(){a("#canevas").hide(),"clone"===q?(a("#toolaxis").val(p.axis),a("#typetool").val(p.typetool),a("#color").val(p.colors),a("#libelle").val(p.cartridge),a("#cartridgecolor").val(p.cartridgeColor),a("#texts").val(p.texts),a("#button").val(p.label),a("#enabled").val(p.enabled),a("#reply").val(p.reply),a("#order").val(p.orderTool),p=new g,q=null):(p=new g,a("#typetool").on("change",function(){p=new g,p.axis=a("#toolaxis").val(),p.typetool=a("#typetool").val();var b=v(p.typetool);p.type=b,p.colors=b.get_color(),p.cartridgeColor=b.get_color_cartridge(),a("#color").val(p.colors),a("#cartridgecolor").val(p.cartridgeColor),w()}),a("#typetool").change()),a("#toolFormSubmit").on("click",function(){if(""===a("#button").val())a("#message_edit_tool").show(),a("#message_edit_tool").html(t.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(t.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=new g;d.initAdmin(b[c]);var e=d.getButton(b[c].selecttool);a("#editpdlplus_toolbar_"+b[0].axeid).append(e)}a(".editpdlplus_tool").on("click",z),a("#toolworkspace").html("");var f=b[0].axeid,h=a("#editpdlplus_axes option[value='"+f+"']");h.data("delete",1);var i=a("#assignfeedback_editpdfplus_widget_admin_button_delaxis");i.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)},t});
\ No newline at end of file
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").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"))}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).removeClass("btn-default"),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()+"&courseid="+a("#courseid").val();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 > .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={};e.loadFragment("assignfeedback_editpdfplus","axisadd",p,f).done(function(a,b){d.appendNodeContents("#assignfeedback_editpdfplus_widget_admin_div_addaxis > .panel-body",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 > .panel-body").html(""),a("#assignfeedback_editpdfplus_widget_admin_toolheader").hide(),a("#assignfeedback_editpdfplus_widget_admin_toolworkspace").hide(),a("#editpdlplus_axes").prop("disabled","disabled");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 > .panel-body",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 > .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};e.loadFragment("assignfeedback_editpdfplus","axisdel",p,g).done(function(a,b){d.appendNodeContents("#assignfeedback_editpdfplus_widget_admin_div_delaxis > .panel-body",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()+"&courseid="+a("#courseid").val();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.addClass("disabled"),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.removeClass("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).removeClass("btn-default"),a(this).css("background-image",""),a(this).css("background-color","");var c=a(this).data("enable");1===c&&a(this).val()!==b?a(this).addClass("btn-default"):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().length>0?q.cartridgeColor=a("#cartridgecolor").val():(a("#cartridgecolor").val(d.cartridge_color),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).hasClass("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.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(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(".btn-primary").addClass("btn-default"),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(b,d){A(a("#editpdlplus_tool_item"),b,d).done(function(){a("#canevas").hide(),"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.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(c.exception)}})}.bind(this)).fail(c.exception)}.bind(this)).fail(c.exception)},u});
\ No newline at end of file
define(["./global"],function(a){function b(){return this._instanceID=d(),this}var c=0,d=function(){return++c};return b.getInstanceCount=function(){return c},b.prototype.getInstanceID=function(){return this._instanceID},b.id=-1,b.axis=-1,b.typetool=-1,b.type=null,b.colors="",b.cartridge="",b.cartridgeColor="",b.texts="",b.label="",b.reply=!0,b.enabled=!0,b.orderTool=1e3,b.prototype.init=function(a){this.id=parseInt(a.id,10)||0,this.axis=parseInt(a.axis,10)||0,this.type=a.type,this.colors=a.colors,this.cartridge=a.cartridge,this.cartridgeColor=a.cartridgeColor,this.texts=a.texts,this.label=a.label,this.reply=a.reply,this.enabled=a.enabled,this.orderTool=a.orderTool},b.prototype.initAdmin=function(a){this.id=parseInt(a.toolid,10)||0,this.axis=parseInt(a.axis,10)||0,this.typetool=a.typetool,this.label=a.button,this.enabled=a.enable,this.orderTool=a.orderTool},b.prototype.getToolTypeLabel=function(){return this.type.label},b.prototype.getToolTypeCartX=function(){return this.type.cartridgeX},b.prototype.getToolTypeCartY=function(){return this.type.cartridgeY},b.prototype.get_color=function(){var b=a.ANNOTATIONCOLOUR[this.colors];return b?(b=b.replace("rgb","rgba"),b=b.replace(")",",0.5)")):b=this.colors,b&&""!==b?b:this.type.get_color()},b.prototype.get_color_cartridge=function(){var b=a.ANNOTATIONCOLOUR[this.cartridgeColor];return b?(b=b.replace("rgb","rgba"),b=b.replace(")",",0.5)")):b=this.cartridgeColor,b&&""!==b?b:this.type.get_color_cartridge()},b.prototype.getButton=function(a){var b="btn-default",c="";1!==this.enabled&&(b="",c="background-image:none;background-color:#CCCCCC;"),this.id===a&&(b="btn-primary"),4!==this.typetool&&1!==this.typetool||(c+="text-decoration: underline;");var d=this.label;4!==this.typetool&&5!==this.typetool||(d="| "+d,4===this.typetool&&(d+=" |"));var e="<button class='btn "+b+" editpdlplus_tool' id='editpdlplus_tool_"+this.id+"' style='"+c+"' value='"+this.id+"' data-enable='"+this.enabled+"'>"+d+"</button>";return e},b});
\ No newline at end of file
define(["./global"],function(a){function b(){return this._instanceID=d(),this}var c=0,d=function(){return++c};return b.getInstanceCount=function(){return c},b.prototype.getInstanceID=function(){return this._instanceID},b.id=-1,b.axis=-1,b.typetool=-1,b.type=null,b.colors="",b.cartridge="",b.cartridgeColor="",b.texts="",b.label="",b.reply=!0,b.enabled=!0,b.orderTool=1e3,b.prototype.init=function(a){this.id=parseInt(a.id,10)||0,this.axis=parseInt(a.axis,10)||0,this.type=a.type,this.colors=a.colors,this.cartridge=a.cartridge,this.cartridgeColor=a.cartridgeColor,this.texts=a.texts,this.label=a.label,this.reply=a.reply,this.enabled=a.enabled,this.orderTool=a.orderTool},b.prototype.initAdmin=function(a){this.id=parseInt(a.toolid,10)||0,this.axis=parseInt(a.axis,10)||0,this.typetool=a.typetool,this.label=a.button,this.enabled=a.enable,this.orderTool=a.orderTool},b.prototype.getToolTypeLabel=function(){return this.type.label},b.prototype.getToolTypeCartX=function(){return this.type.cartridgeX},b.prototype.getToolTypeCartY=function(){return this.type.cartridgeY},b.prototype.get_color=function(){var b=a.ANNOTATIONCOLOUR[this.colors];return b?(b=b.replace("rgb","rgba"),b=b.replace(")",",0.5)")):b=this.colors,b&&""!==b?b:this.type.get_color()},b.prototype.get_color_cartridge=function(){var b=a.ANNOTATIONCOLOUR[this.cartridgeColor];return b?(b=b.replace("rgb","rgba"),b=b.replace(")",",0.5)")):b=this.cartridgeColor,b&&""!==b?b:this.type.get_color_cartridge()},b.prototype.getButton=function(a){var b="btn-default",c="";1!==this.enabled&&(b="",c="background-image:none;background-color:#CCCCCC;"),this.id===a&&(b="btn-primary"),4!==this.typetool&&1!==this.typetool||(c+="text-decoration: underline;");var d=this.label;4!==this.typetool&&5!==this.typetool||(d="| "+d,4===this.typetool&&(d+=" |"));var e="<button class='btn "+b+" editpdlplus_tool' id='editpdlplus_tool_"+this.id+"' style='"+c+"' value='"+this.id+"' data-enable='"+this.enabled+"'>"+d+"</button>";return e},b.prototype.getButtonSortable=function(a){return"<li style='float: left;display: block;'>"+this.getButton(a)+"</li>"},b});
\ No newline at end of file
......@@ -20,6 +20,7 @@
/**
* @module mod_assignfeedback_editpdfplus/admin_panel
* @param {Jquery} $
* @param {Jqueryui} $.ui
* @param {core/notification} notification
* @param {core/templates} templates
* @param {core/fragment} fragment
......@@ -34,13 +35,13 @@
* @param {assignfeedback_editpdfplus/annotationverticalline} AnnotationVerticalline
* @param {assignfeedback_editpdfplus/annotationstampcomment} AnnotationStampcomment
*/
define(['jquery', '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',
'assignfeedback_editpdfplus/annotationhighlightplus',
'assignfeedback_editpdfplus/annotationstampplus', 'assignfeedback_editpdfplus/annotationframe',
'assignfeedback_editpdfplus/annotationcommentplus', 'assignfeedback_editpdfplus/annotationverticalline',
'assignfeedback_editpdfplus/annotationstampcomment'],
function ($, notification, templates, fragment, ajax, str, Tool, ToolType,
function ($, jqui, notification, templates, fragment, ajax, str, Tool, ToolType,
AnnotationHighlightplus, AnnotationStampplus, AnnotationFrame,
AnnotationCommentplus, AnnotationVerticalline, AnnotationStampcomment) {
......@@ -219,6 +220,49 @@ define(['jquery', 'core/notification', 'core/templates', 'core/fragment',
AdminPanel.prototype.initToolUI = function () {
$(this.selectTool).removeClass("btn-default");
$(this.selectTool).addClass("btn-primary");
initSortableToolBar();
};
var initSortableToolBar = function () {
$(".sortable").sortable({
placeholder: "alert-warning",
handle: 'button',
cancel: '',
stop: function (event, uiElement) {
var prevButtonId = $(uiElement.item).prev().find("button").val();
var nextButtonId = $(uiElement.item).next().find("button").val();
var currentButtonId = $(uiElement.item).find("button").val();
$("input[name^='previoustoolid']").val(prevButtonId);
$("input[name^='toolid']").val(currentButtonId);
$("input[name^='nexttoolid']").val(nextButtonId);
var form = $('#assignfeedback_editpdfplus_order_tool');
var data = form.serialize() + "&courseid=" + $("#courseid").val();
ajax.call([
{
methodname: 'assignfeedback_editpdfplus_submit_tool_order_form',
args: {jsonformdata: JSON.stringify(data)}
}
])[0].done(function (retour) {
if (retour.message === "ok") {
//mise à jour du message
$("#message_order_tool").show();
$("#message_order_tool").html(AdminPanel.messageEditOk);
$("#message_order_tool").addClass("alert-success");
$("#message_order_tool").removeClass("alert-danger");
$("#message_order_tool").removeClass("alert-warning");
$("#message_order_tool").fadeOut(5000);
} else {
$("#message_order_tool").show();
$("#message_order_tool").html(AdminPanel.messageko);
$("#message_order_tool").addClass("alert-danger");
$("#message_order_tool").removeClass("alert-success");
$("#message_order_tool").fadeOut(5000);
}
}).fail(notification.exception);
}
});
$(".sortable").disableSelection();
};
/**
......@@ -486,8 +530,11 @@ define(['jquery', 'core/notification', 'core/templates', 'core/fragment',
//maj axis
var divAxis = "<div id='editpdlplus_toolbar_"
+ toolbar[0].axeid
+ "' class='btn-group toolbar' style='display: none;'></div>";
+ "' class='btn-group toolbar' style='display: none;'>"
+ "<ul class='sortable' style='list-style-type: none;margin: 0;padding: 0;width: 100%;'></ul>"
+ "</div>";
$('#editpdlplus_toolbars').append(divAxis);
initSortableToolBar();
var option = new Option(toolbar[0].axelabel, toolbar[0].axeid, true, true);
$("#editpdlplus_axes").append(option);
var axeOption = $("#editpdlplus_axes option[value='" + toolbar[0].axeid + "']");
......@@ -500,8 +547,8 @@ define(['jquery', 'core/notification', 'core/templates', 'core/fragment',
for (var i = 0; i < toolbar.length; i++) {
var toolTmp = new Tool();
toolTmp.initAdmin(toolbar[i]);
var buttonTmp = toolTmp.getButton(toolbar[i].selecttool);
$("#editpdlplus_toolbar_" + toolbar[0].axeid).append(buttonTmp);
var buttonTmp = toolTmp.getButtonSortable(toolbar[i].selecttool);
$("#editpdlplus_toolbar_" + toolbar[0].axeid + " > ul").append(buttonTmp);
}
} else {
var axeid = toolbar[0].axeid;
......@@ -621,12 +668,12 @@ define(['jquery', 'core/notification', 'core/templates', 'core/fragment',
$("#message_edit_tool").removeClass("alert-warning");
//mise à jour bar d'outils
$("#editpdlplus_tool_" + toolbar[0].selecttool).remove();
$("#editpdlplus_toolbar_" + toolbar[0].axeid).html("");
$("#editpdlplus_toolbar_" + toolbar[0].axeid + " > ul").html("");
for (var i = 0; i < toolbar.length; i++) {
var toolTmp = new Tool();
toolTmp.initAdmin(toolbar[i]);
var buttonTmp = toolTmp.getButton(toolbar[i].selecttool);
$("#editpdlplus_toolbar_" + toolbar[0].axeid).append(buttonTmp);
var buttonTmp = toolTmp.getButtonSortable(toolbar[i].selecttool);
$("#editpdlplus_toolbar_" + toolbar[0].axeid + " > ul").append(buttonTmp);
}
$(".editpdlplus_tool").on("click", refreshToolView);
var oldaxeid = $("#axisid").val();
......@@ -678,13 +725,13 @@ define(['jquery', 'core/notification', 'core/templates', 'core/fragment',
$("#message_edit_tool").removeClass("alert-danger");
$("#message_edit_tool").removeClass("alert-warning");
//mise à jour bar d'outils
$("#editpdlplus_toolbar_" + toolbar[0].axeid).html("");
$("#editpdlplus_toolbar_" + toolbar[0].axeid + " > ul").html("");
if (parseInt(toolbar[0].toolid) > 0) {
for (var i = 0; i < toolbar.length; i++) {
var toolTmp = new Tool();
toolTmp.initAdmin(toolbar[i]);
var buttonTmp = toolTmp.getButton(toolbar[i].selecttool);
$("#editpdlplus_toolbar_" + toolbar[0].axeid).append(buttonTmp);
var bT = toolTmp.getButtonSortable(toolbar[i].selecttool);
$("#editpdlplus_toolbar_" + toolbar[0].axeid + " > ul").append(bT);
}
$(".editpdlplus_tool").on("click", refreshToolView);
} else {
......@@ -793,12 +840,12 @@ define(['jquery', 'core/notification', 'core/templates', 'core/fragment',
$("#message_edit_tool").removeClass("alert-danger");
$("#message_edit_tool").removeClass("alert-warning");
//mise à jour bar d'outils
$("#editpdlplus_toolbar_" + toolbar[0].axeid).html("");
$("#editpdlplus_toolbar_" + toolbar[0].axeid + " > ul").html("");
for (var i = 0; i < toolbar.length; i++) {
var toolTmp = new Tool();
toolTmp.initAdmin(toolbar[i]);
var buttonTmp = toolTmp.getButton(toolbar[i].selecttool);
$("#editpdlplus_toolbar_" + toolbar[0].axeid).append(buttonTmp);
var btnTmp = toolTmp.getButtonSortable(toolbar[i].selecttool);
$("#editpdlplus_toolbar_" + toolbar[0].axeid + " > ul").append(btnTmp);
}
$(".editpdlplus_tool").on("click", refreshToolView);
$('#toolworkspace').html("");
......
......@@ -267,6 +267,14 @@ define(['./global'],
+ "</button>";
return buttonTmp;
};
/**
* Get the html code for design the tool's button into the toolbar
* @param {int} selectToolId
* @return {string} HTML code
*/
Tool.prototype.getButtonSortable = function (selectToolId) {
return "<li style='float: left;display: block;'>" + this.getButton(selectToolId) + "</li>";
};
return Tool;
});
\ No newline at end of file
......@@ -108,6 +108,34 @@ class admin_editor {
return null;
}
public static function edit_tool_order($data) {
global $DB;
$record = $DB->get_record('assignfeedback_editpp_tool', array('id' => $data->toolid), '*', MUST_EXIST);
$toolCurrent = new tool($record);
$previousorder = -1;
$toolPrevious = null;
$toolNext = null;
if ($data->previoustoolid) {
$record = $DB->get_record('assignfeedback_editpp_tool', array('id' => $data->previoustoolid), '*', MUST_EXIST);
$toolPrevious = new tool($record);
$previousorder = $toolPrevious->order_tool + 1;
} elseif ($data->nexttoolid) {
$record = $DB->get_record('assignfeedback_editpp_tool', array('id' => $data->nexttoolid), '*', MUST_EXIST);
$toolNext = new tool($record);
$previousorder = $toolNext->order_tool - 1;
}
if ($previousorder > -1 && ($toolPrevious || $toolNext )) {
if ($previousorder == 0) {
$previousorder = 1;
}
$toolCurrent->order_tool = $previousorder;
debugging($previousorder);
if ($DB->update_record('assignfeedback_editpp_tool', $toolCurrent)) {
admin_editor::reorder_tool($toolCurrent->axis, $data->toolid);
}
}
}
/**
* Order tools of a toolbar
* @global type $DB
......
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* This file contains the tool_form class for the assignfeedback_editpdfplus plugin
*
* @package assignfeedback_editpdfplus
* @copyright 2017 Université de Lausanne
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace assignfeedback_editpdfplus\form;
require_once("$CFG->libdir/formslib.php");
use moodleform;
/**
* Form to add and edit a tool
*
* @package assignfeedback_editpdfplus
* @copyright 2017 Université de Lausanne
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class tool_order_form extends moodleform {
protected function definition() {
$mform = $this->_form;
$mform->addElement('hidden', 'previoustoolid', 'previoustoolid'); // Add elements to your form
$mform->setType('previoustoolid', PARAM_INT); //Set type of element
$mform->addElement('hidden', 'toolid', ''); // Add elements to your form
$mform->setType('toolid', PARAM_INT); //Set type of element
$mform->addElement('hidden', 'nexttoolid', ''); // Add elements to your form
$mform->setType('nexttoolid', PARAM_INT); //Set type of element
}
//Custom validation should be added here
function validation($data, $files) {
return array();
}
}
......@@ -99,5 +99,16 @@ $functions = array(
'requiredcapability' => 'assignfeedback/editpdfplus:managetools',
'enabled' => 1,
'services' => array(MOODLE_OFFICIAL_MOBILE_SERVICE)
),
'assignfeedback_editpdfplus_submit_tool_order_form' => array(
'classname' => 'assignfeedback_editpdfplus_external',
'methodname' => 'submit_tool_order_form',
'classpath' => 'mod/assign/feedback/editpdfplus/externallib.php',
'description' => 'Order a tool',
'type' => 'write',
'ajax' => true,
'requiredcapability' => 'assignfeedback/editpdfplus:managetools',
'enabled' => 1,
'services' => array(MOODLE_OFFICIAL_MOBILE_SERVICE)
)
);
......@@ -551,4 +551,72 @@ class assignfeedback_editpdfplus_external extends external_api {
);
}
/**
* Returns description of method parameters
* @return external_function_parameters
*/
public static function submit_tool_order_form_parameters() {
return new external_function_parameters(
array(
'jsonformdata' => new external_value(PARAM_RAW, 'The data from the grading form, encoded as a json array')
)
);
}
/**
* Submit tool form for changing order
* @global $USER
* @global $PAGE
* @global $DB
* @param String $jsonformdata
* @return array
*/
public static function submit_tool_order_form($jsonformdata) {
global $USER, $PAGE, $DB;
$params = self::validate_parameters(self::submit_tool_order_form_parameters(), array(
'jsonformdata' => $jsonformdata
));
$serialiseddata = json_decode($params['jsonformdata']);
$data = array();
parse_str($serialiseddata, $data);
$warnings = array();
if (WS_SERVER) {
// Assume form submission if coming from WS.
$USER->ignoresesskey = true;
}
$course = $DB->get_record('course', array('id' => $data['courseid']), '*', MUST_EXIST);
$context = context_course::instance($course->id, MUST_EXIST);
$PAGE->set_context($context);
$customdata = (object) $data;
$sessionkey = sesskey();
if ($sessionkey == $customdata->sesskey && $customdata->toolid) {
admin_editor::edit_tool_order($customdata);
$warnings = array('message' => 'ok');
} else {
$warnings = array('message' => get_string('admin_messageko', 'assignfeedback_editpdfplus'));
}
return $warnings;
}
/**
* Form return structure
* @return \external_multiple_structure
*/
public static function submit_tool_order_form_returns() {
return new external_single_structure(
array(
'message' => new external_value(PARAM_TEXT, 'message', VALUE_OPTIONAL)
)
);
}
}
......@@ -29,6 +29,7 @@ use \assignfeedback_editpdfplus\widget_admin;
use \assignfeedback_editpdfplus\form\axis_form;
use \assignfeedback_editpdfplus\form\axis_import_form;
use \assignfeedback_editpdfplus\form\axis_del_form;
use \assignfeedback_editpdfplus\form\tool_order_form;
use \assignfeedback_editpdfplus\admin_editor;
class assign_feedback_editpdfplus_admin {
......@@ -58,8 +59,13 @@ class assign_feedback_editpdfplus_admin {
$axisimportform->id = "assignfeedback_editpdfplus_import_axis";
$axisimportform->title = "";
$axisimportform->action = "import";
$toolorderform = new tool_order_form(null, array('id' => $this->course->id), null, null, array('id' => "assignfeedback_editpdfplus_order_tool"));
$toolorderform->id = "assignfeedback_editpdfplus_order_tool";
$toolorderform->title = "";
$toolorderform->action = "order";
$widget = $this->get_widget();
$widget->axisimportform = $axisimportform;
$widget->toolorderform = $toolorderform;
$widget->courseid = $this->course->id;
$html .= $renderer->render_assignfeedback_editpdfplus_widget_admin($widget);
return $html;
......
......@@ -32,6 +32,15 @@
<div class="assignfeedback_editpdfplus_widget_admin">
<h5>{{# str }} adminsubtitle, assignfeedback_editpdfplus {{/ str }}</h5>
<!--ul id="sortable" style="list-style-type: none;margin: 0;padding: 0;overflow: hidden;">
<li style="float: left;display: block;text-decoration: none;"><button class="sortable">Item 1</button></li>
<li style="float: left;display: block;text-decoration: none;"><button class="sortable">Item 2</button></li>
<li style="float: left;display: block;text-decoration: none;"><button class="sortable">Item 3</button></li>
<li style="float: left;display: block;text-decoration: none;"><button class="sortable">Item 4</button></li>
<li style="float: left;display: block;text-decoration: none;"><button class="sortable">Item 5</button></li>
</ul-->
<div class="panel panel-default">
<div class="panel-heading">
<a data-toggle="collapse" href="#collapseadmin1" >{{# str }} adminaxisimporttitle, assignfeedback_editpdfplus {{/ str }}</a>
......@@ -77,6 +86,7 @@
</div>
<div class="panel-body">
<div id="message_import_axis" class="alert" style="display:none;"></div>
<div id="message_order_tool" class="alert" style="display:none;"></div>
<table>
<tr>
<td class='assignfeedback_editpdfplus_widget_admin_col1'>
......@@ -118,15 +128,20 @@