Gitlab CSE Unil

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

optimisation php tools

parent 86f640c4
......@@ -45,7 +45,14 @@ class tool_generic extends tool {
public function getRendererBoutonHTMLDisplay($disabled = false) {
$iconhtml = \html_writer::tag("i", "", array('class' => self::DISPLAY_CLASS_BUTTON[$this->label], 'aria-hidden' => 'true'));
$iconparams = array('data-tool' => $this->label, 'class' => $this->label . 'button generictoolbarbutton btn btn-secondary', 'type' => 'button');
$iconparams = array(
'data-tool' => $this->label,
'class' => $this->label . 'button generictoolbarbutton btn btn-secondary',
'type' => 'button'
);
if ($this->id) {
$iconparams['id'] = 'ctbutton' . $this->id;
}
if ($disabled) {
$iconparams['disabled'] = 'true';
}
......
......@@ -48,6 +48,7 @@ class page_editor {
const CONTEXTID = "contextid";
const GRADEID = "gradeid";
const DRAFLIB = "draft";
const AXISGENERIC = 0;
/**
* Get all tools for a page.
......@@ -72,7 +73,7 @@ class page_editor {
}
foreach ($records as $record) {
$tooltmp = null;
if (7 < $record->type && $record->type < 13) {
if ($record->axis == self::AXISGENERIC) {
$tooltmp = new tool_generic($record);
} else {
$tooltmp = new tool($record);
......
......@@ -110,17 +110,14 @@ class assignfeedback_editpdfplus_renderer extends plugin_renderer_base {
'aria-hidden' => 'true'));
$navigation .= html_writer::tag('button', $iconhtmlP, array('disabled' => 'true',
'class' => 'btn btn-secondary navigate-previous-button',
'type' => 'button',
'accesskey' => $this->get_shortcut('navigate-previous-button')));
'type' => 'button'));
$navigation .= html_writer::tag('select', null, array('disabled' => 'true',
'aria-label' => get_string('gotopage', 'assignfeedback_editpdfplus'), 'class' => self::TOOL_NAVPAGESELECT,
'accesskey' => $this->get_shortcut(self::TOOL_NAVPAGESELECT)));
'aria-label' => get_string('gotopage', 'assignfeedback_editpdfplus'), 'class' => self::TOOL_NAVPAGESELECT));
$iconhtmlN = html_writer::tag("i", "", array('class' => 'fa fa-caret-right fa-2x',
'aria-hidden' => 'true'));
$navigation .= html_writer::tag('button', $iconhtmlN, array('disabled' => 'true',
'class' => 'btn btn-secondary ' . self::TOOL_NAVPAGENEXT,
'type' => 'button',
'accesskey' => $this->get_shortcut(self::TOOL_NAVPAGENEXT)));
'type' => 'button'));
$navigationBlock = html_writer::div($navigation, "btn-group btn-group-sm mr-auto", array('role' => 'group'));
......
......@@ -34,8 +34,6 @@ var AJAXBASE = M.cfg.wwwroot + '/mod/assign/feedback/editpdfplus/ajax.php',
DRAWINGREGION: '.drawingregion',
DRAWINGCANVAS: '.drawingcanvas',
SAVE: '.savebutton',
COMMENTCOLOURBUTTON: '.commentcolourbutton',
COMMENTMENU: '.commentdrawable a',
ANNOTATIONCOLOURBUTTON: '.annotationcolourbutton',
DELETEANNOTATIONBUTTON: '.deleteannotationbutton',
UNSAVEDCHANGESDIV: '.assignfeedback_editpdfplus_unsavedchanges',
......@@ -46,6 +44,7 @@ var AJAXBASE = M.cfg.wwwroot + '/mod/assign/feedback/editpdfplus/ajax.php',
CUSTOMTOOLBARS: '.customtoolbar',
AXISCUSTOMTOOLBAR: '.menuaxisselection',
CUSTOMTOOLBARBUTTONS: '.costumtoolbarbutton',
GENERICTOOLBARBUTTONS: '.generictoolbarbutton',
STATUTSELECTOR: '#menustatutselection',
QUESTIONSELECTOR: '#menuquestionselection',
STUDENTVALIDATION: '#student_valide_button'
......@@ -5657,11 +5656,11 @@ EDITOR.prototype = {
currenttoolnode.setAttribute('aria-pressed', 'false');
drawingregion.setStyle('cursor', 'auto');
}
//update le currentedit object with the new tool
//update the currentedit object with the new tool
this.currentedit.tool = tool;
this.currentedit.id = toolid;
if (tool !== "comment" && tool !== "select" && tool !== "drag") {
if (tool !== "select" && tool !== "drag") {
this.lastannotationtool = tool;
drawingregion.setStyle('cursor', 'crosshair');
} else if (tool === "drag") {
......@@ -5921,38 +5920,36 @@ EDITOR.prototype = {
return;
}
if (this.currentedit.tool !== 'comment') {
var toolid = this.currentedit.id;
if (this.currentedit.id && this.currentedit.id[0] === 'c') {
toolid = this.currentedit.id.substr(8);
var toolid = this.currentedit.id;
if (this.currentedit.id && this.currentedit.id[0] === 'c') {
toolid = this.currentedit.id.substr(8);
}
annotation = this.create_annotation(this.currentedit.tool, this.currentedit.id, {}, this.tools[toolid]);
if (annotation) {
if (this.currentdrawable) {
this.currentdrawable.erase();
}
annotation = this.create_annotation(this.currentedit.tool, this.currentedit.id, {}, this.tools[toolid]);
if (annotation) {
if (this.currentdrawable) {
this.currentdrawable.erase();
}
this.currentdrawable = false;
if (annotation.init_from_edit(this.currentedit)) {
this.currentannotation = annotation;
annotation.draw_catridge(this.currentedit);
annotation.edit_annot();
if (annotation.parent_annot_element) {
var index = 0;
if (annotation.parent_annot_element.id) {
index = annotation.parent_annot_element.id;
} else {
index = annotation.parent_annot_element.divcartridge;
}
if (this.annotationsparent[index]) {
this.annotationsparent[index][this.annotationsparent[index].length] = annotation;
} else {
this.annotationsparent[index] = [annotation];
}
this.currentdrawable = false;
if (annotation.init_from_edit(this.currentedit)) {
this.currentannotation = annotation;
annotation.draw_catridge(this.currentedit);
annotation.edit_annot();
if (annotation.parent_annot_element) {
var index = 0;
if (annotation.parent_annot_element.id) {
index = annotation.parent_annot_element.id;
} else {
index = annotation.parent_annot_element.divcartridge;
}
if (this.annotationsparent[index]) {
this.annotationsparent[index][this.annotationsparent[index].length] = annotation;
} else {
this.annotationsparent[index] = [annotation];
}
this.pages[this.currentpage].annotations.push(annotation);
this.drawables.push(annotation.draw());
this.drawablesannotations.push(annotation);
}
this.pages[this.currentpage].annotations.push(annotation);
this.drawables.push(annotation.draw());
this.drawablesannotations.push(annotation);
}
}
......
......@@ -34,8 +34,6 @@ var AJAXBASE = M.cfg.wwwroot + '/mod/assign/feedback/editpdfplus/ajax.php',
DRAWINGREGION: '.drawingregion',
DRAWINGCANVAS: '.drawingcanvas',
SAVE: '.savebutton',
COMMENTCOLOURBUTTON: '.commentcolourbutton',
COMMENTMENU: '.commentdrawable a',
ANNOTATIONCOLOURBUTTON: '.annotationcolourbutton',
DELETEANNOTATIONBUTTON: '.deleteannotationbutton',
UNSAVEDCHANGESDIV: '.assignfeedback_editpdfplus_unsavedchanges',
......@@ -46,6 +44,7 @@ var AJAXBASE = M.cfg.wwwroot + '/mod/assign/feedback/editpdfplus/ajax.php',
CUSTOMTOOLBARS: '.customtoolbar',
AXISCUSTOMTOOLBAR: '.menuaxisselection',
CUSTOMTOOLBARBUTTONS: '.costumtoolbarbutton',
GENERICTOOLBARBUTTONS: '.generictoolbarbutton',
STATUTSELECTOR: '#menustatutselection',
QUESTIONSELECTOR: '#menuquestionselection',
STUDENTVALIDATION: '#student_valide_button'
......@@ -5657,11 +5656,11 @@ EDITOR.prototype = {
currenttoolnode.setAttribute('aria-pressed', 'false');
drawingregion.setStyle('cursor', 'auto');
}
//update le currentedit object with the new tool
//update the currentedit object with the new tool
this.currentedit.tool = tool;
this.currentedit.id = toolid;
if (tool !== "comment" && tool !== "select" && tool !== "drag") {
if (tool !== "select" && tool !== "drag") {
this.lastannotationtool = tool;
drawingregion.setStyle('cursor', 'crosshair');
} else if (tool === "drag") {
......@@ -5921,38 +5920,36 @@ EDITOR.prototype = {
return;
}
if (this.currentedit.tool !== 'comment') {
var toolid = this.currentedit.id;
if (this.currentedit.id && this.currentedit.id[0] === 'c') {
toolid = this.currentedit.id.substr(8);
var toolid = this.currentedit.id;
if (this.currentedit.id && this.currentedit.id[0] === 'c') {
toolid = this.currentedit.id.substr(8);
}
annotation = this.create_annotation(this.currentedit.tool, this.currentedit.id, {}, this.tools[toolid]);
if (annotation) {
if (this.currentdrawable) {
this.currentdrawable.erase();
}
annotation = this.create_annotation(this.currentedit.tool, this.currentedit.id, {}, this.tools[toolid]);
if (annotation) {
if (this.currentdrawable) {
this.currentdrawable.erase();
}
this.currentdrawable = false;
if (annotation.init_from_edit(this.currentedit)) {
this.currentannotation = annotation;
annotation.draw_catridge(this.currentedit);
annotation.edit_annot();
if (annotation.parent_annot_element) {
var index = 0;
if (annotation.parent_annot_element.id) {
index = annotation.parent_annot_element.id;
} else {
index = annotation.parent_annot_element.divcartridge;
}
if (this.annotationsparent[index]) {
this.annotationsparent[index][this.annotationsparent[index].length] = annotation;
} else {
this.annotationsparent[index] = [annotation];
}
this.currentdrawable = false;
if (annotation.init_from_edit(this.currentedit)) {
this.currentannotation = annotation;
annotation.draw_catridge(this.currentedit);
annotation.edit_annot();
if (annotation.parent_annot_element) {
var index = 0;
if (annotation.parent_annot_element.id) {
index = annotation.parent_annot_element.id;
} else {
index = annotation.parent_annot_element.divcartridge;
}
if (this.annotationsparent[index]) {
this.annotationsparent[index][this.annotationsparent[index].length] = annotation;
} else {
this.annotationsparent[index] = [annotation];
}
this.pages[this.currentpage].annotations.push(annotation);
this.drawables.push(annotation.draw());
this.drawablesannotations.push(annotation);
}
this.pages[this.currentpage].annotations.push(annotation);
this.drawables.push(annotation.draw());
this.drawablesannotations.push(annotation);
}
}
......
......@@ -877,11 +877,11 @@ EDITOR.prototype = {
currenttoolnode.setAttribute('aria-pressed', 'false');
drawingregion.setStyle('cursor', 'auto');
}
//update le currentedit object with the new tool
//update the currentedit object with the new tool
this.currentedit.tool = tool;
this.currentedit.id = toolid;
if (tool !== "comment" && tool !== "select" && tool !== "drag") {
if (tool !== "select" && tool !== "drag") {
this.lastannotationtool = tool;
drawingregion.setStyle('cursor', 'crosshair');
} else if (tool === "drag") {
......@@ -1141,38 +1141,36 @@ EDITOR.prototype = {
return;
}
if (this.currentedit.tool !== 'comment') {
var toolid = this.currentedit.id;
if (this.currentedit.id && this.currentedit.id[0] === 'c') {
toolid = this.currentedit.id.substr(8);
var toolid = this.currentedit.id;
if (this.currentedit.id && this.currentedit.id[0] === 'c') {
toolid = this.currentedit.id.substr(8);
}
annotation = this.create_annotation(this.currentedit.tool, this.currentedit.id, {}, this.tools[toolid]);
if (annotation) {
if (this.currentdrawable) {
this.currentdrawable.erase();
}
annotation = this.create_annotation(this.currentedit.tool, this.currentedit.id, {}, this.tools[toolid]);
if (annotation) {
if (this.currentdrawable) {
this.currentdrawable.erase();
}
this.currentdrawable = false;
if (annotation.init_from_edit(this.currentedit)) {
this.currentannotation = annotation;
annotation.draw_catridge(this.currentedit);
annotation.edit_annot();
if (annotation.parent_annot_element) {
var index = 0;
if (annotation.parent_annot_element.id) {
index = annotation.parent_annot_element.id;
} else {
index = annotation.parent_annot_element.divcartridge;
}
if (this.annotationsparent[index]) {
this.annotationsparent[index][this.annotationsparent[index].length] = annotation;
} else {
this.annotationsparent[index] = [annotation];
}
this.currentdrawable = false;
if (annotation.init_from_edit(this.currentedit)) {
this.currentannotation = annotation;
annotation.draw_catridge(this.currentedit);
annotation.edit_annot();
if (annotation.parent_annot_element) {
var index = 0;
if (annotation.parent_annot_element.id) {
index = annotation.parent_annot_element.id;
} else {
index = annotation.parent_annot_element.divcartridge;
}
if (this.annotationsparent[index]) {
this.annotationsparent[index][this.annotationsparent[index].length] = annotation;
} else {
this.annotationsparent[index] = [annotation];
}
this.pages[this.currentpage].annotations.push(annotation);
this.drawables.push(annotation.draw());
this.drawablesannotations.push(annotation);
}
this.pages[this.currentpage].annotations.push(annotation);
this.drawables.push(annotation.draw());
this.drawablesannotations.push(annotation);
}
}
......
......@@ -32,8 +32,6 @@ var AJAXBASE = M.cfg.wwwroot + '/mod/assign/feedback/editpdfplus/ajax.php',
DRAWINGREGION: '.drawingregion',
DRAWINGCANVAS: '.drawingcanvas',
SAVE: '.savebutton',
COMMENTCOLOURBUTTON: '.commentcolourbutton',
COMMENTMENU: '.commentdrawable a',
ANNOTATIONCOLOURBUTTON: '.annotationcolourbutton',
DELETEANNOTATIONBUTTON: '.deleteannotationbutton',
UNSAVEDCHANGESDIV: '.assignfeedback_editpdfplus_unsavedchanges',
......@@ -44,6 +42,7 @@ var AJAXBASE = M.cfg.wwwroot + '/mod/assign/feedback/editpdfplus/ajax.php',
CUSTOMTOOLBARS: '.customtoolbar',
AXISCUSTOMTOOLBAR: '.menuaxisselection',
CUSTOMTOOLBARBUTTONS: '.costumtoolbarbutton',
GENERICTOOLBARBUTTONS: '.generictoolbarbutton',
STATUTSELECTOR: '#menustatutselection',
QUESTIONSELECTOR: '#menuquestionselection',
STUDENTVALIDATION: '#student_valide_button'
......
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