Gitlab CSE Unil

Commit 1a9aacaa authored by M. Chardon's avatar M. Chardon
Browse files

optimisation code

parent f161a8a6
This diff is collapsed.
......@@ -42,7 +42,6 @@ define(['jquery', './global'],
function Annotation() {
// Store the private instance id.
this._instanceID = getNewInstanceID();
$("#tutu").val();
// Return this object reference.
return(this);
......@@ -107,19 +106,12 @@ define(['jquery', './global'],
*/
Annotation.colour = 'red';
/**
* Reference to M.assignfeedback_editpdfplus.tool
* Reference to assignfeedback_editpdfplus.tool
* @property tooltype
* @type M.assignfeedback_editpdfplus.tool
* @type assignfeedback_editpdfplus.tool
* @public
*/
Annotation.tooltype = null;
/**
* Reference to M.assignfeedback_editpdfplus.type_tool
* @property tooltypefamille
* @type M.assignfeedback_editpdfplus.type_tool
* @public
*/
Annotation.tooltypefamille = null;
/**
* id of the annotation in BDD.
* @property id
......@@ -154,20 +146,14 @@ define(['jquery', './global'],
this.endy = parseInt(config.endy, 10) || 0;
this.path = config.path || '';
this.toolid = config.toolid;
this.tooltypefamille = this.editor.typetools[this.tooltype.type];
};
Annotation.prototype.initAdminDemo = function (currentTool, typetoolEntity) {
Annotation.prototype.initAdminDemo = function (currentTool) {
this.id = 'previsu_annot';
this.displaylock = 1;
this.adminDemo = 1;
this.tooltype = currentTool;
this.tooltypefamille = typetoolEntity;
if (currentTool.color) {
this.colour = currentTool.color;
} else {
this.colour = typetoolEntity.color;
}
this.colour = currentTool.get_color();
};
/**
* Draw an annotation
......@@ -200,17 +186,14 @@ define(['jquery', './global'],
* @protected
*/
Annotation.prototype.get_color_cartridge = function () {
var color = global.ANNOTATIONCOLOUR[this.tooltype.catridgecolor];
var color = global.ANNOTATIONCOLOUR[this.tooltype.get_color_cartridge()];
if (!color) {
color = this.tooltype.catridgecolor;
color = this.tooltype.get_color_cartridge();
} else {
// Add an alpha channel to the rgb colour.
color = color.replace('rgb', 'rgba');
color = color.replace(')', ',0.5)');
}
if (!color || color === '') {
return this.tooltypefamille.cartridge_color;
}
return color;
};
/**
......@@ -256,14 +239,14 @@ define(['jquery', './global'],
Annotation.prototype.get_div_cartridge_label = function (colorcartridge, canevas/*, draggable*/) {
var divcartridge = "<div ";
divcartridge += "id='" + this.divcartridge + "_cartridge' ";
divcartridge += "class='assignfeedback_editpdfplus_" + this.tooltypefamille.label + "_cartridge' ";
divcartridge += "class='assignfeedback_editpdfplus_" + this.tooltype.getToolTypeLabel() + "_cartridge' ";
//if (this.editor.get('readonly') && this.get_valref() === '') {
//divcartridge += "style='border-right:none;padding-right:0px;color:" + colorcartridge + ";' ";
//} else {
divcartridge += "style='border-right-color: " + colorcartridge + ";color:" + colorcartridge + ";' ";
//}
divcartridge += "> ";
divcartridge += this.tooltype.libelle;
divcartridge += this.tooltype.cartridge;
divcartridge += "</div>";
if (canevas) {
canevas.append(divcartridge);
......@@ -302,7 +285,7 @@ define(['jquery', './global'],
Annotation.prototype.get_div_edition = function (canevas) {
var divedition = "<div ";
divedition += "id='" + this.divcartridge + "_edit' ";
divedition += "class='assignfeedback_editpdfplus_" + this.tooltypefamille.label + "_edition' ";
divedition += "class='assignfeedback_editpdfplus_" + this.tooltype.getToolTypeLabel() + "_edition' ";
divedition += "style='display:none;'> ";
divedition += "<textarea id='"
+ this.divcartridge
......@@ -351,14 +334,14 @@ define(['jquery', './global'],
*/
Annotation.prototype.get_div_container = function (colorcartridge, canevas) {
var divconteneur = "<div ";
divconteneur += "class='assignfeedback_editpdfplus_" + this.tooltypefamille.label + "_conteneur' >";
divconteneur += "class='assignfeedback_editpdfplus_" + this.tooltype.getToolTypeLabel() + "_conteneur' >";
divconteneur += "</div>";
if (canevas) {
canevas.append(divconteneur);
}
var divconteneurdisplay = $('.assignfeedback_editpdfplus_' + this.tooltypefamille.label + "_conteneur");
var divconteneurdisplay = $('.assignfeedback_editpdfplus_' + this.tooltype.getToolTypeLabel() + "_conteneur");
var divinputdisplay = this.get_div_input(colorcartridge, divconteneurdisplay);
divinputdisplay.addClass('assignfeedback_editpdfplus_' + this.tooltypefamille.label + '_input');
divinputdisplay.addClass('assignfeedback_editpdfplus_' + this.tooltype.getToolTypeLabel() + '_input');
var onof = 1;
if (this.displaylock || this.displaylock >= 0) {
onof = this.displaylock;
......@@ -576,7 +559,7 @@ define(['jquery', './global'],
if (divdisplay) {
divdisplay.html(this.get_text_to_diplay_in_cartridge());
}
if (this.tooltypefamille.label === 'frame' && buttonplusr) {
if (this.tooltype.getToolTypeLabel() === 'frame' && buttonplusr) {
buttonplusr.hide();
buttonplusl.hide();
}
......
......@@ -32,8 +32,8 @@ define(['jquery', './annotation'],
// The Friend class extends the base Model class.
AnnotationCommentplus.prototype = Object.create(Annotation.prototype);
AnnotationCommentplus.prototype.initAdminDemo = function (currentTool, typetoolEntity) {
Annotation.prototype.initAdminDemo.call(this, currentTool, typetoolEntity);
AnnotationCommentplus.prototype.initAdminDemo = function (currentTool) {
Annotation.prototype.initAdminDemo.call(this, currentTool);
this.x = 30;
this.y = 90;
};
......@@ -93,10 +93,10 @@ define(['jquery', './annotation'],
//positionnement de la div par rapport a l'annotation
if (!this.cartridgex || this.cartridgex === 0) {
this.cartridgex = parseInt(this.tooltypefamille.cartridge_x, 10);
this.cartridgex = parseInt(this.tooltype.getToolTypeCartX(), 10);
}
if (!this.cartridgey || this.cartridgey === 0) {
this.cartridgey = parseInt(this.tooltypefamille.cartridge_y, 10);
this.cartridgey = parseInt(this.tooltype.getToolTypeCartY(), 10);
}
divdisplay.css('left', this.x + 20);
divdisplay.css('top', this.y - 20);
......
......@@ -32,8 +32,8 @@ define(['jquery', './annotation'],
// The Friend class extends the base Model class.
AnnotationFrame.prototype = Object.create(Annotation.prototype);
AnnotationFrame.prototype.initAdminDemo = function (currentTool, typetoolEntity) {
Annotation.prototype.initAdminDemo.call(this, currentTool, typetoolEntity);
AnnotationFrame.prototype.initAdminDemo = function (currentTool) {
Annotation.prototype.initAdminDemo.call(this, currentTool);
this.x = 279;
this.y = 113;
this.endx = 435;
......@@ -43,7 +43,7 @@ define(['jquery', './annotation'],
};
AnnotationFrame.prototype.initChildAdminDemo = function (annotationparent) {
Annotation.prototype.initAdminDemo.call(this, annotationparent.tooltype, annotationparent.tooltypefamille);
Annotation.prototype.initAdminDemo.call(this, annotationparent.tooltype);
this.x = 144;
this.y = 192;
this.endx = 296;
......@@ -138,10 +138,10 @@ define(['jquery', './annotation'],
//positionnement de la div par rapport a l'annotation
if (!this.cartridgex || this.cartridgex === 0) {
this.cartridgex = parseInt(this.tooltypefamille.cartridge_x, 10);
this.cartridgex = parseInt(this.tooltype.getToolTypeCartX(), 10);
}
if (!this.cartridgey || this.cartridgey === 0) {
this.cartridgey = parseInt(this.tooltypefamille.cartridge_y, 10);
this.cartridgey = parseInt(this.tooltype.getToolTypeCartY(), 10);
}
divdisplay.css('left', this.cartridgex + 15);
divdisplay.css('top', this.y + this.cartridgey - 12);
......
......@@ -32,8 +32,8 @@ define(['jquery', './annotation'],
// The Friend class extends the base Model class.
AnnotationHighlightplus.prototype = Object.create(Annotation.prototype);
AnnotationHighlightplus.prototype.initAdminDemo = function (currentTool, typetoolEntity) {
Annotation.prototype.initAdminDemo.call(this, currentTool, typetoolEntity);
AnnotationHighlightplus.prototype.initAdminDemo = function (currentTool) {
Annotation.prototype.initAdminDemo.call(this, currentTool);
this.x = 83;
this.y = 84;
this.endx = 239;
......@@ -94,10 +94,10 @@ define(['jquery', './annotation'],
//positionnement de la div par rapport a l'annotation
if (!this.cartridgex || this.cartridgex === 0) {
this.cartridgex = parseInt(this.tooltypefamille.cartridge_x, 10);
this.cartridgex = parseInt(this.tooltype.getToolTypeCartX(), 10);
}
if (!this.cartridgey || this.cartridgey === 0) {
this.cartridgey = parseInt(this.tooltypefamille.cartridge_y, 10);
this.cartridgey = parseInt(this.tooltype.getToolTypeCartY(), 10);
}
divdisplay.css('left', this.x + this.cartridgex);
divdisplay.css('top', this.y + this.cartridgey - 15);
......
......@@ -32,8 +32,8 @@ define(['jquery', './annotation'],
// The Friend class extends the base Model class.
AnnotationStampcomment.prototype = Object.create(Annotation.prototype);
AnnotationStampcomment.prototype.initAdminDemo = function (currentTool, typetoolEntity) {
Annotation.prototype.initAdminDemo.call(this, currentTool, typetoolEntity);
AnnotationStampcomment.prototype.initAdminDemo = function (currentTool) {
Annotation.prototype.initAdminDemo.call(this, currentTool);
this.x = 188;
this.y = 118;
this.displayrotation = 1;
......@@ -120,10 +120,10 @@ define(['jquery', './annotation'],
//positionnement de la div par rapport a l'annotation
if (!this.cartridgex || this.cartridgex === 0) {
this.cartridgex = parseInt(this.tooltypefamille.cartridge_x, 10);
this.cartridgex = parseInt(this.tooltype.getToolTypeCartX(), 10);
}
if (!this.cartridgey || this.cartridgey === 0) {
this.cartridgey = parseInt(this.tooltypefamille.cartridge_y, 10);
this.cartridgey = parseInt(this.tooltype.getToolTypeCartY(), 10);
}
divdisplay.css('left', this.x + this.cartridgex);
divdisplay.css('top', this.y + this.cartridgey - 30);
......
......@@ -54,7 +54,7 @@ define(['jquery', './annotation'],
$("#" + this.id).css('border', '2px solid ' + this.colour);
$("#" + this.id).css('padding', '0 2px');
$("#" + this.id).css('display', 'inline-block');
$("#" + this.id).append(this.tooltype.button);
$("#" + this.id).append(this.tooltype.label);
}
return this;
};
......
......@@ -32,8 +32,8 @@ define(['jquery', './annotation'],
// The Friend class extends the base Model class.
AnnotationVerticalline.prototype = Object.create(Annotation.prototype);
AnnotationVerticalline.prototype.initAdminDemo = function (currentTool, typetoolEntity) {
Annotation.prototype.initAdminDemo.call(this, currentTool, typetoolEntity);
AnnotationVerticalline.prototype.initAdminDemo = function (currentTool) {
Annotation.prototype.initAdminDemo.call(this, currentTool);
this.x = 285;
this.y = 65;
this.endy = 175;
......@@ -95,10 +95,10 @@ define(['jquery', './annotation'],
//positionnement de la div par rapport a l'annotation
if (!this.cartridgex || this.cartridgex === 0) {
this.cartridgex = parseInt(this.tooltypefamille.cartridge_x, 10);
this.cartridgex = parseInt(this.tooltype.getToolTypeCartX(), 10);
}
if (!this.cartridgey || this.cartridgey === 0) {
this.cartridgey = parseInt(this.tooltypefamille.cartridge_y, 10);
this.cartridgey = parseInt(this.tooltype.getToolTypeCartY(), 10);
}
divdisplay.css('left', this.x + this.cartridgex);
divdisplay.css('top', this.y + this.cartridgey - 109);
......
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/*
* @package assignfeedback_editpdfplus
* @copyright 2017 Université de Lausanne
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
/**
* @module mod_assignfeedback_editpdfplus/annotation
*/
define(['jquery', './global'],
function ($, global) {
// I am the internal, static counter for the number of models
// that have been created in the system. This is used to
// power the unique identifier of each instance.
var instanceCount = 0;
// I get the next instance ID.
var getNewInstanceID = function () {
// Precrement the instance count in order to generate the
// next value instance ID.
return(++instanceCount);
};
// I return an initialized object.
/**
* Annotation class.
*
* @class Annotation
*/
function Tool() {
// Store the private instance id.
this._instanceID = getNewInstanceID();
// Return this object reference.
return(this);
}
// I return the current instance count. I am a static method
// on the Model class.
Tool.getInstanceCount = function () {
return(instanceCount);
};
Tool.prototype.getInstanceID = function () {
return(this._instanceID);
};
Tool.id = -1;
Tool.axis = -1;
Tool.typetool = -1;
Tool.type = null;
Tool.colors = "";
Tool.cartridge = "";
Tool.cartridgeColor = "";
Tool.texts = "";
Tool.label = "";
Tool.reply = true;
Tool.enabled = true;
Tool.orderTool = 1000;
Tool.prototype.init = function (config) {
this.id = parseInt(config.id, 10) || 0;
this.axis = parseInt(config.axis, 10) || 0;
this.type = config.type;
this.colors = config.colors;
this.cartridge = config.cartridge;
this.cartridgeColor = config.cartridgeColor;
this.texts = config.texts;
this.label = config.label;
this.reply = config.reply;
this.enabled = config.enabled;
this.orderTool = config.orderTool;
};
Tool.prototype.initAdmin = function (config) {
this.id = parseInt(config.toolid, 10) || 0;
this.typetool = config.typetool;
this.label = config.button;
this.enabled = config.enable;
this.orderTool = config.orderTool;
};
Tool.prototype.getToolTypeLabel = function () {
return this.type.label;
};
Tool.prototype.getToolTypeCartX = function () {
return this.type.cartridgeX;
};
Tool.prototype.getToolTypeCartY = function () {
return this.type.cartridgeY;
};
/**
* Get the final color for the annotation
* @return string
* @protected
*/
Tool.prototype.get_color = function () {
var color = global.ANNOTATIONCOLOUR[this.colors];
if (!color) {
color = this.colors;
} else {
// Add an alpha channel to the rgb colour.
color = color.replace('rgb', 'rgba');
color = color.replace(')', ',0.5)');
}
if (!color || color === '') {
return this.type.get_color();
}
return color;
};
/**
* Get the final color for the cartridge
* @return string
* @protected
*/
Tool.prototype.get_color_cartridge = function () {
var color = global.ANNOTATIONCOLOUR[this.cartridgeColor];
if (!color) {
color = this.cartridgeColor;
} else {
// Add an alpha channel to the rgb colour.
color = color.replace('rgb', 'rgba');
color = color.replace(')', ',0.5)');
}
if (!color || color === '') {
return this.type.get_color_cartridge();
}
return color;
};
Tool.prototype.getButton = function (selectToolId) {
var classButton = "btn-default";
var style = "";
if (this.enabled !== 1) {
classButton = "";
style = "background-image:none;background-color:#CCCCCC;";
}
if (this.id === selectToolId) {
classButton = "btn-primary";
}
if (this.typetool === 4 || this.typetool === 1) {
style += "text-decoration: underline;";
}
var label = this.label;
if (this.typetool === 4 || this.typetool === 5) {
label = "| " + label;
if (this.typetool === 4) {
label += " |";
}
}
var buttonTmp = "<button class='btn "
+ classButton
+ " editpdlplus_tool' id='editpdlplus_tool_"
+ this.id + "' style='"
+ style
+ "' value='"
+ this.id
+ "' data-enable='"
+ this.enabled + "'>"
+ label
+ "</button>";
return buttonTmp;
};
return Tool;
});
\ No newline at end of file
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/*
* @package assignfeedback_editpdfplus
* @copyright 2017 Université de Lausanne
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
/**
* @module mod_assignfeedback_editpdfplus/annotation
*/
define(['jquery', './global'],
function ($, global) {
// I am the internal, static counter for the number of models
// that have been created in the system. This is used to
// power the unique identifier of each instance.
var instanceCount = 0;
// I get the next instance ID.
var getNewInstanceID = function () {
// Precrement the instance count in order to generate the
// next value instance ID.
return(++instanceCount);
};
// I return an initialized object.
/**
* Annotation class.
*
* @class Annotation
*/
function ToolType() {
// Store the private instance id.
this._instanceID = getNewInstanceID();
// Return this object reference.
return(this);
}
// I return the current instance count. I am a static method
// on the Model class.
ToolType.getInstanceCount = function () {
return(instanceCount);
};
ToolType.prototype.getInstanceID = function () {
return(this._instanceID);
};
ToolType.id = -1;
ToolType.label = "";
ToolType.color = "";
ToolType.cartridgeColor = "";
ToolType.cartridgeX = 0;
ToolType.cartridgeY = 0;
ToolType.configurableCartridge = 1;
ToolType.configurableCartridgeColor = 1;
ToolType.configurableColor = 1;
ToolType.configurableTexts = 1;
ToolType.configurableQuestion = 1;
ToolType.prototype.init = function (config) {
this.id = parseInt(config.id, 10) || 0;
};
ToolType.prototype.initAdmin = function (config) {
this.id = parseInt(config.id, 10) || 0;
this.label = config.label;
this.color = config.color;
this.cartridgeColor = config.cartridge_color;
this.cartridgeX = config.cartridge_x;
this.cartridgeY = config.cartridge_y;
this.configurableCartridge = config.configurable_cartridge;
this.configurableCartridgeColor = config.configurable_cartridge_color;
this.configurableColor = config.configurable_color;
this.configurableTexts = config.configurable_texts;
this.configurableQuestion = config.configurable_question;
};
/**
* Get the final color for the annotation
* @return string
* @protected
*/
ToolType.prototype.get_color = function () {
var color = global.ANNOTATIONCOLOUR[this.color];
if (!color) {
color = this.color;
} else {
// Add an alpha channel to the rgb colour.
color = color.replace('rgb', 'rgba');
color = color.replace(')', ',0.5)');
}
return color;
};
/**
* Get the final color for the cartridge
* @return string
* @protected
*/
ToolType.prototype.get_color_cartridge = function () {
var color = global.ANNOTATIONCOLOUR[this.cartridgeColor];
if (!color) {
color = this.cartridgeColor;
} else {
// Add an alpha channel to the rgb colour.
color = color.replace('rgb', 'rgba');
color = color.replace(')', ',0.5)');
}
return color;
};
return ToolType;
});
\ No newline at end of file
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