Gitlab CSE Unil

Commit 0591b597 authored by M. Chardon's avatar M. Chardon
Browse files

bug changement de page

parent a5372294
......@@ -6450,6 +6450,9 @@ EDITOR.prototype = {
}
annot.divcartridge = "";
}
if (annot.drawable) {
annot.drawable.erase();
}
}
for (i = 0; i < page.annotations.length; i++) {
......
......@@ -12,5 +12,5 @@ s+'" src="'+t+'"/></button>'),r.setAttribute("data-stamp",t),r.setStyle("backgro
(),this.drawable=n,n},this.delete_comment_later=function(){this.deleteme&&this.remove()},this.attach_events=function(t,n){t.on("blur",function(){this.rawtext=t.get("value"),this.width=parseInt(t.getStyle("width"),10),this.rawtext.replace(/^\s+|\s+$/g,"")===""&&(this.deleteme=!0,e.later(400,this,this.delete_comment_later)),this.editor.save_current_page(),this.editor.editingcomment=!1},this),n.setData("comment",this),t.on("keyup",function(){var e=t.get("scrollHeight"),n=parseInt(t.getStyle("height"),10);e===n+8&&(e-=8),t.setStyle("height",e+"px")}),t.on("gesturemovestart",function(e){t.setData("dragging",!0),t.setData("offsetx",e.clientX-t.getX()),t.setData("offsety",e.clientY-t.getY())}),t.on("gesturemoveend",function(){t.setData("dragging",!1),this.editor.save_current_page()},null,this),t.on("gesturemove",function(e){var n=e.clientX-t.getData("offsetx"),r=e.clientY-t.getData("offsety"),i,s,o,u,a;i=parseInt(t.getStyle("width"),10),s=parseInt(t.getStyle("height"),10),o=this.editor.get_canvas_coordinates(new M.assignfeedback_editpdfplus.point(n,r)),a=this.editor.get_canvas_bounds(!0),a.x=0,a.y=0,a.width-=i+42,a.height-=s+8,o.clip(a),this.x=o.x,this.y=o.y,u=this.editor.get_window_coordinates(o),t.ancestor().setX(u.x),t.ancestor().setY(u.y),this.drawable.store_position(t.ancestor(),u.x,u.y)},null,this),this.menu=new M.assignfeedback_editpdfplus.commentmenu({buttonNode:this.menulink,comment:this})},this.remove=function(){var e=0,t;t=this.editor.pages[this.editor.currentpage].comments;for(e=0;e<t.length;e++)if(t[e]===this){t.splice(e,1),this.drawable.erase(),this.editor.save_current_page();return}},this.remove_from_quicklist=function(e,t){e.preventDefault(),this.menu.hide(),this.editor.quicklist.remove(t)},this.set_from_quick_comment=function(e,t){e.preventDefault(),this.menu.hide(),this.rawtext=t.rawtext,this.width=t.width,this.colour=t.colour,this.editor.save_current_page(),this.editor.redraw()},this.add_to_quicklist=function(e){e.preventDefault(),this.menu.hide(),this.editor.quicklist.add(this)},this.draw_current_edit=function(t){var n=new M.assignfeedback_editpdfplus.drawable(this.editor),r,i;return i=new M.assignfeedback_editpdfplus.rect,i.bound([t.start,t.end]),r=this.editor.graphic.addShape({type:e.Rect,width:i.width,height:i.height,fill:{color:l[t.commentcolour]},x:i.x,y:i.y}),n.shapes.push(r),n},this.init_from_edit=function(e){var t=new M.assignfeedback_editpdfplus.rect;return t.bound([e.start,e.end]),t.width<100&&(t.width=100),this.gradeid=this.editor.get("gradeid"),this.pageno=this.editor.currentpage,this.x=t.x,this.y=t.y,this.width=t.width,this.colour=e.commentcolour,this.rawtext="",t.has_min_width()&&t.has_min_height()}};M.assignfeedback_editpdfplus=M.assignfeedback_editpdfplus||{},M.assignfeedback_editpdfplus.comment=X;var V=function(e,t,n,r){this.rawtext=t||"",this.id=e||0,this.width=n||100,this.colour=r||"yellow"};M.assignfeedback_editpdfplus=M.assignfeedback_editpdfplus||{},M.assignfeedback_editpdfplus.quickcomment=V;var $=function(t){this.editor=t,this.comments=[],this.add=function(t){var r=n,i;if(t.rawtext==="")return;i={method:"post",context:this,sync:!1,data:{sesskey:M.cfg.sesskey,action:"addtoquicklist",userid:this.editor.get("userid"),commenttext:t.rawtext,width:t.width,colour:t.colour,attemptnumber:this.editor.get("attemptnumber"),assignmentid:this.editor.get("assignmentid")},on:{success:function(t,n){var r,i;try{r=e.JSON.parse(n.responseText);if(r.error)return new M.core.ajaxException(r);i=new M.assignfeedback_editpdfplus.quickcomment(r.id,r.rawtext,r.width,r.colour),this.comments.push(i)}catch(s){return new M.core.exception(s)}},failure:function(e,t){return M.core.exception(t.responseText)}}},e.io(r,i)},this.remove=function(t){var r=n,i;if(!t)return;i={method:"post",context:this,sync:!1,data:{sesskey:M.cfg.sesskey,action:"removefromquicklist",userid:this.editor.get("userid"),commentid:t.id,attemptnumber:this.editor.get("attemptnumber"),assignmentid:this.editor.get("assignmentid")},on:{success:function(){var e;e=this.comments.indexOf(t),e>=0&&this.comments.splice(e,1)},failure:function(e,t){return M.core.exception(t.responseText)}}},e.io(r,i)},this.load=function(){var t=n,r;r={method:"get",context:this,sync:!1,data:{sesskey:M.cfg.sesskey,action:"loadquicklist",userid:this.editor.get("userid"),attemptnumber:this.editor.get("attemptnumber"),assignmentid:this.editor.get("assignmentid")},on:{success:function(t,n){var r;try{r=e.JSON.parse(n.responseText);if(r.error)return new M.core.ajaxException(r);e.each(r,function(e){var t=new M.assignfeedback_editpdfplus.quickcomment(e.id,e.rawtext,e.width,e.colour);this.comments.push(t)},this)}catch(i){return new M.core.exception(i)}},failure:function(e,t){return M.core.exception(t.responseText)}}},e.io(t,r)}};M.assignfeedback_editpdfplus=M.assignfeedback_editpdfplus||{},M.assignfeedback_editpdfplus.quickcommentlist=$;var J=function(){J.superclass.constructor.apply(this,arguments)};J.prototype={dialogue:null,panel:null,pagecount:0,currentpage:0,pages:[],loadingicon:null,pageimage:null,graphic:null,currentedit:new M.assignfeedback_editpdfplus.edit,currentdrawable:!1,drawables:[],drawablesannotations:[],currentcomment:null,currentannotation:null,lastanntationtool:"pen",quicklist:null,searchcommentswindow:null,currentstamp:null,stamps:[],editingcomment:!1,annotationsparent:[],initializer:function(){var t;t=e.one("#"+this.get("linkid")),t&&(t.on("click",this.link_handler,this),t.on("key",this.link_handler,"down:13",this),require(["mod_assign/grading_review_panel"],function(n){var r=new n,i=r.getReviewPanel("assignfeedback_editpdfplus");i&&(i=e.one(i),i.empty(),t.ancestor(".fitem").hide(),this.open_in_panel(i)),this.currentedit.start=!1,this.currentedit.end=!1,this.get("readonly")||(this.quicklist=new M.assignfeedback_editpdfplus.quickcommentlist(this))}.bind(this)))},refresh_button_state:function(){var e,t,n,r;e=this.get_dialogue_element(o.ANNOTATIONCOLOURBUTTON),n=M.util.image_url("colour_"+this.currentedit.annotationcolour,"assignfeedback_editpdfplus"
),e.one("img").setAttribute("src",n),this.currentedit.id?t=this.get_dialogue_element("#"+this.currentedit.id):t=this.get_dialogue_element(p[this.currentedit.tool]),t.addClass("assignfeedback_editpdfplus_selectedbutton"),t.setAttribute("aria-pressed","true"),r=this.get_dialogue_element(o.DRAWINGREGION),r.setAttribute("data-currenttool",this.currentedit.tool)},get_canvas_bounds:function(){var e=this.get_dialogue_element(o.DRAWINGCANVAS),t=e.getXY(),n=t[0],r=t[1],i=parseInt(e.getStyle("width"),10),s=parseInt(e.getStyle("height"),10);return new M.assignfeedback_editpdfplus.rect(n,r,i,s)},get_canvas_coordinates:function(e){var t=this.get_canvas_bounds(),n=new M.assignfeedback_editpdfplus.point(e.x-t.x,e.y-t.y);return t.x=t.y=0,n.clip(t),n},get_window_coordinates:function(e){var t=this.get_canvas_bounds(),n=new M.assignfeedback_editpdfplus.point(e.x+t.x,e.y+t.y);return n},open_in_panel:function(t){var n,r;this.panel=t,t.append(this.get("body")),t.addClass(s.DIALOGUE),this.loadingicon=this.get_dialogue_element(o.LOADINGICON),n=this.get_dialogue_element(o.DRAWINGCANVAS),this.graphic=new e.Graphic({render:n}),r=this.get_dialogue_element(o.DRAWINGREGION),r.on("scroll",this.move_canvas,this),this.get("readonly")||(n.on("gesturemovestart",this.edit_start,null,this),n.on("gesturemove",this.edit_move,null,this),n.on("gesturemoveend",this.edit_end,null,this),this.refresh_button_state()),this.load_all_pages()},link_handler:function(t){var n,r,i=!0;t.preventDefault(),this.dialogue||(this.dialogue=new M.core.dialogue({headerContent:this.get("header"),bodyContent:this.get("body"),footerContent:this.get("footer"),modal:!0,width:"840px",visible:!1,draggable:!0}),this.dialogue.get("boundingBox").addClass(s.DIALOGUE),this.loadingicon=this.get_dialogue_element(o.LOADINGICON),n=this.get_dialogue_element(o.DRAWINGCANVAS),this.graphic=new e.Graphic({render:n}),r=this.get_dialogue_element(o.DRAWINGREGION),r.on("scroll",this.move_canvas,this),this.get("readonly")||(n.on("gesturemovestart",this.edit_start,null,this),n.on("gesturemove",this.edit_move,null,this),n.on("gesturemoveend",this.edit_end,null,this),this.refresh_button_state()),this.load_all_pages(),n.on("windowresize",this.resize,this),i=!1),this.dialogue.centerDialogue(),this.dialogue.show(),this.dialogue.dd.on("drag:end",this.redraw,this),i&&this.resize()},load_all_pages:function(){var t=n,i,s,u;i={method:"get",context:this,sync:!1,data:{sesskey:M.cfg.sesskey,action:"loadallpages",userid:this.get("userid"),attemptnumber:this.get("attemptnumber"),assignmentid:this.get("assignmentid"),readonly:this.get("readonly")?1:0},on:{success:function(e,t){this.all_pages_loaded(t.responseText)},failure:function(e,t){return new M.core.exception(t.responseText)}}},e.io(t,i),this.pagecount<=0&&(s={method:"get",context:this,sync:!1,data:{sesskey:M.cfg.sesskey,action:"conversionstatus",userid:this.get("userid"),attemptnumber:this.get("attemptnumber"),assignmentid:this.get("assignmentid")},on:{success:function(t,n){u=0;if(this.pagecount===0){var i=this.get("pagetotal"),a=this.get_dialogue_element(o.PROGRESSBARCONTAINER),f=a.one(".bar");if(f){var l=n.response/i*100;f.setStyle("width",l+"%"),a.setAttribute("aria-valuenow",l)}e.later(1e3,this,function(){e.io(r,s)})}},failure:function(t,n){return u+=1,this.pagecount===0&&u<5&&e.later(1e3,this,function(){e.io(r,s)}),new M.core.exception(n.responseText)}}},e.later(1e3,this,function(){u=0,e.io(r,s)}))},all_pages_loaded:function(t){var n,r,i,s,o,u;try{n=e.JSON.parse(t);if(n.error||!n.pagecount){this.dialogue&&this.dialogue.hide(),u=new M.core.alert({message:M.util.get_string("cannotopenpdf","assignfeedback_editpdfplus")}),u.show();return}}catch(a){this.dialogue&&this.dialogue.hide(),u=new M.core.alert({title:M.util.get_string("cannotopenpdf","assignfeedback_editpdfplus")}),u.show();return}this.pagecount=n.pagecount,this.pages=n.pages,this.tools=[];for(r=0;r<n.tools.length;r++){var f=n.tools[r];this.tools[f.id]=f}this.typetools=[];for(r=0;r<n.typetools.length;r++){var l=n.typetools[r];this.typetools[l.id]=l}for(r=0;r<this.pages.length;r++){for(i=0;i<this.pages[r].comments.length;i++)o=this.pages[r].comments[i],this.pages[r].comments[i]=new M.assignfeedback_editpdfplus.comment(this,o.gradeid,o.pageno,o.x,o.y,o.width,o.colour,o.rawtext);var c=[];for(i=0;i<this.pages[r].annotations.length;i++){n=this.pages[r].annotations[i],n.parent_annot&&(n.parent_annot_element=c[n.parent_annot]);var h=this.create_annotation(this.typetools[this.tools[n.toolid].type].label,n.toolid,n,this.tools[n.toolid]);h.parent_annot_element&&(this.annotationsparent[h.parent_annot_element.id]?this.annotationsparent[h.parent_annot_element.id][this.annotationsparent[h.parent_annot_element.id].length]=h:this.annotationsparent[h.parent_annot_element.id]=[h]),c[n.id]=h,this.pages[r].annotations[i]=h}}this.quicklist&&this.quicklist.load(),this.setup_navigation(),this.setup_toolbar(),this.change_page()},get_stamp_image_url:function(t){var n=this.get("stampfiles"),r="";return e.Array.each(n,function(e){e.indexOf(t)>0&&(r=e)},this),r},setup_toolbar:function(){var t,n,r;if(this.get("readonly"))return;var i=this.get_dialogue_element(o.CUSTOMTOOLBARID+"1");i.show();var s=this.get_dialogue_element(o.AXISCUSTOMTOOLBAR);s.on("change",this.update_custom_toolbars,this),e.all(o.CUSTOMTOOLBARBUTTONS).each(function(e){var t=e.get("id"),n=e.getAttribute("data-tool");e.on("click",this.handle_tool_button,this,n,t),e.on("key",this.handle_tool_button,"down:13",this,n,t),e.setAttribute("aria-pressed","false")},this),e.each(p,function(e,n){t=this.get_dialogue_element(e),t.on("click",this.handle_tool_button,this,n),t.on("key",this.handle_tool_button,"down:13",this,n),t.setAttribute("aria-pressed","false")},this),n=this.get_dialogue_element(o.ANNOTATIONCOLOURBUTTON),r=new M.assignfeedback_editpdfplus.colourpicker({buttonNode:n,iconprefix:"colour_",colours:c,callback:function(e){var t=e.target.getAttribute("data-colour");t||(t=e.target.ancestor().getAttribute("data-colour")),this.currentedit.annotationcolour=
t,this.lastannotationtool?this.handle_tool_button(e,this.lastannotationtool):this.handle_tool_button(e,"pen")},context:this})},update_custom_toolbars:function(){e.all(o.CUSTOMTOOLBARS).each(function(e){e.hide()},this);var t=this.get_dialogue_element(o.AXISCUSTOMTOOLBAR+" option:checked"),n=parseInt(t.get("value"))+1,r=this.get_dialogue_element(o.CUSTOMTOOLBARID+""+n);r.show()},handle_tool_button:function(e,t,n,r){e.preventDefault(),this.handle_tool_button_action(t,n,r)},handle_tool_button_action:function(e,t,n){var r;this.currentedit.id?r=this.get_dialogue_element("#"+this.currentedit.id):r=this.get_dialogue_element(p[this.currentedit.tool]),r.removeClass("assignfeedback_editpdfplus_selectedbutton"),r.setAttribute("aria-pressed","false"),this.currentedit.tool=e,this.currentedit.id=t,e!=="comment"&&e!=="select"&&e!=="drag"&&e!=="stamp"&&(this.lastannotationtool=e),e!=="select"&&this.redraw_annotation(),n||(this.currentedit.parent_annot_element=null),this.refresh_button_state()},redraw_annotation:function(t){this.currentannotation=null;var n=this.pages[this.currentpage].annotations;e.each(n,function(e){e&&e.drawable&&(e.drawable.erase(),e.draw())})},stringify_current_page:function(){var t=[],n=[],r,i=0;for(i=0;i<this.pages[this.currentpage].comments.length;i++)t[i]=this.pages[this.currentpage].comments[i].clean();for(i=0;i<this.pages[this.currentpage].annotations.length;i++)n[i]=this.pages[this.currentpage].annotations[i].clean();return r={comments:t,annotations:n},e.JSON.stringify(r)},get_current_drawable:function(){var e,t,n=!1;if(!this.currentedit.start||!this.currentedit.end)return!1;if(this.currentedit.tool==="comment")e=new M.assignfeedback_editpdfplus.comment(this),n=e.draw_current_edit(this.currentedit);else{var r=this.currentedit.id;this.currentedit.id&&this.currentedit.id[0]==="c"&&(r=this.currentedit.id.substr(8)),t=this.create_annotation(this.currentedit.tool,this.currentedit.id,{},this.tools[r]),t&&(n=t.draw_current_edit(this.currentedit))}return n},get_dialogue_element:function(e){return this.panel?this.panel.one(e):this.dialogue.get("boundingBox").one(e)},redraw_current_edit:function(){this.currentdrawable&&this.currentdrawable.erase(),this.currentdrawable=this.get_current_drawable()},edit_start:function(t){t.preventDefault();var n=this.get_dialogue_element(o.DRAWINGCANVAS),r=n.getXY(),i=n.get("docScrollY"),s=n.get("docScrollX"),u={x:t.clientX-r[0]+s,y:t.clientY-r[1]+i},a=!1,f;if(t.button===3)return;if(this.currentedit.starttime)return;if(this.editingcomment)return;this.currentedit.starttime=(new Date).getTime(),this.currentedit.start=u,this.currentedit.end={x:u.x,y:u.y};if(this.currentedit.tool==="select"){var l=this.currentedit.end.x,c=this.currentedit.end.y,h=this.pages[this.currentpage].annotations;e.each(h,function(e){(l-e.x)*(l-e.endx)<=0&&(c-e.y)*(c-e.endy)<=0&&(a=e)}),a&&(f=this.currentannotation,this.currentannotation=a,f&&f!==a&&f.drawable&&(f.drawable.erase(),this.drawables.push(f.draw()),this.drawablesannotations.push(f)),this.currentannotation.drawable&&this.currentannotation.drawable.erase(),this.drawables.push(this.currentannotation.draw()),this.drawablesannotations.push(this.currentannotation))}this.currentannotation&&(this.currentedit.annotationstart={x:this.currentannotation.x,y:this.currentannotation.y})},edit_move:function(e){e.preventDefault();var t=this.get_canvas_bounds(),n=this.get_dialogue_element(o.DRAWINGCANVAS),r=this.get_dialogue_element(o.DRAWINGREGION),i=new M.assignfeedback_editpdfplus.point(e.clientX+n.get("docScrollX"),e.clientY+n.get("docScrollY")),s=this.get_canvas_coordinates(i),u,a;if(s.x<0||s.x>t.width||s.y<0||s.y>t.height)return;this.currentedit.tool==="pen"&&this.currentedit.path.push(s),this.currentedit.tool==="select"?this.currentannotation&&this.currentedit&&this.currentannotation.move(this.currentedit.annotationstart.x+s.x-this.currentedit.start.x,this.currentedit.annotationstart.y+s.y-this.currentedit.start.y):this.currentedit.tool==="drag"?(u=s.x-this.currentedit.start.x,a=s.y-this.currentedit.start.y,r.getDOMNode().scrollLeft-=u,r.getDOMNode().scrollTop-=a):this.currentedit.start&&(this.currentedit.end=s,this.redraw_current_edit())},edit_end:function(){var e,t,n;e=(new Date).getTime()-this.currentedit.start;if(e<h||this.currentedit.start===!1)return;if(this.currentedit.tool==="comment")this.currentdrawable&&this.currentdrawable.erase(),this.currentdrawable=!1,t=new M.assignfeedback_editpdfplus.comment(this),t.init_from_edit(this.currentedit)&&(this.pages[this.currentpage].comments.push(t),this.drawables.push(t.draw(!0)),this.editingcomment=!0);else{var r=this.currentedit.id;this.currentedit.id&&this.currentedit.id[0]==="c"&&(r=this.currentedit.id.substr(8)),n=this.create_annotation(this.currentedit.tool,this.currentedit.id,{},this.tools[r]);if(n){this.currentdrawable&&this.currentdrawable.erase(),this.currentdrawable=!1;if(n.init_from_edit(this.currentedit)){this.currentannotation=n,n.draw_catridge(this.currentedit),n.edit_annot();if(n.parent_annot_element){var i=0;n.parent_annot_element.id?i=n.parent_annot_element.id:i=n.parent_annot_element.divcartridge,this.annotationsparent[i]?this.annotationsparent[i][this.annotationsparent[i].length]=n:this.annotationsparent[i]=[n]}this.pages[this.currentpage].annotations.push(n),this.drawables.push(n.draw()),this.drawablesannotations.push(n)}}}this.save_current_page(),this.currentedit.starttime=0,this.currentedit.start=!1,this.currentedit.end=!1,this.currentedit.path=[],this.currentedit.tool!=="drag"&&this.handle_tool_button_action("select")},resize:function(){var t,n;if(this.dialogue){if(!this.dialogue.get("visible"))return;this.dialogue.centerDialogue()}return n=e.one("body").get("winHeight")-120,n<100&&(n=100),t=this.get_dialogue_element(o.DRAWINGREGION),this.dialogue&&t.setStyle("maxHeight",n+"px"),this.redraw(),!0},create_annotation:function(e,t,n,r){!e||typeof e=="undefined"||typeof t!="undefined"&&t!==null?t!==null&&t[0]==="c"&&(n.toolid=t.substr(8)):(e==="line"?n.toolid=d.LINE:e==="rectangle"?
n.toolid=d.RECTANGLE:e==="oval"?n.toolid=d.OVAL:e==="pen"?n.toolid=d.PEN:e==="highlight"&&(n.toolid=d.HIGHLIGHT),n.tooltype=this.tools[n.toolid]);if(!n.tooltype||n.tooltype==="")n.tooltype=r;return n.tool=e,n.editor=this,n.tool===d.LINE+""||n.tool===v.LINE?new M.assignfeedback_editpdfplus.annotationline(n):n.tool===d.RECTANGLE+""||n.tool===v.RECTANGLE?new M.assignfeedback_editpdfplus.annotationrectangle(n):n.tool===d.OVAL+""||n.tool===v.OVAL?new M.assignfeedback_editpdfplus.annotationoval(n):n.tool===d.PEN+""||n.tool===v.PEN?new M.assignfeedback_editpdfplus.annotationpen(n):n.tool===d.HIGHLIGHT+""||n.tool===v.HIGHLIGHT?new M.assignfeedback_editpdfplus.annotationhighlight(n):n.tool===d.FRAME+""||n.tool===v.FRAME?(r&&n.colour===""&&(n.colour=this.typetools[r.type].color),!n.parent_annot&&!n.parent_annot_element&&(this.currentedit.parent_annot_element?n.parent_annot_element=this.currentedit.parent_annot_element:(n.parent_annot_element=null,n.parent_annot=0)),new M.assignfeedback_editpdfplus.annotationframe(n)):(r&&(r.colors&&r.colors.indexOf(",")!==-1?n.colour=r.colors.substr(0,r.colors.indexOf(",")):n.colour=r.colors,n.colour===""&&(n.colour=this.typetools[r.type].color)),n.tool===d.HIGHLIGHTPLUS+""||n.tool===v.HIGHLIGHTPLUS?new M.assignfeedback_editpdfplus.annotationhighlightplus(n):n.tool===d.STAMPPLUS+""||n.tool===v.STAMPPLUS?new M.assignfeedback_editpdfplus.annotationstampplus(n):n.tool===d.VERTICALLINE+""||n.tool===v.VERTICALLINE?new M.assignfeedback_editpdfplus.annotationverticalline(n):n.tool===d.STAMPCOMMENT+""||n.tool===v.STAMPCOMMENT?new M.assignfeedback_editpdfplus.annotationstampcomment(n):n.tool===d.COMMENTPLUS+""||n.tool===v.COMMENTPLUS?new M.assignfeedback_editpdfplus.annotationcommentplus(n):!1)},save_current_page:function(){var t=n,r;r={method:"post",context:this,sync:!1,data:{sesskey:M.cfg.sesskey,action:"savepage",index:this.currentpage,userid:this.get("userid"),attemptnumber:this.get("attemptnumber"),assignmentid:this.get("assignmentid"),page:this.stringify_current_page()},on:{success:function(t,n){var r;try{r=e.JSON.parse(n.responseText);if(r.error)return new M.core.ajaxException(r);e.one(o.UNSAVEDCHANGESINPUT).set("value","true"),e.one(o.UNSAVEDCHANGESDIV).setStyle("opacity",1),e.one(o.UNSAVEDCHANGESDIV).setStyle("display","inline-block"),e.one(o.UNSAVEDCHANGESDIV).transition({duration:1,delay:2,opacity:0},function(){e.one(o.UNSAVEDCHANGESDIV).setStyle("display","none")})}catch(i){return new M.core.exception(i)}},failure:function(e,t){return new M.core.exception(t.responseText)}}},e.io(t,r)},open_search_comments:function(e){this.searchcommentswindow||(this.searchcommentswindow=new M.assignfeedback_editpdfplus.commentsearch({editor:this})),this.searchcommentswindow.show(),e.preventDefault()},redraw:function(){var t,n;n=this.pages[this.currentpage];if(n===undefined)return;while(this.drawables.length>0)this.drawables.pop().erase();while(this.drawablesannotations.length>0){var r=this.drawablesannotations.pop();if(r.divcartridge){var i=e.one("#"+r.divcartridge);i&&i.remove(),r.divcartridge=""}}for(t=0;t<n.annotations.length;t++)this.drawables.push(n.annotations[t].draw()),this.drawablesannotations.push(n.annotations[t]);for(t=0;t<n.comments.length;t++)this.drawables.push(n.comments[t].draw(!1))},change_page:function(){var e=this.get_dialogue_element(o.DRAWINGCANVAS),t,n,r;n=this.get_dialogue_element(o.PREVIOUSBUTTON),r=this.get_dialogue_element(o.NEXTBUTTON),this.currentpage>0?n.removeAttribute("disabled"):n.setAttribute("disabled","true"),this.currentpage<this.pagecount-1?r.removeAttribute("disabled"):r.setAttribute("disabled","true"),t=this.pages[this.currentpage],this.loadingicon.hide(),e.setStyle("backgroundImage",'url("'+t.url+'")'),e.setStyle("width",t.width+"px"),e.setStyle("height",t.height+"px"),this.get_dialogue_element(o.PAGESELECT).set("selectedIndex",this.currentpage),this.resize()},setup_navigation:function(){var t,n,r,i,s,u;t=this.get_dialogue_element(o.PAGESELECT);var a=t.all("option");if(a.size()<=1)for(n=0;n<this.pages.length;n++)i=e.Node.create("<option/>"),i.setAttribute("value",n),r={page:n+1,total:this.pages.length},i.setHTML(M.util.get_string("pagexofy","assignfeedback_editpdfplus",r)),t.append(i);t.removeAttribute("disabled"),t.on("change",function(){this.currentpage=t.get("value"),this.change_page()},this),s=this.get_dialogue_element(o.PREVIOUSBUTTON),u=this.get_dialogue_element(o.NEXTBUTTON),s.on("click",this.previous_page,this),s.on("key",this.previous_page,"down:13",this),u.on("click",this.next_page,this),u.on("key",this.next_page,"down:13",this)},previous_page:function(e){e.preventDefault(),this.currentpage--,this.currentpage<0&&(this.currentpage=0),this.change_page()},next_page:function(e){e.preventDefault(),this.currentpage++,this.currentpage>=this.pages.length&&(this.currentpage=this.pages.length-1),this.change_page()},move_canvas:function(){var e,t,n,r;e=this.get_dialogue_element(o.DRAWINGREGION),t=parseInt(e.get("scrollLeft"),10),n=parseInt(e.get("scrollTop"),10);for(r=0;r<this.drawables.length;r++)this.drawables[r].scroll_update(t,n)}},e.extend(J,e.Base,J.prototype,{NAME:"moodle-assignfeedback_editpdfplus-editor",ATTRS:{userid:{validator:e.Lang.isInteger,value:0},assignmentid:{validator:e.Lang.isInteger,value:0},attemptnumber:{validator:e.Lang.isInteger,value:0},header:{validator:e.Lang.isString,value:""},body:{validator:e.Lang.isString,value:""},footer:{validator:e.Lang.isString,value:""},linkid:{validator:e.Lang.isString,value:""},deletelinkid:{validator:e.Lang.isString,value:""},readonly:{validator:e.Lang.isBoolean,value:!0},stampfiles:{validator:e.Lang.isArray,value:""},pagetotal:{validator:e.Lang.isInteger,value:0}}}),M.assignfeedback_editpdfplus=M.assignfeedback_editpdfplus||{},M.assignfeedback_editpdfplus.editor=M.assignfeedback_editpdfplus.editor||{},M.assignfeedback_editpdfplus.editor.init=M.assignfeedback_editpdfplus.editor.init||function(e){return M.assignfeedback_editpdfplus.instance=new J(e),M.assignfeedback_editpdfplus.instance
}},"@VERSION@",{requires:["base","event","node","io","graphics","json","event-move","event-resize","transition","querystring-stringify-simple","moodle-core-notification-dialog","moodle-core-notification-exception","moodle-core-notification-ajaxexception"]});
n.toolid=d.RECTANGLE:e==="oval"?n.toolid=d.OVAL:e==="pen"?n.toolid=d.PEN:e==="highlight"&&(n.toolid=d.HIGHLIGHT),n.tooltype=this.tools[n.toolid]);if(!n.tooltype||n.tooltype==="")n.tooltype=r;return n.tool=e,n.editor=this,n.tool===d.LINE+""||n.tool===v.LINE?new M.assignfeedback_editpdfplus.annotationline(n):n.tool===d.RECTANGLE+""||n.tool===v.RECTANGLE?new M.assignfeedback_editpdfplus.annotationrectangle(n):n.tool===d.OVAL+""||n.tool===v.OVAL?new M.assignfeedback_editpdfplus.annotationoval(n):n.tool===d.PEN+""||n.tool===v.PEN?new M.assignfeedback_editpdfplus.annotationpen(n):n.tool===d.HIGHLIGHT+""||n.tool===v.HIGHLIGHT?new M.assignfeedback_editpdfplus.annotationhighlight(n):n.tool===d.FRAME+""||n.tool===v.FRAME?(r&&n.colour===""&&(n.colour=this.typetools[r.type].color),!n.parent_annot&&!n.parent_annot_element&&(this.currentedit.parent_annot_element?n.parent_annot_element=this.currentedit.parent_annot_element:(n.parent_annot_element=null,n.parent_annot=0)),new M.assignfeedback_editpdfplus.annotationframe(n)):(r&&(r.colors&&r.colors.indexOf(",")!==-1?n.colour=r.colors.substr(0,r.colors.indexOf(",")):n.colour=r.colors,n.colour===""&&(n.colour=this.typetools[r.type].color)),n.tool===d.HIGHLIGHTPLUS+""||n.tool===v.HIGHLIGHTPLUS?new M.assignfeedback_editpdfplus.annotationhighlightplus(n):n.tool===d.STAMPPLUS+""||n.tool===v.STAMPPLUS?new M.assignfeedback_editpdfplus.annotationstampplus(n):n.tool===d.VERTICALLINE+""||n.tool===v.VERTICALLINE?new M.assignfeedback_editpdfplus.annotationverticalline(n):n.tool===d.STAMPCOMMENT+""||n.tool===v.STAMPCOMMENT?new M.assignfeedback_editpdfplus.annotationstampcomment(n):n.tool===d.COMMENTPLUS+""||n.tool===v.COMMENTPLUS?new M.assignfeedback_editpdfplus.annotationcommentplus(n):!1)},save_current_page:function(){var t=n,r;r={method:"post",context:this,sync:!1,data:{sesskey:M.cfg.sesskey,action:"savepage",index:this.currentpage,userid:this.get("userid"),attemptnumber:this.get("attemptnumber"),assignmentid:this.get("assignmentid"),page:this.stringify_current_page()},on:{success:function(t,n){var r;try{r=e.JSON.parse(n.responseText);if(r.error)return new M.core.ajaxException(r);e.one(o.UNSAVEDCHANGESINPUT).set("value","true"),e.one(o.UNSAVEDCHANGESDIV).setStyle("opacity",1),e.one(o.UNSAVEDCHANGESDIV).setStyle("display","inline-block"),e.one(o.UNSAVEDCHANGESDIV).transition({duration:1,delay:2,opacity:0},function(){e.one(o.UNSAVEDCHANGESDIV).setStyle("display","none")})}catch(i){return new M.core.exception(i)}},failure:function(e,t){return new M.core.exception(t.responseText)}}},e.io(t,r)},open_search_comments:function(e){this.searchcommentswindow||(this.searchcommentswindow=new M.assignfeedback_editpdfplus.commentsearch({editor:this})),this.searchcommentswindow.show(),e.preventDefault()},redraw:function(){var t,n;n=this.pages[this.currentpage];if(n===undefined)return;while(this.drawables.length>0)this.drawables.pop().erase();while(this.drawablesannotations.length>0){var r=this.drawablesannotations.pop();if(r.divcartridge){var i=e.one("#"+r.divcartridge);i&&i.remove(),r.divcartridge=""}r.drawable&&r.drawable.erase()}for(t=0;t<n.annotations.length;t++)this.drawables.push(n.annotations[t].draw()),this.drawablesannotations.push(n.annotations[t]);for(t=0;t<n.comments.length;t++)this.drawables.push(n.comments[t].draw(!1))},change_page:function(){var e=this.get_dialogue_element(o.DRAWINGCANVAS),t,n,r;n=this.get_dialogue_element(o.PREVIOUSBUTTON),r=this.get_dialogue_element(o.NEXTBUTTON),this.currentpage>0?n.removeAttribute("disabled"):n.setAttribute("disabled","true"),this.currentpage<this.pagecount-1?r.removeAttribute("disabled"):r.setAttribute("disabled","true"),t=this.pages[this.currentpage],this.loadingicon.hide(),e.setStyle("backgroundImage",'url("'+t.url+'")'),e.setStyle("width",t.width+"px"),e.setStyle("height",t.height+"px"),this.get_dialogue_element(o.PAGESELECT).set("selectedIndex",this.currentpage),this.resize()},setup_navigation:function(){var t,n,r,i,s,u;t=this.get_dialogue_element(o.PAGESELECT);var a=t.all("option");if(a.size()<=1)for(n=0;n<this.pages.length;n++)i=e.Node.create("<option/>"),i.setAttribute("value",n),r={page:n+1,total:this.pages.length},i.setHTML(M.util.get_string("pagexofy","assignfeedback_editpdfplus",r)),t.append(i);t.removeAttribute("disabled"),t.on("change",function(){this.currentpage=t.get("value"),this.change_page()},this),s=this.get_dialogue_element(o.PREVIOUSBUTTON),u=this.get_dialogue_element(o.NEXTBUTTON),s.on("click",this.previous_page,this),s.on("key",this.previous_page,"down:13",this),u.on("click",this.next_page,this),u.on("key",this.next_page,"down:13",this)},previous_page:function(e){e.preventDefault(),this.currentpage--,this.currentpage<0&&(this.currentpage=0),this.change_page()},next_page:function(e){e.preventDefault(),this.currentpage++,this.currentpage>=this.pages.length&&(this.currentpage=this.pages.length-1),this.change_page()},move_canvas:function(){var e,t,n,r;e=this.get_dialogue_element(o.DRAWINGREGION),t=parseInt(e.get("scrollLeft"),10),n=parseInt(e.get("scrollTop"),10);for(r=0;r<this.drawables.length;r++)this.drawables[r].scroll_update(t,n)}},e.extend(J,e.Base,J.prototype,{NAME:"moodle-assignfeedback_editpdfplus-editor",ATTRS:{userid:{validator:e.Lang.isInteger,value:0},assignmentid:{validator:e.Lang.isInteger,value:0},attemptnumber:{validator:e.Lang.isInteger,value:0},header:{validator:e.Lang.isString,value:""},body:{validator:e.Lang.isString,value:""},footer:{validator:e.Lang.isString,value:""},linkid:{validator:e.Lang.isString,value:""},deletelinkid:{validator:e.Lang.isString,value:""},readonly:{validator:e.Lang.isBoolean,value:!0},stampfiles:{validator:e.Lang.isArray,value:""},pagetotal:{validator:e.Lang.isInteger,value:0}}}),M.assignfeedback_editpdfplus=M.assignfeedback_editpdfplus||{},M.assignfeedback_editpdfplus.editor=M.assignfeedback_editpdfplus.editor||{},M.assignfeedback_editpdfplus.editor.init=M.assignfeedback_editpdfplus.editor.init||function(e){return M.assignfeedback_editpdfplus.instance=new J(e),M.assignfeedback_editpdfplus
.instance}},"@VERSION@",{requires:["base","event","node","io","graphics","json","event-move","event-resize","transition","querystring-stringify-simple","moodle-core-notification-dialog","moodle-core-notification-exception","moodle-core-notification-ajaxexception"]});
......@@ -6443,6 +6443,9 @@ EDITOR.prototype = {
}
annot.divcartridge = "";
}
if (annot.drawable) {
annot.drawable.erase();
}
}
for (i = 0; i < page.annotations.length; i++) {
......
......@@ -1163,6 +1163,9 @@ EDITOR.prototype = {
}
annot.divcartridge = "";
}
if (annot.drawable) {
annot.drawable.erase();
}
}
for (i = 0; i < page.annotations.length; i++) {
......
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