Gitlab CSE Unil

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

mise en place des axes

parent 00328255
......@@ -97,8 +97,10 @@ if ($action == 'loadallpages') {
$tools = page_editor::get_tools();
$typetools = page_editor::get_typetools();
$axis = page_editor::get_axis();
$response->tools = $tools;
$response->typetools = $typetools;
$response->axis = $axis;
echo json_encode($response);
die();
......
......@@ -205,7 +205,7 @@ class page_editor {
* Get all tools for a page.
* @param int $contextid
* @param int $axis
* @return tool[]
* @return axis[]
*/
public static function get_axis($contextidlist) {
global $DB;
......@@ -216,7 +216,7 @@ class page_editor {
$records = $DB->get_records('assignfeedback_editpp_axis');
}
foreach ($records as $record) {
array_push($axis, new tool($record));
array_push($axis, new axis($record));
}
usort($axis, function($a, $b) {
$al = $a->order;
......
......@@ -142,6 +142,12 @@ class assignfeedback_editpdfplus_renderer extends plugin_renderer_base {
return html_writer::tag('button', $iconhtml, $iconparams);
}
private function render_toolbar_axis(assignfeedback_editpdfplus\axis $axis) {
$iconhtml = $axis->label;
$iconparams = array('type' => 'checkbox', 'class' => 'axis', 'id' => 'ctaxis' . $axis->id, 'value' => $axis->id);
return html_writer::tag('input', $iconhtml, $iconparams);
}
/**
* Render the editpdf widget in the grading form.
*
......@@ -168,7 +174,7 @@ class assignfeedback_editpdfplus_renderer extends plugin_renderer_base {
$body = '';
// Create the page navigation.
$navigation1 = '';
$navigation2 = '';
//$navigation2 = '';
//$divToolbar;
// Pick the correct arrow icons for right to left mode.
if (right_to_left()) {
......@@ -193,13 +199,15 @@ class assignfeedback_editpdfplus_renderer extends plugin_renderer_base {
$divnavigation1 = html_writer::div($navigation1, 'navigation', array('role' => 'navigation'));
$navigation2 .= $this->render_toolbar_button('comment_search', 'searchcomments', null, $this->get_shortcut('searchcomments'));
$divnavigation2 = html_writer::div($navigation2, 'navigation-search', array('role' => 'navigation'));
//$navigation2 .= $this->render_toolbar_button('comment_search', 'searchcomments', null, $this->get_shortcut('searchcomments'));
//$divnavigation2 = html_writer::div($navigation2, 'navigation-search', array('role' => 'navigation'));
$toolbar001 = '';
$toolbar002 = '';
$toolbarCostumdiv = '';
$toolbaraxis = '';
$clearfix = html_writer::div('', 'clearfix');
if (!$widget->readonly) {
/** Toolbar n°0 : basic tools * */
......@@ -237,21 +245,28 @@ class assignfeedback_editpdfplus_renderer extends plugin_renderer_base {
return ($al > $bl) ? +1 : -1;
});
$axischoice = html_writer::div(html_writer::select($axis, 'axisselection', 0, FALSE), 'toolbar ', array('role' => 'toolbar'));
foreach ($toolbarCostum as $toolbarCostumUnit) {
$toolbarCostumdiv.= $toolbarCostumUnit;
}
$toolbarCostumdiv.= $axischoice;
} else {
$toolbaraxis = "<div class='navigation' style='padding-left:10px;margin-left:10px;'><div style='display:inline;margin-right:5px;text-align:left;'>";
$axis = $widget->axis;
$compteur = 0;
foreach ($axis as $ax) {
$toolbaraxis .= $this->render_toolbar_axis($ax);
$toolbaraxis .= "</div><div style='display:inline;margin-left:5px;margin-right:5px;text-align:left;'>";
}
$toolbaraxis .= "</div></div>";
}
// Toobars written in reverse order because they are floated right.
$pageheader = html_writer::div($divnavigation1 .
// $divnavigation2 .
$toolbar002 .
$toolbaraxis .
$toolbarCostumdiv .
$toolbar001 .
$clearfix, 'pageheader');
//debugging($pageheader);
$body .= $pageheader;
......@@ -287,8 +302,6 @@ class assignfeedback_editpdfplus_renderer extends plugin_renderer_base {
'readonly' => $widget->readonly,
'pagetotal' => $widget->pagetotal));
//$this->page->requires->js_call_amd('assignfeedback_editpdfplus/toolbar', 'setup');
$this->page->requires->yui_module('moodle-assignfeedback_editpdfplus-editor', 'M.assignfeedback_editpdfplus.editor.init', $editorparams);
$this->page->requires->strings_for_js(array(
......
......@@ -57,8 +57,11 @@ class assignfeedback_editpdfplus_widget implements renderable {
/** @var integer $pagetotal */
public $pagetotal = 0;
/** @var string[] $toolbars */
/** @var tool[] $toolbars */
public $toolbars = array();
/** @var axis[] $toolbars */
public $axis = array();
/**
* Constructor
......@@ -71,7 +74,7 @@ class assignfeedback_editpdfplus_widget implements renderable {
* @param bool $readonly - Show the readonly interface (no tools).
* @param integer $pagetotal - The total number of pages.
*/
public function __construct($assignment, $userid, $attemptnumber, $downloadurl, $downloadfilename, $stampfiles, $readonly, $pagetotal, $toolbars) {
public function __construct($assignment, $userid, $attemptnumber, $downloadurl, $downloadfilename, $stampfiles, $readonly, $pagetotal, $toolbars, $axis) {
$this->assignment = $assignment;
$this->userid = $userid;
$this->attemptnumber = $attemptnumber;
......@@ -81,6 +84,7 @@ class assignfeedback_editpdfplus_widget implements renderable {
$this->readonly = $readonly;
$this->pagetotal = $pagetotal;
$this->toolbars = $toolbars;
$this->axis = $axis;
}
}
......@@ -99,5 +99,6 @@ $string['tool'] = 'Tool';
$string['viewfeedbackonline'] = 'View annotated PDF...';
$string['white'] = 'White';
$string['yellow'] = 'Yellow';
$string['yellowlemon'] = 'Lemon yellow';
$string['draftchangessaved'] = 'Draft annotations saved';
$string['preparesubmissionsforannotation'] = 'Prepare submissions for annotation';
......@@ -84,12 +84,6 @@ class assign_feedback_editpdfplus extends assign_feedback_plugin {
}
}
}
/*foreach ($tools as $tool) {
if ($tool->axis > 0) {
$toolbars[$tool->axis - 1][] = $tool;
}
}*/
//debugging(sizeof($toolbars[0]) . ' ' . sizeof($toolbars[1]) . ' ' . sizeof($toolbars[2]));
// Copy any new stamps to this instance.
if ($files = $fs->get_area_files($syscontext->id, 'assignfeedback_editpdfplus', 'stamps', 0, "filename", false)) {
foreach ($files as $file) {
......@@ -128,7 +122,7 @@ class assign_feedback_editpdfplus extends assign_feedback_plugin {
// Retrieve total number of pages.
$pagetotal = document_services::page_number_for_attempt($this->assignment->get_instance()->id, $userid, $attempt, $readonly);
$widget = new assignfeedback_editpdfplus_widget($this->assignment->get_instance()->id, $userid, $attempt, $url, $filename, $stampfiles, $readonly, $pagetotal, $toolbars);
$widget = new assignfeedback_editpdfplus_widget($this->assignment->get_instance()->id, $userid, $attempt, $url, $filename, $stampfiles, $readonly, $pagetotal, $toolbars, $axis);
return $widget;
}
......
......@@ -5765,7 +5765,7 @@ EDITOR.prototype = {
* @method all_pages_loaded
*/
all_pages_loaded: function (responsetext) {
var data, i, j, k, comment, error;
var data, i, j, comment, error;
try {
data = Y.JSON.parse(responsetext);
if (data.error || !data.pagecount) {
......@@ -5803,6 +5803,13 @@ EDITOR.prototype = {
this.typetools[typetooltmp.id] = typetooltmp;
}
this.axis = [];
for (i = 0; i < data.axis.length; i++) {
var axistmp = data.axis[i];
axistmp.visibility = true;
this.axis[axistmp.id] = axistmp;
}
for (i = 0; i < this.pages.length; i++) {
for (j = 0; j < this.pages[i].comments.length; j++) {
comment = this.pages[i].comments[j];
......@@ -5861,6 +5868,10 @@ EDITOR.prototype = {
return fullurl;
},
handle_axis_button: function (edit, axis, axe) {
axis.visibility = axe.get('checked');
this.redraw();
},
/**
* Attach listeners and enable the color picker buttons.
* @protected
......@@ -5872,6 +5883,13 @@ EDITOR.prototype = {
picker;
if (this.get('readonly')) {
// Setup the tool buttons.
for (var i = 1; i < this.axis.length; i++) {
var axis = this.axis[i];
var axe = this.get_dialogue_element('#ctaxis' + axis.id);
axe.set('checked', 'true');
axe.on('click', this.handle_axis_button, this, axis, axe);
}
return;
}
......@@ -6458,8 +6476,12 @@ EDITOR.prototype = {
}
for (i = 0; i < page.annotations.length; i++) {
this.drawables.push(page.annotations[i].draw());
this.drawablesannotations.push(page.annotations[i]);
var annot = page.annotations[i];
var tool = annot.tooltype;
if (this.get('readonly') && tool.axis && this.axis[tool.axis] && this.axis[tool.axis].visibility || !this.get('readonly')) {
this.drawables.push(annot.draw());
this.drawablesannotations.push(annot);
}
}
for (i = 0; i < page.comments.length; i++) {
this.drawables.push(page.comments[i].draw(false));
......
......@@ -10,7 +10,7 @@ function(){var t=new M.assignfeedback_editpdfplus.drawable(this.editor),n=this.e
:function(t){var n=new M.assignfeedback_editpdfplus.rect,r=new M.assignfeedback_editpdfplus.drawable(this.editor),i=this.editor.get_dialogue_element(o.DRAWINGREGION),s,u;return n.bound([t.start,t.end]),u=this.editor.get_window_coordinates(new M.assignfeedback_editpdfplus.point(n.x,n.y)),s=e.Node.create("<div>"+this.tooltype.label+"</div>"),s.setStyles({position:"absolute",display:"inline-block",zIndex:50,color:this.colour,padding:"0 2px"}),i.append(s),s.setX(u.x),s.setY(u.y),r.store_position(s,u.x,u.y),r.nodes.push(s),r},init_from_edit:function(e){var t=new M.assignfeedback_editpdfplus.rect;return t.bound([e.start,e.end]),t.width<20&&(t.width=20),t.height<20&&(t.height=20),this.gradeid=this.editor.get("gradeid"),this.pageno=this.editor.currentpage,this.x=t.x-20,this.y=t.y-10,this.endx=t.x+t.width,this.endy=t.y+t.height,!0},draw_catridge:function(e){var t=this.editor.get_dialogue_element(o.DRAWINGCANVAS).getXY();if(this.divcartridge===""){this.init_div_cartridge_id();var n=this.editor.get_dialogue_element(o.DRAWINGCANVAS),r=this.get_color_cartridge(),i=this.get_div_cartridge(r);i.addClass("assignfeedback_editpdfplus_commentplus");var s=this.get_div_cartridge_label(r);i.append(s);var u=this.get_div_container(r);i.append(u);if(!this.editor.get("readonly")){var a=this.get_div_edition();u.append(a)}i.setX(this.x+20),i.setY(this.y),n.append(i),this.apply_visibility_annot()}else{var i=this.editor.get_dialogue_element("#"+this.divcartridge);i.setX(t[0]+this.x+20),i.setY(t[1]+this.y)}return!0},apply_visibility_annot:function(){P.superclass.apply_visibility_annot.apply(this);var e=this.editor.get_dialogue_element("#"+this.divcartridge+"_display"),t=this.editor.get_dialogue_element("#"+this.divcartridge+"_onof"),n=this.editor.get_dialogue_element("#"+this.divcartridge+"_buttonedit_right"),r=this.editor.get_dialogue_element("#"+this.divcartridge+"_buttonedit_left");n&&(n.one("img").setAttribute("src",M.util.image_url("t/down","core")),r.one("img").setAttribute("src",M.util.image_url("t/up","core")),t.get("value")==="2"?e.setContent("<table><tr><td>"+this.get_text_to_diplay_in_cartridge().replace(/\n/g,"<br/>")+"</td></tr></table><br/>"):t.get("value")==="1"?r.one("img").setAttribute("src",M.util.image_url("t/left","core")):t.get("value")==="0"&&n.one("img").setAttribute("src",M.util.image_url("t/right","core")))},save_annot:function(){var e=this.editor.get_dialogue_element("#"+this.divcartridge+"_editinput"),t=e.get("value");this.textannot=t,this.editor.save_current_page(),t.length===0&&(t="&nbsp;&nbsp;");var n=this.editor.get_dialogue_element("#"+this.divcartridge+"_valref");n.set("value",t),this.apply_visibility_annot(),this.hide_edit();return},move:function(e,t){var n=e-this.x,r=t-this.y;this.x+=n,this.y+=r,this.endx+=n,this.endy+=r,this.drawable&&this.drawable.erase(),this.editor.drawables.push(this.draw())},remove:function(e){var t,n;e.preventDefault(),t=this.editor.pages[this.editor.currentpage].annotations;for(n=0;n<t.length;n++)if(t[n]===this){if(this.divcartridge!==""){var r="#"+this.divcartridge,i=this.editor.get_dialogue_element(r);i.remove()}t.splice(n,1),this.drawable&&this.drawable.erase(),this.editor.currentannotation=!1,this.editor.save_current_page();return}}}),M.assignfeedback_editpdfplus=M.assignfeedback_editpdfplus||{},M.assignfeedback_editpdfplus.annotationcommentplus=P;var H="Dropdown menu",B;B=function(e){e.draggable=!1,e.centered=!1,e.width="auto",e.visible=!1,e.footerContent="",B.superclass.constructor.apply(this,[e])},e.extend(B,M.core.dialogue,{initializer:function(t){var n,r,i,s;B.superclass.initializer.call(this,t),s=this.get("boundingBox"),s.addClass("assignfeedback_editpdfplus_dropdown"),n=this.get("buttonNode"),r=this.bodyNode,i=e.Node.create("<h3/>"),i.addClass("accesshide"),i.setHTML(this.get("headerText")),r.prepend(i),r.on("clickoutside",function(e){this.get("visible")&&e.target.get("id")!==n.get("id")&&e.target.ancestor().get("id")!==n.get("id")&&(e.preventDefault(),this.hide())},this),n.on("click",function(e){e.preventDefault(),this.show()},this),n.on("key",this.show,"enter,space",this)},show:function(){var t=this.get("buttonNode"),n=B.superclass.show.call(this);return this.align(t,[e.WidgetPositionAlign.TL,e.WidgetPositionAlign.BL]),n}},{NAME:H,ATTRS:{headerText:{value:""},buttonNode:{value:null}}}),e.Base.modifyAttrs(B,{modal:{getter:function(){return!1}}}),M.assignfeedback_editpdfplus=M.assignfeedback_editpdfplus||{},M.assignfeedback_editpdfplus.dropdown=B;var j="Colourpicker",F;F=function(e){F.superclass.constructor.apply(this,[e])},e.extend(F,M.assignfeedback_editpdfplus.dropdown,{initializer:function(t){var n=e.Node.create('<ul role="menu" class="assignfeedback_editpdfplus_menu"/>'),r;e.each(this.get("colours"),function(t,r){var i,s,o,u,a;o=M.util.get_string(r,"assignfeedback_editpdfplus"),a=this.get("iconprefix")+r,u=M.util.image_url(a,"assignfeedback_editpdfplus"),i=e.Node.create('<button><img alt="'+o+'" src="'+u+'"/></button>'),i.setAttribute("data-colour",r),i.setAttribute("data-rgb",t),i.setStyle("backgroundImage","none"),s=e.Node.create("<li/>"),s.append(i),n.append(s)},this),r=e.Node.create("<div/>"),n.delegate("click",this.callback_handler,"button",this),n.delegate("key",this.callback_handler,"down:13","button",this),this.set("headerText",M.util.get_string("colourpicker","assignfeedback_editpdfplus")),r.append(n),this.set("bodyContent",r),F.superclass.initializer.call(this,t)},callback_handler:function(t){t.preventDefault();var n=this.get("callback"),r=this.get("context"),i;this.hide(),i=e.bind(n,r,t),i()}},{NAME:j,ATTRS:{colours:{value:{}},callback:{value:null},context:{value:null},iconprefix:{value:"colour_"}}}),M.assignfeedback_editpdfplus=M.assignfeedback_editpdfplus||{},M.assignfeedback_editpdfplus.colourpicker=F;var I="Colourpicker",q;q=function(e){q.superclass.constructor.apply(this,[e])},e.extend(q,M.assignfeedback_editpdfplus.dropdown,{initializer:function(t){var n=e.Node.create('<ul role="menu" class="assignfeedback_editpdfplus_menu"/>');
e.each(this.get("stamps"),function(t){var r,i,s;s=M.util.get_string("stamp","assignfeedback_editpdfplus"),r=e.Node.create('<button><img height="16" width="16" alt="'+s+'" src="'+t+'"/></button>'),r.setAttribute("data-stamp",t),r.setStyle("backgroundImage","none"),i=e.Node.create("<li/>"),i.append(r),n.append(i)},this),n.delegate("click",this.callback_handler,"button",this),n.delegate("key",this.callback_handler,"down:13","button",this),this.set("headerText",M.util.get_string("stamppicker","assignfeedback_editpdfplus")),this.set("bodyContent",n),q.superclass.initializer.call(this,t)},callback_handler:function(t){t.preventDefault();var n=this.get("callback"),r=this.get("context"),i;this.hide(),i=e.bind(n,r,t),i()}},{NAME:I,ATTRS:{stamps:{value:[]},callback:{value:null},context:{value:null}}}),M.assignfeedback_editpdfplus=M.assignfeedback_editpdfplus||{},M.assignfeedback_editpdfplus.stamppicker=q;var R="Commentmenu",U;U=function(e){U.superclass.constructor.apply(this,[e])},e.extend(U,M.assignfeedback_editpdfplus.dropdown,{initializer:function(t){var n,r,i,s;s=this.get("comment"),n=e.Node.create('<ul role="menu" class="assignfeedback_editpdfplus_menu"/>'),r=e.Node.create('<li><a tabindex="-1" href="#">'+M.util.get_string("addtoquicklist","assignfeedback_editpdfplus")+"</a></li>"),r.on("click",s.add_to_quicklist,s),r.on("key",s.add_to_quicklist,"enter,space",s),n.append(r),r=e.Node.create('<li><a tabindex="-1" href="#">'+M.util.get_string("deletecomment","assignfeedback_editpdfplus")+"</a></li>"),r.on("click",function(e){e.preventDefault(),this.menu.hide(),this.remove()},s),r.on("key",function(){s.menu.hide(),s.remove()},"enter,space",s),n.append(r),r=e.Node.create("<li><hr/></li>"),n.append(r),this.set("headerText",M.util.get_string("commentcontextmenu","assignfeedback_editpdfplus")),i=e.Node.create("<div/>"),i.append(n),this.set("bodyContent",i),U.superclass.initializer.call(this,t)},show:function(){var t=this.get("boundingBox").one("ul");t.all(".quicklist_comment").remove(!0);var n=this.get("comment");n.deleteme=!1,e.each(n.editor.quicklist.comments,function(r){var i=e.Node.create('<li class="quicklist_comment"></li>'),s=e.Node.create('<a href="#" tabindex="-1">'+r.rawtext+"</a>"),o=e.Node.create('<a href="#" tabindex="-1" class="delete_quicklist_comment"><img src="'+M.util.image_url("t/delete","core")+'" '+'alt="'+M.util.get_string("deletecomment","assignfeedback_editpdfplus")+'"/>'+"</a>");i.append(s),i.append(o),t.append(i),s.on("click",n.set_from_quick_comment,n,r),s.on("key",n.set_from_quick_comment,"space,enter",n,r),o.on("click",n.remove_from_quicklist,n,r),o.on("key",n.remove_from_quicklist,"space,enter",n,r)},this),U.superclass.show.call(this)}},{NAME:R,ATTRS:{comment:{value:null}}}),M.assignfeedback_editpdfplus=M.assignfeedback_editpdfplus||{},M.assignfeedback_editpdfplus.commentmenu=U;var z="commentsearch",W;W=function(e){e.draggable=!1,e.centered=!0,e.width="400px",e.visible=!1,e.headerContent=M.util.get_string("searchcomments","assignfeedback_editpdfplus"),e.footerContent="",W.superclass.constructor.apply(this,[e])},e.extend(W,M.core.dialogue,{initializer:function(t){var n,r,i,s,o,u;u=this.get("boundingBox"),u.addClass("assignfeedback_editpdfplus_commentsearch"),n=this.get("editor"),r=e.Node.create("<div/>"),i=M.util.get_string("filter","assignfeedback_editpdfplus"),s=e.Node.create('<input type="text" size="20" placeholder="'+i+'"/>'),r.append(s),o=e.Node.create('<ul role="menu" class="assignfeedback_editpdfplus_menu"/>'),r.append(o),s.on("keyup",this.filter_search_comments,this),o.delegate("click",this.focus_on_comment,"a",this),o.delegate("key",this.focus_on_comment,"enter,space","a",this),this.set("bodyContent",r),W.superclass.initializer.call(this,t)},filter_search_comments:function(){var t,n,r,i;i=this.get("id"),t=e.one("#"+i+o.SEARCHFILTER),n=e.one("#"+i+o.SEARCHCOMMENTSLIST),r=t.get("value"),n.all("li").each(function(e){e.get("text").indexOf(r)!==-1?e.show():e.hide()})},focus_on_comment:function(e){e.preventDefault();var t=e.target.ancestor("li"),n=t.getData("comment"),r=this.get("editor");this.hide(),n.pageno===r.currentpage?n.drawable.nodes[0].one("textarea").focus():(r.currentpage=n.pageno,r.change_page(),n.drawable.nodes[0].one("textarea").focus())},show:function(){var t=this.get("boundingBox").one("ul"),n=this.get("editor");t.all("li").remove(!0),e.each(n.pages,function(n){e.each(n.comments,function(n){var r=e.Node.create('<li><a href="#" tabindex="-1"><pre>'+n.rawtext+"</pre></a></li>");t.append(r),r.setData("comment",n)},this)},this),this.centerDialogue(),W.superclass.show.call(this)}},{NAME:z,ATTRS:{editor:{value:null}}}),e.Base.modifyAttrs(W,{modal:{getter:function(){return!0}}}),M.assignfeedback_editpdfplus=M.assignfeedback_editpdfplus||{},M.assignfeedback_editpdfplus.commentsearch=W;var X=function(t,n,r,i,s,u,a,c){this.editor=t,this.gradeid=n||0,this.x=parseInt(i,10)||0,this.y=parseInt(s,10)||0,this.width=parseInt(u,10)||0,this.rawtext=c||"",this.pageno=r||0,this.colour=a||"yellow",this.drawable=!1,this.deleteme=!1,this.menulink=null,this.menu=null,this.clean=function(){return{gradeid:this.gradeid,x:parseInt(this.x,10),y:parseInt(this.y,10),width:parseInt(this.width,10),rawtext:this.rawtext,pageno:this.currentpage,colour:this.colour}},this.draw=function(t){var n=new M.assignfeedback_editpdfplus.drawable(this.editor),r,i=this.editor.get_dialogue_element(o.DRAWINGCANVAS),s,u,a,c;return r=e.Node.create("<textarea/>"),s=e.Node.create('<div class="commentdrawable"/>'),u=e.Node.create('<a href="#"><img src="'+M.util.image_url("t/contextmenu","core")+'"/></a>'),this.menulink=u,s.append(r),this.editor.get("readonly")?r.setAttribute("readonly","readonly"):s.append(u),this.width<100&&(this.width=100),a=this.editor.get_window_coordinates(new M.assignfeedback_editpdfplus.point(this.x,this.y)),r.setStyles({width:this.width+"px",backgroundColor:l[this.colour],color:f}),i.append(s),s.setStyle("position","absolute"),s.setX(a.x),s.setY(a.y),n.store_position(s,a.x,a.y),n.nodes.
push(s),r.set("value",this.rawtext),c=r.get("scrollHeight"),r.setStyles({height:c+"px",overflow:"hidden"}),this.editor.get("readonly")||this.attach_events(r,u),t&&r.focus(),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=""}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"]});
: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;try{n=e.JSON.parse(t);if(n.error||!n.pagecount){this.dialogue&&this.dialogue.hide(),o=new M.core.alert({message:M.util.get_string("cannotopenpdf","assignfeedback_editpdfplus")}),o.show();return}}catch(u){this.dialogue&&this.dialogue.hide(),o=new M.core.alert({title:M.util.get_string("cannotopenpdf","assignfeedback_editpdfplus")}),o.show();return}this.pagecount=n.pagecount,this.pages=n.pages,this.tools=[];for(r=0;r<n.tools.length;r++){var a=n.tools[r];this.tools[a.id]=a}this.typetools=[];for(r=0;r<n.typetools.length;r++){var f=n.typetools[r];this.typetools[f.id]=f}this.axis=[];for(r=0;r<n.axis.length;r++){var l=n.axis[r];l.visibility=!0,this.axis[l.id]=l}for(r=0;r<this.pages.length;r++){for(i=0;i<this.pages[r].comments.length;i++)s=this.pages[r].comments[i],this.pages[r].comments[i]=new M.assignfeedback_editpdfplus.comment(this,s.gradeid,s.pageno,s.x,s.y,s.width,s.colour,s.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},handle_axis_button:function(e,t,n){t.visibility=n.get("checked"),this.redraw()},setup_toolbar:function(){var t,n,r;if(this.get("readonly")){for(var i=1;i<this.axis.length;i++){var s=this.axis[i],u=this.get_dialogue_element("#ctaxis"+s.id);u.set("checked","true"),u.on("click",this.handle_axis_button,this,s,u)}return}var a=this.get_dialogue_element(o.CUSTOMTOOLBARID+"1");a.show();var f=this.get_dialogue_element(o.AXISCUSTOMTOOLBAR);f.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=""}r.drawable&&r.drawable.erase()}for(t=0;t<n.annotations.length;t++){var r=n.annotations[t],s=r.tooltype;if(this.get("readonly")&&s.axis&&this.axis[s.axis]&&this.axis[s.axis].visibility||!this.get("readonly"))this.drawables.push(r.draw()),this.drawablesannotations.push(r)}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"]});
......@@ -5761,7 +5761,7 @@ EDITOR.prototype = {
* @method all_pages_loaded
*/
all_pages_loaded: function (responsetext) {
var data, i, j, k, comment, error;
var data, i, j, comment, error;
try {
data = Y.JSON.parse(responsetext);
if (data.error || !data.pagecount) {
......@@ -5799,6 +5799,13 @@ EDITOR.prototype = {
this.typetools[typetooltmp.id] = typetooltmp;
}
this.axis = [];
for (i = 0; i < data.axis.length; i++) {
var axistmp = data.axis[i];
axistmp.visibility = true;
this.axis[axistmp.id] = axistmp;
}
for (i = 0; i < this.pages.length; i++) {
for (j = 0; j < this.pages[i].comments.length; j++) {
comment = this.pages[i].comments[j];
......@@ -5857,6 +5864,10 @@ EDITOR.prototype = {
return fullurl;
},
handle_axis_button: function (edit, axis, axe) {
axis.visibility = axe.get('checked');
this.redraw();
},
/**
* Attach listeners and enable the color picker buttons.
* @protected
......@@ -5868,6 +5879,13 @@ EDITOR.prototype = {